summaryrefslogtreecommitdiff
path: root/parser/parse.go
diff options
context:
space:
mode:
authorMarc Vertes <mvertes@free.fr>2023-09-01 11:42:55 +0200
committerMarc Vertes <mvertes@free.fr>2023-09-01 11:42:55 +0200
commit459eca16816023fb0afdd6e0948e5406d84e5bc5 (patch)
treeb752b860d92af8421614d2d147ea953e85a25871 /parser/parse.go
parent851c793da43be9e4d3319afe440d603c85834045 (diff)
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.
Diffstat (limited to 'parser/parse.go')
-rw-r--r--parser/parse.go11
1 files changed, 8 insertions, 3 deletions
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()