llgocppg ast/token

This commit is contained in:
xushiwei
2024-08-20 08:58:43 +08:00
parent 1a8b319ce2
commit 864b078610
2 changed files with 20 additions and 15 deletions

View File

@@ -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() {}

View File

@@ -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
)