syntax-tree-accessors #2
@ -16,7 +16,7 @@ var validArgumentStartTokens = []lexer.TokenKind {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (parser *ParsingOperation) parseArgument () (argument Argument, err error) {
|
func (parser *ParsingOperation) parseArgument () (argument Argument, err error) {
|
||||||
argument.setLocation(parser.token.Location())
|
argument.location = parser.token.Location()
|
||||||
|
|
||||||
err = parser.expect(validArgumentStartTokens...)
|
err = parser.expect(validArgumentStartTokens...)
|
||||||
if err != nil { return }
|
if err != nil { return }
|
||||||
@ -44,8 +44,8 @@ func (parser *ParsingOperation) parseArgument () (argument Argument, err error)
|
|||||||
|
|
||||||
declaration := Declaration { }
|
declaration := Declaration { }
|
||||||
declaration.what = what
|
declaration.what = what
|
||||||
declaration.setName(identifier.trail[0])
|
declaration.name = identifier.trail[0]
|
||||||
declaration.setLocation(argument.Location())
|
declaration.location = argument.Location()
|
||||||
|
|
||||||
argument.kind = ArgumentKindDeclaration
|
argument.kind = ArgumentKindDeclaration
|
||||||
argument.value = declaration
|
argument.value = declaration
|
||||||
|
@ -12,7 +12,7 @@ func (parser *ParsingOperation) parseDataSection () (
|
|||||||
if err != nil { return }
|
if err != nil { return }
|
||||||
|
|
||||||
section = &DataSection { }
|
section = &DataSection { }
|
||||||
section.setLocation(parser.token.Location())
|
section.location = parser.token.Location()
|
||||||
|
|
||||||
err = parser.nextToken(lexer.TokenKindPermission)
|
err = parser.nextToken(lexer.TokenKindPermission)
|
||||||
if err != nil { return }
|
if err != nil { return }
|
||||||
|
@ -12,7 +12,7 @@ func (parser *ParsingOperation) parseEnumSection () (
|
|||||||
if err != nil { return }
|
if err != nil { return }
|
||||||
|
|
||||||
section = &EnumSection { }
|
section = &EnumSection { }
|
||||||
section.setLocation(parser.token.Location())
|
section.location = parser.token.Location()
|
||||||
|
|
||||||
// get permission
|
// get permission
|
||||||
err = parser.nextToken(lexer.TokenKindPermission)
|
err = parser.nextToken(lexer.TokenKindPermission)
|
||||||
|
@ -15,7 +15,7 @@ func (parser *ParsingOperation) parseFaceSection () (
|
|||||||
section = &FaceSection {
|
section = &FaceSection {
|
||||||
behaviors: make(map[string] FaceBehavior),
|
behaviors: make(map[string] FaceBehavior),
|
||||||
}
|
}
|
||||||
section.setLocation(parser.token.Location())
|
section.location = parser.token.Location()
|
||||||
|
|
||||||
// get permission
|
// get permission
|
||||||
err = parser.nextToken(lexer.TokenKindPermission)
|
err = parser.nextToken(lexer.TokenKindPermission)
|
||||||
|
@ -13,7 +13,7 @@ func (parser *ParsingOperation) parseFuncSection () (
|
|||||||
if err != nil { return }
|
if err != nil { return }
|
||||||
|
|
||||||
section = &FuncSection { }
|
section = &FuncSection { }
|
||||||
section.setLocation(parser.token.Location())
|
section.location = parser.token.Location()
|
||||||
|
|
||||||
// get permission
|
// get permission
|
||||||
err = parser.nextToken(lexer.TokenKindPermission)
|
err = parser.nextToken(lexer.TokenKindPermission)
|
||||||
|
@ -14,11 +14,6 @@ func (trait locatable) Location () (location file.Location) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// setLocation sets the location of the node.
|
|
||||||
func (trait* locatable) setLocation (location file.Location) {
|
|
||||||
trait.location = location
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewError creates a new error at the node's location.
|
// NewError creates a new error at the node's location.
|
||||||
func (trait locatable) NewError (
|
func (trait locatable) NewError (
|
||||||
message string,
|
message string,
|
||||||
@ -39,11 +34,6 @@ func (trait nameable) Name () (name string) {
|
|||||||
name = trait.name
|
name = trait.name
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// setName sets the name of the node.
|
|
||||||
func (trait *nameable) setName (name string) {
|
|
||||||
trait.name = name
|
|
||||||
}
|
|
||||||
|
|
||||||
// typeable allows a node to have a type.
|
// typeable allows a node to have a type.
|
||||||
type typeable struct {
|
type typeable struct {
|
||||||
what Type
|
what Type
|
||||||
@ -53,8 +43,3 @@ type typeable struct {
|
|||||||
func (trait typeable) Type () (what Type) {
|
func (trait typeable) Type () (what Type) {
|
||||||
return trait.what
|
return trait.what
|
||||||
}
|
}
|
||||||
|
|
||||||
// setType sets the type of the node.
|
|
||||||
func (trait *typeable) setType (what Type) () {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
@ -14,7 +14,7 @@ func (parser *ParsingOperation) parseObjtSection () (
|
|||||||
if err != nil { return }
|
if err != nil { return }
|
||||||
|
|
||||||
section = &ObjtSection { }
|
section = &ObjtSection { }
|
||||||
section.setLocation(parser.token.Location())
|
section.location = parser.token.Location()
|
||||||
|
|
||||||
// get permission
|
// get permission
|
||||||
err = parser.nextToken(lexer.TokenKindPermission)
|
err = parser.nextToken(lexer.TokenKindPermission)
|
||||||
|
@ -14,7 +14,7 @@ func (parser *ParsingOperation) parseTypeSection () (
|
|||||||
if err != nil { return }
|
if err != nil { return }
|
||||||
|
|
||||||
section = &TypeSection { }
|
section = &TypeSection { }
|
||||||
section.setLocation(parser.token.Location())
|
section.location = parser.token.Location()
|
||||||
|
|
||||||
// get permission
|
// get permission
|
||||||
err = parser.nextToken(lexer.TokenKindPermission)
|
err = parser.nextToken(lexer.TokenKindPermission)
|
||||||
|
Reference in New Issue
Block a user