Use strict unmarshal for configuration file, to detect typos in

config directives. Do not panic on failed regexp in AST parsing,
instead return &ast.Unknown{} for further debugging. Add debutast:
directive to print context when AST nodes are not recognized.
This commit is contained in:
Greg 2019-06-03 11:07:12 -04:00
parent 4f0cdf4d1a
commit d8552bcf9d
163 changed files with 2600 additions and 131 deletions

View File

@ -9,11 +9,14 @@ type AlignedAttr struct {
ChildNodes []Node
}
func parseAlignedAttr(line string) *AlignedAttr {
func parseAlignedAttr(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)>(?P<aligned> aligned)?",
line,
)
if groups == nil {
return &Unknown{}
}
return &AlignedAttr{
Addr: ParseAddress(groups["address"]),

View File

@ -17,11 +17,14 @@ type AllocSizeAttr struct {
ChildNodes []Node
}
func parseAllocSizeAttr(line string) *AllocSizeAttr {
func parseAllocSizeAttr(line string) Node {
groups := groupsFromRegex(
`<(?P<position>.*)>(?P<inherited> Inherited)?(?P<a> \d+)(?P<b> \d+)?`,
line,
)
if groups == nil {
return &Unknown{}
}
return &AllocSizeAttr{
Addr: ParseAddress(groups["address"]),

View File

@ -8,11 +8,14 @@ type AlwaysInlineAttr struct {
ChildNodes []Node
}
func parseAlwaysInlineAttr(line string) *AlwaysInlineAttr {
func parseAlwaysInlineAttr(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)> always_inline",
line,
)
if groups == nil {
return &Unknown{}
}
return &AlwaysInlineAttr{
Addr: ParseAddress(groups["address"]),

View File

@ -0,0 +1,47 @@
package ast
// ArcWeakrefUnavailableAttr
type ArcWeakrefUnavailableAttr struct {
Addr Address
Pos Position
ChildNodes []Node
}
func parseArcWeakrefUnavailableAttr(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)>",
line,
)
if groups == nil {
return &Unknown{}
}
return &ArcWeakrefUnavailableAttr{
Addr: ParseAddress(groups["address"]),
Pos: NewPositionFromString(groups["position"]),
ChildNodes: []Node{},
}
}
// AddChild adds a new child node. Child nodes can then be accessed with the
// Children attribute.
func (n *ArcWeakrefUnavailableAttr) AddChild(node Node) {
n.ChildNodes = append(n.ChildNodes, node)
}
// Address returns the numeric address of the node. See the documentation for
// the Address type for more information.
func (n *ArcWeakrefUnavailableAttr) Address() Address {
return n.Addr
}
// Children returns the child nodes. If this node does not have any children or
// this node does not support children it will always return an empty slice.
func (n *ArcWeakrefUnavailableAttr) Children() []Node {
return n.ChildNodes
}
// Position returns the position in the original source code.
func (n *ArcWeakrefUnavailableAttr) Position() Position {
return n.Pos
}

View File

@ -11,13 +11,16 @@ type ArraySubscriptExpr struct {
ChildNodes []Node
}
func parseArraySubscriptExpr(line string) *ArraySubscriptExpr {
func parseArraySubscriptExpr(line string) Node {
groups := groupsFromRegex(
`<(?P<position>.*)> '(?P<type>.*?)'(:'(?P<type2>.*?)')?
(?P<lvalue> lvalue)?
(?P<vcomp> vectorcomponent)?`,
line,
)
if groups == nil {
return &Unknown{}
}
return &ArraySubscriptExpr{
Addr: ParseAddress(groups["address"]),

View File

@ -9,13 +9,16 @@ type AsmLabelAttr struct {
ChildNodes []Node
}
func parseAsmLabelAttr(line string) *AsmLabelAttr {
func parseAsmLabelAttr(line string) Node {
groups := groupsFromRegex(
`<(?P<position>.*)>
(?P<inherited> Inherited)?
"(?P<function>.+)"`,
line,
)
if groups == nil {
return &Unknown{}
}
return &AsmLabelAttr{
Addr: ParseAddress(groups["address"]),

View File

@ -2,6 +2,7 @@
package ast
import (
"fmt"
"strconv"
"strings"
@ -69,6 +70,8 @@ func Parse(fullline string) Node {
return parseAlwaysInlineAttr(line)
case "ArraySubscriptExpr":
return parseArraySubscriptExpr(line)
case "ArcWeakrefUnavailableAttr":
return parseArcWeakrefUnavailableAttr(line)
case "AsmLabelAttr":
return parseAsmLabelAttr(line)
case "AttributedType":
@ -87,8 +90,18 @@ func Parse(fullline string) Node {
return parseBuiltinType(line)
case "CallExpr":
return parseCallExpr(line)
case "ConvertVectorExpr":
return parseConvertVectorExpr(line)
case "CaseStmt":
return parseCaseStmt(line)
case "CFAuditedTransferAttr":
return parseCFAuditedTransferAttr(line)
case "CFConsumedAttr":
return parseCFConsumedAttr(line)
case "CFReturnsRetainedAttr":
return parseCFReturnsRetainedAttr(line)
case "CFReturnsNotRetainedAttr":
return parseCFReturnsNotRetainedAttr(line)
case "CharacterLiteral":
return parseCharacterLiteral(line)
case "CompoundLiteralExpr":
@ -129,12 +142,16 @@ func Parse(fullline string) Node {
return parseEnumConstantDecl(line)
case "EnumDecl":
return parseEnumDecl(line)
case "EnumExtensibilityAttr":
return parseEnumExtensibilityAttr(line)
case "EnumType":
return parseEnumType(line)
case "Field":
return parseField(line)
case "FieldDecl":
return parseFieldDecl(line)
case "FlagEnumAttr":
return parseFlagEnumAttr(line)
case "FloatingLiteral":
return parseFloatingLiteral(line)
case "FormatAttr":
@ -157,6 +174,10 @@ func Parse(fullline string) Node {
return parseGCCAsmStmt(line)
case "GotoStmt":
return parseGotoStmt(line)
case "IBActionAttr":
return parseIBActionAttr(line)
case "IBOutletAttr":
return parseIBOutletAttr(line)
case "IfStmt":
return parseIfStmt(line)
case "ImplicitCastExpr":
@ -179,10 +200,18 @@ func Parse(fullline string) Node {
return parseMallocAttr(line)
case "MaxFieldAlignmentAttr":
return parseMaxFieldAlignmentAttr(line)
case "MayAliasAttr":
return parseMayAliasAttr(line)
case "MemberExpr":
return parseMemberExpr(line)
case "MinVectorWidthAttr":
return parseMinVectorWidthAttr(line)
case "ModeAttr":
return parseModeAttr(line)
case "NoDebugAttr":
return parseNoDebugAttr(line)
case "NoEscapeAttr":
return parseNoEscapeAttr(line)
case "NoInlineAttr":
return parseNoInlineAttr(line)
case "NoThrowAttr":
@ -191,8 +220,34 @@ func Parse(fullline string) Node {
return parseNonNullAttr(line)
case "NotTailCalledAttr":
return parseNotTailCalledAttr(line)
case "NSConsumedAttr":
return parseNSConsumedAttr(line)
case "NSConsumesSelfAttr":
return parseNSConsumesSelfAttr(line)
case "NSErrorDomainAttr":
return parseNSErrorDomainAttr(line)
case "NSReturnsRetainedAttr":
return parseNSReturnsRetainedAttr(line)
case "ObjCBoolLiteralExpr":
return parseObjCBoolLiteralExpr(line)
case "ObjCBoxableAttr":
return parseObjCBoxableAttr(line)
case "ObjCBridgeAttr":
return parseObjCBridgeAttr(line)
case "ObjCBridgeRelatedAttr":
return parseObjCBridgeRelatedAttr(line)
case "ObjCBridgeMutableAttr":
return parseObjCBridgeMutableAttr(line)
case "ObjCCategoryDecl":
return parseObjCCategoryDecl(line)
case "ObjCDesignatedInitializerAttr":
return parseObjCDesignatedInitializerAttr(line)
case "ObjCExceptionAttr":
return parseObjCExceptionAttr(line)
case "ObjCExplicitProtocolImplAttr":
return parseObjCExplicitProtocolImplAttr(line)
case "ObjCIndependentClassAttr":
return parseObjCIndependentClassAttr(line)
case "ObjCInterface":
return parseObjCInterface(line,false)
case "super ObjCInterface":
@ -201,10 +256,14 @@ func Parse(fullline string) Node {
return parseObjCInterfaceDecl(line)
case "ObjCInterfaceType":
return parseObjCInterfaceType(line)
case "ObjCIvarDecl":
return parseObjCIvarDecl(line)
case "getter ObjCMethod":
return parseObjCMethod(line)
case "ObjCMethod":
return parseObjCMethod(line)
case "ObjCMessageExpr":
return parseObjCMessageExpr(line)
case "ObjCMethodDecl":
return parseObjCMethodDecl(line)
case "ObjCObjectType":
@ -213,8 +272,14 @@ func Parse(fullline string) Node {
return parseObjCObjectPointerType(line)
case "ObjCProtocol":
return parseObjCProtocol(line)
case "ObjCReturnsInnerPointerAttr":
return parseObjCReturnsInnerPointerAttr(line)
case "ObjCRequiresSuperAttr":
return parseObjCRequiresSuperAttr(line)
case "ObjCProtocolDecl":
return parseObjCProtocolDecl(line)
case "ObjCRootClassAttr":
return parseObjCRootClassAttr(line)
case "ObjCPropertyDecl":
return parseObjCPropertyDecl(line)
case "ObjCTypeParamDecl":
@ -257,12 +322,26 @@ func Parse(fullline string) Node {
return parseReturnsTwiceAttr(line)
case "SentinelAttr":
return parseSentinelAttr(line)
case "ShuffleVectorExpr":
return parseShuffleVectorExpr(line)
case "StmtExpr":
return parseStmtExpr(line)
case "StringLiteral":
return parseStringLiteral(line)
case "SwiftBridgedTypedefAttr":
return parseSwiftBridgedTypedefAttr(line)
case "SwiftErrorAttr":
return parseSwiftErrorAttr(line)
case "SwiftNameAttr":
return parseSwiftNameAttr(line)
case "SwiftNewtypeAttr":
return parseSwiftNewtypeAttr(line)
case "SwiftPrivateAttr":
return parseSwiftPrivateAttr(line)
case "SwitchStmt":
return parseSwitchStmt(line)
case "TargetAttr":
return parseTargetAttr(line)
case "TextComment":
return parseTextComment(line)
case "TranslationUnitDecl":
@ -281,6 +360,8 @@ func Parse(fullline string) Node {
return parseUnaryOperator(line)
case "UnavailableAttr":
return parseUnavailableAttr(line)
case "UsedAttr":
return parseUsedAttr(line)
case "UnusedAttr":
return parseUnusedAttr(line)
case "VAArgExpr":
@ -301,6 +382,8 @@ func Parse(fullline string) Node {
return parseWarnUnusedResultAttr(line)
case "WeakAttr":
return parseWeakAttr(line)
case "WeakImportAttr":
return parseWeakImportAttr(line)
case "WhileStmt":
return parseWhileStmt(line)
case "...":
@ -323,7 +406,8 @@ func groupsFromRegex(rx, line string) map[string]string {
re := util.GetRegex(rx)
match := re.FindStringSubmatch(line)
if len(match) == 0 {
panic("could not match regexp with string\n" + rx + "\n" + line + "\n")
fmt.Printf("AST parser: could not match regexp with string. Regexp:\n" + rx + "\nOriginal line:\n" + line + "\n\n")
return nil
}
result := make(map[string]string)

View File

@ -8,12 +8,15 @@ type AttributedType struct {
ChildNodes []Node
}
func parseAttributedType(line string) *AttributedType {
func parseAttributedType(line string) Node {
groups := groupsFromRegex(
`'(?P<type>.*)'
(?P<sugar> sugar)?`,
line,
)
if groups == nil {
return &Unknown{}
}
return &AttributedType{
Addr: ParseAddress(groups["address"]),

View File

@ -16,7 +16,7 @@ type AvailabilityAttr struct {
ChildNodes []Node
}
func parseAvailabilityAttr(line string) *AvailabilityAttr {
func parseAvailabilityAttr(line string) Node {
groups := groupsFromRegex(
`<(?P<position>.*)>
(?P<inherited> Inherited)?
@ -29,6 +29,9 @@ func parseAvailabilityAttr(line string) *AvailabilityAttr {
(?P<message2> ".*?")?`,
line,
)
if groups == nil {
return &Unknown{}
}
return &AvailabilityAttr{
Addr: ParseAddress(groups["address"]),

View File

@ -10,11 +10,14 @@ type BinaryOperator struct {
ChildNodes []Node
}
func parseBinaryOperator(line string) *BinaryOperator {
func parseBinaryOperator(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)> '(?P<type1>.*?)'(:'(?P<type2>.*?)')? '(?P<operator>.*?)'",
line,
)
if groups == nil {
return &Unknown{}
}
return &BinaryOperator{
Addr: ParseAddress(groups["address"]),

View File

@ -8,11 +8,14 @@ type BlockCommandComment struct {
ChildNodes []Node
}
func parseBlockCommandComment(line string) *BlockCommandComment {
func parseBlockCommandComment(line string) Node {
groups := groupsFromRegex(
`<(?P<position>.*)> Name="(?P<name>.*)"`,
line,
)
if groups == nil {
return &Unknown{}
}
return &BlockCommandComment{
Addr: ParseAddress(groups["address"]),

View File

@ -7,11 +7,14 @@ type BlockPointerType struct {
ChildNodes []Node
}
func parseBlockPointerType(line string) *BlockPointerType {
func parseBlockPointerType(line string) Node {
groups := groupsFromRegex(
"'(?P<type>.*)'",
line,
)
if groups == nil {
return &Unknown{}
}
return &BlockPointerType{
Addr: ParseAddress(groups["address"]),

View File

@ -7,11 +7,14 @@ type BreakStmt struct {
ChildNodes []Node
}
func parseBreakStmt(line string) *BreakStmt {
func parseBreakStmt(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)>",
line,
)
if groups == nil {
return &Unknown{}
}
return &BreakStmt{
Addr: ParseAddress(groups["address"]),

View File

@ -7,11 +7,14 @@ type BuiltinType struct {
ChildNodes []Node
}
func parseBuiltinType(line string) *BuiltinType {
func parseBuiltinType(line string) Node {
groups := groupsFromRegex(
"'(?P<type>.*?)'",
line,
)
if groups == nil {
return &Unknown{}
}
return &BuiltinType{
Addr: ParseAddress(groups["address"]),

View File

@ -16,11 +16,14 @@ var CStyleCastExprNullToPointer = "NullToPointer"
// CStyleCastExprToVoid - string of kind ToVoid
var CStyleCastExprToVoid = "ToVoid"
func parseCStyleCastExpr(line string) *CStyleCastExpr {
func parseCStyleCastExpr(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)> '(?P<type1>.*?)'(:'(?P<type2>.*?)')? <(?P<kind>.*)>",
line,
)
if groups == nil {
return &Unknown{}
}
return &CStyleCastExpr{
Addr: ParseAddress(groups["address"]),

View File

@ -8,11 +8,14 @@ type CallExpr struct {
ChildNodes []Node
}
func parseCallExpr(line string) *CallExpr {
func parseCallExpr(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)> '(?P<type>.*?)'",
line,
)
if groups == nil {
return &Unknown{}
}
return &CallExpr{
Addr: ParseAddress(groups["address"]),

View File

@ -7,8 +7,11 @@ type CaseStmt struct {
ChildNodes []Node
}
func parseCaseStmt(line string) *CaseStmt {
func parseCaseStmt(line string) Node {
groups := groupsFromRegex(`<(?P<position>.*)>`, line)
if groups == nil {
return &Unknown{}
}
return &CaseStmt{
Addr: ParseAddress(groups["address"]),

View File

@ -0,0 +1,49 @@
package ast
// CFAuditedTransferAttr
type CFAuditedTransferAttr struct {
Addr Address
Pos Position
Content string
ChildNodes []Node
}
func parseCFAuditedTransferAttr(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)>(?P<content>.*)",
line,
)
if groups == nil {
return &Unknown{}
}
return &CFAuditedTransferAttr{
Addr: ParseAddress(groups["address"]),
Pos: NewPositionFromString(groups["position"]),
Content: groups["content"],
ChildNodes: []Node{},
}
}
// AddChild adds a new child node. Child nodes can then be accessed with the
// Children attribute.
func (n *CFAuditedTransferAttr) AddChild(node Node) {
n.ChildNodes = append(n.ChildNodes, node)
}
// Address returns the numeric address of the node. See the documentation for
// the Address type for more information.
func (n *CFAuditedTransferAttr) Address() Address {
return n.Addr
}
// Children returns the child nodes. If this node does not have any children or
// this node does not support children it will always return an empty slice.
func (n *CFAuditedTransferAttr) Children() []Node {
return n.ChildNodes
}
// Position returns the position in the original source code.
func (n *CFAuditedTransferAttr) Position() Position {
return n.Pos
}

49
ast/cf_consumed_attr.go Normal file
View File

@ -0,0 +1,49 @@
package ast
// CFConsumedAttr
type CFConsumedAttr struct {
Addr Address
Pos Position
Content string
ChildNodes []Node
}
func parseCFConsumedAttr(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)>(?P<content>.*)",
line,
)
if groups == nil {
return &Unknown{}
}
return &CFConsumedAttr{
Addr: ParseAddress(groups["address"]),
Pos: NewPositionFromString(groups["position"]),
Content: groups["content"],
ChildNodes: []Node{},
}
}
// AddChild adds a new child node. Child nodes can then be accessed with the
// Children attribute.
func (n *CFConsumedAttr) AddChild(node Node) {
n.ChildNodes = append(n.ChildNodes, node)
}
// Address returns the numeric address of the node. See the documentation for
// the Address type for more information.
func (n *CFConsumedAttr) Address() Address {
return n.Addr
}
// Children returns the child nodes. If this node does not have any children or
// this node does not support children it will always return an empty slice.
func (n *CFConsumedAttr) Children() []Node {
return n.ChildNodes
}
// Position returns the position in the original source code.
func (n *CFConsumedAttr) Position() Position {
return n.Pos
}

View File

@ -0,0 +1,47 @@
package ast
// CFReturnsNotRetainedAttr
type CFReturnsNotRetainedAttr struct {
Addr Address
Pos Position
ChildNodes []Node
}
func parseCFReturnsNotRetainedAttr(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)>",
line,
)
if groups == nil {
return &Unknown{}
}
return &CFReturnsNotRetainedAttr{
Addr: ParseAddress(groups["address"]),
Pos: NewPositionFromString(groups["position"]),
ChildNodes: []Node{},
}
}
// AddChild adds a new child node. Child nodes can then be accessed with the
// Children attribute.
func (n *CFReturnsNotRetainedAttr) AddChild(node Node) {
n.ChildNodes = append(n.ChildNodes, node)
}
// Address returns the numeric address of the node. See the documentation for
// the Address type for more information.
func (n *CFReturnsNotRetainedAttr) Address() Address {
return n.Addr
}
// Children returns the child nodes. If this node does not have any children or
// this node does not support children it will always return an empty slice.
func (n *CFReturnsNotRetainedAttr) Children() []Node {
return n.ChildNodes
}
// Position returns the position in the original source code.
func (n *CFReturnsNotRetainedAttr) Position() Position {
return n.Pos
}

View File

@ -0,0 +1,47 @@
package ast
// CFReturnsRetainedAttr
type CFReturnsRetainedAttr struct {
Addr Address
Pos Position
ChildNodes []Node
}
func parseCFReturnsRetainedAttr(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)>",
line,
)
if groups == nil {
return &Unknown{}
}
return &CFReturnsRetainedAttr{
Addr: ParseAddress(groups["address"]),
Pos: NewPositionFromString(groups["position"]),
ChildNodes: []Node{},
}
}
// AddChild adds a new child node. Child nodes can then be accessed with the
// Children attribute.
func (n *CFReturnsRetainedAttr) AddChild(node Node) {
n.ChildNodes = append(n.ChildNodes, node)
}
// Address returns the numeric address of the node. See the documentation for
// the Address type for more information.
func (n *CFReturnsRetainedAttr) Address() Address {
return n.Addr
}
// Children returns the child nodes. If this node does not have any children or
// this node does not support children it will always return an empty slice.
func (n *CFReturnsRetainedAttr) Children() []Node {
return n.ChildNodes
}
// Position returns the position in the original source code.
func (n *CFReturnsRetainedAttr) Position() Position {
return n.Pos
}

View File

@ -13,11 +13,14 @@ type CharacterLiteral struct {
ChildNodes []Node
}
func parseCharacterLiteral(line string) *CharacterLiteral {
func parseCharacterLiteral(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)> '(?P<type>.*?)' (?P<value>\\d+)",
line,
)
if groups == nil {
return &Unknown{}
}
return &CharacterLiteral{
Addr: ParseAddress(groups["address"]),

View File

@ -11,7 +11,7 @@ type CompoundAssignOperator struct {
ChildNodes []Node
}
func parseCompoundAssignOperator(line string) *CompoundAssignOperator {
func parseCompoundAssignOperator(line string) Node {
groups := groupsFromRegex(
`<(?P<position>.*)>
'(?P<type>.+?)'
@ -20,6 +20,9 @@ func parseCompoundAssignOperator(line string) *CompoundAssignOperator {
ComputeResultTy='(?P<crestype>.+?)'`,
line,
)
if groups == nil {
return &Unknown{}
}
return &CompoundAssignOperator{
Addr: ParseAddress(groups["address"]),

View File

@ -9,11 +9,14 @@ type CompoundLiteralExpr struct {
ChildNodes []Node
}
func parseCompoundLiteralExpr(line string) *CompoundLiteralExpr {
func parseCompoundLiteralExpr(line string) Node {
groups := groupsFromRegex(
`<(?P<position>.*)> '(?P<type1>.*?)'(:'(?P<type2>.*?)')? lvalue`,
line,
)
if groups == nil {
return &Unknown{}
}
return &CompoundLiteralExpr{
Addr: ParseAddress(groups["address"]),

View File

@ -10,11 +10,14 @@ type CompoundStmt struct {
BelongsToSwitch bool
}
func parseCompoundStmt(line string) *CompoundStmt {
func parseCompoundStmt(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)>",
line,
)
if groups == nil {
return &Unknown{}
}
return &CompoundStmt{
Addr: ParseAddress(groups["address"]),

View File

@ -8,11 +8,14 @@ type ConditionalOperator struct {
ChildNodes []Node
}
func parseConditionalOperator(line string) *ConditionalOperator {
func parseConditionalOperator(line string) Node {
groups := groupsFromRegex(
`<(?P<position>.*)> '(?P<type>.*?)'`,
line,
)
if groups == nil {
return &Unknown{}
}
return &ConditionalOperator{
Addr: ParseAddress(groups["address"]),

View File

@ -9,11 +9,14 @@ type ConstAttr struct {
ChildNodes []Node
}
func parseConstAttr(line string) *ConstAttr {
func parseConstAttr(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)>(?P<tags>.*)",
line,
)
if groups == nil {
return &Unknown{}
}
return &ConstAttr{
Addr: ParseAddress(groups["address"]),

View File

@ -12,11 +12,14 @@ type ConstantArrayType struct {
ChildNodes []Node
}
func parseConstantArrayType(line string) *ConstantArrayType {
func parseConstantArrayType(line string) Node {
groups := groupsFromRegex(
"'(?P<type>.*)' (?P<size>\\d+)",
line,
)
if groups == nil {
return &Unknown{}
}
return &ConstantArrayType{
Addr: ParseAddress(groups["address"]),

View File

@ -7,11 +7,14 @@ type ContinueStmt struct {
ChildNodes []Node
}
func parseContinueStmt(line string) *ContinueStmt {
func parseContinueStmt(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)>",
line,
)
if groups == nil {
return &Unknown{}
}
return &ContinueStmt{
Addr: ParseAddress(groups["address"]),

View File

@ -0,0 +1,53 @@
package ast
// ConvertVectorExpr
type ConvertVectorExpr struct {
Addr Address
Pos Position
Type string
Type2 string
ChildNodes []Node
}
func parseConvertVectorExpr(line string) Node {
groups := groupsFromRegex(
`<(?P<position><invalid sloc>|.*?)>
(?P<type> '.*?')?
(?P<type2>:'.*?')?`,
line,
)
if groups == nil {
return &Unknown{}
}
return &ConvertVectorExpr{
Addr: ParseAddress(groups["address"]),
Pos: NewPositionFromString(groups["position"]),
Type: removeQuotes(groups["type"]),
Type2: groups["type2"],
ChildNodes: []Node{},
}
}
// AddChild adds a new child node. Child nodes can then be accessed with the
// Children attribute.
func (n *ConvertVectorExpr) AddChild(node Node) {
n.ChildNodes = append(n.ChildNodes, node)
}
// Address returns the numeric address of the node. See the documentation for
// the Address type for more information.
func (n *ConvertVectorExpr) Address() Address {
return n.Addr
}
// Children returns the child nodes. If this node does not have any children or
// this node does not support children it will always return an empty slice.
func (n *ConvertVectorExpr) Children() []Node {
return n.ChildNodes
}
// Position returns the position in the original source code.
func (n *ConvertVectorExpr) Position() Position {
return n.Pos
}

View File

@ -7,11 +7,14 @@ type DecayedType struct {
ChildNodes []Node
}
func parseDecayedType(line string) *DecayedType {
func parseDecayedType(line string) Node {
groups := groupsFromRegex(
"'(?P<type>.*)' sugar",
line,
)
if groups == nil {
return &Unknown{}
}
return &DecayedType{
Addr: ParseAddress(groups["address"]),

View File

@ -15,7 +15,7 @@ type DeclRefExpr struct {
ChildNodes []Node
}
func parseDeclRefExpr(line string) *DeclRefExpr {
func parseDeclRefExpr(line string) Node {
groups := groupsFromRegex(
`<(?P<position>.*)>
'(?P<type>.*?)'(:'(?P<type1>.*?)')?
@ -28,6 +28,9 @@ func parseDeclRefExpr(line string) *DeclRefExpr {
`,
line,
)
if groups == nil {
return &Unknown{}
}
return &DeclRefExpr{
Addr: ParseAddress(groups["address"]),

View File

@ -7,11 +7,14 @@ type DeclStmt struct {
ChildNodes []Node
}
func parseDeclStmt(line string) *DeclStmt {
func parseDeclStmt(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)>",
line,
)
if groups == nil {
return &Unknown{}
}
return &DeclStmt{
Addr: ParseAddress(groups["address"]),

View File

@ -7,8 +7,11 @@ type DefaultStmt struct {
ChildNodes []Node
}
func parseDefaultStmt(line string) *DefaultStmt {
func parseDefaultStmt(line string) Node {
groups := groupsFromRegex(`<(?P<position>.*)>`, line)
if groups == nil {
return &Unknown{}
}
return &DefaultStmt{
Addr: ParseAddress(groups["address"]),

View File

@ -11,11 +11,14 @@ type DeprecatedAttr struct {
ChildNodes []Node
}
func parseDeprecatedAttr(line string) *DeprecatedAttr {
func parseDeprecatedAttr(line string) Node {
groups := groupsFromRegex(
`<(?P<position>.*)>(?P<inherited> Inherited)? "(?P<message1>.*?)"(?P<message2> ".*?")?`,
line,
)
if groups == nil {
return &Unknown{}
}
return &DeprecatedAttr{
Addr: ParseAddress(groups["address"]),

View File

@ -8,11 +8,14 @@ type DisableTailCallsAttr struct {
ChildNodes []Node
}
func parseDisableTailCallsAttr(line string) *DisableTailCallsAttr {
func parseDisableTailCallsAttr(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)>",
line,
)
if groups == nil {
return &Unknown{}
}
return &DisableTailCallsAttr{
Addr: ParseAddress(groups["address"]),

View File

@ -7,11 +7,14 @@ type DoStmt struct {
ChildNodes []Node
}
func parseDoStmt(line string) *DoStmt {
func parseDoStmt(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)>",
line,
)
if groups == nil {
return &Unknown{}
}
return &DoStmt{
Addr: ParseAddress(groups["address"]),

View File

@ -8,11 +8,14 @@ type ElaboratedType struct {
ChildNodes []Node
}
func parseElaboratedType(line string) *ElaboratedType {
func parseElaboratedType(line string) Node {
groups := groupsFromRegex(
"'(?P<type>.*?)' (?P<tags>.+)",
line,
)
if groups == nil {
return &Unknown{}
}
return &ElaboratedType{
Addr: ParseAddress(groups["address"]),

View File

@ -8,12 +8,15 @@ type EmptyDecl struct {
ChildNodes []Node
}
func parseEmptyDecl(line string) *EmptyDecl {
func parseEmptyDecl(line string) Node {
groups := groupsFromRegex(
`<(?P<position>.*)>
( (?P<position2>.*))?`,
line,
)
if groups == nil {
return &Unknown{}
}
return &EmptyDecl{
Addr: ParseAddress(groups["address"]),

View File

@ -7,11 +7,14 @@ type Enum struct {
ChildNodes []Node
}
func parseEnum(line string) *Enum {
func parseEnum(line string) Node {
groups := groupsFromRegex(
"'(?P<name>.*?)'",
line,
)
if groups == nil {
return &Unknown{}
}
return &Enum{
Addr: ParseAddress(groups["address"]),

View File

@ -16,7 +16,7 @@ type EnumConstantDecl struct {
ChildNodes []Node
}
func parseEnumConstantDecl(line string) *EnumConstantDecl {
func parseEnumConstantDecl(line string) Node {
groups := groupsFromRegex(
`<(?P<position>.*)>
( (?P<position2>[^ ]+))?
@ -26,6 +26,9 @@ func parseEnumConstantDecl(line string) *EnumConstantDecl {
(?P<type2>:'.*?')?`,
line,
)
if groups == nil {
return &Unknown{}
}
/*type2 := groups["type2"]
if type2 != "" {

View File

@ -15,7 +15,7 @@ type EnumDecl struct {
ChildNodes []Node
}
func parseEnumDecl(line string) *EnumDecl {
func parseEnumDecl(line string) Node {
groups := groupsFromRegex(
`(?:prev (?P<prev>0x[0-9a-f]+) )?
<(?P<position>.*)>
@ -25,6 +25,9 @@ func parseEnumDecl(line string) *EnumDecl {
(?P<type2>:'.*')?`,
line,
)
if groups == nil {
return &Unknown{}
}
/*type2 := groups["type2"]
if type2 != "" {

View File

@ -0,0 +1,49 @@
package ast
// EnumExtensibilityAttr
type EnumExtensibilityAttr struct {
Addr Address
Pos Position
Content string
ChildNodes []Node
}
func parseEnumExtensibilityAttr(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)>(?P<content>.*)",
line,
)
if groups == nil {
return &Unknown{}
}
return &EnumExtensibilityAttr{
Addr: ParseAddress(groups["address"]),
Pos: NewPositionFromString(groups["position"]),
Content: groups["content"],
ChildNodes: []Node{},
}
}
// AddChild adds a new child node. Child nodes can then be accessed with the
// Children attribute.
func (n *EnumExtensibilityAttr) AddChild(node Node) {
n.ChildNodes = append(n.ChildNodes, node)
}
// Address returns the numeric address of the node. See the documentation for
// the Address type for more information.
func (n *EnumExtensibilityAttr) Address() Address {
return n.Addr
}
// Children returns the child nodes. If this node does not have any children or
// this node does not support children it will always return an empty slice.
func (n *EnumExtensibilityAttr) Children() []Node {
return n.ChildNodes
}
// Position returns the position in the original source code.
func (n *EnumExtensibilityAttr) Position() Position {
return n.Pos
}

View File

@ -7,11 +7,14 @@ type EnumType struct {
ChildNodes []Node
}
func parseEnumType(line string) *EnumType {
func parseEnumType(line string) Node {
groups := groupsFromRegex(
"'(?P<name>.*?)'",
line,
)
if groups == nil {
return &Unknown{}
}
return &EnumType{
Addr: ParseAddress(groups["address"]),

View File

@ -8,11 +8,14 @@ type Field struct {
ChildNodes []Node
}
func parseField(line string) *Field {
func parseField(line string) Node {
groups := groupsFromRegex(
`'(?P<string1>.*?)' '(?P<string2>.*?)'`,
line,
)
if groups == nil {
return &Unknown{}
}
return &Field{
Addr: ParseAddress(groups["address"]),

View File

@ -17,7 +17,7 @@ type FieldDecl struct {
ChildNodes []Node
}
func parseFieldDecl(line string) *FieldDecl {
func parseFieldDecl(line string) Node {
groups := groupsFromRegex(
`<(?P<position>.*)>
(?P<position2> col:\d+| line:\d+:\d+)?
@ -29,6 +29,9 @@ func parseFieldDecl(line string) *FieldDecl {
`,
line,
)
if groups == nil {
return &Unknown{}
}
return &FieldDecl{
Addr: ParseAddress(groups["address"]),

49
ast/flag_enum_attr.go Normal file
View File

@ -0,0 +1,49 @@
package ast
// FlagEnumAttr
type FlagEnumAttr struct {
Addr Address
Pos Position
Content string
ChildNodes []Node
}
func parseFlagEnumAttr(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)>(?P<content>.*)",
line,
)
if groups == nil {
return &Unknown{}
}
return &FlagEnumAttr{
Addr: ParseAddress(groups["address"]),
Pos: NewPositionFromString(groups["position"]),
Content: groups["content"],
ChildNodes: []Node{},
}
}
// AddChild adds a new child node. Child nodes can then be accessed with the
// Children attribute.
func (n *FlagEnumAttr) AddChild(node Node) {
n.ChildNodes = append(n.ChildNodes, node)
}
// Address returns the numeric address of the node. See the documentation for
// the Address type for more information.
func (n *FlagEnumAttr) Address() Address {
return n.Addr
}
// Children returns the child nodes. If this node does not have any children or
// this node does not support children it will always return an empty slice.
func (n *FlagEnumAttr) Children() []Node {
return n.ChildNodes
}
// Position returns the position in the original source code.
func (n *FlagEnumAttr) Position() Position {
return n.Pos
}

View File

@ -17,11 +17,14 @@ type FloatingLiteral struct {
ChildNodes []Node
}
func parseFloatingLiteral(line string) *FloatingLiteral {
func parseFloatingLiteral(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)> '(?P<type>.*?)' (?P<value>.+)",
line,
)
if groups == nil {
return &Unknown{}
}
return &FloatingLiteral{
Addr: ParseAddress(groups["address"]),

View File

@ -7,11 +7,14 @@ type ForStmt struct {
ChildNodes []Node
}
func parseForStmt(line string) *ForStmt {
func parseForStmt(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)>",
line,
)
if groups == nil {
return &Unknown{}
}
return &ForStmt{
Addr: ParseAddress(groups["address"]),

View File

@ -9,12 +9,15 @@ type FormatArgAttr struct {
ChildNodes []Node
}
func parseFormatArgAttr(line string) *FormatArgAttr {
func parseFormatArgAttr(line string) Node {
groups := groupsFromRegex(
`<(?P<position>.*)>
*(?P<arg>\d+)`,
line,
)
if groups == nil {
return &Unknown{}
}
return &FormatArgAttr{
Addr: ParseAddress(groups["address"]),

View File

@ -17,7 +17,7 @@ type FormatAttr struct {
ChildNodes []Node
}
func parseFormatAttr(line string) *FormatAttr {
func parseFormatAttr(line string) Node {
groups := groupsFromRegex(
`<(?P<position>.*)>
(?P<implicit> Implicit)?
@ -27,6 +27,9 @@ func parseFormatAttr(line string) *FormatAttr {
(?P<unknown2>\d+)`,
line,
)
if groups == nil {
return &Unknown{}
}
return &FormatAttr{
Addr: ParseAddress(groups["address"]),

View File

@ -7,11 +7,14 @@ type FullComment struct {
ChildNodes []Node
}
func parseFullComment(line string) *FullComment {
func parseFullComment(line string) Node {
groups := groupsFromRegex(
`<(?P<position>.*)>`,
line,
)
if groups == nil {
return &Unknown{}
}
return &FullComment{
Addr: ParseAddress(groups["address"]),

View File

@ -23,7 +23,7 @@ type FunctionDecl struct {
ChildNodes []Node
}
func parseFunctionDecl(line string) *FunctionDecl {
func parseFunctionDecl(line string) Node {
groups := groupsFromRegex(
`(?:parent (?P<parent>0x[0-9a-f]+) )?
(?:prev (?P<prev>0x[0-9a-f]+) )?
@ -41,6 +41,9 @@ func parseFunctionDecl(line string) *FunctionDecl {
`,
line,
)
if groups == nil {
return &Unknown{}
}
return &FunctionDecl{
Addr: ParseAddress(groups["address"]),

View File

@ -8,11 +8,14 @@ type FunctionProtoType struct {
ChildNodes []Node
}
func parseFunctionProtoType(line string) *FunctionProtoType {
func parseFunctionProtoType(line string) Node {
groups := groupsFromRegex(
"'(?P<type>.*?)' (?P<kind>.*)",
line,
)
if groups == nil {
return &Unknown{}
}
return &FunctionProtoType{
Addr: ParseAddress(groups["address"]),

View File

@ -7,11 +7,14 @@ type GCCAsmStmt struct {
ChildNodes []Node
}
func parseGCCAsmStmt(line string) *GCCAsmStmt {
func parseGCCAsmStmt(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)>",
line,
)
if groups == nil {
return &Unknown{}
}
return &GCCAsmStmt{
Addr: ParseAddress(groups["address"]),

View File

@ -9,11 +9,14 @@ type GotoStmt struct {
ChildNodes []Node
}
func parseGotoStmt(line string) *GotoStmt {
func parseGotoStmt(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)> '(?P<name>.*)' (?P<position2>.*)",
line,
)
if groups == nil {
return &Unknown{}
}
return &GotoStmt{
Addr: ParseAddress(groups["address"]),

View File

@ -8,11 +8,14 @@ type HTMLEndTagComment struct {
ChildNodes []Node
}
func parseHTMLEndTagComment(line string) *HTMLEndTagComment {
func parseHTMLEndTagComment(line string) Node {
groups := groupsFromRegex(
`<(?P<position>.*)> Name="(?P<name>.*)"`,
line,
)
if groups == nil {
return &Unknown{}
}
return &HTMLEndTagComment{
Addr: ParseAddress(groups["address"]),

View File

@ -8,11 +8,14 @@ type HTMLStartTagComment struct {
ChildNodes []Node
}
func parseHTMLStartTagComment(line string) *HTMLStartTagComment {
func parseHTMLStartTagComment(line string) Node {
groups := groupsFromRegex(
`<(?P<position>.*)> Name="(?P<name>.*)"`,
line,
)
if groups == nil {
return &Unknown{}
}
return &HTMLStartTagComment{
Addr: ParseAddress(groups["address"]),

47
ast/ib_action_attr.go Normal file
View File

@ -0,0 +1,47 @@
package ast
// IBActionAttr
type IBActionAttr struct {
Addr Address
Pos Position
ChildNodes []Node
}
func parseIBActionAttr(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)>",
line,
)
if groups == nil {
return &Unknown{}
}
return &IBActionAttr{
Addr: ParseAddress(groups["address"]),
Pos: NewPositionFromString(groups["position"]),
ChildNodes: []Node{},
}
}
// AddChild adds a new child node. Child nodes can then be accessed with the
// Children attribute.
func (n *IBActionAttr) AddChild(node Node) {
n.ChildNodes = append(n.ChildNodes, node)
}
// Address returns the numeric address of the node. See the documentation for
// the Address type for more information.
func (n *IBActionAttr) Address() Address {
return n.Addr
}
// Children returns the child nodes. If this node does not have any children or
// this node does not support children it will always return an empty slice.
func (n *IBActionAttr) Children() []Node {
return n.ChildNodes
}
// Position returns the position in the original source code.
func (n *IBActionAttr) Position() Position {
return n.Pos
}

47
ast/ib_outlet_attr.go Normal file
View File

@ -0,0 +1,47 @@
package ast
// IBOutletAttr
type IBOutletAttr struct {
Addr Address
Pos Position
ChildNodes []Node
}
func parseIBOutletAttr(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)>",
line,
)
if groups == nil {
return &Unknown{}
}
return &IBOutletAttr{
Addr: ParseAddress(groups["address"]),
Pos: NewPositionFromString(groups["position"]),
ChildNodes: []Node{},
}
}
// AddChild adds a new child node. Child nodes can then be accessed with the
// Children attribute.
func (n *IBOutletAttr) AddChild(node Node) {
n.ChildNodes = append(n.ChildNodes, node)
}
// Address returns the numeric address of the node. See the documentation for
// the Address type for more information.
func (n *IBOutletAttr) Address() Address {
return n.Addr
}
// Children returns the child nodes. If this node does not have any children or
// this node does not support children it will always return an empty slice.
func (n *IBOutletAttr) Children() []Node {
return n.ChildNodes
}
// Position returns the position in the original source code.
func (n *IBOutletAttr) Position() Position {
return n.Pos
}

View File

@ -7,11 +7,14 @@ type IfStmt struct {
ChildNodes []Node
}
func parseIfStmt(line string) *IfStmt {
func parseIfStmt(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)>",
line,
)
if groups == nil {
return &Unknown{}
}
return &IfStmt{
Addr: ParseAddress(groups["address"]),

View File

@ -13,7 +13,7 @@ type ImplicitCastExpr struct {
// ImplicitCastExprArrayToPointerDecay - constant
const ImplicitCastExprArrayToPointerDecay = "ArrayToPointerDecay"
func parseImplicitCastExpr(line string) *ImplicitCastExpr {
func parseImplicitCastExpr(line string) Node {
groups := groupsFromRegex(
`<(?P<position>.*)>
'(?P<type>.*?)'
@ -22,6 +22,9 @@ func parseImplicitCastExpr(line string) *ImplicitCastExpr {
( part_of_explicit_cast)?`,
line,
)
if groups == nil {
return &Unknown{}
}
return &ImplicitCastExpr{
Addr: ParseAddress(groups["address"]),

View File

@ -9,11 +9,14 @@ type ImplicitValueInitExpr struct {
ChildNodes []Node
}
func parseImplicitValueInitExpr(line string) *ImplicitValueInitExpr {
func parseImplicitValueInitExpr(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)> '(?P<type1>.*?)'(:'(?P<type2>.*)')?",
line,
)
if groups == nil {
return &Unknown{}
}
return &ImplicitValueInitExpr{
Addr: ParseAddress(groups["address"]),

View File

@ -7,11 +7,14 @@ type IncompleteArrayType struct {
ChildNodes []Node
}
func parseIncompleteArrayType(line string) *IncompleteArrayType {
func parseIncompleteArrayType(line string) Node {
groups := groupsFromRegex(
"'(?P<type>.*)' ",
line,
)
if groups == nil {
return &Unknown{}
}
return &IncompleteArrayType{
Addr: ParseAddress(groups["address"]),

View File

@ -13,7 +13,7 @@ type IndirectFieldDecl struct {
ChildNodes []Node
}
func parseIndirectFieldDecl(line string) *IndirectFieldDecl {
func parseIndirectFieldDecl(line string) Node {
groups := groupsFromRegex(
`<(?P<position>.*)>
(?P<position2> [^ ]+:[\d:]+)?
@ -22,6 +22,9 @@ func parseIndirectFieldDecl(line string) *IndirectFieldDecl {
'(?P<type>.+?)'`,
line,
)
if groups == nil {
return &Unknown{}
}
return &IndirectFieldDecl{
Addr: ParseAddress(groups["address"]),

View File

@ -9,11 +9,14 @@ type InitListExpr struct {
ChildNodes []Node
}
func parseInitListExpr(line string) *InitListExpr {
func parseInitListExpr(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)> '(?P<type1>.*?)'(:'(?P<type2>.*)')?",
line,
)
if groups == nil {
return &Unknown{}
}
return &InitListExpr{
Addr: ParseAddress(groups["address"]),

View File

@ -8,11 +8,14 @@ type InlineCommandComment struct {
ChildNodes []Node
}
func parseInlineCommandComment(line string) *InlineCommandComment {
func parseInlineCommandComment(line string) Node {
groups := groupsFromRegex(
`<(?P<position>.*)> (?P<other>.*)`,
line,
)
if groups == nil {
return &Unknown{}
}
return &InlineCommandComment{
Addr: ParseAddress(groups["address"]),

View File

@ -9,11 +9,14 @@ type IntegerLiteral struct {
ChildNodes []Node
}
func parseIntegerLiteral(line string) *IntegerLiteral {
func parseIntegerLiteral(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)> '(?P<type>.*?)' (?P<value>\\d+)",
line,
)
if groups == nil {
return &Unknown{}
}
return &IntegerLiteral{
Addr: ParseAddress(groups["address"]),

View File

@ -8,11 +8,14 @@ type LabelStmt struct {
ChildNodes []Node
}
func parseLabelStmt(line string) *LabelStmt {
func parseLabelStmt(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)> '(?P<name>.*)'",
line,
)
if groups == nil {
return &Unknown{}
}
return &LabelStmt{
Addr: ParseAddress(groups["address"]),

View File

@ -8,11 +8,14 @@ type MallocAttr struct {
ChildNodes []Node
}
func parseMallocAttr(line string) *MallocAttr {
func parseMallocAttr(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)>",
line,
)
if groups == nil {
return &Unknown{}
}
return &MallocAttr{
Addr: ParseAddress(groups["address"]),

View File

@ -11,11 +11,14 @@ type MaxFieldAlignmentAttr struct {
ChildNodes []Node
}
func parseMaxFieldAlignmentAttr(line string) *MaxFieldAlignmentAttr {
func parseMaxFieldAlignmentAttr(line string) Node {
groups := groupsFromRegex(
`<(?P<position>.*)> Implicit (?P<size>\d*)`,
line,
)
if groups == nil {
return &Unknown{}
}
return &MaxFieldAlignmentAttr{
Addr: ParseAddress(groups["address"]),

47
ast/may_alias_attr.go Normal file
View File

@ -0,0 +1,47 @@
package ast
// MayAliasAttr
type MayAliasAttr struct {
Addr Address
Pos Position
ChildNodes []Node
}
func parseMayAliasAttr(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)>",
line,
)
if groups == nil {
return &Unknown{}
}
return &MayAliasAttr{
Addr: ParseAddress(groups["address"]),
Pos: NewPositionFromString(groups["position"]),
ChildNodes: []Node{},
}
}
// AddChild adds a new child node. Child nodes can then be accessed with the
// Children attribute.
func (n *MayAliasAttr) AddChild(node Node) {
n.ChildNodes = append(n.ChildNodes, node)
}
// Address returns the numeric address of the node. See the documentation for
// the Address type for more information.
func (n *MayAliasAttr) Address() Address {
return n.Addr
}
// Children returns the child nodes. If this node does not have any children or
// this node does not support children it will always return an empty slice.
func (n *MayAliasAttr) Children() []Node {
return n.ChildNodes
}
// Position returns the position in the original source code.
func (n *MayAliasAttr) Position() Position {
return n.Pos
}

View File

@ -14,7 +14,7 @@ type MemberExpr struct {
ChildNodes []Node
}
func parseMemberExpr(line string) *MemberExpr {
func parseMemberExpr(line string) Node {
groups := groupsFromRegex(
`<(?P<position>.*)>
'(?P<type>.*?)'
@ -26,6 +26,9 @@ func parseMemberExpr(line string) *MemberExpr {
(?P<address2>[0-9a-fx]+)`,
line,
)
if groups == nil {
return &Unknown{}
}
type2 := groups["type2"]
if type2 != "" {

View File

@ -0,0 +1,49 @@
package ast
// MinVectorWidthAttr
type MinVectorWidthAttr struct {
Addr Address
Pos Position
Content string
ChildNodes []Node
}
func parseMinVectorWidthAttr(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)>(?P<content>.*)",
line,
)
if groups == nil {
return &Unknown{}
}
return &MinVectorWidthAttr{
Addr: ParseAddress(groups["address"]),
Pos: NewPositionFromString(groups["position"]),
Content: groups["content"],
ChildNodes: []Node{},
}
}
// AddChild adds a new child node. Child nodes can then be accessed with the
// Children attribute.
func (n *MinVectorWidthAttr) AddChild(node Node) {
n.ChildNodes = append(n.ChildNodes, node)
}
// Address returns the numeric address of the node. See the documentation for
// the Address type for more information.
func (n *MinVectorWidthAttr) Address() Address {
return n.Addr
}
// Children returns the child nodes. If this node does not have any children or
// this node does not support children it will always return an empty slice.
func (n *MinVectorWidthAttr) Children() []Node {
return n.ChildNodes
}
// Position returns the position in the original source code.
func (n *MinVectorWidthAttr) Position() Position {
return n.Pos
}

View File

@ -9,11 +9,14 @@ type ModeAttr struct {
ChildNodes []Node
}
func parseModeAttr(line string) *ModeAttr {
func parseModeAttr(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)> (?P<name>.+)",
line,
)
if groups == nil {
return &Unknown{}
}
return &ModeAttr{
Addr: ParseAddress(groups["address"]),

47
ast/no_debug_attr.go Normal file
View File

@ -0,0 +1,47 @@
package ast
// NoDebugAttr
type NoDebugAttr struct {
Addr Address
Pos Position
ChildNodes []Node
}
func parseNoDebugAttr(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)>",
line,
)
if groups == nil {
return &Unknown{}
}
return &NoDebugAttr{
Addr: ParseAddress(groups["address"]),
Pos: NewPositionFromString(groups["position"]),
ChildNodes: []Node{},
}
}
// AddChild adds a new child node. Child nodes can then be accessed with the
// Children attribute.
func (n *NoDebugAttr) AddChild(node Node) {
n.ChildNodes = append(n.ChildNodes, node)
}
// Address returns the numeric address of the node. See the documentation for
// the Address type for more information.
func (n *NoDebugAttr) Address() Address {
return n.Addr
}
// Children returns the child nodes. If this node does not have any children or
// this node does not support children it will always return an empty slice.
func (n *NoDebugAttr) Children() []Node {
return n.ChildNodes
}
// Position returns the position in the original source code.
func (n *NoDebugAttr) Position() Position {
return n.Pos
}

47
ast/no_escape_attr.go Normal file
View File

@ -0,0 +1,47 @@
package ast
// NoEscapeAttr
type NoEscapeAttr struct {
Addr Address
Pos Position
ChildNodes []Node
}
func parseNoEscapeAttr(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)>",
line,
)
if groups == nil {
return &Unknown{}
}
return &NoEscapeAttr{
Addr: ParseAddress(groups["address"]),
Pos: NewPositionFromString(groups["position"]),
ChildNodes: []Node{},
}
}
// AddChild adds a new child node. Child nodes can then be accessed with the
// Children attribute.
func (n *NoEscapeAttr) AddChild(node Node) {
n.ChildNodes = append(n.ChildNodes, node)
}
// Address returns the numeric address of the node. See the documentation for
// the Address type for more information.
func (n *NoEscapeAttr) Address() Address {
return n.Addr
}
// Children returns the child nodes. If this node does not have any children or
// this node does not support children it will always return an empty slice.
func (n *NoEscapeAttr) Children() []Node {
return n.ChildNodes
}
// Position returns the position in the original source code.
func (n *NoEscapeAttr) Position() Position {
return n.Pos
}

View File

@ -8,11 +8,14 @@ type NoInlineAttr struct {
ChildNodes []Node
}
func parseNoInlineAttr(line string) *NoInlineAttr {
func parseNoInlineAttr(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)>",
line,
)
if groups == nil {
return &Unknown{}
}
return &NoInlineAttr{
Addr: ParseAddress(groups["address"]),

View File

@ -10,7 +10,7 @@ type NoThrowAttr struct {
Inherited bool
}
func parseNoThrowAttr(line string) *NoThrowAttr {
func parseNoThrowAttr(line string) Node {
groups := groupsFromRegex(
`<(?P<position>.*)>
(?P<inherited> Inherited)?
@ -18,6 +18,9 @@ func parseNoThrowAttr(line string) *NoThrowAttr {
`,
line,
)
if groups == nil {
return &Unknown{}
}
return &NoThrowAttr{
Addr: ParseAddress(groups["address"]),

View File

@ -19,13 +19,16 @@ type NonNullAttr struct {
ChildNodes []Node
}
func parseNonNullAttr(line string) *NonNullAttr {
func parseNonNullAttr(line string) Node {
groups := groupsFromRegex(
`<(?P<position>.*)>
(?P<inherited> Inherited)?
(?P<a> \d+)?(?P<b> \d+)?(?P<c> \d+)?(?P<d> \d+)?`,
line,
)
if groups == nil {
return &Unknown{}
}
a := 0
if groups["a"] != "" {

View File

@ -8,11 +8,14 @@ type NotTailCalledAttr struct {
ChildNodes []Node
}
func parseNotTailCalledAttr(line string) *NotTailCalledAttr {
func parseNotTailCalledAttr(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)>",
line,
)
if groups == nil {
return &Unknown{}
}
return &NotTailCalledAttr{
Addr: ParseAddress(groups["address"]),

49
ast/ns_consumed_attr.go Normal file
View File

@ -0,0 +1,49 @@
package ast
// NSConsumedAttr
type NSConsumedAttr struct {
Addr Address
Pos Position
Content string
ChildNodes []Node
}
func parseNSConsumedAttr(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)>(?P<content>.*)",
line,
)
if groups == nil {
return &Unknown{}
}
return &NSConsumedAttr{
Addr: ParseAddress(groups["address"]),
Pos: NewPositionFromString(groups["position"]),
Content: groups["content"],
ChildNodes: []Node{},
}
}
// AddChild adds a new child node. Child nodes can then be accessed with the
// Children attribute.
func (n *NSConsumedAttr) AddChild(node Node) {
n.ChildNodes = append(n.ChildNodes, node)
}
// Address returns the numeric address of the node. See the documentation for
// the Address type for more information.
func (n *NSConsumedAttr) Address() Address {
return n.Addr
}
// Children returns the child nodes. If this node does not have any children or
// this node does not support children it will always return an empty slice.
func (n *NSConsumedAttr) Children() []Node {
return n.ChildNodes
}
// Position returns the position in the original source code.
func (n *NSConsumedAttr) Position() Position {
return n.Pos
}

View File

@ -0,0 +1,47 @@
package ast
// NSConsumesSelfAttr
type NSConsumesSelfAttr struct {
Addr Address
Pos Position
ChildNodes []Node
}
func parseNSConsumesSelfAttr(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)>",
line,
)
if groups == nil {
return &Unknown{}
}
return &NSConsumesSelfAttr{
Addr: ParseAddress(groups["address"]),
Pos: NewPositionFromString(groups["position"]),
ChildNodes: []Node{},
}
}
// AddChild adds a new child node. Child nodes can then be accessed with the
// Children attribute.
func (n *NSConsumesSelfAttr) AddChild(node Node) {
n.ChildNodes = append(n.ChildNodes, node)
}
// Address returns the numeric address of the node. See the documentation for
// the Address type for more information.
func (n *NSConsumesSelfAttr) Address() Address {
return n.Addr
}
// Children returns the child nodes. If this node does not have any children or
// this node does not support children it will always return an empty slice.
func (n *NSConsumesSelfAttr) Children() []Node {
return n.ChildNodes
}
// Position returns the position in the original source code.
func (n *NSConsumesSelfAttr) Position() Position {
return n.Pos
}

View File

@ -0,0 +1,49 @@
package ast
// NSErrorDomainAttr
type NSErrorDomainAttr struct {
Addr Address
Pos Position
Content string
ChildNodes []Node
}
func parseNSErrorDomainAttr(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)>(?P<content>.*)",
line,
)
if groups == nil {
return &Unknown{}
}
return &NSErrorDomainAttr{
Addr: ParseAddress(groups["address"]),
Pos: NewPositionFromString(groups["position"]),
Content: groups["content"],
ChildNodes: []Node{},
}
}
// AddChild adds a new child node. Child nodes can then be accessed with the
// Children attribute.
func (n *NSErrorDomainAttr) AddChild(node Node) {
n.ChildNodes = append(n.ChildNodes, node)
}
// Address returns the numeric address of the node. See the documentation for
// the Address type for more information.
func (n *NSErrorDomainAttr) Address() Address {
return n.Addr
}
// Children returns the child nodes. If this node does not have any children or
// this node does not support children it will always return an empty slice.
func (n *NSErrorDomainAttr) Children() []Node {
return n.ChildNodes
}
// Position returns the position in the original source code.
func (n *NSErrorDomainAttr) Position() Position {
return n.Pos
}

View File

@ -0,0 +1,47 @@
package ast
// NSReturnsRetainedAttr
type NSReturnsRetainedAttr struct {
Addr Address
Pos Position
ChildNodes []Node
}
func parseNSReturnsRetainedAttr(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)>",
line,
)
if groups == nil {
return &Unknown{}
}
return &NSReturnsRetainedAttr{
Addr: ParseAddress(groups["address"]),
Pos: NewPositionFromString(groups["position"]),
ChildNodes: []Node{},
}
}
// AddChild adds a new child node. Child nodes can then be accessed with the
// Children attribute.
func (n *NSReturnsRetainedAttr) AddChild(node Node) {
n.ChildNodes = append(n.ChildNodes, node)
}
// Address returns the numeric address of the node. See the documentation for
// the Address type for more information.
func (n *NSReturnsRetainedAttr) Address() Address {
return n.Addr
}
// Children returns the child nodes. If this node does not have any children or
// this node does not support children it will always return an empty slice.
func (n *NSReturnsRetainedAttr) Children() []Node {
return n.ChildNodes
}
// Position returns the position in the original source code.
func (n *NSReturnsRetainedAttr) Position() Position {
return n.Pos
}

View File

@ -0,0 +1,56 @@
package ast
// ObjCBoolLiteralExpr
type ObjCBoolLiteralExpr struct {
Addr Address
Pos Position
Type string
Type2 string
Attr string
ChildNodes []Node
}
func parseObjCBoolLiteralExpr(line string) Node {
groups := groupsFromRegex(
`<(?P<position><invalid sloc>|.*?)>
(?P<type> '.*?')?
(?P<type2>:'.*?')?
(?P<attr>.*)`,
line,
)
if groups == nil {
return &Unknown{}
}
return &ObjCBoolLiteralExpr{
Addr: ParseAddress(groups["address"]),
Pos: NewPositionFromString(groups["position"]),
Type: removeQuotes(groups["type"]),
Type2: groups["type2"],
Attr: groups["attr"],
ChildNodes: []Node{},
}
}
// AddChild adds a new child node. Child nodes can then be accessed with the
// Children attribute.
func (n *ObjCBoolLiteralExpr) AddChild(node Node) {
n.ChildNodes = append(n.ChildNodes, node)
}
// Address returns the numeric address of the node. See the documentation for
// the Address type for more information.
func (n *ObjCBoolLiteralExpr) Address() Address {
return n.Addr
}
// Children returns the child nodes. If this node does not have any children or
// this node does not support children it will always return an empty slice.
func (n *ObjCBoolLiteralExpr) Children() []Node {
return n.ChildNodes
}
// Position returns the position in the original source code.
func (n *ObjCBoolLiteralExpr) Position() Position {
return n.Pos
}

47
ast/objc_boxable_attr.go Normal file
View File

@ -0,0 +1,47 @@
package ast
// ObjCBoxableAttr
type ObjCBoxableAttr struct {
Addr Address
Pos Position
ChildNodes []Node
}
func parseObjCBoxableAttr(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)>",
line,
)
if groups == nil {
return &Unknown{}
}
return &ObjCBoxableAttr{
Addr: ParseAddress(groups["address"]),
Pos: NewPositionFromString(groups["position"]),
ChildNodes: []Node{},
}
}
// AddChild adds a new child node. Child nodes can then be accessed with the
// Children attribute.
func (n *ObjCBoxableAttr) AddChild(node Node) {
n.ChildNodes = append(n.ChildNodes, node)
}
// Address returns the numeric address of the node. See the documentation for
// the Address type for more information.
func (n *ObjCBoxableAttr) Address() Address {
return n.Addr
}
// Children returns the child nodes. If this node does not have any children or
// this node does not support children it will always return an empty slice.
func (n *ObjCBoxableAttr) Children() []Node {
return n.ChildNodes
}
// Position returns the position in the original source code.
func (n *ObjCBoxableAttr) Position() Position {
return n.Pos
}

49
ast/objc_bridge_attr.go Normal file
View File

@ -0,0 +1,49 @@
package ast
// ObjCBridgeAttr
type ObjCBridgeAttr struct {
Addr Address
Pos Position
Content string
ChildNodes []Node
}
func parseObjCBridgeAttr(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)>(?P<content>.*)",
line,
)
if groups == nil {
return &Unknown{}
}
return &ObjCBridgeAttr{
Addr: ParseAddress(groups["address"]),
Pos: NewPositionFromString(groups["position"]),
Content: groups["content"],
ChildNodes: []Node{},
}
}
// AddChild adds a new child node. Child nodes can then be accessed with the
// Children attribute.
func (n *ObjCBridgeAttr) AddChild(node Node) {
n.ChildNodes = append(n.ChildNodes, node)
}
// Address returns the numeric address of the node. See the documentation for
// the Address type for more information.
func (n *ObjCBridgeAttr) Address() Address {
return n.Addr
}
// Children returns the child nodes. If this node does not have any children or
// this node does not support children it will always return an empty slice.
func (n *ObjCBridgeAttr) Children() []Node {
return n.ChildNodes
}
// Position returns the position in the original source code.
func (n *ObjCBridgeAttr) Position() Position {
return n.Pos
}

View File

@ -0,0 +1,49 @@
package ast
// ObjCBridgeMutableAttr
type ObjCBridgeMutableAttr struct {
Addr Address
Pos Position
Content string
ChildNodes []Node
}
func parseObjCBridgeMutableAttr(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)>(?P<content>.*)",
line,
)
if groups == nil {
return &Unknown{}
}
return &ObjCBridgeMutableAttr{
Addr: ParseAddress(groups["address"]),
Pos: NewPositionFromString(groups["position"]),
Content: groups["content"],
ChildNodes: []Node{},
}
}
// AddChild adds a new child node. Child nodes can then be accessed with the
// Children attribute.
func (n *ObjCBridgeMutableAttr) AddChild(node Node) {
n.ChildNodes = append(n.ChildNodes, node)
}
// Address returns the numeric address of the node. See the documentation for
// the Address type for more information.
func (n *ObjCBridgeMutableAttr) Address() Address {
return n.Addr
}
// Children returns the child nodes. If this node does not have any children or
// this node does not support children it will always return an empty slice.
func (n *ObjCBridgeMutableAttr) Children() []Node {
return n.ChildNodes
}
// Position returns the position in the original source code.
func (n *ObjCBridgeMutableAttr) Position() Position {
return n.Pos
}

View File

@ -0,0 +1,49 @@
package ast
// ObjCBridgeRelatedAttr
type ObjCBridgeRelatedAttr struct {
Addr Address
Pos Position
Content string
ChildNodes []Node
}
func parseObjCBridgeRelatedAttr(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)>(?P<content>.*)",
line,
)
if groups == nil {
return &Unknown{}
}
return &ObjCBridgeRelatedAttr{
Addr: ParseAddress(groups["address"]),
Pos: NewPositionFromString(groups["position"]),
Content: groups["content"],
ChildNodes: []Node{},
}
}
// AddChild adds a new child node. Child nodes can then be accessed with the
// Children attribute.
func (n *ObjCBridgeRelatedAttr) AddChild(node Node) {
n.ChildNodes = append(n.ChildNodes, node)
}
// Address returns the numeric address of the node. See the documentation for
// the Address type for more information.
func (n *ObjCBridgeRelatedAttr) Address() Address {
return n.Addr
}
// Children returns the child nodes. If this node does not have any children or
// this node does not support children it will always return an empty slice.
func (n *ObjCBridgeRelatedAttr) Children() []Node {
return n.ChildNodes
}
// Position returns the position in the original source code.
func (n *ObjCBridgeRelatedAttr) Position() Position {
return n.Pos
}

View File

@ -14,7 +14,7 @@ type ObjCCategoryDecl struct {
ChildNodes []Node
}
func parseObjCCategoryDecl(line string) *ObjCCategoryDecl {
func parseObjCCategoryDecl(line string) Node {
groups := groupsFromRegex(
`(?:prev (?P<prev>0x[0-9a-f]+) )?
<(?P<position><invalid sloc>|.*)>
@ -22,6 +22,9 @@ func parseObjCCategoryDecl(line string) *ObjCCategoryDecl {
(?P<name> \w+)?`,
line,
)
if groups == nil {
return &Unknown{}
}
return &ObjCCategoryDecl{
Addr: ParseAddress(groups["address"]),

View File

@ -0,0 +1,47 @@
package ast
// ObjCDesignatedInitializerAttr
type ObjCDesignatedInitializerAttr struct {
Addr Address
Pos Position
ChildNodes []Node
}
func parseObjCDesignatedInitializerAttr(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)>",
line,
)
if groups == nil {
return &Unknown{}
}
return &ObjCDesignatedInitializerAttr{
Addr: ParseAddress(groups["address"]),
Pos: NewPositionFromString(groups["position"]),
ChildNodes: []Node{},
}
}
// AddChild adds a new child node. Child nodes can then be accessed with the
// Children attribute.
func (n *ObjCDesignatedInitializerAttr) AddChild(node Node) {
n.ChildNodes = append(n.ChildNodes, node)
}
// Address returns the numeric address of the node. See the documentation for
// the Address type for more information.
func (n *ObjCDesignatedInitializerAttr) Address() Address {
return n.Addr
}
// Children returns the child nodes. If this node does not have any children or
// this node does not support children it will always return an empty slice.
func (n *ObjCDesignatedInitializerAttr) Children() []Node {
return n.ChildNodes
}
// Position returns the position in the original source code.
func (n *ObjCDesignatedInitializerAttr) Position() Position {
return n.Pos
}

View File

@ -0,0 +1,47 @@
package ast
// ObjCExceptionAttr
type ObjCExceptionAttr struct {
Addr Address
Pos Position
ChildNodes []Node
}
func parseObjCExceptionAttr(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)>",
line,
)
if groups == nil {
return &Unknown{}
}
return &ObjCExceptionAttr{
Addr: ParseAddress(groups["address"]),
Pos: NewPositionFromString(groups["position"]),
ChildNodes: []Node{},
}
}
// AddChild adds a new child node. Child nodes can then be accessed with the
// Children attribute.
func (n *ObjCExceptionAttr) AddChild(node Node) {
n.ChildNodes = append(n.ChildNodes, node)
}
// Address returns the numeric address of the node. See the documentation for
// the Address type for more information.
func (n *ObjCExceptionAttr) Address() Address {
return n.Addr
}
// Children returns the child nodes. If this node does not have any children or
// this node does not support children it will always return an empty slice.
func (n *ObjCExceptionAttr) Children() []Node {
return n.ChildNodes
}
// Position returns the position in the original source code.
func (n *ObjCExceptionAttr) Position() Position {
return n.Pos
}

View File

@ -0,0 +1,47 @@
package ast
// ObjCExplicitProtocolImplAttr
type ObjCExplicitProtocolImplAttr struct {
Addr Address
Pos Position
ChildNodes []Node
}
func parseObjCExplicitProtocolImplAttr(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)>",
line,
)
if groups == nil {
return &Unknown{}
}
return &ObjCExplicitProtocolImplAttr{
Addr: ParseAddress(groups["address"]),
Pos: NewPositionFromString(groups["position"]),
ChildNodes: []Node{},
}
}
// AddChild adds a new child node. Child nodes can then be accessed with the
// Children attribute.
func (n *ObjCExplicitProtocolImplAttr) AddChild(node Node) {
n.ChildNodes = append(n.ChildNodes, node)
}
// Address returns the numeric address of the node. See the documentation for
// the Address type for more information.
func (n *ObjCExplicitProtocolImplAttr) Address() Address {
return n.Addr
}
// Children returns the child nodes. If this node does not have any children or
// this node does not support children it will always return an empty slice.
func (n *ObjCExplicitProtocolImplAttr) Children() []Node {
return n.ChildNodes
}
// Position returns the position in the original source code.
func (n *ObjCExplicitProtocolImplAttr) Position() Position {
return n.Pos
}

View File

@ -0,0 +1,47 @@
package ast
// ObjCIndependentClassAttr
type ObjCIndependentClassAttr struct {
Addr Address
Pos Position
ChildNodes []Node
}
func parseObjCIndependentClassAttr(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)>",
line,
)
if groups == nil {
return &Unknown{}
}
return &ObjCIndependentClassAttr{
Addr: ParseAddress(groups["address"]),
Pos: NewPositionFromString(groups["position"]),
ChildNodes: []Node{},
}
}
// AddChild adds a new child node. Child nodes can then be accessed with the
// Children attribute.
func (n *ObjCIndependentClassAttr) AddChild(node Node) {
n.ChildNodes = append(n.ChildNodes, node)
}
// Address returns the numeric address of the node. See the documentation for
// the Address type for more information.
func (n *ObjCIndependentClassAttr) Address() Address {
return n.Addr
}
// Children returns the child nodes. If this node does not have any children or
// this node does not support children it will always return an empty slice.
func (n *ObjCIndependentClassAttr) Children() []Node {
return n.ChildNodes
}
// Position returns the position in the original source code.
func (n *ObjCIndependentClassAttr) Position() Position {
return n.Pos
}

View File

@ -8,11 +8,14 @@ type ObjCInterface struct {
ChildNodes []Node
}
func parseObjCInterface(line string, super bool) *ObjCInterface {
func parseObjCInterface(line string, super bool) Node {
groups := groupsFromRegex(
"'(?P<name>.*)'",
line,
)
if groups == nil {
return &Unknown{}
}
return &ObjCInterface{
Addr: ParseAddress(groups["address"]),

View File

@ -5,7 +5,7 @@ import (
"strings"
)
// ObjCInterfaceDecl is node represents a typedef declaration.
// ObjCInterfaceDecl
type ObjCInterfaceDecl struct {
Addr Address
Pos Position
@ -15,7 +15,7 @@ type ObjCInterfaceDecl struct {
ChildNodes []Node
}
func parseObjCInterfaceDecl(line string) *ObjCInterfaceDecl {
func parseObjCInterfaceDecl(line string) Node {
groups := groupsFromRegex(
`(?:prev (?P<prev>0x[0-9a-f]+) )?
<(?P<position><invalid sloc>|.*)>
@ -24,6 +24,9 @@ func parseObjCInterfaceDecl(line string) *ObjCInterfaceDecl {
(?P<name> \w+)?`,
line,
)
if groups == nil {
return &Unknown{}
}
return &ObjCInterfaceDecl{
Addr: ParseAddress(groups["address"]),

View File

@ -7,11 +7,14 @@ type ObjCInterfaceType struct {
ChildNodes []Node
}
func parseObjCInterfaceType(line string) *ObjCInterfaceType {
func parseObjCInterfaceType(line string) Node {
groups := groupsFromRegex(
"'(?P<type>.*)'",
line,
)
if groups == nil {
return &Unknown{}
}
return &ObjCInterfaceType{
Addr: ParseAddress(groups["address"]),

66
ast/objc_ivar_decl.go Normal file
View File

@ -0,0 +1,66 @@
package ast
import (
"strings"
)
// ObjCIvarDecl is node represents an Objective-C property declaration
type ObjCIvarDecl struct {
Addr Address
Pos Position
Position2 string
Name string
Type string
Type2 string
Attr string
ChildNodes []Node
}
func parseObjCIvarDecl(line string) Node {
groups := groupsFromRegex(
`<(?P<position>.*)>
(?P<position2> col:\d+)?
(?P<name>.*?)
'(?P<type>[^']*?)'
(:'(?P<type2>.*?)')?
(?P<attr> .*)?`,
line,
)
if groups == nil {
return &Unknown{}
}
return &ObjCIvarDecl{
Addr: ParseAddress(groups["address"]),
Pos: NewPositionFromString(groups["position"]),
Position2: strings.TrimSpace(groups["position2"]),
Name: strings.TrimSpace(groups["name"]),
Type: groups["type"],
//Type2: strings.TrimSpace(groups["type2"]),
Attr: strings.TrimSpace(groups["attr"]),
ChildNodes: []Node{},
}
}
// AddChild adds a new child node. Child nodes can then be accessed with the
// Children attribute.
func (n *ObjCIvarDecl) AddChild(node Node) {
n.ChildNodes = append(n.ChildNodes, node)
}
// Address returns the numeric address of the node. See the documentation for
// the Address type for more information.
func (n *ObjCIvarDecl) Address() Address {
return n.Addr
}
// Children returns the child nodes. If this node does not have any children or
// this node does not support children it will always return an empty slice.
func (n *ObjCIvarDecl) Children() []Node {
return n.ChildNodes
}
// Position returns the position in the original source code.
func (n *ObjCIvarDecl) Position() Position {
return n.Pos
}

49
ast/objc_message_expr.go Normal file
View File

@ -0,0 +1,49 @@
package ast
// ObjCMessageExpr
type ObjCMessageExpr struct {
Addr Address
Pos Position
Content string
ChildNodes []Node
}
func parseObjCMessageExpr(line string) Node {
groups := groupsFromRegex(
"<(?P<position>.*)>(?P<content>.*)",
line,
)
if groups == nil {
return &Unknown{}
}
return &ObjCMessageExpr{
Addr: ParseAddress(groups["address"]),
Pos: NewPositionFromString(groups["position"]),
Content: groups["content"],
ChildNodes: []Node{},
}
}
// AddChild adds a new child node. Child nodes can then be accessed with the
// Children attribute.
func (n *ObjCMessageExpr) AddChild(node Node) {
n.ChildNodes = append(n.ChildNodes, node)
}
// Address returns the numeric address of the node. See the documentation for
// the Address type for more information.
func (n *ObjCMessageExpr) Address() Address {
return n.Addr
}
// Children returns the child nodes. If this node does not have any children or
// this node does not support children it will always return an empty slice.
func (n *ObjCMessageExpr) Children() []Node {
return n.ChildNodes
}
// Position returns the position in the original source code.
func (n *ObjCMessageExpr) Position() Position {
return n.Pos
}

Some files were not shown because too many files have changed in this diff Show More