Merge pull request #730 from xushiwei/q

llgocppg ast/token
This commit is contained in:
xushiwei
2024-08-20 09:05:48 +08:00
committed by GitHub
2 changed files with 20 additions and 15 deletions

View File

@@ -16,9 +16,7 @@
package ast package ast
import ( import "github.com/goplus/llgo/chore/llcppg/token"
"github.com/goplus/llgo/chore/llcppg/token"
)
// ============================================================================= // =============================================================================
@@ -48,11 +46,6 @@ type PPD interface { // preprocessing directive
// ============================================================================= // =============================================================================
// Expressions (Types are also expressions) // Expressions (Types are also expressions)
type Token struct {
Token token.Token
Lit string
}
type BasicLitKind uint type BasicLitKind uint
const ( const (
@@ -69,6 +62,8 @@ type BasicLit struct {
func (*BasicLit) exprNode() {} func (*BasicLit) exprNode() {}
// ------------------------------------------------
type TypeKind uint type TypeKind uint
const ( const (
@@ -308,9 +303,14 @@ func (*Include) ppdNode() {}
// ------------------------------------------------ // ------------------------------------------------
type Token struct {
Token token.Token
Lit string
}
type Macro struct { type Macro struct {
Name string Name string
Info []*Token Tokens []*Token // Tokens[0].Lit is the macro name
} }
func (*Macro) ppdNode() {} func (*Macro) ppdNode() {}

View File

@@ -3,25 +3,30 @@ package token
type Token uint type Token uint
const ( const (
ILLEGAL Token = iota
/** /**
* A token that contains some kind of punctuation. * A token that contains some kind of punctuation.
*/ */
PunctuationToken Token = iota PUNCT
/** /**
* A language keyword. * A language keyword.
*/ */
KeywordToken KEYWORD
/** /**
* An identifier (that is not a keyword). * An identifier (that is not a keyword).
*/ */
IdentifierToken IDENT
/** /**
* A numeric, string, or character literal. * A numeric, string, or character literal.
*/ */
LiteralToken LITERAL
/** /**
* A comment. * A comment.
*/ */
CommentToken COMMENT
) )