This repository has been archived on 2024-02-27. You can view files and clone it, but cannot push or open issues or pull requests.
arf/parser/misc.go

44 lines
967 B
Go
Raw Normal View History

2022-09-03 18:16:49 -06:00
package parser
import "git.tebibyte.media/arf/arf/lexer"
// parseIdentifier parses an identifier made out of dot separated names.
func (parser *ParsingOperation) parseIdentifier () (
identifier Identifier,
err error,
) {
err = parser.expect(lexer.TokenKindName)
if err != nil { return }
identifier.location = parser.token.Location()
for {
2022-09-17 00:07:50 -06:00
if !parser.token.Is(lexer.TokenKindName) {
parser.previousToken()
break
}
2022-09-03 18:16:49 -06:00
identifier.trail = append (
identifier.trail,
parser.token.Value().(string))
err = parser.nextToken()
if err != nil { return }
if !parser.token.Is(lexer.TokenKindDot) { break }
err = parser.nextToken()
if err != nil { return }
// allow the identifier to continue on to the next line if there
// is a line break right after the dot
for parser.token.Is(lexer.TokenKindNewline) ||
parser.token.Is(lexer.TokenKindIndent) {
err = parser.nextToken()
if err != nil { return }
}
}
return
}