From 459eca16816023fb0afdd6e0948e5406d84e5bc5 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Fri, 1 Sep 2023 11:42:55 +0200 Subject: parser: skip comment modes Refctor node kind names by concatenating category and instance, to allow better sorting. Comments are now parsed and skipped during generation of AST. --- parser/parse.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'parser/parse.go') diff --git a/parser/parse.go b/parser/parse.go index 4f186bd..08fbdbd 100644 --- a/parser/parse.go +++ b/parser/parse.go @@ -1,6 +1,8 @@ package parser -import "github.com/gnolang/parscan/scanner" +import ( + "github.com/gnolang/parscan/scanner" +) const ( Stmt = 1 << iota @@ -43,13 +45,16 @@ func (p *Parser) ParseTokens(tokens []scanner.Token) (roots []*Node, err error) Token: t, Kind: p.Spec[t.Name()].Kind, } + if c.Kind == Comment { + continue + } if t.IsOperator() && (i == 0 || tokens[i-1].IsOperator()) { unaryOp[c] = true } if c.Kind == Undefined { switch t.Kind() { case scanner.Number: - c.Kind = NumberLit + c.Kind = LiteralNumber case scanner.Identifier: c.Kind = Ident } @@ -80,7 +85,7 @@ func (p *Parser) ParseTokens(tokens []scanner.Token) (roots []*Node, err error) } lce.Child = []*Node{{Token: lce.Token, Child: lce.Child, Kind: lce.Kind}} lce.Token = scanner.NewToken("Call", c.Pos()) - lce.Kind = CallExpr + lce.Kind = ExprCall } } tcont := t.Content() -- cgit v1.2.3