Skip to content

Commit

Permalink
Merge pull request goplus#730 from xushiwei/q
Browse files Browse the repository at this point in the history
llgocppg ast/token
  • Loading branch information
xushiwei authored Aug 20, 2024
2 parents 7046415 + 864b078 commit 7eeca21
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
20 changes: 10 additions & 10 deletions chore/llcppg/ast/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@

package ast

import (
"github.com/goplus/llgo/chore/llcppg/token"
)
import "github.com/goplus/llgo/chore/llcppg/token"

// =============================================================================

Expand Down Expand Up @@ -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 (
Expand All @@ -69,6 +62,8 @@ type BasicLit struct {

func (*BasicLit) exprNode() {}

// ------------------------------------------------

type TypeKind uint

const (
Expand Down Expand Up @@ -308,9 +303,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() {}
Expand Down
15 changes: 10 additions & 5 deletions chore/llcppg/token/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

0 comments on commit 7eeca21

Please sign in to comment.