diff options
author | Ryo Nihei <nihei.dev@gmail.com> | 2022-03-29 19:10:23 +0900 |
---|---|---|
committer | Ryo Nihei <nihei.dev@gmail.com> | 2022-03-29 19:10:23 +0900 |
commit | dbd2e20de97cdef56da0de07adff4251de94ef43 (patch) | |
tree | 0f21929ff0147d757c59e6ac558f0c68fc100846 /spec/parser.go | |
parent | Use IDs and labels as parameters of an #ast directive instead of symbol posit... (diff) | |
download | cotia-dbd2e20de97cdef56da0de07adff4251de94ef43.tar.gz cotia-dbd2e20de97cdef56da0de07adff4251de94ef43.tar.xz |
Change syntax of production directives
The position of directives given to productions has moved from before a left-hand side value to after a left-hand side value.
This change aims to simplify the syntax.
However, there is no change in positions of directives given to alternatives.
Diffstat (limited to 'spec/parser.go')
-rw-r--r-- | spec/parser.go | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/spec/parser.go b/spec/parser.go index e092f59..be20e7d 100644 --- a/spec/parser.go +++ b/spec/parser.go @@ -306,19 +306,14 @@ func (p *parser) parseProduction() *ProductionNode { return nil } - dir := p.parseDirective() - if dir != nil { - if !p.consume(tokenKindNewline) { - raiseSyntaxError(p.pos.Row, synErrProdDirNoNewline) - } - } - if !p.consume(tokenKindID) { raiseSyntaxError(p.pos.Row, synErrNoProductionName) } lhs := p.lastTok.text lhsPos := p.lastTok.pos + dir := p.parseDirective() + p.consume(tokenKindNewline) if !p.consume(tokenKindColon) { |