diff options
author | Ryo Nihei <nihei.dev@gmail.com> | 2021-08-28 11:03:09 +0900 |
---|---|---|
committer | Ryo Nihei <nihei.dev@gmail.com> | 2021-08-28 16:59:27 +0900 |
commit | 936b600ce23cce4350a730817a067a8926384baf (patch) | |
tree | 23467c2a49ee4795a0479d960addc1bb747b2c7b /spec/parser.go | |
parent | Support the escape sequecens \' and \\ in a string literal (diff) | |
download | urubu-936b600ce23cce4350a730817a067a8926384baf.tar.gz urubu-936b600ce23cce4350a730817a067a8926384baf.tar.xz |
Use a pattern string defined by a string literal as its alias
Diffstat (limited to 'spec/parser.go')
-rw-r--r-- | spec/parser.go | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/spec/parser.go b/spec/parser.go index 9778521..71ee50b 100644 --- a/spec/parser.go +++ b/spec/parser.go @@ -36,9 +36,10 @@ type AlternativeNode struct { } type ElementNode struct { - ID string - Pattern string - Pos Position + ID string + Pattern string + Literally bool + Pos Position } type DirectiveNode struct { @@ -407,8 +408,9 @@ func (p *parser) parseElement() *ElementNode { } case p.consume(tokenKindStringLiteral): return &ElementNode{ - Pattern: mlspec.EscapePattern(p.lastTok.text), - Pos: p.lastTok.pos, + Pattern: p.lastTok.text, + Literally: true, + Pos: p.lastTok.pos, } } return nil |