diff options
author | Ryo Nihei <nihei.dev@gmail.com> | 2022-05-07 20:41:33 +0900 |
---|---|---|
committer | Ryo Nihei <nihei.dev@gmail.com> | 2022-05-10 23:14:41 +0900 |
commit | 3eb0e88f911386a4e6eca991c1471070596c5554 (patch) | |
tree | 4c3ea445a804d781b846739d70392ceb1353ea6d /spec/lexer.go | |
parent | Make #prec directive change only precedence and not associativity (diff) | |
download | urubu-3eb0e88f911386a4e6eca991c1471070596c5554.tar.gz urubu-3eb0e88f911386a4e6eca991c1471070596c5554.tar.xz |
Change syntax for top-level directives
%name changes to:
#name example;
%left and %right change to:
#prec (
#left a b
#right c d
);
Diffstat (limited to 'spec/lexer.go')
-rw-r--r-- | spec/lexer.go | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/spec/lexer.go b/spec/lexer.go index f9ad871..2459c40 100644 --- a/spec/lexer.go +++ b/spec/lexer.go @@ -25,7 +25,8 @@ const ( tokenKindLabelMarker = tokenKind("@") tokenKindDirectiveMarker = tokenKind("#") tokenKindExpantion = tokenKind("...") - tokenKindMetaDataMarker = tokenKind("%") + tokenKindLParen = tokenKind("(") + tokenKindRParen = tokenKind(")") tokenKindNewline = tokenKind("newline") tokenKindEOF = tokenKind("eof") tokenKindInvalid = tokenKind("invalid") @@ -265,8 +266,10 @@ func (l *lexer) lexAndSkipWSs() (*token, error) { return newSymbolToken(tokenKindDirectiveMarker, newPosition(tok.Row+1, tok.Col+1)), nil case KindIDExpansion: return newSymbolToken(tokenKindExpantion, newPosition(tok.Row+1, tok.Col+1)), nil - case KindIDMetadataMarker: - return newSymbolToken(tokenKindMetaDataMarker, newPosition(tok.Row+1, tok.Col+1)), nil + case KindIDLParen: + return newSymbolToken(tokenKindLParen, newPosition(tok.Row+1, tok.Col+1)), nil + case KindIDRParen: + return newSymbolToken(tokenKindRParen, newPosition(tok.Row+1, tok.Col+1)), nil default: return newInvalidToken(string(tok.Lexeme), newPosition(tok.Row+1, tok.Col+1)), nil } |