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 ChildNodes []Node
} }
func parseAlignedAttr(line string) *AlignedAttr { func parseAlignedAttr(line string) Node {
groups := groupsFromRegex( groups := groupsFromRegex(
"<(?P<position>.*)>(?P<aligned> aligned)?", "<(?P<position>.*)>(?P<aligned> aligned)?",
line, line,
) )
if groups == nil {
return &Unknown{}
}
return &AlignedAttr{ return &AlignedAttr{
Addr: ParseAddress(groups["address"]), Addr: ParseAddress(groups["address"]),

View File

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

View File

@ -8,11 +8,14 @@ type AlwaysInlineAttr struct {
ChildNodes []Node ChildNodes []Node
} }
func parseAlwaysInlineAttr(line string) *AlwaysInlineAttr { func parseAlwaysInlineAttr(line string) Node {
groups := groupsFromRegex( groups := groupsFromRegex(
"<(?P<position>.*)> always_inline", "<(?P<position>.*)> always_inline",
line, line,
) )
if groups == nil {
return &Unknown{}
}
return &AlwaysInlineAttr{ return &AlwaysInlineAttr{
Addr: ParseAddress(groups["address"]), 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 ChildNodes []Node
} }
func parseArraySubscriptExpr(line string) *ArraySubscriptExpr { func parseArraySubscriptExpr(line string) Node {
groups := groupsFromRegex( groups := groupsFromRegex(
`<(?P<position>.*)> '(?P<type>.*?)'(:'(?P<type2>.*?)')? `<(?P<position>.*)> '(?P<type>.*?)'(:'(?P<type2>.*?)')?
(?P<lvalue> lvalue)? (?P<lvalue> lvalue)?
(?P<vcomp> vectorcomponent)?`, (?P<vcomp> vectorcomponent)?`,
line, line,
) )
if groups == nil {
return &Unknown{}
}
return &ArraySubscriptExpr{ return &ArraySubscriptExpr{
Addr: ParseAddress(groups["address"]), Addr: ParseAddress(groups["address"]),

View File

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

View File

@ -2,6 +2,7 @@
package ast package ast
import ( import (
"fmt"
"strconv" "strconv"
"strings" "strings"
@ -69,6 +70,8 @@ func Parse(fullline string) Node {
return parseAlwaysInlineAttr(line) return parseAlwaysInlineAttr(line)
case "ArraySubscriptExpr": case "ArraySubscriptExpr":
return parseArraySubscriptExpr(line) return parseArraySubscriptExpr(line)
case "ArcWeakrefUnavailableAttr":
return parseArcWeakrefUnavailableAttr(line)
case "AsmLabelAttr": case "AsmLabelAttr":
return parseAsmLabelAttr(line) return parseAsmLabelAttr(line)
case "AttributedType": case "AttributedType":
@ -87,8 +90,18 @@ func Parse(fullline string) Node {
return parseBuiltinType(line) return parseBuiltinType(line)
case "CallExpr": case "CallExpr":
return parseCallExpr(line) return parseCallExpr(line)
case "ConvertVectorExpr":
return parseConvertVectorExpr(line)
case "CaseStmt": case "CaseStmt":
return parseCaseStmt(line) 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": case "CharacterLiteral":
return parseCharacterLiteral(line) return parseCharacterLiteral(line)
case "CompoundLiteralExpr": case "CompoundLiteralExpr":
@ -129,12 +142,16 @@ func Parse(fullline string) Node {
return parseEnumConstantDecl(line) return parseEnumConstantDecl(line)
case "EnumDecl": case "EnumDecl":
return parseEnumDecl(line) return parseEnumDecl(line)
case "EnumExtensibilityAttr":
return parseEnumExtensibilityAttr(line)
case "EnumType": case "EnumType":
return parseEnumType(line) return parseEnumType(line)
case "Field": case "Field":
return parseField(line) return parseField(line)
case "FieldDecl": case "FieldDecl":
return parseFieldDecl(line) return parseFieldDecl(line)
case "FlagEnumAttr":
return parseFlagEnumAttr(line)
case "FloatingLiteral": case "FloatingLiteral":
return parseFloatingLiteral(line) return parseFloatingLiteral(line)
case "FormatAttr": case "FormatAttr":
@ -157,6 +174,10 @@ func Parse(fullline string) Node {
return parseGCCAsmStmt(line) return parseGCCAsmStmt(line)
case "GotoStmt": case "GotoStmt":
return parseGotoStmt(line) return parseGotoStmt(line)
case "IBActionAttr":
return parseIBActionAttr(line)
case "IBOutletAttr":
return parseIBOutletAttr(line)
case "IfStmt": case "IfStmt":
return parseIfStmt(line) return parseIfStmt(line)
case "ImplicitCastExpr": case "ImplicitCastExpr":
@ -179,10 +200,18 @@ func Parse(fullline string) Node {
return parseMallocAttr(line) return parseMallocAttr(line)
case "MaxFieldAlignmentAttr": case "MaxFieldAlignmentAttr":
return parseMaxFieldAlignmentAttr(line) return parseMaxFieldAlignmentAttr(line)
case "MayAliasAttr":
return parseMayAliasAttr(line)
case "MemberExpr": case "MemberExpr":
return parseMemberExpr(line) return parseMemberExpr(line)
case "MinVectorWidthAttr":
return parseMinVectorWidthAttr(line)
case "ModeAttr": case "ModeAttr":
return parseModeAttr(line) return parseModeAttr(line)
case "NoDebugAttr":
return parseNoDebugAttr(line)
case "NoEscapeAttr":
return parseNoEscapeAttr(line)
case "NoInlineAttr": case "NoInlineAttr":
return parseNoInlineAttr(line) return parseNoInlineAttr(line)
case "NoThrowAttr": case "NoThrowAttr":
@ -191,8 +220,34 @@ func Parse(fullline string) Node {
return parseNonNullAttr(line) return parseNonNullAttr(line)
case "NotTailCalledAttr": case "NotTailCalledAttr":
return parseNotTailCalledAttr(line) 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": case "ObjCCategoryDecl":
return parseObjCCategoryDecl(line) 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": case "ObjCInterface":
return parseObjCInterface(line,false) return parseObjCInterface(line,false)
case "super ObjCInterface": case "super ObjCInterface":
@ -201,10 +256,14 @@ func Parse(fullline string) Node {
return parseObjCInterfaceDecl(line) return parseObjCInterfaceDecl(line)
case "ObjCInterfaceType": case "ObjCInterfaceType":
return parseObjCInterfaceType(line) return parseObjCInterfaceType(line)
case "ObjCIvarDecl":
return parseObjCIvarDecl(line)
case "getter ObjCMethod": case "getter ObjCMethod":
return parseObjCMethod(line) return parseObjCMethod(line)
case "ObjCMethod": case "ObjCMethod":
return parseObjCMethod(line) return parseObjCMethod(line)
case "ObjCMessageExpr":
return parseObjCMessageExpr(line)
case "ObjCMethodDecl": case "ObjCMethodDecl":
return parseObjCMethodDecl(line) return parseObjCMethodDecl(line)
case "ObjCObjectType": case "ObjCObjectType":
@ -213,8 +272,14 @@ func Parse(fullline string) Node {
return parseObjCObjectPointerType(line) return parseObjCObjectPointerType(line)
case "ObjCProtocol": case "ObjCProtocol":
return parseObjCProtocol(line) return parseObjCProtocol(line)
case "ObjCReturnsInnerPointerAttr":
return parseObjCReturnsInnerPointerAttr(line)
case "ObjCRequiresSuperAttr":
return parseObjCRequiresSuperAttr(line)
case "ObjCProtocolDecl": case "ObjCProtocolDecl":
return parseObjCProtocolDecl(line) return parseObjCProtocolDecl(line)
case "ObjCRootClassAttr":
return parseObjCRootClassAttr(line)
case "ObjCPropertyDecl": case "ObjCPropertyDecl":
return parseObjCPropertyDecl(line) return parseObjCPropertyDecl(line)
case "ObjCTypeParamDecl": case "ObjCTypeParamDecl":
@ -257,12 +322,26 @@ func Parse(fullline string) Node {
return parseReturnsTwiceAttr(line) return parseReturnsTwiceAttr(line)
case "SentinelAttr": case "SentinelAttr":
return parseSentinelAttr(line) return parseSentinelAttr(line)
case "ShuffleVectorExpr":
return parseShuffleVectorExpr(line)
case "StmtExpr": case "StmtExpr":
return parseStmtExpr(line) return parseStmtExpr(line)
case "StringLiteral": case "StringLiteral":
return parseStringLiteral(line) 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": case "SwitchStmt":
return parseSwitchStmt(line) return parseSwitchStmt(line)
case "TargetAttr":
return parseTargetAttr(line)
case "TextComment": case "TextComment":
return parseTextComment(line) return parseTextComment(line)
case "TranslationUnitDecl": case "TranslationUnitDecl":
@ -281,6 +360,8 @@ func Parse(fullline string) Node {
return parseUnaryOperator(line) return parseUnaryOperator(line)
case "UnavailableAttr": case "UnavailableAttr":
return parseUnavailableAttr(line) return parseUnavailableAttr(line)
case "UsedAttr":
return parseUsedAttr(line)
case "UnusedAttr": case "UnusedAttr":
return parseUnusedAttr(line) return parseUnusedAttr(line)
case "VAArgExpr": case "VAArgExpr":
@ -301,6 +382,8 @@ func Parse(fullline string) Node {
return parseWarnUnusedResultAttr(line) return parseWarnUnusedResultAttr(line)
case "WeakAttr": case "WeakAttr":
return parseWeakAttr(line) return parseWeakAttr(line)
case "WeakImportAttr":
return parseWeakImportAttr(line)
case "WhileStmt": case "WhileStmt":
return parseWhileStmt(line) return parseWhileStmt(line)
case "...": case "...":
@ -323,7 +406,8 @@ func groupsFromRegex(rx, line string) map[string]string {
re := util.GetRegex(rx) re := util.GetRegex(rx)
match := re.FindStringSubmatch(line) match := re.FindStringSubmatch(line)
if len(match) == 0 { 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) result := make(map[string]string)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -11,11 +11,14 @@ type MaxFieldAlignmentAttr struct {
ChildNodes []Node ChildNodes []Node
} }
func parseMaxFieldAlignmentAttr(line string) *MaxFieldAlignmentAttr { func parseMaxFieldAlignmentAttr(line string) Node {
groups := groupsFromRegex( groups := groupsFromRegex(
`<(?P<position>.*)> Implicit (?P<size>\d*)`, `<(?P<position>.*)> Implicit (?P<size>\d*)`,
line, line,
) )
if groups == nil {
return &Unknown{}
}
return &MaxFieldAlignmentAttr{ return &MaxFieldAlignmentAttr{
Addr: ParseAddress(groups["address"]), 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 ChildNodes []Node
} }
func parseMemberExpr(line string) *MemberExpr { func parseMemberExpr(line string) Node {
groups := groupsFromRegex( groups := groupsFromRegex(
`<(?P<position>.*)> `<(?P<position>.*)>
'(?P<type>.*?)' '(?P<type>.*?)'
@ -26,6 +26,9 @@ func parseMemberExpr(line string) *MemberExpr {
(?P<address2>[0-9a-fx]+)`, (?P<address2>[0-9a-fx]+)`,
line, line,
) )
if groups == nil {
return &Unknown{}
}
type2 := groups["type2"] type2 := groups["type2"]
if 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 ChildNodes []Node
} }
func parseModeAttr(line string) *ModeAttr { func parseModeAttr(line string) Node {
groups := groupsFromRegex( groups := groupsFromRegex(
"<(?P<position>.*)> (?P<name>.+)", "<(?P<position>.*)> (?P<name>.+)",
line, line,
) )
if groups == nil {
return &Unknown{}
}
return &ModeAttr{ return &ModeAttr{
Addr: ParseAddress(groups["address"]), 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 ChildNodes []Node
} }
func parseNoInlineAttr(line string) *NoInlineAttr { func parseNoInlineAttr(line string) Node {
groups := groupsFromRegex( groups := groupsFromRegex(
"<(?P<position>.*)>", "<(?P<position>.*)>",
line, line,
) )
if groups == nil {
return &Unknown{}
}
return &NoInlineAttr{ return &NoInlineAttr{
Addr: ParseAddress(groups["address"]), Addr: ParseAddress(groups["address"]),

View File

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

View File

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

View File

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

View File

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

View File

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