From 864b078610cda814edcdf312d9e85112c854c383 Mon Sep 17 00:00:00 2001 From: xushiwei Date: Tue, 20 Aug 2024 08:58:43 +0800 Subject: [PATCH] llgocppg ast/token --- chore/llcppg/ast/ast.go | 20 ++++++++++---------- chore/llcppg/token/token.go | 15 ++++++++++----- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/chore/llcppg/ast/ast.go b/chore/llcppg/ast/ast.go index 27566722..50c2874c 100644 --- a/chore/llcppg/ast/ast.go +++ b/chore/llcppg/ast/ast.go @@ -16,9 +16,7 @@ package ast -import ( - "github.com/goplus/llgo/chore/llcppg/token" -) +import "github.com/goplus/llgo/chore/llcppg/token" // ============================================================================= @@ -48,11 +46,6 @@ type PPD interface { // preprocessing directive // ============================================================================= // Expressions (Types are also expressions) -type Token struct { - Token token.Token - Lit string -} - type BasicLitKind uint const ( @@ -69,6 +62,8 @@ type BasicLit struct { func (*BasicLit) exprNode() {} +// ------------------------------------------------ + type TypeKind uint const ( @@ -301,9 +296,14 @@ func (*Include) ppdNode() {} // ------------------------------------------------ +type Token struct { + Token token.Token + Lit string +} + type Macro struct { - Name string - Info []*Token + Name string + Tokens []*Token // Tokens[0].Lit is the macro name } func (*Macro) ppdNode() {} diff --git a/chore/llcppg/token/token.go b/chore/llcppg/token/token.go index 398919cc..c1be0dc3 100644 --- a/chore/llcppg/token/token.go +++ b/chore/llcppg/token/token.go @@ -3,25 +3,30 @@ package token type Token uint const ( + ILLEGAL Token = iota + /** * A token that contains some kind of punctuation. */ - PunctuationToken Token = iota + PUNCT + /** * A language keyword. */ - KeywordToken + KEYWORD /** * An identifier (that is not a keyword). */ - IdentifierToken + IDENT + /** * A numeric, string, or character literal. */ - LiteralToken + LITERAL + /** * A comment. */ - CommentToken + COMMENT )