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.
2022-09-04 00:16:49 +00:00
|
|
|
package parser
|
|
|
|
|
|
|
|
import "git.tebibyte.media/arf/arf/lexer"
|
|
|
|
|
|
|
|
// parseIdentifier parses an identifier made out of dot separated names.
|
2022-10-12 03:57:27 +00:00
|
|
|
func (parser *parsingOperation) parseIdentifier () (
|
2022-09-04 00:16:49 +00:00
|
|
|
identifier Identifier,
|
|
|
|
err error,
|
|
|
|
) {
|
|
|
|
err = parser.expect(lexer.TokenKindName)
|
|
|
|
if err != nil { return }
|
|
|
|
identifier.location = parser.token.Location()
|
|
|
|
|
|
|
|
for {
|
2022-09-17 06:07:50 +00:00
|
|
|
if !parser.token.Is(lexer.TokenKindName) {
|
|
|
|
parser.previousToken()
|
|
|
|
break
|
|
|
|
}
|
2022-09-04 00:16:49 +00: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
|
|
|
|
}
|