Documentation ¶
Overview ¶
Package cc is a C99 compiler front end (Work in progress).
Installation ¶
To install/update cc/v3 invoke:
$ go get [-u] modernc.org/cc/v3
Online documentation ¶
See https://godoc.org/modernc.org/cc/v3.
Status ¶
Most of the functionality is now working.
Supported platforms ¶
The code is known to work on Darwin, Linux and Windows, but the supported features may vary.
Index ¶
- Constants
- func HostConfig(cpp string, opts ...string) (predefined string, includePaths, sysIncludePaths []string, err error)
- func Inspect(n Node, f func(Node, bool) bool)
- func Preprocess(cfg *Config, includePaths, sysIncludePaths []string, sources []Source, ...) error
- func PrettyString(v interface{}) string
- type ABI
- type ABIType
- type AST
- type AbstractDeclarator
- type AbstractDeclaratorCase
- type AdditiveExpression
- type AdditiveExpressionCase
- type AlignmentSpecifier
- type AlignmentSpecifierCase
- type AndExpression
- type AndExpressionCase
- type ArgumentExpressionList
- type Asm
- type AsmArgList
- type AsmExpressionList
- type AsmFunctionDefinition
- type AsmIndex
- type AsmQualifier
- type AsmQualifierCase
- type AsmQualifierList
- type AsmStatement
- type AssignmentExpression
- type AssignmentExpressionCase
- type AtomicTypeSpecifier
- type AttributeSpecifier
- type AttributeSpecifierList
- type AttributeValue
- type AttributeValueCase
- type AttributeValueList
- type BlockItem
- type BlockItemCase
- type BlockItemList
- type CastExpression
- type CastExpressionCase
- type Complex128Value
- type Complex256Value
- type Complex64Value
- type CompoundStatement
- func (n *CompoundStatement) Children() []*CompoundStatement
- func (n *CompoundStatement) Declarations() []*Declaration
- func (n *CompoundStatement) IsJumpTarget() bool
- func (n *CompoundStatement) LabeledStatements() []*LabeledStatement
- func (n *CompoundStatement) Parent() *CompoundStatement
- func (n *CompoundStatement) Position() (r token.Position)
- func (n *CompoundStatement) String() string
- type ConditionalExpression
- type ConditionalExpressionCase
- type Config
- type Config3
- type ConstantExpression
- type Declaration
- type DeclarationList
- type DeclarationSpecifiers
- type DeclarationSpecifiersCase
- type Declarator
- func (n *Declarator) Called() bool
- func (n *Declarator) DeclarationSpecifiers() *DeclarationSpecifiers
- func (n *Declarator) FunctionDefinition() *FunctionDefinition
- func (n *Declarator) HasInitializer() bool
- func (n *Declarator) IsExtern() bool
- func (n *Declarator) IsFunctionPrototype() bool
- func (n *Declarator) IsImplicit() bool
- func (n *Declarator) IsStatic() bool
- func (n *Declarator) LHS() map[*Declarator]struct{}
- func (n *Declarator) LexicalScope() Scope
- func (n *Declarator) Name() StringID
- func (n *Declarator) NameTok() (r Token)
- func (n *Declarator) ParamScope() Scope
- func (n *Declarator) Position() (r token.Position)
- func (n *Declarator) SpecifierQualifierList() *SpecifierQualifierList
- func (n *Declarator) String() string
- func (n *Declarator) Type() Type
- func (n *Declarator) TypeQualifiers() *TypeQualifiers
- type Designation
- type Designator
- type DesignatorCase
- type DesignatorList
- type DirectAbstractDeclarator
- type DirectAbstractDeclaratorCase
- type DirectDeclarator
- type DirectDeclaratorCase
- type EnumSpecifier
- type EnumSpecifierCase
- type Enumerator
- type EnumeratorCase
- type EnumeratorList
- type EqualityExpression
- type EqualityExpressionCase
- type ExclusiveOrExpression
- type ExclusiveOrExpressionCase
- type Expression
- type ExpressionCase
- type ExpressionList
- type ExpressionStatement
- type ExternalDeclaration
- type ExternalDeclarationCase
- type Field
- type Filesystem
- type Float128Value
- type Float32Value
- type Float64Value
- type FunctionDefinition
- type FunctionSpecifier
- type FunctionSpecifierCase
- type IdentifierList
- type InclusiveOrExpression
- type InclusiveOrExpressionCase
- type InitDeclarator
- type InitDeclaratorCase
- type InitDeclaratorList
- type Initializer
- func (n *Initializer) Dump() string
- func (n *Initializer) FirstDesignatorField() Field
- func (n *Initializer) IsConst() bool
- func (n *Initializer) IsZero() bool
- func (n *Initializer) List() []*Initializer
- func (n *Initializer) Parent() *Initializer
- func (n *Initializer) Position() (r token.Position)
- func (n *Initializer) String() string
- func (n *Initializer) TrailingComma() *Token
- func (n *Initializer) Type() Type
- type InitializerCase
- type InitializerList
- func (n *InitializerList) Dump() string
- func (n *InitializerList) IsConst() bool
- func (n *InitializerList) IsEmpty() bool
- func (n *InitializerList) IsZero() bool
- func (n *InitializerList) List() []*Initializer
- func (n *InitializerList) Position() (r token.Position)
- func (n *InitializerList) String() string
- type InitializerValue
- type Int64Value
- type IterationStatement
- type IterationStatementCase
- type JumpStatement
- type JumpStatementCase
- type Kind
- type LabelDeclaration
- type LabeledStatement
- type LabeledStatementCase
- type Linkage
- type LogicalAndExpression
- type LogicalAndExpressionCase
- type LogicalOrExpression
- type LogicalOrExpressionCase
- type Macro
- type MultiplicativeExpression
- type MultiplicativeExpressionCase
- type Node
- type Operand
- type Parameter
- type ParameterDeclaration
- type ParameterDeclarationCase
- type ParameterList
- type ParameterTypeList
- type ParameterTypeListCase
- type Pointer
- type PointerCase
- type PostfixExpression
- type PostfixExpressionCase
- type Pragma
- type PragmaSTDC
- type PrimaryExpression
- type PrimaryExpressionCase
- type RelationalExpression
- type RelationalExpressionCase
- type Scope
- type SelectionStatement
- type SelectionStatementCase
- type SharedFunctionDefinitions
- type ShiftExpression
- type ShiftExpressionCase
- type Source
- type SpecifierQualifierList
- type SpecifierQualifierListCase
- type Statement
- type StatementCase
- type StorageClass
- type StorageClassSpecifier
- type StorageClassSpecifierCase
- type StringID
- type StringValue
- type StructDeclaration
- type StructDeclarationList
- type StructDeclarator
- type StructDeclaratorCase
- type StructDeclaratorList
- type StructInfo
- type StructLayout
- type StructOrUnion
- type StructOrUnionCase
- type StructOrUnionSpecifier
- type StructOrUnionSpecifierCase
- type Token
- type TranslationUnit
- type Type
- type TypeName
- type TypeQualifier
- type TypeQualifierCase
- type TypeQualifiers
- type TypeQualifiersCase
- type TypeSpecifier
- type TypeSpecifierCase
- type Uint64Value
- type UnaryExpression
- type UnaryExpressionCase
- type Value
- type WideStringValue
Examples ¶
- AbstractDeclarator (Decl)
- AbstractDeclarator (Ptr)
- AdditiveExpression (Add)
- AdditiveExpression (Mul)
- AdditiveExpression (Sub)
- AlignmentSpecifier (AlignasExpr)
- AlignmentSpecifier (AlignasType)
- AndExpression (And)
- AndExpression (Eq)
- ArgumentExpressionList (Case0)
- ArgumentExpressionList (Case1)
- Asm (Case0)
- AsmArgList (Case0)
- AsmArgList (Case1)
- AsmExpressionList (Case0)
- AsmExpressionList (Case1)
- AsmFunctionDefinition (Case0)
- AsmIndex (Case0)
- AsmQualifier (Goto)
- AsmQualifier (Inline)
- AsmQualifier (Volatile)
- AsmQualifierList (Case0)
- AsmQualifierList (Case1)
- AsmStatement (Case0)
- AssignmentExpression (Add)
- AssignmentExpression (And)
- AssignmentExpression (Assign)
- AssignmentExpression (Cond)
- AssignmentExpression (Div)
- AssignmentExpression (Lsh)
- AssignmentExpression (Mod)
- AssignmentExpression (Mul)
- AssignmentExpression (Or)
- AssignmentExpression (Rsh)
- AssignmentExpression (Sub)
- AssignmentExpression (Xor)
- AtomicTypeSpecifier (Case0)
- AttributeSpecifier (Case0)
- AttributeSpecifierList (Case0)
- AttributeSpecifierList (Case1)
- AttributeValue (Expr)
- AttributeValue (Ident)
- AttributeValueList (Case0)
- AttributeValueList (Case1)
- BlockItem (Decl)
- BlockItem (FuncDef)
- BlockItem (Label)
- BlockItem (Pragma)
- BlockItem (Stmt)
- BlockItemList (Case0)
- BlockItemList (Case1)
- CastExpression (Cast)
- CastExpression (Unary)
- CompoundStatement (Case0)
- ConditionalExpression (Cond)
- ConditionalExpression (LOr)
- ConstantExpression (Case0)
- Declaration (Case0)
- DeclarationList (Case0)
- DeclarationList (Case1)
- DeclarationSpecifiers (AlignSpec)
- DeclarationSpecifiers (Attribute)
- DeclarationSpecifiers (Func)
- DeclarationSpecifiers (Storage)
- DeclarationSpecifiers (TypeQual)
- DeclarationSpecifiers (TypeSpec)
- Declarator (Case0)
- Designation (Case0)
- Designator (Field)
- Designator (Field2)
- Designator (Index)
- DesignatorList (Case0)
- DesignatorList (Case1)
- DirectAbstractDeclarator (Arr)
- DirectAbstractDeclarator (ArrStar)
- DirectAbstractDeclarator (ArrStatic)
- DirectAbstractDeclarator (Decl)
- DirectAbstractDeclarator (Func)
- DirectAbstractDeclarator (StaticArr)
- DirectDeclarator (Arr)
- DirectDeclarator (ArrStatic)
- DirectDeclarator (Decl)
- DirectDeclarator (FuncIdent)
- DirectDeclarator (FuncParam)
- DirectDeclarator (Ident)
- DirectDeclarator (Line)
- DirectDeclarator (Line2)
- DirectDeclarator (Line3)
- DirectDeclarator (Line4)
- DirectDeclarator (Star)
- DirectDeclarator (StaticArr)
- EnumSpecifier (Def)
- EnumSpecifier (Tag)
- Enumerator (Expr)
- Enumerator (Ident)
- EnumeratorList (Case0)
- EnumeratorList (Case1)
- EqualityExpression (Eq)
- EqualityExpression (Neq)
- EqualityExpression (Rel)
- ExclusiveOrExpression (And)
- ExclusiveOrExpression (Xor)
- Expression (Assign)
- Expression (Comma)
- ExpressionList (Case0)
- ExpressionList (Case1)
- ExpressionStatement (Case0)
- ExternalDeclaration (Asm)
- ExternalDeclaration (AsmStmt)
- ExternalDeclaration (Decl)
- ExternalDeclaration (Empty)
- ExternalDeclaration (FuncDef)
- ExternalDeclaration (Pragma)
- FunctionDefinition (Case0)
- FunctionSpecifier (Inline)
- FunctionSpecifier (Noreturn)
- IdentifierList (Case0)
- IdentifierList (Case1)
- InclusiveOrExpression (Or)
- InclusiveOrExpression (Xor)
- InitDeclarator (Decl)
- InitDeclarator (Init)
- InitDeclaratorList (Case0)
- InitDeclaratorList (Case1)
- InitDeclaratorList (UCN)
- Initializer (Expr)
- Initializer (InitList)
- InitializerList (Case0)
- InitializerList (Case1)
- IterationStatement (Do)
- IterationStatement (For)
- IterationStatement (ForDecl)
- IterationStatement (While)
- JumpStatement (Break)
- JumpStatement (Continue)
- JumpStatement (Goto)
- JumpStatement (GotoExpr)
- JumpStatement (Return)
- LabelDeclaration (Case0)
- LabeledStatement (CaseLabel)
- LabeledStatement (Default)
- LabeledStatement (Label)
- LabeledStatement (Range)
- LogicalAndExpression (LAnd)
- LogicalAndExpression (Or)
- LogicalOrExpression (LAnd)
- LogicalOrExpression (LOr)
- MultiplicativeExpression (Cast)
- MultiplicativeExpression (Div)
- MultiplicativeExpression (Mod)
- MultiplicativeExpression (Mul)
- ParameterDeclaration (Abstract)
- ParameterDeclaration (Decl)
- ParameterList (Case0)
- ParameterList (Case1)
- ParameterTypeList (List)
- ParameterTypeList (Var)
- Pointer (Ptr)
- Pointer (TypeQual)
- PostfixExpression (Call)
- PostfixExpression (ChooseExpr)
- PostfixExpression (Complit)
- PostfixExpression (Dec)
- PostfixExpression (Inc)
- PostfixExpression (Index)
- PostfixExpression (PSelect)
- PostfixExpression (Primary)
- PostfixExpression (Select)
- PostfixExpression (TypeCmp)
- PragmaSTDC (Case0)
- PrimaryExpression (Char)
- PrimaryExpression (Enum)
- PrimaryExpression (Expr)
- PrimaryExpression (Float)
- PrimaryExpression (Ident)
- PrimaryExpression (Int)
- PrimaryExpression (LChar)
- PrimaryExpression (LString)
- PrimaryExpression (Stmt)
- PrimaryExpression (String)
- PrimaryExpression (StringLiteral)
- RelationalExpression (Geq)
- RelationalExpression (Gt)
- RelationalExpression (Leq)
- RelationalExpression (Lt)
- RelationalExpression (Shift)
- SelectionStatement (If)
- SelectionStatement (IfElse)
- SelectionStatement (Switch)
- ShiftExpression (Add)
- ShiftExpression (Lsh)
- ShiftExpression (Rsh)
- SpecifierQualifierList (AlignSpec)
- SpecifierQualifierList (Attribute)
- SpecifierQualifierList (TypeQual)
- SpecifierQualifierList (TypeSpec)
- Statement (Asm)
- Statement (Compound)
- Statement (Expr)
- Statement (Iteration)
- Statement (Jump)
- Statement (Labeled)
- Statement (Selection)
- StorageClassSpecifier (Auto)
- StorageClassSpecifier (Extern)
- StorageClassSpecifier (Register)
- StorageClassSpecifier (Static)
- StorageClassSpecifier (ThreadLocal)
- StorageClassSpecifier (Typedef)
- StructDeclaration (Case0)
- StructDeclarationList (Case0)
- StructDeclarationList (Case1)
- StructDeclarator (BitField)
- StructDeclarator (Decl)
- StructDeclaratorList (Case0)
- StructDeclaratorList (Case1)
- StructOrUnion (Struct)
- StructOrUnion (Union)
- StructOrUnionSpecifier (Def)
- StructOrUnionSpecifier (Tag)
- TranslationUnit (Case0)
- TranslationUnit (Case1)
- TypeName (Case0)
- TypeQualifier (Atomic)
- TypeQualifier (Const)
- TypeQualifier (Restrict)
- TypeQualifier (Volatile)
- TypeQualifiers (Attribute)
- TypeQualifiers (Case2)
- TypeQualifiers (Case3)
- TypeQualifiers (TypeQual)
- TypeSpecifier (Accum)
- TypeSpecifier (Atomic)
- TypeSpecifier (Bool)
- TypeSpecifier (Char)
- TypeSpecifier (Complex)
- TypeSpecifier (Decimal128)
- TypeSpecifier (Decimal32)
- TypeSpecifier (Decimal64)
- TypeSpecifier (Double)
- TypeSpecifier (Enum)
- TypeSpecifier (Float)
- TypeSpecifier (Float128)
- TypeSpecifier (Float16)
- TypeSpecifier (Float32)
- TypeSpecifier (Float32x)
- TypeSpecifier (Float64)
- TypeSpecifier (Float64x)
- TypeSpecifier (Float80)
- TypeSpecifier (Fract)
- TypeSpecifier (Int)
- TypeSpecifier (Int128)
- TypeSpecifier (Int16)
- TypeSpecifier (Int32)
- TypeSpecifier (Int64)
- TypeSpecifier (Int8)
- TypeSpecifier (Long)
- TypeSpecifier (Sat)
- TypeSpecifier (Short)
- TypeSpecifier (Signed)
- TypeSpecifier (StructOrUnion)
- TypeSpecifier (TypedefName)
- TypeSpecifier (TypeofExpr)
- TypeSpecifier (TypeofType)
- TypeSpecifier (Unsigned)
- TypeSpecifier (Void)
- UnaryExpression (Addrof)
- UnaryExpression (AlignofExpr)
- UnaryExpression (AlignofType)
- UnaryExpression (Cpl)
- UnaryExpression (Dec)
- UnaryExpression (Deref)
- UnaryExpression (Imag)
- UnaryExpression (Inc)
- UnaryExpression (LabelAddr)
- UnaryExpression (Minus)
- UnaryExpression (Not)
- UnaryExpression (Plus)
- UnaryExpression (Postfix)
- UnaryExpression (Real)
- UnaryExpression (SizeofExpr)
- UnaryExpression (SizeofType)
Constants ¶
const ( ACCUM // _Accum ADDASSIGN // += ALIGNAS // _Alignas ALIGNOF // _Alignof ANDAND // && ANDASSIGN // &= ARROW // -> ASM // __asm__ ATOMIC // _Atomic ATTRIBUTE // __attribute__ AUTO // auto BOOL // _Bool BREAK // break BUILTINCHOOSEEXPR // __builtin_choose_expr BUILTINTYPESCOMPATIBLE // __builtin_types_compatible_p CASE // case CHAR // char CHARCONST // 'a' COMPLEX // _Complex CONST // const CONTINUE // continue DDD // ... DEC // -- DECIMAL128 // _Decimal128 DECIMAL32 // _Decimal32 DECIMAL64 // _Decimal64 DEFAULT // default DIVASSIGN // /= DO // do DOUBLE // double ELSE // else ENUM // enum ENUMCONST // foo in enum x { foo, bar }; EQ // == EXTERN // extern FLOAT // float FLOAT128 // _Float128 FLOAT16 // __fp16 FLOAT32 // _Float32 FLOAT32X // _Float32x FLOAT64 // _Float64 FLOAT64X // _Float64x FLOAT80 // __float80 FLOATCONST // 1.23 FOR // for FRACT // _Fract GEQ // >= GOTO // goto IDENTIFIER // foo IF // if IMAG // __imag__ INC // ++ INLINE // inline INT // int INT8 // __int8 INT16 // __int16 INT32 // __int32 INT64 // __int64 INT128 // __int128 INTCONST // 42 LABEL // __label__ LEQ // <= LONG // long LONGCHARCONST // L'a' LONGSTRINGLITERAL // L"foo" LSH // << LSHASSIGN // <<= MODASSIGN // %= MULASSIGN // *= NEQ // != NORETURN // _Noreturn ORASSIGN // |= OROR // || PPNUMBER // .32e. PPPASTE // ## PRAGMASTDC // __pragma_stdc REAL // __real__ REGISTER // register RESTRICT // restrict RETURN // return RSH // >> RSHASSIGN // >>= SAT // _Sat SHORT // short SIGNED // signed SIZEOF // sizeof STATIC // static STRINGLITERAL // "foo" STRUCT // struct SUBASSIGN // -= SWITCH // switch THREADLOCAL // _Thread_local TYPEDEF // typedef TYPEDEFNAME // int_t in typedef int int_t; TYPEOF // typeof UNION // union UNSIGNED // unsigned VOID // void VOLATILE // volatile WHILE // while XORASSIGN // ^= )
Values of Token.Rune for lexemes.
Variables ¶
This section is empty.
Functions ¶
func HostConfig ¶
func HostConfig(cpp string, opts ...string) (predefined string, includePaths, sysIncludePaths []string, err error)
HostConfig returns the system C preprocessor/compiler configuration, or an error, if any. The configuration is obtained by running the command named by the cpp argumnent or "cpp" when it's empty. For the predefined macros list the '-dM' options is added. For the include paths lists, the option '-v' is added and the output is parsed to extract the "..." include and <...> include paths. To add any other options to cpp, list them in opts.
The function relies on a POSIX/GCC compatible C preprocessor installed. Execution of HostConfig is not free, so caching of the results is recommended.
func Inspect ¶
Inspect inspects AST node trees.
If n is a non-terminal node, f(n, true) is called first. Next, f is called recursively for each of n's non-nil non-terminal children nodes, if any, in alphabetical order. Next, all n's terminal nodes, if any, are visited in the numeric order of their suffixes (Token, Token2, Token3, ...). Finally, f(n, false) is invoked.
If n a terminal node, of type *Token, f(n, <unspecified boolean value> is called once.
Inspect stops when any invocation of f returns false.
func Preprocess ¶
func Preprocess(cfg *Config, includePaths, sysIncludePaths []string, sources []Source, w io.Writer) error
Preprocess preprocesses a translation unit and outputs the result to w.
Please see Parse for the documentation of the other parameters.
func PrettyString ¶
func PrettyString(v interface{}) string
PrettyString returns a formatted representation of things produced by this package.
Types ¶
type ABI ¶
type ABI struct { ByteOrder binary.ByteOrder Types map[Kind]ABIType SignedChar bool // contains filtered or unexported fields }
ABI describes selected parts of the Application Binary Interface.
func NewABI ¶
NewABI creates an ABI for a given OS and architecture. The OS and architecture values are the same as used in Go. The ABI type map may miss advanced types like complex numbers, etc. If the os/arch pair is not recognized, a *ErrUnsupportedOSArch is returned.
func NewABIFromEnv ¶
NewABIFromEnv uses GOOS and GOARCH values to create a corresponding ABI. If those environment variables are not set, an OS/arch of a Go runtime is used. It returns a *ErrUnsupportedOSArch if OS/arch pair is not supported.
type AST ¶
type AST struct { Enums map[StringID]Operand // Enumeration constants declared in file scope. Macros map[StringID]*Macro // Macros as defined after parsing. PtrdiffType Type Scope Scope // File scope. SizeType Type StructTypes map[StringID]Type // Tagged struct/union types declared in file scope. // Alignment and size of every struct/union defined in the translation // unit. Valid only after Translate. Structs map[StructInfo]struct{} // TLD contains pruned file scope declarators, ie. either the first one // or the first one that has an initializer. TLD map[*Declarator]struct{} TrailingSeperator StringID // White space and/or comments preceding EOF. TranslationUnit *TranslationUnit WideCharType Type // contains filtered or unexported fields }
AST represents a translation unit and its related data.
func Parse ¶
Parse preprocesses and parses a translation unit and returns an *AST or error, if any.
Search paths listed in includePaths and sysIncludePaths are used to resolve #include "foo.h" and #include <foo.h> preprocessing directives respectively. A special search path "@" is interpreted as 'the same directory as where the file with the #include directive is'.
The sources should typically provide, usually in this particular order:
- predefined macros, eg.
#define __SIZE_TYPE__ long unsigned int
- built-in declarations, eg.
int __builtin_printf(char *__format, ...);
- command-line provided directives, eg.
#define FOO #define BAR 42 #undef QUX
- normal C sources, eg.
int main() {}
All search and file paths should be absolute paths.
If the preprocessed translation unit is empty, the function may return (nil, nil).
The parser does only the minimum declarations/identifier resolving necessary for correct parsing. Redeclarations are not checked.
Declarators (*Declarator) and StructDeclarators (*StructDeclarator) are inserted in the appropriate scopes.
Tagged struct/union specifier definitions (*StructOrUnionSpecifier) are inserted in the appropriate scopes.
Tagged enum specifier definitions (*EnumSpecifier) and enumeration constants (*Enumerator) are inserted in the appropriate scopes.
Labels (*LabeledStatement) are inserted in the appropriate scopes.
func Translate ¶
Translate parses and typechecks a translation unit and returns an *AST or error, if any.
Please see Parse for the documentation of the parameters.
type AbstractDeclarator ¶
type AbstractDeclarator struct { Case AbstractDeclaratorCase `PrettyPrint:"stringer,zero"` DirectAbstractDeclarator *DirectAbstractDeclarator Pointer *Pointer // contains filtered or unexported fields }
AbstractDeclarator represents data reduced by productions:
AbstractDeclarator: Pointer // Case AbstractDeclaratorPtr | Pointer DirectAbstractDeclarator // Case AbstractDeclaratorDecl
Example (Decl) ¶
fmt.Println(exampleAST(193, "void f(int());"))
Output: &cc.AbstractDeclarator{ · Case: AbstractDeclaratorDecl, · DirectAbstractDeclarator: &cc.DirectAbstractDeclarator{ · · Case: DirectAbstractDeclaratorFunc, · · Token: example.c:1:11: '(' "(", · · Token2: example.c:1:12: ')' ")", · }, }
Example (Ptr) ¶
fmt.Println(exampleAST(192, "void f(int*);"))
Output: &cc.AbstractDeclarator{ · Case: AbstractDeclaratorPtr, · Pointer: &cc.Pointer{ · · Case: PointerTypeQual, · · Token: example.c:1:11: '*' "*", · }, }
func (*AbstractDeclarator) Position ¶
func (n *AbstractDeclarator) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*AbstractDeclarator) String ¶
func (n *AbstractDeclarator) String() string
String implements fmt.Stringer.
type AbstractDeclaratorCase ¶
type AbstractDeclaratorCase int
AbstractDeclaratorCase represents case numbers of production AbstractDeclarator
const ( AbstractDeclaratorPtr AbstractDeclaratorCase = iota AbstractDeclaratorDecl )
Values of type AbstractDeclaratorCase
func (AbstractDeclaratorCase) String ¶
func (n AbstractDeclaratorCase) String() string
String implements fmt.Stringer
type AdditiveExpression ¶
type AdditiveExpression struct { Operand Operand IsSideEffectsFree bool AdditiveExpression *AdditiveExpression Case AdditiveExpressionCase `PrettyPrint:"stringer,zero"` MultiplicativeExpression *MultiplicativeExpression Token Token // contains filtered or unexported fields }
AdditiveExpression represents data reduced by productions:
AdditiveExpression: MultiplicativeExpression // Case AdditiveExpressionMul | AdditiveExpression '+' MultiplicativeExpression // Case AdditiveExpressionAdd | AdditiveExpression '-' MultiplicativeExpression // Case AdditiveExpressionSub
Example (Add) ¶
fmt.Println(exampleAST(46, "int i = x+y;"))
Output: &cc.AdditiveExpression{ · AdditiveExpression: &cc.AdditiveExpression{ · · Case: AdditiveExpressionMul, · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · Case: MultiplicativeExpressionCast, · · · CastExpression: &cc.CastExpression{ · · · · Case: CastExpressionUnary, · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · Case: UnaryExpressionPostfix, · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · Case: PostfixExpressionPrimary, · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · Token: example.c:1:9: IDENTIFIER "x", · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · }, · Case: AdditiveExpressionAdd, · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · Case: MultiplicativeExpressionCast, · · CastExpression: &cc.CastExpression{ · · · Case: CastExpressionUnary, · · · UnaryExpression: &cc.UnaryExpression{ · · · · Case: UnaryExpressionPostfix, · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · Case: PostfixExpressionPrimary, · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · Case: PrimaryExpressionIdent, · · · · · · Token: example.c:1:11: IDENTIFIER "y", · · · · · }, · · · · }, · · · }, · · }, · }, · Token: example.c:1:10: '+' "+", }
Example (Mul) ¶
fmt.Println(exampleAST(45, "int i = x;"))
Output: &cc.AdditiveExpression{ · Case: AdditiveExpressionMul, · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · Case: MultiplicativeExpressionCast, · · CastExpression: &cc.CastExpression{ · · · Case: CastExpressionUnary, · · · UnaryExpression: &cc.UnaryExpression{ · · · · Case: UnaryExpressionPostfix, · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · Case: PostfixExpressionPrimary, · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · Case: PrimaryExpressionIdent, · · · · · · Token: example.c:1:9: IDENTIFIER "x", · · · · · }, · · · · }, · · · }, · · }, · }, }
Example (Sub) ¶
fmt.Println(exampleAST(47, "int i = x-y;"))
Output: &cc.AdditiveExpression{ · AdditiveExpression: &cc.AdditiveExpression{ · · Case: AdditiveExpressionMul, · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · Case: MultiplicativeExpressionCast, · · · CastExpression: &cc.CastExpression{ · · · · Case: CastExpressionUnary, · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · Case: UnaryExpressionPostfix, · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · Case: PostfixExpressionPrimary, · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · Token: example.c:1:9: IDENTIFIER "x", · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · }, · Case: AdditiveExpressionSub, · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · Case: MultiplicativeExpressionCast, · · CastExpression: &cc.CastExpression{ · · · Case: CastExpressionUnary, · · · UnaryExpression: &cc.UnaryExpression{ · · · · Case: UnaryExpressionPostfix, · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · Case: PostfixExpressionPrimary, · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · Case: PrimaryExpressionIdent, · · · · · · Token: example.c:1:11: IDENTIFIER "y", · · · · · }, · · · · }, · · · }, · · }, · }, · Token: example.c:1:10: '-' "-", }
func (*AdditiveExpression) Declarator ¶
func (n *AdditiveExpression) Declarator() *Declarator
func (*AdditiveExpression) Position ¶
func (n *AdditiveExpression) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*AdditiveExpression) Promote ¶
func (n *AdditiveExpression) Promote() Type
Promote returns the type the operands of the binary operation are promoted to.
func (*AdditiveExpression) String ¶
func (n *AdditiveExpression) String() string
String implements fmt.Stringer.
type AdditiveExpressionCase ¶
type AdditiveExpressionCase int
AdditiveExpressionCase represents case numbers of production AdditiveExpression
const ( AdditiveExpressionMul AdditiveExpressionCase = iota AdditiveExpressionAdd AdditiveExpressionSub )
Values of type AdditiveExpressionCase
func (AdditiveExpressionCase) String ¶
func (n AdditiveExpressionCase) String() string
String implements fmt.Stringer
type AlignmentSpecifier ¶
type AlignmentSpecifier struct { Case AlignmentSpecifierCase `PrettyPrint:"stringer,zero"` ConstantExpression *ConstantExpression Token Token Token2 Token Token3 Token TypeName *TypeName }
AlignmentSpecifier represents data reduced by productions:
AlignmentSpecifier: "_Alignas" '(' TypeName ')' // Case AlignmentSpecifierAlignasType | "_Alignas" '(' ConstantExpression ')' // Case AlignmentSpecifierAlignasExpr
Example (AlignasExpr) ¶
fmt.Println(exampleAST(168, "_Alignas(0ll) char c;"))
Output: &cc.AlignmentSpecifier{ · Case: AlignmentSpecifierAlignasExpr, · ConstantExpression: &cc.ConstantExpression{ · · ConditionalExpression: &cc.ConditionalExpression{ · · · Case: ConditionalExpressionLOr, · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · Case: LogicalOrExpressionLAnd, · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · Case: LogicalAndExpressionOr, · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · Case: InclusiveOrExpressionXor, · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · Case: AndExpressionEq, · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · Case: PrimaryExpressionInt, · · · · · · · · · · · · · · · · · Token: example.c:1:10: INTCONST "0ll", · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · }, · Token: example.c:1:1: ALIGNAS "_Alignas", · Token2: example.c:1:9: '(' "(", · Token3: example.c:1:13: ')' ")", }
Example (AlignasType) ¶
fmt.Println(exampleAST(167, "_Alignas(double) char c;"))
Output: &cc.AlignmentSpecifier{ · Case: AlignmentSpecifierAlignasType, · Token: example.c:1:1: ALIGNAS "_Alignas", · Token2: example.c:1:9: '(' "(", · Token3: example.c:1:16: ')' ")", · TypeName: &cc.TypeName{ · · SpecifierQualifierList: &cc.SpecifierQualifierList{ · · · Case: SpecifierQualifierListTypeSpec, · · · TypeSpecifier: &cc.TypeSpecifier{ · · · · Case: TypeSpecifierDouble, · · · · Token: example.c:1:10: DOUBLE "double", · · · }, · · }, · }, }
func (*AlignmentSpecifier) Position ¶
func (n *AlignmentSpecifier) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*AlignmentSpecifier) String ¶
func (n *AlignmentSpecifier) String() string
String implements fmt.Stringer.
type AlignmentSpecifierCase ¶
type AlignmentSpecifierCase int
AlignmentSpecifierCase represents case numbers of production AlignmentSpecifier
const ( AlignmentSpecifierAlignasType AlignmentSpecifierCase = iota AlignmentSpecifierAlignasExpr )
Values of type AlignmentSpecifierCase
func (AlignmentSpecifierCase) String ¶
func (n AlignmentSpecifierCase) String() string
String implements fmt.Stringer
type AndExpression ¶
type AndExpression struct { Operand Operand IsSideEffectsFree bool AndExpression *AndExpression Case AndExpressionCase `PrettyPrint:"stringer,zero"` EqualityExpression *EqualityExpression Token Token // contains filtered or unexported fields }
AndExpression represents data reduced by productions:
AndExpression: EqualityExpression // Case AndExpressionEq | AndExpression '&' EqualityExpression // Case AndExpressionAnd
Example (And) ¶
fmt.Println(exampleAST(60, "int i = x & y;"))
Output: &cc.AndExpression{ · AndExpression: &cc.AndExpression{ · · Case: AndExpressionEq, · · EqualityExpression: &cc.EqualityExpression{ · · · Case: EqualityExpressionRel, · · · RelationalExpression: &cc.RelationalExpression{ · · · · Case: RelationalExpressionShift, · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · Case: AdditiveExpressionMul, · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · Case: CastExpressionUnary, · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · Token: example.c:1:9: IDENTIFIER "x", · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · · Case: ShiftExpressionAdd, · · · · }, · · · }, · · }, · }, · Case: AndExpressionAnd, · EqualityExpression: &cc.EqualityExpression{ · · Case: EqualityExpressionRel, · · RelationalExpression: &cc.RelationalExpression{ · · · Case: RelationalExpressionShift, · · · ShiftExpression: &cc.ShiftExpression{ · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · Case: AdditiveExpressionMul, · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · Case: MultiplicativeExpressionCast, · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · Case: CastExpressionUnary, · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · Token: example.c:1:13: IDENTIFIER "y", · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · · Case: ShiftExpressionAdd, · · · }, · · }, · }, · Token: example.c:1:11: '&' "&", }
Example (Eq) ¶
fmt.Println(exampleAST(59, "int i = x;"))
Output: &cc.AndExpression{ · Case: AndExpressionEq, · EqualityExpression: &cc.EqualityExpression{ · · Case: EqualityExpressionRel, · · RelationalExpression: &cc.RelationalExpression{ · · · Case: RelationalExpressionShift, · · · ShiftExpression: &cc.ShiftExpression{ · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · Case: AdditiveExpressionMul, · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · Case: MultiplicativeExpressionCast, · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · Case: CastExpressionUnary, · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · Token: example.c:1:9: IDENTIFIER "x", · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · · Case: ShiftExpressionAdd, · · · }, · · }, · }, }
func (*AndExpression) Declarator ¶
func (n *AndExpression) Declarator() *Declarator
func (*AndExpression) Position ¶
func (n *AndExpression) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*AndExpression) Promote ¶ added in v3.25.2
func (n *AndExpression) Promote() Type
Promote returns the type the operands of the binary operation are promoted to.
func (*AndExpression) String ¶
func (n *AndExpression) String() string
String implements fmt.Stringer.
type AndExpressionCase ¶
type AndExpressionCase int
AndExpressionCase represents case numbers of production AndExpression
const ( AndExpressionEq AndExpressionCase = iota AndExpressionAnd )
Values of type AndExpressionCase
func (AndExpressionCase) String ¶
func (n AndExpressionCase) String() string
String implements fmt.Stringer
type ArgumentExpressionList ¶
type ArgumentExpressionList struct { ArgumentExpressionList *ArgumentExpressionList AssignmentExpression *AssignmentExpression Token Token }
ArgumentExpressionList represents data reduced by productions:
ArgumentExpressionList: AssignmentExpression | ArgumentExpressionList ',' AssignmentExpression
Example (Case0) ¶
fmt.Println(exampleAST(21, "int i = f(x);"))
Output: &cc.ArgumentExpressionList{ · AssignmentExpression: &cc.AssignmentExpression{ · · Case: AssignmentExpressionCond, · · ConditionalExpression: &cc.ConditionalExpression{ · · · Case: ConditionalExpressionLOr, · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · Case: LogicalOrExpressionLAnd, · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · Case: LogicalAndExpressionOr, · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · Case: InclusiveOrExpressionXor, · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · Case: AndExpressionEq, · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · Token: example.c:1:11: IDENTIFIER "x", · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · }, }
Example (Case1) ¶
fmt.Println(exampleAST(22, "int i = f(x, y);"))
Output: &cc.ArgumentExpressionList{ · ArgumentExpressionList: &cc.ArgumentExpressionList{ · · AssignmentExpression: &cc.AssignmentExpression{ · · · Case: AssignmentExpressionCond, · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · Case: ConditionalExpressionLOr, · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · Case: LogicalOrExpressionLAnd, · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · Case: LogicalAndExpressionOr, · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · Token: example.c:1:14: IDENTIFIER "y", · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · · Token: example.c:1:12: ',' ",", · }, · AssignmentExpression: &cc.AssignmentExpression{ · · Case: AssignmentExpressionCond, · · ConditionalExpression: &cc.ConditionalExpression{ · · · Case: ConditionalExpressionLOr, · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · Case: LogicalOrExpressionLAnd, · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · Case: LogicalAndExpressionOr, · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · Case: InclusiveOrExpressionXor, · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · Case: AndExpressionEq, · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · Token: example.c:1:11: IDENTIFIER "x", · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · }, }
func (*ArgumentExpressionList) Position ¶
func (n *ArgumentExpressionList) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*ArgumentExpressionList) String ¶
func (n *ArgumentExpressionList) String() string
String implements fmt.Stringer.
type Asm ¶
type Asm struct { AsmArgList *AsmArgList AsmQualifierList *AsmQualifierList Token Token Token2 Token Token3 Token Token4 Token }
Asm represents data reduced by production:
Asm: "__asm__" AsmQualifierList '(' STRINGLITERAL AsmArgList ')'
Example (Case0) ¶
fmt.Println(exampleAST(258, "__asm__(\"nop\");"))
Output: &cc.Asm{ · Token: example.c:1:1: ASM "__asm__", · Token2: example.c:1:8: '(' "(", · Token3: example.c:1:9: STRINGLITERAL "nop", · Token4: example.c:1:14: ')' ")", }
type AsmArgList ¶
type AsmArgList struct { AsmArgList *AsmArgList AsmExpressionList *AsmExpressionList Token Token }
AsmArgList represents data reduced by productions:
AsmArgList: ':' AsmExpressionList | AsmArgList ':' AsmExpressionList
Example (Case0) ¶
fmt.Println(exampleAST(256, "__asm__(\"nop\": a);"))
Output: &cc.AsmArgList{ · AsmExpressionList: &cc.AsmExpressionList{ · · AssignmentExpression: &cc.AssignmentExpression{ · · · Case: AssignmentExpressionCond, · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · Case: ConditionalExpressionLOr, · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · Case: LogicalOrExpressionLAnd, · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · Case: LogicalAndExpressionOr, · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · Token: example.c:1:16: IDENTIFIER "a", · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · }, · Token: example.c:1:14: ':' ":", }
Example (Case1) ¶
fmt.Println(exampleAST(257, "__asm__(\"nop\": a : b);"))
Output: &cc.AsmArgList{ · AsmArgList: &cc.AsmArgList{ · · AsmExpressionList: &cc.AsmExpressionList{ · · · AssignmentExpression: &cc.AssignmentExpression{ · · · · Case: AssignmentExpressionCond, · · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · · Case: ConditionalExpressionLOr, · · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · · Case: LogicalOrExpressionLAnd, · · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · · Case: LogicalAndExpressionOr, · · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · · Token: example.c:1:20: IDENTIFIER "b", · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · · Token: example.c:1:18: ':' ":", · }, · AsmExpressionList: &cc.AsmExpressionList{ · · AssignmentExpression: &cc.AssignmentExpression{ · · · Case: AssignmentExpressionCond, · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · Case: ConditionalExpressionLOr, · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · Case: LogicalOrExpressionLAnd, · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · Case: LogicalAndExpressionOr, · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · Token: example.c:1:16: IDENTIFIER "a", · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · }, · Token: example.c:1:14: ':' ":", }
func (*AsmArgList) Position ¶
func (n *AsmArgList) Position() (r token.Position)
Position reports the position of the first component of n, if available.
type AsmExpressionList ¶
type AsmExpressionList struct { AsmExpressionList *AsmExpressionList AsmIndex *AsmIndex AssignmentExpression *AssignmentExpression Token Token }
AsmExpressionList represents data reduced by productions:
AsmExpressionList: AsmIndex AssignmentExpression | AsmExpressionList ',' AsmIndex AssignmentExpression
Example (Case0) ¶
fmt.Println(exampleAST(254, "__asm__(\"nop\": a);"))
Output: &cc.AsmExpressionList{ · AssignmentExpression: &cc.AssignmentExpression{ · · Case: AssignmentExpressionCond, · · ConditionalExpression: &cc.ConditionalExpression{ · · · Case: ConditionalExpressionLOr, · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · Case: LogicalOrExpressionLAnd, · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · Case: LogicalAndExpressionOr, · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · Case: InclusiveOrExpressionXor, · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · Case: AndExpressionEq, · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · Token: example.c:1:16: IDENTIFIER "a", · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · }, }
Example (Case1) ¶
fmt.Println(exampleAST(255, "__asm__(\"nop\": a, b);"))
Output: &cc.AsmExpressionList{ · AsmExpressionList: &cc.AsmExpressionList{ · · AssignmentExpression: &cc.AssignmentExpression{ · · · Case: AssignmentExpressionCond, · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · Case: ConditionalExpressionLOr, · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · Case: LogicalOrExpressionLAnd, · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · Case: LogicalAndExpressionOr, · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · Token: example.c:1:19: IDENTIFIER "b", · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · · Token: example.c:1:17: ',' ",", · }, · AssignmentExpression: &cc.AssignmentExpression{ · · Case: AssignmentExpressionCond, · · ConditionalExpression: &cc.ConditionalExpression{ · · · Case: ConditionalExpressionLOr, · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · Case: LogicalOrExpressionLAnd, · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · Case: LogicalAndExpressionOr, · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · Case: InclusiveOrExpressionXor, · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · Case: AndExpressionEq, · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · Token: example.c:1:16: IDENTIFIER "a", · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · }, }
func (*AsmExpressionList) Position ¶
func (n *AsmExpressionList) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*AsmExpressionList) String ¶
func (n *AsmExpressionList) String() string
String implements fmt.Stringer.
type AsmFunctionDefinition ¶
type AsmFunctionDefinition struct { AsmStatement *AsmStatement DeclarationSpecifiers *DeclarationSpecifiers Declarator *Declarator }
AsmFunctionDefinition represents data reduced by production:
AsmFunctionDefinition: DeclarationSpecifiers Declarator AsmStatement
Example (Case0) ¶
fmt.Println(exampleAST(260, "int f() __asm__(\"nop\");"))
Output: &cc.AsmFunctionDefinition{ · AsmStatement: &cc.AsmStatement{ · · Asm: &cc.Asm{ · · · Token: example.c:1:9: ASM "__asm__", · · · Token2: example.c:1:16: '(' "(", · · · Token3: example.c:1:17: STRINGLITERAL "nop", · · · Token4: example.c:1:22: ')' ")", · · }, · · Token: example.c:1:23: ';' ";", · }, · DeclarationSpecifiers: &cc.DeclarationSpecifiers{ · · Case: DeclarationSpecifiersTypeSpec, · · TypeSpecifier: &cc.TypeSpecifier{ · · · Case: TypeSpecifierInt, · · · Token: example.c:1:1: INT "int", · · }, · }, · Declarator: &cc.Declarator{ · · DirectDeclarator: &cc.DirectDeclarator{ · · · Case: DirectDeclaratorFuncIdent, · · · DirectDeclarator: &cc.DirectDeclarator{ · · · · Case: DirectDeclaratorIdent, · · · · Token: example.c:1:5: IDENTIFIER "f", · · · }, · · · Token: example.c:1:6: '(' "(", · · · Token2: example.c:1:7: ')' ")", · · }, · }, }
func (*AsmFunctionDefinition) Position ¶
func (n *AsmFunctionDefinition) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*AsmFunctionDefinition) String ¶
func (n *AsmFunctionDefinition) String() string
String implements fmt.Stringer.
type AsmIndex ¶
type AsmIndex struct { Expression *Expression Token Token Token2 Token }
AsmIndex represents data reduced by production:
AsmIndex: '[' Expression ']'
Example (Case0) ¶
fmt.Println(exampleAST(253, "__asm__(\"nop\": [a] b);"))
Output: &cc.AsmIndex{ · Expression: &cc.Expression{ · · AssignmentExpression: &cc.AssignmentExpression{ · · · Case: AssignmentExpressionCond, · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · Case: ConditionalExpressionLOr, · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · Case: LogicalOrExpressionLAnd, · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · Case: LogicalAndExpressionOr, · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · Token: example.c:1:17: IDENTIFIER "a", · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · · Case: ExpressionAssign, · }, · Token: example.c:1:16: '[' "[", · Token2: example.c:1:18: ']' "]", }
type AsmQualifier ¶
type AsmQualifier struct { Case AsmQualifierCase `PrettyPrint:"stringer,zero"` Token Token }
AsmQualifier represents data reduced by productions:
AsmQualifier: "volatile" // Case AsmQualifierVolatile | "inline" // Case AsmQualifierInline | "goto" // Case AsmQualifierGoto
Example (Goto) ¶
fmt.Println(exampleAST(263, "__asm__ goto (\"nop\");"))
Output: &cc.AsmQualifier{ · Case: AsmQualifierGoto, · Token: example.c:1:9: GOTO "goto", }
Example (Inline) ¶
fmt.Println(exampleAST(262, "__asm__ inline (\"nop\");"))
Output: &cc.AsmQualifier{ · Case: AsmQualifierInline, · Token: example.c:1:9: INLINE "inline", }
Example (Volatile) ¶
fmt.Println(exampleAST(261, "__asm__ volatile (\"nop\");"))
Output: &cc.AsmQualifier{ · Case: AsmQualifierVolatile, · Token: example.c:1:9: VOLATILE "volatile", }
func (*AsmQualifier) Position ¶
func (n *AsmQualifier) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*AsmQualifier) String ¶
func (n *AsmQualifier) String() string
String implements fmt.Stringer.
type AsmQualifierCase ¶
type AsmQualifierCase int
AsmQualifierCase represents case numbers of production AsmQualifier
const ( AsmQualifierVolatile AsmQualifierCase = iota AsmQualifierInline AsmQualifierGoto )
Values of type AsmQualifierCase
func (AsmQualifierCase) String ¶
func (n AsmQualifierCase) String() string
String implements fmt.Stringer
type AsmQualifierList ¶
type AsmQualifierList struct { AsmQualifier *AsmQualifier AsmQualifierList *AsmQualifierList }
AsmQualifierList represents data reduced by productions:
AsmQualifierList: AsmQualifier | AsmQualifierList AsmQualifier
Example (Case0) ¶
fmt.Println(exampleAST(264, "__asm__ inline (\"nop\");"))
Output: &cc.AsmQualifierList{ · AsmQualifier: &cc.AsmQualifier{ · · Case: AsmQualifierInline, · · Token: example.c:1:9: INLINE "inline", · }, }
Example (Case1) ¶
fmt.Println(exampleAST(265, "__asm__ inline volatile (\"nop\");"))
Output: &cc.AsmQualifierList{ · AsmQualifier: &cc.AsmQualifier{ · · Case: AsmQualifierInline, · · Token: example.c:1:9: INLINE "inline", · }, · AsmQualifierList: &cc.AsmQualifierList{ · · AsmQualifier: &cc.AsmQualifier{ · · · Case: AsmQualifierVolatile, · · · Token: example.c:1:16: VOLATILE "volatile", · · }, · }, }
func (*AsmQualifierList) Position ¶
func (n *AsmQualifierList) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*AsmQualifierList) String ¶
func (n *AsmQualifierList) String() string
String implements fmt.Stringer.
type AsmStatement ¶
type AsmStatement struct { Asm *Asm AttributeSpecifierList *AttributeSpecifierList Token Token }
AsmStatement represents data reduced by production:
AsmStatement: Asm AttributeSpecifierList ';'
Example (Case0) ¶
fmt.Println(exampleAST(259, "void f() { __asm__(\"nop\"); }"))
Output: &cc.AsmStatement{ · Asm: &cc.Asm{ · · Token: example.c:1:12: ASM "__asm__", · · Token2: example.c:1:19: '(' "(", · · Token3: example.c:1:20: STRINGLITERAL "nop", · · Token4: example.c:1:25: ')' ")", · }, · Token: example.c:1:26: ';' ";", }
func (*AsmStatement) Position ¶
func (n *AsmStatement) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*AsmStatement) String ¶
func (n *AsmStatement) String() string
String implements fmt.Stringer.
type AssignmentExpression ¶
type AssignmentExpression struct { Operand Operand InitializerOperand Operand // When the expression is used in an initializer IsSideEffectsFree bool AssignmentExpression *AssignmentExpression Case AssignmentExpressionCase `PrettyPrint:"stringer,zero"` ConditionalExpression *ConditionalExpression Token Token UnaryExpression *UnaryExpression // contains filtered or unexported fields }
AssignmentExpression represents data reduced by productions:
AssignmentExpression: ConditionalExpression // Case AssignmentExpressionCond | UnaryExpression '=' AssignmentExpression // Case AssignmentExpressionAssign | UnaryExpression "*=" AssignmentExpression // Case AssignmentExpressionMul | UnaryExpression "/=" AssignmentExpression // Case AssignmentExpressionDiv | UnaryExpression "%=" AssignmentExpression // Case AssignmentExpressionMod | UnaryExpression "+=" AssignmentExpression // Case AssignmentExpressionAdd | UnaryExpression "-=" AssignmentExpression // Case AssignmentExpressionSub | UnaryExpression "<<=" AssignmentExpression // Case AssignmentExpressionLsh | UnaryExpression ">>=" AssignmentExpression // Case AssignmentExpressionRsh | UnaryExpression "&=" AssignmentExpression // Case AssignmentExpressionAnd | UnaryExpression "^=" AssignmentExpression // Case AssignmentExpressionXor | UnaryExpression "|=" AssignmentExpression // Case AssignmentExpressionOr
Example (Add) ¶
fmt.Println(exampleAST(76, "int f() { x += y; }"))
Output: &cc.AssignmentExpression{ · AssignmentExpression: &cc.AssignmentExpression{ · · Case: AssignmentExpressionCond, · · ConditionalExpression: &cc.ConditionalExpression{ · · · Case: ConditionalExpressionLOr, · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · Case: LogicalOrExpressionLAnd, · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · Case: LogicalAndExpressionOr, · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · Case: InclusiveOrExpressionXor, · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · Case: AndExpressionEq, · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · Token: example.c:1:16: IDENTIFIER "y", · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · }, · Case: AssignmentExpressionAdd, · Token: example.c:1:13: ADDASSIGN "+=", · UnaryExpression: &cc.UnaryExpression{ · · Case: UnaryExpressionPostfix, · · PostfixExpression: &cc.PostfixExpression{ · · · Case: PostfixExpressionPrimary, · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · Case: PrimaryExpressionIdent, · · · · Token: example.c:1:11: IDENTIFIER "x", · · · }, · · }, · }, }
Example (And) ¶
fmt.Println(exampleAST(80, "int f() { x &= y; }"))
Output: &cc.AssignmentExpression{ · AssignmentExpression: &cc.AssignmentExpression{ · · Case: AssignmentExpressionCond, · · ConditionalExpression: &cc.ConditionalExpression{ · · · Case: ConditionalExpressionLOr, · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · Case: LogicalOrExpressionLAnd, · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · Case: LogicalAndExpressionOr, · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · Case: InclusiveOrExpressionXor, · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · Case: AndExpressionEq, · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · Token: example.c:1:16: IDENTIFIER "y", · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · }, · Case: AssignmentExpressionAnd, · Token: example.c:1:13: ANDASSIGN "&=", · UnaryExpression: &cc.UnaryExpression{ · · Case: UnaryExpressionPostfix, · · PostfixExpression: &cc.PostfixExpression{ · · · Case: PostfixExpressionPrimary, · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · Case: PrimaryExpressionIdent, · · · · Token: example.c:1:11: IDENTIFIER "x", · · · }, · · }, · }, }
Example (Assign) ¶
fmt.Println(exampleAST(72, "int f() { x = y; }"))
Output: &cc.AssignmentExpression{ · AssignmentExpression: &cc.AssignmentExpression{ · · Case: AssignmentExpressionCond, · · ConditionalExpression: &cc.ConditionalExpression{ · · · Case: ConditionalExpressionLOr, · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · Case: LogicalOrExpressionLAnd, · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · Case: LogicalAndExpressionOr, · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · Case: InclusiveOrExpressionXor, · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · Case: AndExpressionEq, · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · Token: example.c:1:15: IDENTIFIER "y", · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · }, · Case: AssignmentExpressionAssign, · Token: example.c:1:13: '=' "=", · UnaryExpression: &cc.UnaryExpression{ · · Case: UnaryExpressionPostfix, · · PostfixExpression: &cc.PostfixExpression{ · · · Case: PostfixExpressionPrimary, · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · Case: PrimaryExpressionIdent, · · · · Token: example.c:1:11: IDENTIFIER "x", · · · }, · · }, · }, }
Example (Cond) ¶
fmt.Println(exampleAST(71, "int i = x; }"))
Output: &cc.AssignmentExpression{ · Case: AssignmentExpressionCond, · ConditionalExpression: &cc.ConditionalExpression{ · · Case: ConditionalExpressionLOr, · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · Case: LogicalOrExpressionLAnd, · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · Case: LogicalAndExpressionOr, · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · Case: InclusiveOrExpressionXor, · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · Case: AndExpressionEq, · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · Token: example.c:1:9: IDENTIFIER "x", · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · }, · · · · }, · · · }, · · }, · }, }
Example (Div) ¶
fmt.Println(exampleAST(74, "int f() { x /= y; }"))
Output: &cc.AssignmentExpression{ · AssignmentExpression: &cc.AssignmentExpression{ · · Case: AssignmentExpressionCond, · · ConditionalExpression: &cc.ConditionalExpression{ · · · Case: ConditionalExpressionLOr, · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · Case: LogicalOrExpressionLAnd, · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · Case: LogicalAndExpressionOr, · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · Case: InclusiveOrExpressionXor, · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · Case: AndExpressionEq, · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · Token: example.c:1:16: IDENTIFIER "y", · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · }, · Case: AssignmentExpressionDiv, · Token: example.c:1:13: DIVASSIGN "/=", · UnaryExpression: &cc.UnaryExpression{ · · Case: UnaryExpressionPostfix, · · PostfixExpression: &cc.PostfixExpression{ · · · Case: PostfixExpressionPrimary, · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · Case: PrimaryExpressionIdent, · · · · Token: example.c:1:11: IDENTIFIER "x", · · · }, · · }, · }, }
Example (Lsh) ¶
fmt.Println(exampleAST(78, "int f() { x <<= y; }"))
Output: &cc.AssignmentExpression{ · AssignmentExpression: &cc.AssignmentExpression{ · · Case: AssignmentExpressionCond, · · ConditionalExpression: &cc.ConditionalExpression{ · · · Case: ConditionalExpressionLOr, · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · Case: LogicalOrExpressionLAnd, · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · Case: LogicalAndExpressionOr, · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · Case: InclusiveOrExpressionXor, · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · Case: AndExpressionEq, · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · Token: example.c:1:17: IDENTIFIER "y", · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · }, · Case: AssignmentExpressionLsh, · Token: example.c:1:13: LSHASSIGN "<<=", · UnaryExpression: &cc.UnaryExpression{ · · Case: UnaryExpressionPostfix, · · PostfixExpression: &cc.PostfixExpression{ · · · Case: PostfixExpressionPrimary, · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · Case: PrimaryExpressionIdent, · · · · Token: example.c:1:11: IDENTIFIER "x", · · · }, · · }, · }, }
Example (Mod) ¶
fmt.Println(exampleAST(75, "int f() { x %= y; }"))
Output: &cc.AssignmentExpression{ · AssignmentExpression: &cc.AssignmentExpression{ · · Case: AssignmentExpressionCond, · · ConditionalExpression: &cc.ConditionalExpression{ · · · Case: ConditionalExpressionLOr, · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · Case: LogicalOrExpressionLAnd, · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · Case: LogicalAndExpressionOr, · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · Case: InclusiveOrExpressionXor, · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · Case: AndExpressionEq, · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · Token: example.c:1:16: IDENTIFIER "y", · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · }, · Case: AssignmentExpressionMod, · Token: example.c:1:13: MODASSIGN "%=", · UnaryExpression: &cc.UnaryExpression{ · · Case: UnaryExpressionPostfix, · · PostfixExpression: &cc.PostfixExpression{ · · · Case: PostfixExpressionPrimary, · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · Case: PrimaryExpressionIdent, · · · · Token: example.c:1:11: IDENTIFIER "x", · · · }, · · }, · }, }
Example (Mul) ¶
fmt.Println(exampleAST(73, "int f() { x *= y; }"))
Output: &cc.AssignmentExpression{ · AssignmentExpression: &cc.AssignmentExpression{ · · Case: AssignmentExpressionCond, · · ConditionalExpression: &cc.ConditionalExpression{ · · · Case: ConditionalExpressionLOr, · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · Case: LogicalOrExpressionLAnd, · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · Case: LogicalAndExpressionOr, · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · Case: InclusiveOrExpressionXor, · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · Case: AndExpressionEq, · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · Token: example.c:1:16: IDENTIFIER "y", · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · }, · Case: AssignmentExpressionMul, · Token: example.c:1:13: MULASSIGN "*=", · UnaryExpression: &cc.UnaryExpression{ · · Case: UnaryExpressionPostfix, · · PostfixExpression: &cc.PostfixExpression{ · · · Case: PostfixExpressionPrimary, · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · Case: PrimaryExpressionIdent, · · · · Token: example.c:1:11: IDENTIFIER "x", · · · }, · · }, · }, }
Example (Or) ¶
fmt.Println(exampleAST(82, "int f() { x |= y; }"))
Output: &cc.AssignmentExpression{ · AssignmentExpression: &cc.AssignmentExpression{ · · Case: AssignmentExpressionCond, · · ConditionalExpression: &cc.ConditionalExpression{ · · · Case: ConditionalExpressionLOr, · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · Case: LogicalOrExpressionLAnd, · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · Case: LogicalAndExpressionOr, · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · Case: InclusiveOrExpressionXor, · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · Case: AndExpressionEq, · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · Token: example.c:1:16: IDENTIFIER "y", · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · }, · Case: AssignmentExpressionOr, · Token: example.c:1:13: ORASSIGN "|=", · UnaryExpression: &cc.UnaryExpression{ · · Case: UnaryExpressionPostfix, · · PostfixExpression: &cc.PostfixExpression{ · · · Case: PostfixExpressionPrimary, · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · Case: PrimaryExpressionIdent, · · · · Token: example.c:1:11: IDENTIFIER "x", · · · }, · · }, · }, }
Example (Rsh) ¶
fmt.Println(exampleAST(79, "int f() { x >>= y; }"))
Output: &cc.AssignmentExpression{ · AssignmentExpression: &cc.AssignmentExpression{ · · Case: AssignmentExpressionCond, · · ConditionalExpression: &cc.ConditionalExpression{ · · · Case: ConditionalExpressionLOr, · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · Case: LogicalOrExpressionLAnd, · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · Case: LogicalAndExpressionOr, · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · Case: InclusiveOrExpressionXor, · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · Case: AndExpressionEq, · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · Token: example.c:1:17: IDENTIFIER "y", · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · }, · Case: AssignmentExpressionRsh, · Token: example.c:1:13: RSHASSIGN ">>=", · UnaryExpression: &cc.UnaryExpression{ · · Case: UnaryExpressionPostfix, · · PostfixExpression: &cc.PostfixExpression{ · · · Case: PostfixExpressionPrimary, · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · Case: PrimaryExpressionIdent, · · · · Token: example.c:1:11: IDENTIFIER "x", · · · }, · · }, · }, }
Example (Sub) ¶
fmt.Println(exampleAST(77, "int f() { x -= y; }"))
Output: &cc.AssignmentExpression{ · AssignmentExpression: &cc.AssignmentExpression{ · · Case: AssignmentExpressionCond, · · ConditionalExpression: &cc.ConditionalExpression{ · · · Case: ConditionalExpressionLOr, · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · Case: LogicalOrExpressionLAnd, · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · Case: LogicalAndExpressionOr, · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · Case: InclusiveOrExpressionXor, · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · Case: AndExpressionEq, · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · Token: example.c:1:16: IDENTIFIER "y", · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · }, · Case: AssignmentExpressionSub, · Token: example.c:1:13: SUBASSIGN "-=", · UnaryExpression: &cc.UnaryExpression{ · · Case: UnaryExpressionPostfix, · · PostfixExpression: &cc.PostfixExpression{ · · · Case: PostfixExpressionPrimary, · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · Case: PrimaryExpressionIdent, · · · · Token: example.c:1:11: IDENTIFIER "x", · · · }, · · }, · }, }
Example (Xor) ¶
fmt.Println(exampleAST(81, "int f() { x ^= y; }"))
Output: &cc.AssignmentExpression{ · AssignmentExpression: &cc.AssignmentExpression{ · · Case: AssignmentExpressionCond, · · ConditionalExpression: &cc.ConditionalExpression{ · · · Case: ConditionalExpressionLOr, · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · Case: LogicalOrExpressionLAnd, · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · Case: LogicalAndExpressionOr, · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · Case: InclusiveOrExpressionXor, · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · Case: AndExpressionEq, · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · Token: example.c:1:16: IDENTIFIER "y", · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · }, · Case: AssignmentExpressionXor, · Token: example.c:1:13: XORASSIGN "^=", · UnaryExpression: &cc.UnaryExpression{ · · Case: UnaryExpressionPostfix, · · PostfixExpression: &cc.PostfixExpression{ · · · Case: PostfixExpressionPrimary, · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · Case: PrimaryExpressionIdent, · · · · Token: example.c:1:11: IDENTIFIER "x", · · · }, · · }, · }, }
func (*AssignmentExpression) Declarator ¶
func (n *AssignmentExpression) Declarator() *Declarator
func (*AssignmentExpression) Position ¶
func (n *AssignmentExpression) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*AssignmentExpression) Promote ¶
func (n *AssignmentExpression) Promote() Type
Promote returns the type the operands of a binary operation are promoted to or the type and argument passed in a function call is promoted.
func (*AssignmentExpression) String ¶
func (n *AssignmentExpression) String() string
String implements fmt.Stringer.
type AssignmentExpressionCase ¶
type AssignmentExpressionCase int
AssignmentExpressionCase represents case numbers of production AssignmentExpression
const ( AssignmentExpressionCond AssignmentExpressionCase = iota AssignmentExpressionAssign AssignmentExpressionMul AssignmentExpressionDiv AssignmentExpressionMod AssignmentExpressionAdd AssignmentExpressionSub AssignmentExpressionLsh AssignmentExpressionRsh AssignmentExpressionAnd AssignmentExpressionXor AssignmentExpressionOr )
Values of type AssignmentExpressionCase
func (AssignmentExpressionCase) String ¶
func (n AssignmentExpressionCase) String() string
String implements fmt.Stringer
type AtomicTypeSpecifier ¶
type AtomicTypeSpecifier struct { Token Token Token2 Token Token3 Token TypeName *TypeName // contains filtered or unexported fields }
AtomicTypeSpecifier represents data reduced by production:
AtomicTypeSpecifier: "_Atomic" '(' TypeName ')'
Example (Case0) ¶
fmt.Println(exampleAST(159, "_Atomic(int) i;"))
Output: &cc.AtomicTypeSpecifier{ · Token: example.c:1:1: ATOMIC "_Atomic", · Token2: example.c:1:8: '(' "(", · Token3: example.c:1:12: ')' ")", · TypeName: &cc.TypeName{ · · SpecifierQualifierList: &cc.SpecifierQualifierList{ · · · Case: SpecifierQualifierListTypeSpec, · · · TypeSpecifier: &cc.TypeSpecifier{ · · · · Case: TypeSpecifierInt, · · · · Token: example.c:1:9: INT "int", · · · }, · · }, · }, }
func (*AtomicTypeSpecifier) Position ¶
func (n *AtomicTypeSpecifier) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*AtomicTypeSpecifier) String ¶
func (n *AtomicTypeSpecifier) String() string
String implements fmt.Stringer.
type AttributeSpecifier ¶
type AttributeSpecifier struct { AttributeValueList *AttributeValueList Token Token Token2 Token Token3 Token Token4 Token Token5 Token }
AttributeSpecifier represents data reduced by production:
AttributeSpecifier: "__attribute__" '(' '(' AttributeValueList ')' ')'
Example (Case0) ¶
fmt.Println(exampleAST(273, "int i __attribute__((a));"))
Output: &cc.AttributeSpecifier{ · AttributeValueList: &cc.AttributeValueList{ · · AttributeValue: &cc.AttributeValue{ · · · Case: AttributeValueIdent, · · · Token: example.c:1:22: IDENTIFIER "a", · · }, · }, · Token: example.c:1:7: ATTRIBUTE "__attribute__", · Token2: example.c:1:20: '(' "(", · Token3: example.c:1:21: '(' "(", · Token4: example.c:1:23: ')' ")", · Token5: example.c:1:24: ')' ")", }
func (*AttributeSpecifier) Has ¶ added in v3.33.0
func (n *AttributeSpecifier) Has(key ...StringID) (*ExpressionList, bool)
Has reports whether n has any of attributes in key.
func (*AttributeSpecifier) Position ¶
func (n *AttributeSpecifier) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*AttributeSpecifier) String ¶
func (n *AttributeSpecifier) String() string
String implements fmt.Stringer.
type AttributeSpecifierList ¶
type AttributeSpecifierList struct { AttributeSpecifier *AttributeSpecifier AttributeSpecifierList *AttributeSpecifierList }
AttributeSpecifierList represents data reduced by productions:
AttributeSpecifierList: AttributeSpecifier | AttributeSpecifierList AttributeSpecifier
Example (Case0) ¶
fmt.Println(exampleAST(274, "int i __attribute__((a));"))
Output: &cc.AttributeSpecifierList{ · AttributeSpecifier: &cc.AttributeSpecifier{ · · AttributeValueList: &cc.AttributeValueList{ · · · AttributeValue: &cc.AttributeValue{ · · · · Case: AttributeValueIdent, · · · · Token: example.c:1:22: IDENTIFIER "a", · · · }, · · }, · · Token: example.c:1:7: ATTRIBUTE "__attribute__", · · Token2: example.c:1:20: '(' "(", · · Token3: example.c:1:21: '(' "(", · · Token4: example.c:1:23: ')' ")", · · Token5: example.c:1:24: ')' ")", · }, }
Example (Case1) ¶
fmt.Println(exampleAST(275, "int i __attribute__((a)) __attribute((b));"))
Output: &cc.AttributeSpecifierList{ · AttributeSpecifier: &cc.AttributeSpecifier{ · · AttributeValueList: &cc.AttributeValueList{ · · · AttributeValue: &cc.AttributeValue{ · · · · Case: AttributeValueIdent, · · · · Token: example.c:1:22: IDENTIFIER "a", · · · }, · · }, · · Token: example.c:1:7: ATTRIBUTE "__attribute__", · · Token2: example.c:1:20: '(' "(", · · Token3: example.c:1:21: '(' "(", · · Token4: example.c:1:23: ')' ")", · · Token5: example.c:1:24: ')' ")", · }, · AttributeSpecifierList: &cc.AttributeSpecifierList{ · · AttributeSpecifier: &cc.AttributeSpecifier{ · · · AttributeValueList: &cc.AttributeValueList{ · · · · AttributeValue: &cc.AttributeValue{ · · · · · Case: AttributeValueIdent, · · · · · Token: example.c:1:39: IDENTIFIER "b", · · · · }, · · · }, · · · Token: example.c:1:26: ATTRIBUTE "__attribute", · · · Token2: example.c:1:37: '(' "(", · · · Token3: example.c:1:38: '(' "(", · · · Token4: example.c:1:40: ')' ")", · · · Token5: example.c:1:41: ')' ")", · · }, · }, }
func (*AttributeSpecifierList) Has ¶ added in v3.33.0
func (n *AttributeSpecifierList) Has(key ...StringID) (*ExpressionList, bool)
Has reports whether n has any of attributes in key.
func (*AttributeSpecifierList) Position ¶
func (n *AttributeSpecifierList) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*AttributeSpecifierList) String ¶
func (n *AttributeSpecifierList) String() string
String implements fmt.Stringer.
type AttributeValue ¶
type AttributeValue struct { Case AttributeValueCase `PrettyPrint:"stringer,zero"` ExpressionList *ExpressionList Token Token Token2 Token Token3 Token // contains filtered or unexported fields }
AttributeValue represents data reduced by productions:
AttributeValue: IDENTIFIER // Case AttributeValueIdent | IDENTIFIER '(' ExpressionList ')' // Case AttributeValueExpr
Example (Expr) ¶
fmt.Println(exampleAST(270, "int i __attribute__((a(b)));"))
Output: &cc.AttributeValue{ · Case: AttributeValueExpr, · ExpressionList: &cc.ExpressionList{ · · AssignmentExpression: &cc.AssignmentExpression{ · · · Case: AssignmentExpressionCond, · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · Case: ConditionalExpressionLOr, · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · Case: LogicalOrExpressionLAnd, · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · Case: LogicalAndExpressionOr, · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · Token: example.c:1:24: IDENTIFIER "b", · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · }, · Token: example.c:1:22: IDENTIFIER "a", · Token2: example.c:1:23: '(' "(", · Token3: example.c:1:25: ')' ")", }
Example (Ident) ¶
fmt.Println(exampleAST(269, "int i __attribute__((a));"))
Output: &cc.AttributeValue{ · Case: AttributeValueIdent, · Token: example.c:1:22: IDENTIFIER "a", }
func (*AttributeValue) Position ¶
func (n *AttributeValue) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*AttributeValue) String ¶
func (n *AttributeValue) String() string
String implements fmt.Stringer.
type AttributeValueCase ¶
type AttributeValueCase int
AttributeValueCase represents case numbers of production AttributeValue
const ( AttributeValueIdent AttributeValueCase = iota AttributeValueExpr )
Values of type AttributeValueCase
func (AttributeValueCase) String ¶
func (n AttributeValueCase) String() string
String implements fmt.Stringer
type AttributeValueList ¶
type AttributeValueList struct { AttributeValue *AttributeValue AttributeValueList *AttributeValueList Token Token }
AttributeValueList represents data reduced by productions:
AttributeValueList: AttributeValue | AttributeValueList ',' AttributeValue
Example (Case0) ¶
fmt.Println(exampleAST(271, "int i __attribute__((a));"))
Output: &cc.AttributeValueList{ · AttributeValue: &cc.AttributeValue{ · · Case: AttributeValueIdent, · · Token: example.c:1:22: IDENTIFIER "a", · }, }
Example (Case1) ¶
fmt.Println(exampleAST(272, "int i __attribute__((a, b));"))
Output: &cc.AttributeValueList{ · AttributeValue: &cc.AttributeValue{ · · Case: AttributeValueIdent, · · Token: example.c:1:22: IDENTIFIER "a", · }, · AttributeValueList: &cc.AttributeValueList{ · · AttributeValue: &cc.AttributeValue{ · · · Case: AttributeValueIdent, · · · Token: example.c:1:25: IDENTIFIER "b", · · }, · · Token: example.c:1:23: ',' ",", · }, }
func (*AttributeValueList) Position ¶
func (n *AttributeValueList) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*AttributeValueList) String ¶
func (n *AttributeValueList) String() string
String implements fmt.Stringer.
type BlockItem ¶
type BlockItem struct { Last bool Case BlockItemCase `PrettyPrint:"stringer,zero"` CompoundStatement *CompoundStatement Declaration *Declaration DeclarationSpecifiers *DeclarationSpecifiers Declarator *Declarator LabelDeclaration *LabelDeclaration PragmaSTDC *PragmaSTDC Statement *Statement // contains filtered or unexported fields }
BlockItem represents data reduced by productions:
BlockItem: Declaration // Case BlockItemDecl | Statement // Case BlockItemStmt | LabelDeclaration // Case BlockItemLabel | DeclarationSpecifiers Declarator CompoundStatement // Case BlockItemFuncDef | PragmaSTDC // Case BlockItemPragma
Example (Decl) ¶
fmt.Println(exampleAST(224, "int f() { int i; }"))
Output: &cc.BlockItem{ · Case: BlockItemDecl, · Declaration: &cc.Declaration{ · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{ · · · Case: DeclarationSpecifiersTypeSpec, · · · TypeSpecifier: &cc.TypeSpecifier{ · · · · Case: TypeSpecifierInt, · · · · Token: example.c:1:11: INT "int", · · · }, · · }, · · InitDeclaratorList: &cc.InitDeclaratorList{ · · · InitDeclarator: &cc.InitDeclarator{ · · · · Case: InitDeclaratorDecl, · · · · Declarator: &cc.Declarator{ · · · · · DirectDeclarator: &cc.DirectDeclarator{ · · · · · · Case: DirectDeclaratorIdent, · · · · · · Token: example.c:1:15: IDENTIFIER "i", · · · · · }, · · · · }, · · · }, · · }, · · Token: example.c:1:16: ';' ";", · }, }
Example (FuncDef) ¶
fmt.Println(exampleAST(227, "int f() { int g() {} }"))
Output: &cc.BlockItem{ · Case: BlockItemFuncDef, · CompoundStatement: &cc.CompoundStatement{ · · Token: example.c:1:19: '{' "{", · · Token2: example.c:1:20: '}' "}", · }, · DeclarationSpecifiers: &cc.DeclarationSpecifiers{ · · Case: DeclarationSpecifiersTypeSpec, · · TypeSpecifier: &cc.TypeSpecifier{ · · · Case: TypeSpecifierInt, · · · Token: example.c:1:11: INT "int", · · }, · }, · Declarator: &cc.Declarator{ · · DirectDeclarator: &cc.DirectDeclarator{ · · · Case: DirectDeclaratorFuncIdent, · · · DirectDeclarator: &cc.DirectDeclarator{ · · · · Case: DirectDeclaratorIdent, · · · · Token: example.c:1:15: IDENTIFIER "g", · · · }, · · · Token: example.c:1:16: '(' "(", · · · Token2: example.c:1:17: ')' ")", · · }, · }, }
Example (Label) ¶
fmt.Println(exampleAST(226, "int f() { __label__ L; }"))
Output: &cc.BlockItem{ · Case: BlockItemLabel, · LabelDeclaration: &cc.LabelDeclaration{ · · IdentifierList: &cc.IdentifierList{ · · · Token: example.c:1:21: IDENTIFIER "L", · · }, · · Token: example.c:1:11: LABEL "__label__", · · Token2: example.c:1:22: ';' ";", · }, }
Example (Pragma) ¶
fmt.Println(exampleAST(228, "int f() {\\n#pragma STDC FENV_ACCESS OFF\\n}"))
Output: &cc.BlockItem{ · Case: BlockItemPragma, · PragmaSTDC: &cc.PragmaSTDC{ · · Token: example.c:2:9: PPPRAGMASTDC "__pragma_stdc", · · Token2: example.c:2:9: IDENTIFIER "STDC", · · Token3: example.c:2:14: IDENTIFIER "FENV_ACCESS", · · Token4: example.c:2:26: IDENTIFIER "OFF", · }, }
Example (Stmt) ¶
fmt.Println(exampleAST(225, "int f() { g(); }"))
Output: &cc.BlockItem{ · Case: BlockItemStmt, · Statement: &cc.Statement{ · · Case: StatementExpr, · · ExpressionStatement: &cc.ExpressionStatement{ · · · Expression: &cc.Expression{ · · · · AssignmentExpression: &cc.AssignmentExpression{ · · · · · Case: AssignmentExpressionCond, · · · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · · · Case: ConditionalExpressionLOr, · · · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · · · Case: LogicalOrExpressionLAnd, · · · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · · · Case: LogicalAndExpressionOr, · · · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · · Case: PostfixExpressionCall, · · · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · · · · Token: example.c:1:11: IDENTIFIER "g", · · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · · Token: example.c:1:12: '(' "(", · · · · · · · · · · · · · · · · · · · Token2: example.c:1:13: ')' ")", · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · · Case: ExpressionAssign, · · · }, · · · Token: example.c:1:14: ';' ";", · · }, · }, }
func (*BlockItem) Closure ¶
Closure reports the variables closed over by a nested function (case BlockItemFuncDef).
func (*BlockItem) FunctionDefinition ¶
func (n *BlockItem) FunctionDefinition() *FunctionDefinition
FunctionDefinition returns the nested function (case BlockItemFuncDef).
type BlockItemCase ¶
type BlockItemCase int
BlockItemCase represents case numbers of production BlockItem
const ( BlockItemDecl BlockItemCase = iota BlockItemStmt BlockItemLabel BlockItemFuncDef BlockItemPragma )
Values of type BlockItemCase
type BlockItemList ¶
type BlockItemList struct { BlockItem *BlockItem BlockItemList *BlockItemList }
BlockItemList represents data reduced by productions:
BlockItemList: BlockItem | BlockItemList BlockItem
Example (Case0) ¶
fmt.Println(exampleAST(222, "int f() { int i; }"))
Output: &cc.BlockItemList{ · BlockItem: &cc.BlockItem{ · · Case: BlockItemDecl, · · Declaration: &cc.Declaration{ · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{ · · · · Case: DeclarationSpecifiersTypeSpec, · · · · TypeSpecifier: &cc.TypeSpecifier{ · · · · · Case: TypeSpecifierInt, · · · · · Token: example.c:1:11: INT "int", · · · · }, · · · }, · · · InitDeclaratorList: &cc.InitDeclaratorList{ · · · · InitDeclarator: &cc.InitDeclarator{ · · · · · Case: InitDeclaratorDecl, · · · · · Declarator: &cc.Declarator{ · · · · · · DirectDeclarator: &cc.DirectDeclarator{ · · · · · · · Case: DirectDeclaratorIdent, · · · · · · · Token: example.c:1:15: IDENTIFIER "i", · · · · · · }, · · · · · }, · · · · }, · · · }, · · · Token: example.c:1:16: ';' ";", · · }, · }, }
Example (Case1) ¶
fmt.Println(exampleAST(223, "int f() { int i; double j; }"))
Output: &cc.BlockItemList{ · BlockItem: &cc.BlockItem{ · · Case: BlockItemDecl, · · Declaration: &cc.Declaration{ · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{ · · · · Case: DeclarationSpecifiersTypeSpec, · · · · TypeSpecifier: &cc.TypeSpecifier{ · · · · · Case: TypeSpecifierInt, · · · · · Token: example.c:1:11: INT "int", · · · · }, · · · }, · · · InitDeclaratorList: &cc.InitDeclaratorList{ · · · · InitDeclarator: &cc.InitDeclarator{ · · · · · Case: InitDeclaratorDecl, · · · · · Declarator: &cc.Declarator{ · · · · · · DirectDeclarator: &cc.DirectDeclarator{ · · · · · · · Case: DirectDeclaratorIdent, · · · · · · · Token: example.c:1:15: IDENTIFIER "i", · · · · · · }, · · · · · }, · · · · }, · · · }, · · · Token: example.c:1:16: ';' ";", · · }, · }, · BlockItemList: &cc.BlockItemList{ · · BlockItem: &cc.BlockItem{ · · · Case: BlockItemDecl, · · · Declaration: &cc.Declaration{ · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{ · · · · · Case: DeclarationSpecifiersTypeSpec, · · · · · TypeSpecifier: &cc.TypeSpecifier{ · · · · · · Case: TypeSpecifierDouble, · · · · · · Token: example.c:1:18: DOUBLE "double", · · · · · }, · · · · }, · · · · InitDeclaratorList: &cc.InitDeclaratorList{ · · · · · InitDeclarator: &cc.InitDeclarator{ · · · · · · Case: InitDeclaratorDecl, · · · · · · Declarator: &cc.Declarator{ · · · · · · · DirectDeclarator: &cc.DirectDeclarator{ · · · · · · · · Case: DirectDeclaratorIdent, · · · · · · · · Token: example.c:1:25: IDENTIFIER "j", · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · · Token: example.c:1:26: ';' ";", · · · }, · · }, · }, }
func (*BlockItemList) Position ¶
func (n *BlockItemList) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*BlockItemList) String ¶
func (n *BlockItemList) String() string
String implements fmt.Stringer.
type CastExpression ¶
type CastExpression struct { Operand Operand IsSideEffectsFree bool Case CastExpressionCase `PrettyPrint:"stringer,zero"` CastExpression *CastExpression Token Token Token2 Token TypeName *TypeName UnaryExpression *UnaryExpression }
CastExpression represents data reduced by productions:
CastExpression: UnaryExpression // Case CastExpressionUnary | '(' TypeName ')' CastExpression // Case CastExpressionCast
Example (Cast) ¶
fmt.Println(exampleAST(40, "int i = (int)3.14;"))
Output: &cc.CastExpression{ · Case: CastExpressionCast, · CastExpression: &cc.CastExpression{ · · Case: CastExpressionUnary, · · UnaryExpression: &cc.UnaryExpression{ · · · Case: UnaryExpressionPostfix, · · · PostfixExpression: &cc.PostfixExpression{ · · · · Case: PostfixExpressionPrimary, · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · Case: PrimaryExpressionFloat, · · · · · Token: example.c:1:14: FLOATCONST "3.14", · · · · }, · · · }, · · }, · }, · Token: example.c:1:9: '(' "(", · Token2: example.c:1:13: ')' ")", · TypeName: &cc.TypeName{ · · SpecifierQualifierList: &cc.SpecifierQualifierList{ · · · Case: SpecifierQualifierListTypeSpec, · · · TypeSpecifier: &cc.TypeSpecifier{ · · · · Case: TypeSpecifierInt, · · · · Token: example.c:1:10: INT "int", · · · }, · · }, · }, }
Example (Unary) ¶
fmt.Println(exampleAST(39, "int i = 42;"))
Output: &cc.CastExpression{ · Case: CastExpressionUnary, · UnaryExpression: &cc.UnaryExpression{ · · Case: UnaryExpressionPostfix, · · PostfixExpression: &cc.PostfixExpression{ · · · Case: PostfixExpressionPrimary, · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · Case: PrimaryExpressionInt, · · · · Token: example.c:1:9: INTCONST "42", · · · }, · · }, · }, }
func (*CastExpression) Declarator ¶
func (n *CastExpression) Declarator() *Declarator
func (*CastExpression) Position ¶
func (n *CastExpression) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*CastExpression) String ¶
func (n *CastExpression) String() string
String implements fmt.Stringer.
type CastExpressionCase ¶
type CastExpressionCase int
CastExpressionCase represents case numbers of production CastExpression
const ( CastExpressionUnary CastExpressionCase = iota CastExpressionCast )
Values of type CastExpressionCase
func (CastExpressionCase) String ¶
func (n CastExpressionCase) String() string
String implements fmt.Stringer
type Complex128Value ¶
type Complex128Value complex128
func (Complex128Value) IsConst ¶ added in v3.33.6
func (v Complex128Value) IsConst() bool
func (Complex128Value) IsNonZero ¶ added in v3.33.6
func (v Complex128Value) IsNonZero() bool
func (Complex128Value) IsZero ¶ added in v3.33.6
func (v Complex128Value) IsZero() bool
type Complex256Value ¶
type Complex256Value struct {
Re, Im *Float128Value
}
func (Complex256Value) IsConst ¶ added in v3.33.6
func (v Complex256Value) IsConst() bool
func (Complex256Value) IsNonZero ¶ added in v3.33.6
func (v Complex256Value) IsNonZero() bool
func (Complex256Value) IsZero ¶ added in v3.33.6
func (v Complex256Value) IsZero() bool
type Complex64Value ¶
type Complex64Value complex64
func (Complex64Value) IsConst ¶ added in v3.33.6
func (v Complex64Value) IsConst() bool
func (Complex64Value) IsNonZero ¶ added in v3.33.6
func (v Complex64Value) IsNonZero() bool
func (Complex64Value) IsZero ¶ added in v3.33.6
func (v Complex64Value) IsZero() bool
type CompoundStatement ¶
type CompoundStatement struct { Operand Operand BlockItemList *BlockItemList Token Token Token2 Token // contains filtered or unexported fields }
CompoundStatement represents data reduced by production:
CompoundStatement: '{' BlockItemList '}'
Example (Case0) ¶
fmt.Println(exampleAST(221, "int f() { int i; }"))
Output: &cc.CompoundStatement{ · BlockItemList: &cc.BlockItemList{ · · BlockItem: &cc.BlockItem{ · · · Case: BlockItemDecl, · · · Declaration: &cc.Declaration{ · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{ · · · · · Case: DeclarationSpecifiersTypeSpec, · · · · · TypeSpecifier: &cc.TypeSpecifier{ · · · · · · Case: TypeSpecifierInt, · · · · · · Token: example.c:1:11: INT "int", · · · · · }, · · · · }, · · · · InitDeclaratorList: &cc.InitDeclaratorList{ · · · · · InitDeclarator: &cc.InitDeclarator{ · · · · · · Case: InitDeclaratorDecl, · · · · · · Declarator: &cc.Declarator{ · · · · · · · DirectDeclarator: &cc.DirectDeclarator{ · · · · · · · · Case: DirectDeclaratorIdent, · · · · · · · · Token: example.c:1:15: IDENTIFIER "i", · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · · Token: example.c:1:16: ';' ";", · · · }, · · }, · }, · Token: example.c:1:9: '{' "{", · Token2: example.c:1:18: '}' "}", }
func (*CompoundStatement) Children ¶
func (n *CompoundStatement) Children() []*CompoundStatement
Children returns the list of n's children.
func (*CompoundStatement) Declarations ¶
func (n *CompoundStatement) Declarations() []*Declaration
Declarations returns the list of declarations in n.
func (*CompoundStatement) IsJumpTarget ¶
func (n *CompoundStatement) IsJumpTarget() bool
IsJumpTarget returns whether n or any of its children contain a named labeled statement.
func (*CompoundStatement) LabeledStatements ¶
func (n *CompoundStatement) LabeledStatements() []*LabeledStatement
LabeledStatements returns labeled statements of n.
func (*CompoundStatement) Parent ¶
func (n *CompoundStatement) Parent() *CompoundStatement
Parent returns the CompoundStatement that contains n, if any.
func (*CompoundStatement) Position ¶
func (n *CompoundStatement) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*CompoundStatement) String ¶
func (n *CompoundStatement) String() string
String implements fmt.Stringer.
type ConditionalExpression ¶
type ConditionalExpression struct { Operand Operand IsSideEffectsFree bool Case ConditionalExpressionCase `PrettyPrint:"stringer,zero"` ConditionalExpression *ConditionalExpression Expression *Expression LogicalOrExpression *LogicalOrExpression Token Token Token2 Token }
ConditionalExpression represents data reduced by productions:
ConditionalExpression: LogicalOrExpression // Case ConditionalExpressionLOr | LogicalOrExpression '?' Expression ':' ConditionalExpression // Case ConditionalExpressionCond
Example (Cond) ¶
fmt.Println(exampleAST(70, "int i = x ? y : z;"))
Output: &cc.ConditionalExpression{ · Case: ConditionalExpressionCond, · ConditionalExpression: &cc.ConditionalExpression{ · · Case: ConditionalExpressionLOr, · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · Case: LogicalOrExpressionLAnd, · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · Case: LogicalAndExpressionOr, · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · Case: InclusiveOrExpressionXor, · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · Case: AndExpressionEq, · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · Token: example.c:1:17: IDENTIFIER "z", · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · }, · · · · }, · · · }, · · }, · }, · Expression: &cc.Expression{ · · AssignmentExpression: &cc.AssignmentExpression{ · · · Case: AssignmentExpressionCond, · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · Case: ConditionalExpressionLOr, · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · Case: LogicalOrExpressionLAnd, · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · Case: LogicalAndExpressionOr, · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · Token: example.c:1:13: IDENTIFIER "y", · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · · Case: ExpressionAssign, · }, · LogicalOrExpression: &cc.LogicalOrExpression{ · · Case: LogicalOrExpressionLAnd, · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · Case: LogicalAndExpressionOr, · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · Case: InclusiveOrExpressionXor, · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · AndExpression: &cc.AndExpression{ · · · · · · Case: AndExpressionEq, · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · Case: EqualityExpressionRel, · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · Token: example.c:1:9: IDENTIFIER "x", · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · · Case: ExclusiveOrExpressionAnd, · · · · }, · · · }, · · }, · }, · Token: example.c:1:11: '?' "?", · Token2: example.c:1:15: ':' ":", }
Example (LOr) ¶
fmt.Println(exampleAST(69, "int i = x;"))
Output: &cc.ConditionalExpression{ · Case: ConditionalExpressionLOr, · LogicalOrExpression: &cc.LogicalOrExpression{ · · Case: LogicalOrExpressionLAnd, · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · Case: LogicalAndExpressionOr, · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · Case: InclusiveOrExpressionXor, · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · AndExpression: &cc.AndExpression{ · · · · · · Case: AndExpressionEq, · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · Case: EqualityExpressionRel, · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · Token: example.c:1:9: IDENTIFIER "x", · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · · Case: ExclusiveOrExpressionAnd, · · · · }, · · · }, · · }, · }, }
func (*ConditionalExpression) Declarator ¶
func (n *ConditionalExpression) Declarator() *Declarator
func (*ConditionalExpression) Position ¶
func (n *ConditionalExpression) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*ConditionalExpression) String ¶
func (n *ConditionalExpression) String() string
String implements fmt.Stringer.
type ConditionalExpressionCase ¶
type ConditionalExpressionCase int
ConditionalExpressionCase represents case numbers of production ConditionalExpression
const ( ConditionalExpressionLOr ConditionalExpressionCase = iota ConditionalExpressionCond )
Values of type ConditionalExpressionCase
func (ConditionalExpressionCase) String ¶
func (n ConditionalExpressionCase) String() string
String implements fmt.Stringer
type Config ¶
type Config struct { Config3 ABI ABI PragmaHandler func(Pragma, []Token) // Called on pragmas, other than #pragma STDC ..., if non nil // position and definition. This can happen, for example, when a function is // defined in a header file included multiple times. Either within a single // translation unit or across translation units. In the later case just supply // the same SharedFunctionDefinitions in Config when translating/parsing each // translation unit. SharedFunctionDefinitions *SharedFunctionDefinitions // IncludeFileHandler, when non nil, is called by the preprocessor for every // successfully included file. IncludeFileHandler func(pos gotoken.Position, includePath string) MaxErrors int // 0: default (10), < 0: unlimited, n: n. CheckExternInlineFnBodies bool // Translate will consider extern inline function bodies. DebugIncludePaths bool // Output to stderr. DebugWorkingDir bool // Output to stderr. DoNotTypecheckAsm bool EnableAssignmentCompatibilityChecking bool // No such checks performed up to v3.31.0. Currently only partially implemented. InjectTracingCode bool // Output to stderr. LongDoubleIsDouble bool PreprocessOnly bool RejectAnonymousFields bool // Pedantic: do not silently accept "struct{int;}". RejectCaseRange bool // Pedantic: do not silently accept "case 'a'...'z':". RejectEmptyCompositeLiterals bool // Pedantic: do not silently accept "foo = (T){}". RejectEmptyDeclarations bool // Pedantic: do not silently accept "int foo(){};". RejectEmptyFields bool // Pedantic: do not silently accept "struct {int a;;} foo;". RejectEmptyInitializerList bool // Pedantic: do not silently accept "foo f = {};". RejectEmptyStructDeclaration bool // Pedantic: do not silently accept "struct{; int i}". RejectEmptyStructs bool // Pedantic: do not silently accept "struct foo {};". RejectIncompatibleMacroRedef bool // Pedantic: do not silently accept "#define MIN(A,B) ...\n#define MIN(a,b) ...\n" etc. RejectLabelValues bool // Pedantic: do not silently accept "foo: bar(); void *ptr = &&foo;" or "goto *ptr". RejectLateBinding bool // Pedantic: do not silently accept void f() { g(); } void g() {} RejectMissingConditionalExpr bool // Pedantic: do not silently accept "foo = bar ? : baz;". RejectMissingDeclarationSpecifiers bool // Pedantic: do not silently accept "main() {}". RejectMissingFinalStructFieldSemicolon bool // Pedantic: do not silently accept "struct{int i; int j}". RejectNestedFunctionDefinitions bool // Pedantic: do not silently accept nested function definitons. RejectParamSemicolon bool // Pedantic: do not silently accept "int f(int a; int b)". RejectStatementExpressions bool // Pedantic: do not silently accept "i = ({foo();})". RejectTypeof bool // Pedantic: do not silently accept "typeof foo" or "typeof(bar*)". RejectUninitializedDeclarators bool // Reject int f() { int j; return j; } TrackAssignments bool // Collect a list of LHS declarators a declarator is used in RHS or as an function argument. // contains filtered or unexported fields }
Config amends behavior of translation phase 4 and above. Instances of Config are not mutated by this package and it's safe to share/reuse them.
The *Config passed to Parse or Translate should not be mutated afterwards.
type Config3 ¶
type Config3 struct { // If IgnoreInclude is not nil, its MatchString method will be called by the // preprocessor with the argument any include directive expands to. If the call // evaluates to is true the include directive will be ignored completely. IgnoreInclude *regexp.Regexp // Name of a macro to use instead of FD_ZERO. // // Note: Temporary solution will be removed/replaced ReplaceMacroFdZero string // Name of a macro to use instead of TCL_DEFAULT_DOUBLE_ROUNDING. // // Note: Temporary solution will be removed/replaced ReplaceMacroTclDefaultDoubleRounding string // Name of a macro to use instead of TCL_DEFAULT_DOUBLE_ROUNDING. Note: Temporrary solution will be removed/replaced // Name of a macro to use instead of TCL_IEEE_DOUBLE_ROUNDING. // // Note: Temporary solution will be removed/replaced ReplaceMacroTclIeeeDoubleRounding string WorkingDir string // Overrides os.Getwd if non empty. Filesystem Filesystem // Overrides filesystem access if not empty. MaxSourceLine int // Zero: Scanner will use default buffer. Non zero: Scanner will use max(default buffer size, MaxSourceLine). // DisableBuiltinResolution disables resolution of undefined identifiers such // that eg. abort, becomes the same as __builtin_abort, prototype of which is // expected to be provided by one of the sources passed to Parse, Preprocess or // Translate. DisableBuiltinResolution bool DisableTrigraphs bool // GCC ignores them unless -trigraphs is used: https://gcc.gnu.org/onlinedocs/cpp/Initial-processing.html GCCStructs bool // Assume __attribute__(gcc_struct) applied to structs by default. //TODO MSStructs bool // Assume __attribute__(ms_struct) applied to structs by default. NoFieldAndBitfieldOverlap bool // Only bitfields can be grouped together. PreserveOnlyLastNonBlankSeparator bool // If PreserveWhiteSpace is true, keep only the last white space, do not combine PreserveWhiteSpace bool // Including also comments. RejectElseExtraTokens bool // Pedantic: do not silently accept "#else foo". RejectEndifExtraTokens bool // Pedantic: do not silently accept "#endif foo". RejectFinalBackslash bool // Pedantic: do not silently accept "foo\\\n". RejectFunctionMacroEmptyReplacementList bool // Pedantic: do not silently accept "#define foo(bar)\n". RejectIfdefExtraTokens bool // Pedantic: do not silently accept "#ifdef foo bar". RejectIfndefExtraTokens bool // Pedantic: do not silently accept "#ifndef foo bar". RejectIncludeNext bool // Pedantic: do not silently accept "#include_next". RejectInvalidVariadicMacros bool // Pedantic: do not silently accept "#define foo(bar...)". Standard allows only #define foo(bar, ...) RejectLineExtraTokens bool // Pedantic: do not silently accept "#line 1234 \"foo.c\" bar". RejectMissingFinalNewline bool // Pedantic: do not silently accept "foo\nbar". RejectUndefExtraTokens bool // Pedantic: do not silently accept "#undef foo bar". UnsignedEnums bool // GCC compatibility: enums with no negative values will have unsigned type. }
Config3 amends behavior of translation phases 1 to 3.
type ConstantExpression ¶
type ConstantExpression struct { Operand Operand ConditionalExpression *ConditionalExpression }
ConstantExpression represents data reduced by production:
ConstantExpression: ConditionalExpression
Example (Case0) ¶
fmt.Println(exampleAST(85, "struct { int i:3; };"))
Output: &cc.ConstantExpression{ · ConditionalExpression: &cc.ConditionalExpression{ · · Case: ConditionalExpressionLOr, · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · Case: LogicalOrExpressionLAnd, · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · Case: LogicalAndExpressionOr, · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · Case: InclusiveOrExpressionXor, · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · Case: AndExpressionEq, · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · Case: PrimaryExpressionInt, · · · · · · · · · · · · · · · · Token: example.c:1:16: INTCONST "3", · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · }, · · · · }, · · · }, · · }, · }, }
func (*ConstantExpression) Position ¶
func (n *ConstantExpression) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*ConstantExpression) String ¶
func (n *ConstantExpression) String() string
String implements fmt.Stringer.
type Declaration ¶
type Declaration struct { DeclarationSpecifiers *DeclarationSpecifiers InitDeclaratorList *InitDeclaratorList Token Token }
Declaration represents data reduced by production:
Declaration: DeclarationSpecifiers InitDeclaratorList ';'
Example (Case0) ¶
fmt.Println(exampleAST(86, "int i, j;"))
Output: &cc.Declaration{ · DeclarationSpecifiers: &cc.DeclarationSpecifiers{ · · Case: DeclarationSpecifiersTypeSpec, · · TypeSpecifier: &cc.TypeSpecifier{ · · · Case: TypeSpecifierInt, · · · Token: example.c:1:1: INT "int", · · }, · }, · InitDeclaratorList: &cc.InitDeclaratorList{ · · InitDeclarator: &cc.InitDeclarator{ · · · Case: InitDeclaratorDecl, · · · Declarator: &cc.Declarator{ · · · · DirectDeclarator: &cc.DirectDeclarator{ · · · · · Case: DirectDeclaratorIdent, · · · · · Token: example.c:1:5: IDENTIFIER "i", · · · · }, · · · }, · · }, · · InitDeclaratorList: &cc.InitDeclaratorList{ · · · InitDeclarator: &cc.InitDeclarator{ · · · · Case: InitDeclaratorDecl, · · · · Declarator: &cc.Declarator{ · · · · · DirectDeclarator: &cc.DirectDeclarator{ · · · · · · Case: DirectDeclaratorIdent, · · · · · · Token: example.c:1:8: IDENTIFIER "j", · · · · · }, · · · · }, · · · }, · · · Token: example.c:1:6: ',' ",", · · }, · }, · Token: example.c:1:9: ';' ";", }
func (*Declaration) Position ¶
func (n *Declaration) Position() (r token.Position)
Position reports the position of the first component of n, if available.
type DeclarationList ¶
type DeclarationList struct { Declaration *Declaration DeclarationList *DeclarationList }
DeclarationList represents data reduced by productions:
DeclarationList: Declaration | DeclarationList Declaration
Example (Case0) ¶
fmt.Println(exampleAST(251, "int f(i) int i; {}"))
Output: &cc.DeclarationList{ · Declaration: &cc.Declaration{ · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{ · · · Case: DeclarationSpecifiersTypeSpec, · · · TypeSpecifier: &cc.TypeSpecifier{ · · · · Case: TypeSpecifierInt, · · · · Token: example.c:1:10: INT "int", · · · }, · · }, · · InitDeclaratorList: &cc.InitDeclaratorList{ · · · InitDeclarator: &cc.InitDeclarator{ · · · · Case: InitDeclaratorDecl, · · · · Declarator: &cc.Declarator{ · · · · · DirectDeclarator: &cc.DirectDeclarator{ · · · · · · Case: DirectDeclaratorIdent, · · · · · · Token: example.c:1:14: IDENTIFIER "i", · · · · · }, · · · · }, · · · }, · · }, · · Token: example.c:1:15: ';' ";", · }, }
Example (Case1) ¶
fmt.Println(exampleAST(252, "int f(i, j) int i; int j; {}"))
Output: &cc.DeclarationList{ · Declaration: &cc.Declaration{ · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{ · · · Case: DeclarationSpecifiersTypeSpec, · · · TypeSpecifier: &cc.TypeSpecifier{ · · · · Case: TypeSpecifierInt, · · · · Token: example.c:1:13: INT "int", · · · }, · · }, · · InitDeclaratorList: &cc.InitDeclaratorList{ · · · InitDeclarator: &cc.InitDeclarator{ · · · · Case: InitDeclaratorDecl, · · · · Declarator: &cc.Declarator{ · · · · · DirectDeclarator: &cc.DirectDeclarator{ · · · · · · Case: DirectDeclaratorIdent, · · · · · · Token: example.c:1:17: IDENTIFIER "i", · · · · · }, · · · · }, · · · }, · · }, · · Token: example.c:1:18: ';' ";", · }, · DeclarationList: &cc.DeclarationList{ · · Declaration: &cc.Declaration{ · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{ · · · · Case: DeclarationSpecifiersTypeSpec, · · · · TypeSpecifier: &cc.TypeSpecifier{ · · · · · Case: TypeSpecifierInt, · · · · · Token: example.c:1:20: INT "int", · · · · }, · · · }, · · · InitDeclaratorList: &cc.InitDeclaratorList{ · · · · InitDeclarator: &cc.InitDeclarator{ · · · · · Case: InitDeclaratorDecl, · · · · · Declarator: &cc.Declarator{ · · · · · · DirectDeclarator: &cc.DirectDeclarator{ · · · · · · · Case: DirectDeclaratorIdent, · · · · · · · Token: example.c:1:24: IDENTIFIER "j", · · · · · · }, · · · · · }, · · · · }, · · · }, · · · Token: example.c:1:25: ';' ";", · · }, · }, }
func (*DeclarationList) Position ¶
func (n *DeclarationList) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*DeclarationList) String ¶
func (n *DeclarationList) String() string
String implements fmt.Stringer.
type DeclarationSpecifiers ¶
type DeclarationSpecifiers struct { AlignmentSpecifier *AlignmentSpecifier AttributeSpecifier *AttributeSpecifier Case DeclarationSpecifiersCase `PrettyPrint:"stringer,zero"` DeclarationSpecifiers *DeclarationSpecifiers FunctionSpecifier *FunctionSpecifier StorageClassSpecifier *StorageClassSpecifier TypeQualifier *TypeQualifier TypeSpecifier *TypeSpecifier // contains filtered or unexported fields }
DeclarationSpecifiers represents data reduced by productions:
DeclarationSpecifiers: StorageClassSpecifier DeclarationSpecifiers // Case DeclarationSpecifiersStorage | TypeSpecifier DeclarationSpecifiers // Case DeclarationSpecifiersTypeSpec | TypeQualifier DeclarationSpecifiers // Case DeclarationSpecifiersTypeQual | FunctionSpecifier DeclarationSpecifiers // Case DeclarationSpecifiersFunc | AlignmentSpecifier DeclarationSpecifiers // Case DeclarationSpecifiersAlignSpec | AttributeSpecifier DeclarationSpecifiers // Case DeclarationSpecifiersAttribute
Example (AlignSpec) ¶
fmt.Println(exampleAST(91, "_Alignas(double) int i;"))
Output: &cc.DeclarationSpecifiers{ · AlignmentSpecifier: &cc.AlignmentSpecifier{ · · Case: AlignmentSpecifierAlignasType, · · Token: example.c:1:1: ALIGNAS "_Alignas", · · Token2: example.c:1:9: '(' "(", · · Token3: example.c:1:16: ')' ")", · · TypeName: &cc.TypeName{ · · · SpecifierQualifierList: &cc.SpecifierQualifierList{ · · · · Case: SpecifierQualifierListTypeSpec, · · · · TypeSpecifier: &cc.TypeSpecifier{ · · · · · Case: TypeSpecifierDouble, · · · · · Token: example.c:1:10: DOUBLE "double", · · · · }, · · · }, · · }, · }, · Case: DeclarationSpecifiersAlignSpec, · DeclarationSpecifiers: &cc.DeclarationSpecifiers{ · · Case: DeclarationSpecifiersTypeSpec, · · TypeSpecifier: &cc.TypeSpecifier{ · · · Case: TypeSpecifierInt, · · · Token: example.c:1:18: INT "int", · · }, · }, }
Example (Attribute) ¶
fmt.Println(exampleAST(92, "int __attribute__((a)) i;"))
Output: &cc.DeclarationSpecifiers{ · Case: DeclarationSpecifiersTypeSpec, · DeclarationSpecifiers: &cc.DeclarationSpecifiers{ · · AttributeSpecifier: &cc.AttributeSpecifier{ · · · AttributeValueList: &cc.AttributeValueList{ · · · · AttributeValue: &cc.AttributeValue{ · · · · · Case: AttributeValueIdent, · · · · · Token: example.c:1:20: IDENTIFIER "a", · · · · }, · · · }, · · · Token: example.c:1:5: ATTRIBUTE "__attribute__", · · · Token2: example.c:1:18: '(' "(", · · · Token3: example.c:1:19: '(' "(", · · · Token4: example.c:1:21: ')' ")", · · · Token5: example.c:1:22: ')' ")", · · }, · · Case: DeclarationSpecifiersAttribute, · }, · TypeSpecifier: &cc.TypeSpecifier{ · · Case: TypeSpecifierInt, · · Token: example.c:1:1: INT "int", · }, }
Example (Func) ¶
fmt.Println(exampleAST(90, "inline int f() {}"))
Output: &cc.DeclarationSpecifiers{ · Case: DeclarationSpecifiersFunc, · DeclarationSpecifiers: &cc.DeclarationSpecifiers{ · · Case: DeclarationSpecifiersTypeSpec, · · TypeSpecifier: &cc.TypeSpecifier{ · · · Case: TypeSpecifierInt, · · · Token: example.c:1:8: INT "int", · · }, · }, · FunctionSpecifier: &cc.FunctionSpecifier{ · · Case: FunctionSpecifierInline, · · Token: example.c:1:1: INLINE "inline", · }, }
Example (Storage) ¶
fmt.Println(exampleAST(87, "static int i;"))
Output: &cc.DeclarationSpecifiers{ · Case: DeclarationSpecifiersStorage, · DeclarationSpecifiers: &cc.DeclarationSpecifiers{ · · Case: DeclarationSpecifiersTypeSpec, · · TypeSpecifier: &cc.TypeSpecifier{ · · · Case: TypeSpecifierInt, · · · Token: example.c:1:8: INT "int", · · }, · }, · StorageClassSpecifier: &cc.StorageClassSpecifier{ · · Case: StorageClassSpecifierStatic, · · Token: example.c:1:1: STATIC "static", · }, }
Example (TypeQual) ¶
fmt.Println(exampleAST(89, "volatile int i;"))
Output: &cc.DeclarationSpecifiers{ · Case: DeclarationSpecifiersTypeQual, · DeclarationSpecifiers: &cc.DeclarationSpecifiers{ · · Case: DeclarationSpecifiersTypeSpec, · · TypeSpecifier: &cc.TypeSpecifier{ · · · Case: TypeSpecifierInt, · · · Token: example.c:1:10: INT "int", · · }, · }, · TypeQualifier: &cc.TypeQualifier{ · · Case: TypeQualifierVolatile, · · Token: example.c:1:1: VOLATILE "volatile", · }, }
Example (TypeSpec) ¶
fmt.Println(exampleAST(88, "int i;"))
Output: &cc.DeclarationSpecifiers{ · Case: DeclarationSpecifiersTypeSpec, · TypeSpecifier: &cc.TypeSpecifier{ · · Case: TypeSpecifierInt, · · Token: example.c:1:1: INT "int", · }, }
func (*DeclarationSpecifiers) Position ¶
func (n *DeclarationSpecifiers) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*DeclarationSpecifiers) String ¶
func (n *DeclarationSpecifiers) String() string
String implements fmt.Stringer.
type DeclarationSpecifiersCase ¶
type DeclarationSpecifiersCase int
DeclarationSpecifiersCase represents case numbers of production DeclarationSpecifiers
const ( DeclarationSpecifiersStorage DeclarationSpecifiersCase = iota DeclarationSpecifiersTypeSpec DeclarationSpecifiersTypeQual DeclarationSpecifiersFunc DeclarationSpecifiersAlignSpec DeclarationSpecifiersAttribute )
Values of type DeclarationSpecifiersCase
func (DeclarationSpecifiersCase) String ¶
func (n DeclarationSpecifiersCase) String() string
String implements fmt.Stringer
type Declarator ¶
type Declarator struct { Linkage Linkage Read int StorageClass StorageClass Write int AddressTaken bool IsParameter bool IsTypedefName bool SubjectOfAsgnOp bool SubjectOfIncDec bool AttributeSpecifierList *AttributeSpecifierList DirectDeclarator *DirectDeclarator Pointer *Pointer // contains filtered or unexported fields }
Declarator represents data reduced by production:
Declarator: Pointer DirectDeclarator AttributeSpecifierList
Example (Case0) ¶
fmt.Println(exampleAST(166, "int *p __attribute__ ((foo));"))
Output: &cc.Declarator{ · AttributeSpecifierList: &cc.AttributeSpecifierList{ · · AttributeSpecifier: &cc.AttributeSpecifier{ · · · AttributeValueList: &cc.AttributeValueList{ · · · · AttributeValue: &cc.AttributeValue{ · · · · · Case: AttributeValueIdent, · · · · · Token: example.c:1:24: IDENTIFIER "foo", · · · · }, · · · }, · · · Token: example.c:1:8: ATTRIBUTE "__attribute__", · · · Token2: example.c:1:22: '(' "(", · · · Token3: example.c:1:23: '(' "(", · · · Token4: example.c:1:27: ')' ")", · · · Token5: example.c:1:28: ')' ")", · · }, · }, · DirectDeclarator: &cc.DirectDeclarator{ · · Case: DirectDeclaratorIdent, · · Token: example.c:1:6: IDENTIFIER "p", · }, · Pointer: &cc.Pointer{ · · Case: PointerTypeQual, · · Token: example.c:1:5: '*' "*", · }, }
func (*Declarator) Called ¶ added in v3.31.0
func (n *Declarator) Called() bool
Called reports whether n is involved in expr in expr(callArgs).
func (*Declarator) DeclarationSpecifiers ¶ added in v3.25.2
func (n *Declarator) DeclarationSpecifiers() *DeclarationSpecifiers
DeclarationSpecifiers returns the declaration specifiers associated with n or nil.
func (*Declarator) FunctionDefinition ¶ added in v3.27.0
func (n *Declarator) FunctionDefinition() *FunctionDefinition
FunctionDefinition returns the function definition associated with n, if any.
func (*Declarator) HasInitializer ¶
func (n *Declarator) HasInitializer() bool
HasInitializer reports whether d has an initializator.
func (*Declarator) IsExtern ¶
func (n *Declarator) IsExtern() bool
IsExtern reports whether n was declared with storage class specifier 'extern'.
func (*Declarator) IsFunctionPrototype ¶ added in v3.25.2
func (n *Declarator) IsFunctionPrototype() bool
IsFunctionPrototype reports whether n is a function prototype.
func (*Declarator) IsImplicit ¶ added in v3.35.16
func (n *Declarator) IsImplicit() bool
IsImplicit reports whether n was not declared nor defined, only inferred.
func (*Declarator) IsStatic ¶
func (n *Declarator) IsStatic() bool
func (*Declarator) LHS ¶ added in v3.31.0
func (n *Declarator) LHS() map[*Declarator]struct{}
LHS reports which declarators n is used in assignment RHS or which function declarators n is used in a function argument. To collect this information, TrackAssignments in Config must be set during type checking. The returned map may contain a nil key. That means that n is assigned to a declarator not known at typechecking time.
func (*Declarator) LexicalScope ¶
func (n *Declarator) LexicalScope() Scope
LexicalScope returns the lexical scope of n.
func (*Declarator) NameTok ¶
func (n *Declarator) NameTok() (r Token)
NameTok returns n's declaring name token.
func (*Declarator) ParamScope ¶
func (n *Declarator) ParamScope() Scope
ParamScope returns the scope in which n's function parameters are declared if the underlying type of n is a function or nil otherwise. If n is part of a function definition the scope is the same as the scope of the function body.
func (*Declarator) Position ¶
func (n *Declarator) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*Declarator) SpecifierQualifierList ¶ added in v3.25.2
func (n *Declarator) SpecifierQualifierList() *SpecifierQualifierList
SpecifierQualifierList returns the specifier qualifer list associated with n or nil.
func (*Declarator) TypeQualifiers ¶ added in v3.25.2
func (n *Declarator) TypeQualifiers() *TypeQualifiers
TypeQualifier returns the type qualifiers associated with n or nil.
type Designation ¶
type Designation struct { DesignatorList *DesignatorList Token Token }
Designation represents data reduced by production:
Designation: DesignatorList '='
Example (Case0) ¶
fmt.Println(exampleAST(204, "int a[] = { [42] = 314 };"))
Output: &cc.Designation{ · DesignatorList: &cc.DesignatorList{ · · Designator: &cc.Designator{ · · · Case: DesignatorIndex, · · · ConstantExpression: &cc.ConstantExpression{ · · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · · Case: ConditionalExpressionLOr, · · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · · Case: LogicalOrExpressionLAnd, · · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · · Case: LogicalAndExpressionOr, · · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionInt, · · · · · · · · · · · · · · · · · · · Token: example.c:1:14: INTCONST "42", · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · · Token: example.c:1:13: '[' "[", · · · Token2: example.c:1:16: ']' "]", · · }, · }, · Token: example.c:1:18: '=' "=", }
func (*Designation) Position ¶
func (n *Designation) Position() (r token.Position)
Position reports the position of the first component of n, if available.
type Designator ¶
type Designator struct { Case DesignatorCase `PrettyPrint:"stringer,zero"` ConstantExpression *ConstantExpression Token Token Token2 Token // contains filtered or unexported fields }
Designator represents data reduced by productions:
Designator: '[' ConstantExpression ']' // Case DesignatorIndex | '.' IDENTIFIER // Case DesignatorField | IDENTIFIER ':' // Case DesignatorField2
Example (Field) ¶
fmt.Println(exampleAST(208, "struct t s = { .fld = 314 };"))
Output: &cc.Designator{ · Case: DesignatorField, · Token: example.c:1:16: '.' ".", · Token2: example.c:1:17: IDENTIFIER "fld", }
Example (Field2) ¶
fmt.Println(exampleAST(209, "struct t s = { fld: 314 };"))
Output: &cc.Designator{ · Case: DesignatorField2, · Token: example.c:1:16: IDENTIFIER "fld", · Token2: example.c:1:19: ':' ":", }
Example (Index) ¶
fmt.Println(exampleAST(207, "int a[] = { [42] = 314 };"))
Output: &cc.Designator{ · Case: DesignatorIndex, · ConstantExpression: &cc.ConstantExpression{ · · ConditionalExpression: &cc.ConditionalExpression{ · · · Case: ConditionalExpressionLOr, · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · Case: LogicalOrExpressionLAnd, · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · Case: LogicalAndExpressionOr, · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · Case: InclusiveOrExpressionXor, · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · Case: AndExpressionEq, · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · Case: PrimaryExpressionInt, · · · · · · · · · · · · · · · · · Token: example.c:1:14: INTCONST "42", · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · }, · Token: example.c:1:13: '[' "[", · Token2: example.c:1:16: ']' "]", }
func (*Designator) Position ¶
func (n *Designator) Position() (r token.Position)
Position reports the position of the first component of n, if available.
type DesignatorCase ¶
type DesignatorCase int
DesignatorCase represents case numbers of production Designator
const ( DesignatorIndex DesignatorCase = iota DesignatorField DesignatorField2 )
Values of type DesignatorCase
func (DesignatorCase) String ¶
func (n DesignatorCase) String() string
String implements fmt.Stringer
type DesignatorList ¶
type DesignatorList struct { Designator *Designator DesignatorList *DesignatorList }
DesignatorList represents data reduced by productions:
DesignatorList: Designator | DesignatorList Designator
Example (Case0) ¶
fmt.Println(exampleAST(205, "int a[] = { [42] = 314 };"))
Output: &cc.DesignatorList{ · Designator: &cc.Designator{ · · Case: DesignatorIndex, · · ConstantExpression: &cc.ConstantExpression{ · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · Case: ConditionalExpressionLOr, · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · Case: LogicalOrExpressionLAnd, · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · Case: LogicalAndExpressionOr, · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionInt, · · · · · · · · · · · · · · · · · · Token: example.c:1:14: INTCONST "42", · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · · Token: example.c:1:13: '[' "[", · · Token2: example.c:1:16: ']' "]", · }, }
Example (Case1) ¶
fmt.Println(exampleAST(206, "int a[100][] = { [42][12] = 314 };"))
Output: &cc.DesignatorList{ · Designator: &cc.Designator{ · · Case: DesignatorIndex, · · ConstantExpression: &cc.ConstantExpression{ · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · Case: ConditionalExpressionLOr, · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · Case: LogicalOrExpressionLAnd, · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · Case: LogicalAndExpressionOr, · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionInt, · · · · · · · · · · · · · · · · · · Token: example.c:1:19: INTCONST "42", · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · · Token: example.c:1:18: '[' "[", · · Token2: example.c:1:21: ']' "]", · }, · DesignatorList: &cc.DesignatorList{ · · Designator: &cc.Designator{ · · · Case: DesignatorIndex, · · · ConstantExpression: &cc.ConstantExpression{ · · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · · Case: ConditionalExpressionLOr, · · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · · Case: LogicalOrExpressionLAnd, · · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · · Case: LogicalAndExpressionOr, · · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionInt, · · · · · · · · · · · · · · · · · · · Token: example.c:1:23: INTCONST "12", · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · · Token: example.c:1:22: '[' "[", · · · Token2: example.c:1:25: ']' "]", · · }, · }, }
func (*DesignatorList) Position ¶
func (n *DesignatorList) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*DesignatorList) String ¶
func (n *DesignatorList) String() string
String implements fmt.Stringer.
type DirectAbstractDeclarator ¶
type DirectAbstractDeclarator struct { AbstractDeclarator *AbstractDeclarator AssignmentExpression *AssignmentExpression Case DirectAbstractDeclaratorCase `PrettyPrint:"stringer,zero"` DirectAbstractDeclarator *DirectAbstractDeclarator ParameterTypeList *ParameterTypeList Token Token Token2 Token Token3 Token TypeQualifiers *TypeQualifiers // contains filtered or unexported fields }
DirectAbstractDeclarator represents data reduced by productions:
DirectAbstractDeclarator: '(' AbstractDeclarator ')' // Case DirectAbstractDeclaratorDecl | DirectAbstractDeclarator '[' TypeQualifiers AssignmentExpression ']' // Case DirectAbstractDeclaratorArr | DirectAbstractDeclarator '[' "static" TypeQualifiers AssignmentExpression ']' // Case DirectAbstractDeclaratorStaticArr | DirectAbstractDeclarator '[' TypeQualifiers "static" AssignmentExpression ']' // Case DirectAbstractDeclaratorArrStatic | DirectAbstractDeclarator '[' '*' ']' // Case DirectAbstractDeclaratorArrStar | DirectAbstractDeclarator '(' ParameterTypeList ')' // Case DirectAbstractDeclaratorFunc
Example (Arr) ¶
fmt.Println(exampleAST(195, "void f(int[const 42]);"))
Output: &cc.DirectAbstractDeclarator{ · AssignmentExpression: &cc.AssignmentExpression{ · · Case: AssignmentExpressionCond, · · ConditionalExpression: &cc.ConditionalExpression{ · · · Case: ConditionalExpressionLOr, · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · Case: LogicalOrExpressionLAnd, · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · Case: LogicalAndExpressionOr, · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · Case: InclusiveOrExpressionXor, · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · Case: AndExpressionEq, · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · Case: PrimaryExpressionInt, · · · · · · · · · · · · · · · · · Token: example.c:1:18: INTCONST "42", · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · }, · Case: DirectAbstractDeclaratorArr, · Token: example.c:1:11: '[' "[", · Token2: example.c:1:20: ']' "]", · TypeQualifiers: &cc.TypeQualifiers{ · · Case: TypeQualifiersTypeQual, · · TypeQualifier: &cc.TypeQualifier{ · · · Case: TypeQualifierConst, · · · Token: example.c:1:12: CONST "const", · · }, · }, }
Example (ArrStar) ¶
fmt.Println(exampleAST(198, "void f(int[*]);"))
Output: &cc.DirectAbstractDeclarator{ · Case: DirectAbstractDeclaratorArrStar, · Token: example.c:1:11: '[' "[", · Token2: example.c:1:12: '*' "*", · Token3: example.c:1:13: ']' "]", }
Example (ArrStatic) ¶
fmt.Println(exampleAST(197, "void f(int[const static 42]);"))
Output: &cc.DirectAbstractDeclarator{ · AssignmentExpression: &cc.AssignmentExpression{ · · Case: AssignmentExpressionCond, · · ConditionalExpression: &cc.ConditionalExpression{ · · · Case: ConditionalExpressionLOr, · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · Case: LogicalOrExpressionLAnd, · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · Case: LogicalAndExpressionOr, · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · Case: InclusiveOrExpressionXor, · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · Case: AndExpressionEq, · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · Case: PrimaryExpressionInt, · · · · · · · · · · · · · · · · · Token: example.c:1:25: INTCONST "42", · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · }, · Case: DirectAbstractDeclaratorArrStatic, · Token: example.c:1:11: '[' "[", · Token2: example.c:1:18: STATIC "static", · Token3: example.c:1:27: ']' "]", · TypeQualifiers: &cc.TypeQualifiers{ · · Case: TypeQualifiersTypeQual, · · TypeQualifier: &cc.TypeQualifier{ · · · Case: TypeQualifierConst, · · · Token: example.c:1:12: CONST "const", · · }, · }, }
Example (Decl) ¶
fmt.Println(exampleAST(194, "void f(int());"))
Output: &cc.DirectAbstractDeclarator{ · Case: DirectAbstractDeclaratorFunc, · Token: example.c:1:11: '(' "(", · Token2: example.c:1:12: ')' ")", }
Example (Func) ¶
fmt.Println(exampleAST(199, "void f(int(char));"))
Output: &cc.DirectAbstractDeclarator{ · Case: DirectAbstractDeclaratorFunc, · ParameterTypeList: &cc.ParameterTypeList{ · · Case: ParameterTypeListList, · · ParameterList: &cc.ParameterList{ · · · ParameterDeclaration: &cc.ParameterDeclaration{ · · · · Case: ParameterDeclarationAbstract, · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{ · · · · · Case: DeclarationSpecifiersTypeSpec, · · · · · TypeSpecifier: &cc.TypeSpecifier{ · · · · · · Case: TypeSpecifierChar, · · · · · · Token: example.c:1:12: CHAR "char", · · · · · }, · · · · }, · · · }, · · }, · }, · Token: example.c:1:11: '(' "(", · Token2: example.c:1:16: ')' ")", }
Example (StaticArr) ¶
fmt.Println(exampleAST(196, "void f(int[static const 42]);"))
Output: &cc.DirectAbstractDeclarator{ · AssignmentExpression: &cc.AssignmentExpression{ · · Case: AssignmentExpressionCond, · · ConditionalExpression: &cc.ConditionalExpression{ · · · Case: ConditionalExpressionLOr, · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · Case: LogicalOrExpressionLAnd, · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · Case: LogicalAndExpressionOr, · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · Case: InclusiveOrExpressionXor, · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · Case: AndExpressionEq, · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · Case: PrimaryExpressionInt, · · · · · · · · · · · · · · · · · Token: example.c:1:25: INTCONST "42", · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · }, · Case: DirectAbstractDeclaratorStaticArr, · Token: example.c:1:11: '[' "[", · Token2: example.c:1:12: STATIC "static", · Token3: example.c:1:27: ']' "]", · TypeQualifiers: &cc.TypeQualifiers{ · · Case: TypeQualifiersTypeQual, · · TypeQualifier: &cc.TypeQualifier{ · · · Case: TypeQualifierConst, · · · Token: example.c:1:19: CONST "const", · · }, · }, }
func (*DirectAbstractDeclarator) Position ¶
func (n *DirectAbstractDeclarator) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*DirectAbstractDeclarator) String ¶
func (n *DirectAbstractDeclarator) String() string
String implements fmt.Stringer.
func (*DirectAbstractDeclarator) TypeQualifier ¶
func (n *DirectAbstractDeclarator) TypeQualifier() Type
type DirectAbstractDeclaratorCase ¶
type DirectAbstractDeclaratorCase int
DirectAbstractDeclaratorCase represents case numbers of production DirectAbstractDeclarator
const ( DirectAbstractDeclaratorDecl DirectAbstractDeclaratorCase = iota DirectAbstractDeclaratorArr DirectAbstractDeclaratorStaticArr DirectAbstractDeclaratorArrStatic DirectAbstractDeclaratorArrStar DirectAbstractDeclaratorFunc )
Values of type DirectAbstractDeclaratorCase
func (DirectAbstractDeclaratorCase) String ¶
func (n DirectAbstractDeclaratorCase) String() string
String implements fmt.Stringer
type DirectDeclarator ¶
type DirectDeclarator struct { Asm *Asm AssignmentExpression *AssignmentExpression AttributeSpecifierList *AttributeSpecifierList Case DirectDeclaratorCase `PrettyPrint:"stringer,zero"` Declarator *Declarator DirectDeclarator *DirectDeclarator IdentifierList *IdentifierList ParameterTypeList *ParameterTypeList Token Token Token2 Token Token3 Token TypeQualifiers *TypeQualifiers // contains filtered or unexported fields }
DirectDeclarator represents data reduced by productions:
DirectDeclarator: IDENTIFIER Asm // Case DirectDeclaratorIdent | '(' AttributeSpecifierList Declarator ')' // Case DirectDeclaratorDecl | DirectDeclarator '[' TypeQualifiers AssignmentExpression ']' // Case DirectDeclaratorArr | DirectDeclarator '[' "static" TypeQualifiers AssignmentExpression ']' // Case DirectDeclaratorStaticArr | DirectDeclarator '[' TypeQualifiers "static" AssignmentExpression ']' // Case DirectDeclaratorArrStatic | DirectDeclarator '[' TypeQualifiers '*' ']' // Case DirectDeclaratorStar | DirectDeclarator '(' ParameterTypeList ')' // Case DirectDeclaratorFuncParam | DirectDeclarator '(' IdentifierList ')' // Case DirectDeclaratorFuncIdent
Example (Arr) ¶
fmt.Println(exampleAST(171, "int i[const 42];"))
Output: &cc.DirectDeclarator{ · AssignmentExpression: &cc.AssignmentExpression{ · · Case: AssignmentExpressionCond, · · ConditionalExpression: &cc.ConditionalExpression{ · · · Case: ConditionalExpressionLOr, · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · Case: LogicalOrExpressionLAnd, · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · Case: LogicalAndExpressionOr, · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · Case: InclusiveOrExpressionXor, · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · Case: AndExpressionEq, · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · Case: PrimaryExpressionInt, · · · · · · · · · · · · · · · · · Token: example.c:1:13: INTCONST "42", · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · }, · Case: DirectDeclaratorArr, · DirectDeclarator: &cc.DirectDeclarator{ · · Case: DirectDeclaratorIdent, · · Token: example.c:1:5: IDENTIFIER "i", · }, · Token: example.c:1:6: '[' "[", · Token2: example.c:1:15: ']' "]", · TypeQualifiers: &cc.TypeQualifiers{ · · Case: TypeQualifiersTypeQual, · · TypeQualifier: &cc.TypeQualifier{ · · · Case: TypeQualifierConst, · · · Token: example.c:1:7: CONST "const", · · }, · }, }
Example (ArrStatic) ¶
fmt.Println(exampleAST(173, "int i[const static 42];"))
Output: &cc.DirectDeclarator{ · AssignmentExpression: &cc.AssignmentExpression{ · · Case: AssignmentExpressionCond, · · ConditionalExpression: &cc.ConditionalExpression{ · · · Case: ConditionalExpressionLOr, · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · Case: LogicalOrExpressionLAnd, · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · Case: LogicalAndExpressionOr, · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · Case: InclusiveOrExpressionXor, · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · Case: AndExpressionEq, · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · Case: PrimaryExpressionInt, · · · · · · · · · · · · · · · · · Token: example.c:1:20: INTCONST "42", · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · }, · Case: DirectDeclaratorArrStatic, · DirectDeclarator: &cc.DirectDeclarator{ · · Case: DirectDeclaratorIdent, · · Token: example.c:1:5: IDENTIFIER "i", · }, · Token: example.c:1:6: '[' "[", · Token2: example.c:1:13: STATIC "static", · Token3: example.c:1:22: ']' "]", · TypeQualifiers: &cc.TypeQualifiers{ · · Case: TypeQualifiersTypeQual, · · TypeQualifier: &cc.TypeQualifier{ · · · Case: TypeQualifierConst, · · · Token: example.c:1:7: CONST "const", · · }, · }, }
Example (Decl) ¶
fmt.Println(exampleAST(170, "int (f);"))
Output: &cc.DirectDeclarator{ · Case: DirectDeclaratorDecl, · Declarator: &cc.Declarator{ · · DirectDeclarator: &cc.DirectDeclarator{ · · · Case: DirectDeclaratorIdent, · · · Token: example.c:1:6: IDENTIFIER "f", · · }, · }, · Token: example.c:1:5: '(' "(", · Token2: example.c:1:7: ')' ")", }
Example (FuncIdent) ¶
fmt.Println(exampleAST(176, "int f(a);"))
Output: &cc.DirectDeclarator{ · Case: DirectDeclaratorFuncIdent, · DirectDeclarator: &cc.DirectDeclarator{ · · Case: DirectDeclaratorIdent, · · Token: example.c:1:5: IDENTIFIER "f", · }, · IdentifierList: &cc.IdentifierList{ · · Token: example.c:1:7: IDENTIFIER "a", · }, · Token: example.c:1:6: '(' "(", · Token2: example.c:1:8: ')' ")", }
Example (FuncParam) ¶
fmt.Println(exampleAST(175, "int f(int i);"))
Output: &cc.DirectDeclarator{ · Case: DirectDeclaratorFuncParam, · DirectDeclarator: &cc.DirectDeclarator{ · · Case: DirectDeclaratorIdent, · · Token: example.c:1:5: IDENTIFIER "f", · }, · ParameterTypeList: &cc.ParameterTypeList{ · · Case: ParameterTypeListList, · · ParameterList: &cc.ParameterList{ · · · ParameterDeclaration: &cc.ParameterDeclaration{ · · · · Case: ParameterDeclarationDecl, · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{ · · · · · Case: DeclarationSpecifiersTypeSpec, · · · · · TypeSpecifier: &cc.TypeSpecifier{ · · · · · · Case: TypeSpecifierInt, · · · · · · Token: example.c:1:7: INT "int", · · · · · }, · · · · }, · · · · Declarator: &cc.Declarator{ · · · · · DirectDeclarator: &cc.DirectDeclarator{ · · · · · · Case: DirectDeclaratorIdent, · · · · · · Token: example.c:1:11: IDENTIFIER "i", · · · · · }, · · · · }, · · · }, · · }, · }, · Token: example.c:1:6: '(' "(", · Token2: example.c:1:12: ')' ")", }
Example (Ident) ¶
fmt.Println(exampleAST(169, "int i;"))
Output: &cc.DirectDeclarator{ · Case: DirectDeclaratorIdent, · Token: example.c:1:5: IDENTIFIER "i", }
Example (Line) ¶
fmt.Println(exampleAST(0, "#line 1234\nint i;"))
Output: &cc.DirectDeclarator{ · Case: DirectDeclaratorIdent, · Token: example.c:1234:5: IDENTIFIER "i", }
Example (Line2) ¶
fmt.Println(exampleAST(0, "#line 1234 \"foo.c\"\nint i;"))
Output: &cc.DirectDeclarator{ · Case: DirectDeclaratorIdent, · Token: foo.c:1234:5: IDENTIFIER "i", }
Example (Line3) ¶
fmt.Println(exampleAST(0, "#line 1234\r\nint i;"))
Output: &cc.DirectDeclarator{ · Case: DirectDeclaratorIdent, · Token: example.c:1234:5: IDENTIFIER "i", }
Example (Line4) ¶
fmt.Println(exampleAST(0, "#line 1234 \"foo.c\"\r\nint i;"))
Output: &cc.DirectDeclarator{ · Case: DirectDeclaratorIdent, · Token: foo.c:1234:5: IDENTIFIER "i", }
Example (Star) ¶
fmt.Println(exampleAST(174, "int i[const *];"))
Output: &cc.DirectDeclarator{ · Case: DirectDeclaratorStar, · DirectDeclarator: &cc.DirectDeclarator{ · · Case: DirectDeclaratorIdent, · · Token: example.c:1:5: IDENTIFIER "i", · }, · Token: example.c:1:6: '[' "[", · Token2: example.c:1:13: '*' "*", · Token3: example.c:1:14: ']' "]", · TypeQualifiers: &cc.TypeQualifiers{ · · Case: TypeQualifiersTypeQual, · · TypeQualifier: &cc.TypeQualifier{ · · · Case: TypeQualifierConst, · · · Token: example.c:1:7: CONST "const", · · }, · }, }
Example (StaticArr) ¶
fmt.Println(exampleAST(172, "int i[static const 42];"))
Output: &cc.DirectDeclarator{ · AssignmentExpression: &cc.AssignmentExpression{ · · Case: AssignmentExpressionCond, · · ConditionalExpression: &cc.ConditionalExpression{ · · · Case: ConditionalExpressionLOr, · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · Case: LogicalOrExpressionLAnd, · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · Case: LogicalAndExpressionOr, · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · Case: InclusiveOrExpressionXor, · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · Case: AndExpressionEq, · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · Case: PrimaryExpressionInt, · · · · · · · · · · · · · · · · · Token: example.c:1:20: INTCONST "42", · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · }, · Case: DirectDeclaratorStaticArr, · DirectDeclarator: &cc.DirectDeclarator{ · · Case: DirectDeclaratorIdent, · · Token: example.c:1:5: IDENTIFIER "i", · }, · Token: example.c:1:6: '[' "[", · Token2: example.c:1:7: STATIC "static", · Token3: example.c:1:22: ']' "]", · TypeQualifiers: &cc.TypeQualifiers{ · · Case: TypeQualifiersTypeQual, · · TypeQualifier: &cc.TypeQualifier{ · · · Case: TypeQualifierConst, · · · Token: example.c:1:14: CONST "const", · · }, · }, }
func (*DirectDeclarator) Name ¶
func (n *DirectDeclarator) Name() StringID
Name returns n's declared name.
func (*DirectDeclarator) NameTok ¶
func (n *DirectDeclarator) NameTok() (r Token)
NameTok returns n's declarin name token.
func (*DirectDeclarator) ParamScope ¶
func (n *DirectDeclarator) ParamScope() Scope
ParamScope returns the innermost scope in which function parameters are declared for Case DirectDeclaratorFuncParam or DirectDeclaratorFuncIdent or nil otherwise.
func (*DirectDeclarator) Position ¶
func (n *DirectDeclarator) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*DirectDeclarator) String ¶
func (n *DirectDeclarator) String() string
String implements fmt.Stringer.
func (*DirectDeclarator) TypeQualifier ¶
func (n *DirectDeclarator) TypeQualifier() Type
type DirectDeclaratorCase ¶
type DirectDeclaratorCase int
DirectDeclaratorCase represents case numbers of production DirectDeclarator
const ( DirectDeclaratorIdent DirectDeclaratorCase = iota DirectDeclaratorDecl DirectDeclaratorArr DirectDeclaratorStaticArr DirectDeclaratorArrStatic DirectDeclaratorStar DirectDeclaratorFuncParam DirectDeclaratorFuncIdent )
Values of type DirectDeclaratorCase
func (DirectDeclaratorCase) String ¶
func (n DirectDeclaratorCase) String() string
String implements fmt.Stringer
type EnumSpecifier ¶
type EnumSpecifier struct { AttributeSpecifierList *AttributeSpecifierList Case EnumSpecifierCase `PrettyPrint:"stringer,zero"` EnumeratorList *EnumeratorList Token Token Token2 Token Token3 Token Token4 Token Token5 Token // contains filtered or unexported fields }
EnumSpecifier represents data reduced by productions:
EnumSpecifier: "enum" AttributeSpecifierList IDENTIFIER '{' EnumeratorList ',' '}' // Case EnumSpecifierDef | "enum" AttributeSpecifierList IDENTIFIER // Case EnumSpecifierTag
Example (Def) ¶
fmt.Println(exampleAST(153, "enum e {a};"))
Output: &cc.EnumSpecifier{ · Case: EnumSpecifierDef, · EnumeratorList: &cc.EnumeratorList{ · · Enumerator: &cc.Enumerator{ · · · Case: EnumeratorIdent, · · · Token: example.c:1:9: IDENTIFIER "a", · · }, · }, · Token: example.c:1:1: ENUM "enum", · Token2: example.c:1:6: IDENTIFIER "e", · Token3: example.c:1:8: '{' "{", · Token5: example.c:1:10: '}' "}", }
Example (Tag) ¶
fmt.Println(exampleAST(154, "enum e i;"))
Output: &cc.EnumSpecifier{ · Case: EnumSpecifierTag, · Token: example.c:1:1: ENUM "enum", · Token2: example.c:1:6: IDENTIFIER "e", }
func (*EnumSpecifier) LexicalScope ¶ added in v3.25.2
func (n *EnumSpecifier) LexicalScope() Scope
LexicalScope returns the lexical scope of n.
func (*EnumSpecifier) Position ¶
func (n *EnumSpecifier) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*EnumSpecifier) String ¶
func (n *EnumSpecifier) String() string
String implements fmt.Stringer.
func (*EnumSpecifier) Type ¶
func (n *EnumSpecifier) Type() Type
type EnumSpecifierCase ¶
type EnumSpecifierCase int
EnumSpecifierCase represents case numbers of production EnumSpecifier
const ( EnumSpecifierDef EnumSpecifierCase = iota EnumSpecifierTag )
Values of type EnumSpecifierCase
func (EnumSpecifierCase) String ¶
func (n EnumSpecifierCase) String() string
String implements fmt.Stringer
type Enumerator ¶
type Enumerator struct { Operand Operand AttributeSpecifierList *AttributeSpecifierList Case EnumeratorCase `PrettyPrint:"stringer,zero"` ConstantExpression *ConstantExpression Token Token Token2 Token // contains filtered or unexported fields }
Enumerator represents data reduced by productions:
Enumerator: IDENTIFIER AttributeSpecifierList // Case EnumeratorIdent | IDENTIFIER AttributeSpecifierList '=' ConstantExpression // Case EnumeratorExpr
Example (Expr) ¶
fmt.Println(exampleAST(158, "enum e {a = 42};"))
Output: &cc.Enumerator{ · Case: EnumeratorExpr, · ConstantExpression: &cc.ConstantExpression{ · · ConditionalExpression: &cc.ConditionalExpression{ · · · Case: ConditionalExpressionLOr, · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · Case: LogicalOrExpressionLAnd, · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · Case: LogicalAndExpressionOr, · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · Case: InclusiveOrExpressionXor, · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · Case: AndExpressionEq, · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · Case: PrimaryExpressionInt, · · · · · · · · · · · · · · · · · Token: example.c:1:13: INTCONST "42", · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · }, · Token: example.c:1:9: IDENTIFIER "a", · Token2: example.c:1:11: '=' "=", }
Example (Ident) ¶
fmt.Println(exampleAST(157, "enum e {a};"))
Output: &cc.Enumerator{ · Case: EnumeratorIdent, · Token: example.c:1:9: IDENTIFIER "a", }
func (*Enumerator) Position ¶
func (n *Enumerator) Position() (r token.Position)
Position reports the position of the first component of n, if available.
type EnumeratorCase ¶
type EnumeratorCase int
EnumeratorCase represents case numbers of production Enumerator
const ( EnumeratorIdent EnumeratorCase = iota EnumeratorExpr )
Values of type EnumeratorCase
func (EnumeratorCase) String ¶
func (n EnumeratorCase) String() string
String implements fmt.Stringer
type EnumeratorList ¶
type EnumeratorList struct { Enumerator *Enumerator EnumeratorList *EnumeratorList Token Token }
EnumeratorList represents data reduced by productions:
EnumeratorList: Enumerator | EnumeratorList ',' Enumerator
Example (Case0) ¶
fmt.Println(exampleAST(155, "enum e {a};"))
Output: &cc.EnumeratorList{ · Enumerator: &cc.Enumerator{ · · Case: EnumeratorIdent, · · Token: example.c:1:9: IDENTIFIER "a", · }, }
Example (Case1) ¶
fmt.Println(exampleAST(156, "enum e {a, b};"))
Output: &cc.EnumeratorList{ · Enumerator: &cc.Enumerator{ · · Case: EnumeratorIdent, · · Token: example.c:1:9: IDENTIFIER "a", · }, · EnumeratorList: &cc.EnumeratorList{ · · Enumerator: &cc.Enumerator{ · · · Case: EnumeratorIdent, · · · Token: example.c:1:12: IDENTIFIER "b", · · }, · · Token: example.c:1:10: ',' ",", · }, }
func (*EnumeratorList) Position ¶
func (n *EnumeratorList) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*EnumeratorList) String ¶
func (n *EnumeratorList) String() string
String implements fmt.Stringer.
type EqualityExpression ¶
type EqualityExpression struct { Operand Operand IsSideEffectsFree bool Case EqualityExpressionCase `PrettyPrint:"stringer,zero"` EqualityExpression *EqualityExpression RelationalExpression *RelationalExpression Token Token // contains filtered or unexported fields }
EqualityExpression represents data reduced by productions:
EqualityExpression: RelationalExpression // Case EqualityExpressionRel | EqualityExpression "==" RelationalExpression // Case EqualityExpressionEq | EqualityExpression "!=" RelationalExpression // Case EqualityExpressionNeq
Example (Eq) ¶
fmt.Println(exampleAST(57, "int i = x == y;"))
Output: &cc.EqualityExpression{ · Case: EqualityExpressionEq, · EqualityExpression: &cc.EqualityExpression{ · · Case: EqualityExpressionRel, · · RelationalExpression: &cc.RelationalExpression{ · · · Case: RelationalExpressionShift, · · · ShiftExpression: &cc.ShiftExpression{ · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · Case: AdditiveExpressionMul, · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · Case: MultiplicativeExpressionCast, · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · Case: CastExpressionUnary, · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · Token: example.c:1:9: IDENTIFIER "x", · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · · Case: ShiftExpressionAdd, · · · }, · · }, · }, · RelationalExpression: &cc.RelationalExpression{ · · Case: RelationalExpressionShift, · · ShiftExpression: &cc.ShiftExpression{ · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · Case: AdditiveExpressionMul, · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · Case: MultiplicativeExpressionCast, · · · · · CastExpression: &cc.CastExpression{ · · · · · · Case: CastExpressionUnary, · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · Token: example.c:1:14: IDENTIFIER "y", · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · · Case: ShiftExpressionAdd, · · }, · }, · Token: example.c:1:11: EQ "==", }
Example (Neq) ¶
fmt.Println(exampleAST(58, "int i = x != y;"))
Output: &cc.EqualityExpression{ · Case: EqualityExpressionNeq, · EqualityExpression: &cc.EqualityExpression{ · · Case: EqualityExpressionRel, · · RelationalExpression: &cc.RelationalExpression{ · · · Case: RelationalExpressionShift, · · · ShiftExpression: &cc.ShiftExpression{ · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · Case: AdditiveExpressionMul, · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · Case: MultiplicativeExpressionCast, · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · Case: CastExpressionUnary, · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · Token: example.c:1:9: IDENTIFIER "x", · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · · Case: ShiftExpressionAdd, · · · }, · · }, · }, · RelationalExpression: &cc.RelationalExpression{ · · Case: RelationalExpressionShift, · · ShiftExpression: &cc.ShiftExpression{ · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · Case: AdditiveExpressionMul, · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · Case: MultiplicativeExpressionCast, · · · · · CastExpression: &cc.CastExpression{ · · · · · · Case: CastExpressionUnary, · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · Token: example.c:1:14: IDENTIFIER "y", · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · · Case: ShiftExpressionAdd, · · }, · }, · Token: example.c:1:11: NEQ "!=", }
Example (Rel) ¶
fmt.Println(exampleAST(56, "int i = x;"))
Output: &cc.EqualityExpression{ · Case: EqualityExpressionRel, · RelationalExpression: &cc.RelationalExpression{ · · Case: RelationalExpressionShift, · · ShiftExpression: &cc.ShiftExpression{ · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · Case: AdditiveExpressionMul, · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · Case: MultiplicativeExpressionCast, · · · · · CastExpression: &cc.CastExpression{ · · · · · · Case: CastExpressionUnary, · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · Token: example.c:1:9: IDENTIFIER "x", · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · · Case: ShiftExpressionAdd, · · }, · }, }
func (*EqualityExpression) Declarator ¶
func (n *EqualityExpression) Declarator() *Declarator
func (*EqualityExpression) Position ¶
func (n *EqualityExpression) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*EqualityExpression) Promote ¶
func (n *EqualityExpression) Promote() Type
Promote returns the type the operands of the binary operation are promoted to.
func (*EqualityExpression) String ¶
func (n *EqualityExpression) String() string
String implements fmt.Stringer.
type EqualityExpressionCase ¶
type EqualityExpressionCase int
EqualityExpressionCase represents case numbers of production EqualityExpression
const ( EqualityExpressionRel EqualityExpressionCase = iota EqualityExpressionEq EqualityExpressionNeq )
Values of type EqualityExpressionCase
func (EqualityExpressionCase) String ¶
func (n EqualityExpressionCase) String() string
String implements fmt.Stringer
type ExclusiveOrExpression ¶
type ExclusiveOrExpression struct { Operand Operand IsSideEffectsFree bool AndExpression *AndExpression Case ExclusiveOrExpressionCase `PrettyPrint:"stringer,zero"` ExclusiveOrExpression *ExclusiveOrExpression Token Token // contains filtered or unexported fields }
ExclusiveOrExpression represents data reduced by productions:
ExclusiveOrExpression: AndExpression // Case ExclusiveOrExpressionAnd | ExclusiveOrExpression '^' AndExpression // Case ExclusiveOrExpressionXor
Example (And) ¶
fmt.Println(exampleAST(61, "int i = x;"))
Output: &cc.ExclusiveOrExpression{ · AndExpression: &cc.AndExpression{ · · Case: AndExpressionEq, · · EqualityExpression: &cc.EqualityExpression{ · · · Case: EqualityExpressionRel, · · · RelationalExpression: &cc.RelationalExpression{ · · · · Case: RelationalExpressionShift, · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · Case: AdditiveExpressionMul, · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · Case: CastExpressionUnary, · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · Token: example.c:1:9: IDENTIFIER "x", · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · · Case: ShiftExpressionAdd, · · · · }, · · · }, · · }, · }, · Case: ExclusiveOrExpressionAnd, }
Example (Xor) ¶
fmt.Println(exampleAST(62, "int i = x^y;"))
Output: &cc.ExclusiveOrExpression{ · AndExpression: &cc.AndExpression{ · · Case: AndExpressionEq, · · EqualityExpression: &cc.EqualityExpression{ · · · Case: EqualityExpressionRel, · · · RelationalExpression: &cc.RelationalExpression{ · · · · Case: RelationalExpressionShift, · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · Case: AdditiveExpressionMul, · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · Case: CastExpressionUnary, · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · Token: example.c:1:11: IDENTIFIER "y", · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · · Case: ShiftExpressionAdd, · · · · }, · · · }, · · }, · }, · Case: ExclusiveOrExpressionXor, · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · AndExpression: &cc.AndExpression{ · · · Case: AndExpressionEq, · · · EqualityExpression: &cc.EqualityExpression{ · · · · Case: EqualityExpressionRel, · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · Case: RelationalExpressionShift, · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · Case: AdditiveExpressionMul, · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · Token: example.c:1:9: IDENTIFIER "x", · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · · Case: ShiftExpressionAdd, · · · · · }, · · · · }, · · · }, · · }, · · Case: ExclusiveOrExpressionAnd, · }, · Token: example.c:1:10: '^' "^", }
func (*ExclusiveOrExpression) Declarator ¶
func (n *ExclusiveOrExpression) Declarator() *Declarator
func (*ExclusiveOrExpression) Position ¶
func (n *ExclusiveOrExpression) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*ExclusiveOrExpression) Promote ¶ added in v3.25.2
func (n *ExclusiveOrExpression) Promote() Type
Promote returns the type the operands of the binary operation are promoted to.
func (*ExclusiveOrExpression) String ¶
func (n *ExclusiveOrExpression) String() string
String implements fmt.Stringer.
type ExclusiveOrExpressionCase ¶
type ExclusiveOrExpressionCase int
ExclusiveOrExpressionCase represents case numbers of production ExclusiveOrExpression
const ( ExclusiveOrExpressionAnd ExclusiveOrExpressionCase = iota ExclusiveOrExpressionXor )
Values of type ExclusiveOrExpressionCase
func (ExclusiveOrExpressionCase) String ¶
func (n ExclusiveOrExpressionCase) String() string
String implements fmt.Stringer
type Expression ¶
type Expression struct { Operand Operand IsSideEffectsFree bool AssignmentExpression *AssignmentExpression Case ExpressionCase `PrettyPrint:"stringer,zero"` Expression *Expression Token Token }
Expression represents data reduced by productions:
Expression: AssignmentExpression // Case ExpressionAssign | Expression ',' AssignmentExpression // Case ExpressionComma
Example (Assign) ¶
fmt.Println(exampleAST(83, "int f() { i = x; };"))
Output: &cc.Expression{ · AssignmentExpression: &cc.AssignmentExpression{ · · AssignmentExpression: &cc.AssignmentExpression{ · · · Case: AssignmentExpressionCond, · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · Case: ConditionalExpressionLOr, · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · Case: LogicalOrExpressionLAnd, · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · Case: LogicalAndExpressionOr, · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · Token: example.c:1:15: IDENTIFIER "x", · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · · Case: AssignmentExpressionAssign, · · Token: example.c:1:13: '=' "=", · · UnaryExpression: &cc.UnaryExpression{ · · · Case: UnaryExpressionPostfix, · · · PostfixExpression: &cc.PostfixExpression{ · · · · Case: PostfixExpressionPrimary, · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · Case: PrimaryExpressionIdent, · · · · · Token: example.c:1:11: IDENTIFIER "i", · · · · }, · · · }, · · }, · }, · Case: ExpressionAssign, }
Example (Comma) ¶
fmt.Println(exampleAST(84, "int f() { x, y; };"))
Output: &cc.Expression{ · AssignmentExpression: &cc.AssignmentExpression{ · · Case: AssignmentExpressionCond, · · ConditionalExpression: &cc.ConditionalExpression{ · · · Case: ConditionalExpressionLOr, · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · Case: LogicalOrExpressionLAnd, · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · Case: LogicalAndExpressionOr, · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · Case: InclusiveOrExpressionXor, · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · Case: AndExpressionEq, · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · Token: example.c:1:14: IDENTIFIER "y", · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · }, · Case: ExpressionComma, · Expression: &cc.Expression{ · · AssignmentExpression: &cc.AssignmentExpression{ · · · Case: AssignmentExpressionCond, · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · Case: ConditionalExpressionLOr, · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · Case: LogicalOrExpressionLAnd, · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · Case: LogicalAndExpressionOr, · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · Token: example.c:1:11: IDENTIFIER "x", · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · · Case: ExpressionAssign, · }, · Token: example.c:1:12: ',' ",", }
func (*Expression) Declarator ¶
func (n *Expression) Declarator() *Declarator
func (*Expression) Position ¶
func (n *Expression) Position() (r token.Position)
Position reports the position of the first component of n, if available.
type ExpressionCase ¶
type ExpressionCase int
ExpressionCase represents case numbers of production Expression
const ( ExpressionAssign ExpressionCase = iota ExpressionComma )
Values of type ExpressionCase
func (ExpressionCase) String ¶
func (n ExpressionCase) String() string
String implements fmt.Stringer
type ExpressionList ¶
type ExpressionList struct { AssignmentExpression *AssignmentExpression ExpressionList *ExpressionList Token Token }
ExpressionList represents data reduced by productions:
ExpressionList: AssignmentExpression | ExpressionList ',' AssignmentExpression
Example (Case0) ¶
fmt.Println(exampleAST(267, "int i __attribute__((a(b)));"))
Output: &cc.ExpressionList{ · AssignmentExpression: &cc.AssignmentExpression{ · · Case: AssignmentExpressionCond, · · ConditionalExpression: &cc.ConditionalExpression{ · · · Case: ConditionalExpressionLOr, · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · Case: LogicalOrExpressionLAnd, · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · Case: LogicalAndExpressionOr, · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · Case: InclusiveOrExpressionXor, · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · Case: AndExpressionEq, · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · Token: example.c:1:24: IDENTIFIER "b", · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · }, }
Example (Case1) ¶
fmt.Println(exampleAST(268, "int i __attribute__((a(b, c)));"))
Output: &cc.ExpressionList{ · AssignmentExpression: &cc.AssignmentExpression{ · · Case: AssignmentExpressionCond, · · ConditionalExpression: &cc.ConditionalExpression{ · · · Case: ConditionalExpressionLOr, · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · Case: LogicalOrExpressionLAnd, · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · Case: LogicalAndExpressionOr, · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · Case: InclusiveOrExpressionXor, · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · Case: AndExpressionEq, · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · Token: example.c:1:24: IDENTIFIER "b", · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · }, · ExpressionList: &cc.ExpressionList{ · · AssignmentExpression: &cc.AssignmentExpression{ · · · Case: AssignmentExpressionCond, · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · Case: ConditionalExpressionLOr, · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · Case: LogicalOrExpressionLAnd, · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · Case: LogicalAndExpressionOr, · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · Token: example.c:1:27: IDENTIFIER "c", · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · · Token: example.c:1:25: ',' ",", · }, }
func (*ExpressionList) Position ¶
func (n *ExpressionList) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*ExpressionList) String ¶
func (n *ExpressionList) String() string
String implements fmt.Stringer.
type ExpressionStatement ¶
type ExpressionStatement struct { AttributeSpecifierList *AttributeSpecifierList Expression *Expression Token Token }
ExpressionStatement represents data reduced by production:
ExpressionStatement: Expression AttributeSpecifierList ';'
Example (Case0) ¶
fmt.Println(exampleAST(229, "int f() { g(); }"))
Output: &cc.ExpressionStatement{ · Expression: &cc.Expression{ · · AssignmentExpression: &cc.AssignmentExpression{ · · · Case: AssignmentExpressionCond, · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · Case: ConditionalExpressionLOr, · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · Case: LogicalOrExpressionLAnd, · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · Case: LogicalAndExpressionOr, · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · Case: PostfixExpressionCall, · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · · Token: example.c:1:11: IDENTIFIER "g", · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · Token: example.c:1:12: '(' "(", · · · · · · · · · · · · · · · · · Token2: example.c:1:13: ')' ")", · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · · Case: ExpressionAssign, · }, · Token: example.c:1:14: ';' ";", }
func (*ExpressionStatement) Position ¶
func (n *ExpressionStatement) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*ExpressionStatement) String ¶
func (n *ExpressionStatement) String() string
String implements fmt.Stringer.
type ExternalDeclaration ¶
type ExternalDeclaration struct { AsmFunctionDefinition *AsmFunctionDefinition AsmStatement *AsmStatement Case ExternalDeclarationCase `PrettyPrint:"stringer,zero"` Declaration *Declaration FunctionDefinition *FunctionDefinition PragmaSTDC *PragmaSTDC Token Token }
ExternalDeclaration represents data reduced by productions:
ExternalDeclaration: FunctionDefinition // Case ExternalDeclarationFuncDef | Declaration // Case ExternalDeclarationDecl | AsmFunctionDefinition // Case ExternalDeclarationAsm | AsmStatement // Case ExternalDeclarationAsmStmt | ';' // Case ExternalDeclarationEmpty | PragmaSTDC // Case ExternalDeclarationPragma
Example (Asm) ¶
fmt.Println(exampleAST(246, "int f() __asm__(\"nop\");"))
Output: &cc.ExternalDeclaration{ · AsmFunctionDefinition: &cc.AsmFunctionDefinition{ · · AsmStatement: &cc.AsmStatement{ · · · Asm: &cc.Asm{ · · · · Token: example.c:1:9: ASM "__asm__", · · · · Token2: example.c:1:16: '(' "(", · · · · Token3: example.c:1:17: STRINGLITERAL "nop", · · · · Token4: example.c:1:22: ')' ")", · · · }, · · · Token: example.c:1:23: ';' ";", · · }, · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{ · · · Case: DeclarationSpecifiersTypeSpec, · · · TypeSpecifier: &cc.TypeSpecifier{ · · · · Case: TypeSpecifierInt, · · · · Token: example.c:1:1: INT "int", · · · }, · · }, · · Declarator: &cc.Declarator{ · · · DirectDeclarator: &cc.DirectDeclarator{ · · · · Case: DirectDeclaratorFuncIdent, · · · · DirectDeclarator: &cc.DirectDeclarator{ · · · · · Case: DirectDeclaratorIdent, · · · · · Token: example.c:1:5: IDENTIFIER "f", · · · · }, · · · · Token: example.c:1:6: '(' "(", · · · · Token2: example.c:1:7: ')' ")", · · · }, · · }, · }, · Case: ExternalDeclarationAsm, }
Example (AsmStmt) ¶
fmt.Println(exampleAST(247, "__asm__(\"nop\");"))
Output: &cc.ExternalDeclaration{ · AsmStatement: &cc.AsmStatement{ · · Asm: &cc.Asm{ · · · Token: example.c:1:1: ASM "__asm__", · · · Token2: example.c:1:8: '(' "(", · · · Token3: example.c:1:9: STRINGLITERAL "nop", · · · Token4: example.c:1:14: ')' ")", · · }, · · Token: example.c:1:15: ';' ";", · }, · Case: ExternalDeclarationAsmStmt, }
Example (Decl) ¶
fmt.Println(exampleAST(245, "int i;"))
Output: &cc.ExternalDeclaration{ · Case: ExternalDeclarationDecl, · Declaration: &cc.Declaration{ · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{ · · · Case: DeclarationSpecifiersTypeSpec, · · · TypeSpecifier: &cc.TypeSpecifier{ · · · · Case: TypeSpecifierInt, · · · · Token: example.c:1:1: INT "int", · · · }, · · }, · · InitDeclaratorList: &cc.InitDeclaratorList{ · · · InitDeclarator: &cc.InitDeclarator{ · · · · Case: InitDeclaratorDecl, · · · · Declarator: &cc.Declarator{ · · · · · DirectDeclarator: &cc.DirectDeclarator{ · · · · · · Case: DirectDeclaratorIdent, · · · · · · Token: example.c:1:5: IDENTIFIER "i", · · · · · }, · · · · }, · · · }, · · }, · · Token: example.c:1:6: ';' ";", · }, }
Example (Empty) ¶
fmt.Println(exampleAST(248, ";"))
Output: &cc.ExternalDeclaration{ · Case: ExternalDeclarationEmpty, · Token: example.c:1:1: ';' ";", }
Example (FuncDef) ¶
fmt.Println(exampleAST(244, "int f() {}"))
Output: &cc.ExternalDeclaration{ · Case: ExternalDeclarationFuncDef, · FunctionDefinition: &cc.FunctionDefinition{ · · CompoundStatement: &cc.CompoundStatement{ · · · Token: example.c:1:9: '{' "{", · · · Token2: example.c:1:10: '}' "}", · · }, · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{ · · · Case: DeclarationSpecifiersTypeSpec, · · · TypeSpecifier: &cc.TypeSpecifier{ · · · · Case: TypeSpecifierInt, · · · · Token: example.c:1:1: INT "int", · · · }, · · }, · · Declarator: &cc.Declarator{ · · · DirectDeclarator: &cc.DirectDeclarator{ · · · · Case: DirectDeclaratorFuncIdent, · · · · DirectDeclarator: &cc.DirectDeclarator{ · · · · · Case: DirectDeclaratorIdent, · · · · · Token: example.c:1:5: IDENTIFIER "f", · · · · }, · · · · Token: example.c:1:6: '(' "(", · · · · Token2: example.c:1:7: ')' ")", · · · }, · · }, · }, }
Example (Pragma) ¶
fmt.Println(exampleAST(249, "#pragma STDC CX_LIMITED_RANGE DEFAULT"))
Output: &cc.ExternalDeclaration{ · Case: ExternalDeclarationPragma, · PragmaSTDC: &cc.PragmaSTDC{ · · Token: example.c:1:9: PPPRAGMASTDC "__pragma_stdc", · · Token2: example.c:1:9: IDENTIFIER "STDC", · · Token3: example.c:1:14: IDENTIFIER "CX_LIMITED_RANGE", · · Token4: example.c:1:31: IDENTIFIER "DEFAULT", · }, }
func (*ExternalDeclaration) Position ¶
func (n *ExternalDeclaration) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*ExternalDeclaration) String ¶
func (n *ExternalDeclaration) String() string
String implements fmt.Stringer.
type ExternalDeclarationCase ¶
type ExternalDeclarationCase int
ExternalDeclarationCase represents case numbers of production ExternalDeclaration
const ( ExternalDeclarationFuncDef ExternalDeclarationCase = iota ExternalDeclarationDecl ExternalDeclarationAsm ExternalDeclarationAsmStmt ExternalDeclarationEmpty ExternalDeclarationPragma )
Values of type ExternalDeclarationCase
func (ExternalDeclarationCase) String ¶
func (n ExternalDeclarationCase) String() string
String implements fmt.Stringer
type Field ¶
type Field interface { BitFieldBlockFirst() Field BitFieldBlockWidth() int BitFieldOffset() int BitFieldWidth() int Declarator() *StructDeclarator InUnion() bool // Directly or indirectly Index() int IsBitField() bool IsFlexible() bool // https://en.wikipedia.org/wiki/Flexible_array_member Mask() uint64 Name() StringID // Can be zero. Offset() uintptr // In bytes from the beginning of the struct/union. Padding() int // In bytes after the field. N/A for bit fields, fields preceding bit fields or union fields. Parent() Type // The struct/union type that contains the field. Promote() Type Type() Type // Field type. }
A Field describes a single field in a struct/union.
type Filesystem ¶ added in v3.25.2
type Filesystem interface { // Stat is an analog of os.Stat, but also accepts a flag to indicate a system include (<file.h>). Stat(path string, sys bool) (os.FileInfo, error) // Open is an analog of os.Open, but also accepts a flag to indicate a system include (<file.h>). Open(path string, sys bool) (io.ReadCloser, error) }
Filesystem abstraction used in CC. The underlying value must be comparable (e.g. pointer) to be used in map keys.
func LocalFS ¶ added in v3.25.2
func LocalFS() Filesystem
LocalFS returns a local filesystem implementation.
func Overlay ¶ added in v3.25.2
func Overlay(pri, sec Filesystem) Filesystem
Overlay is a filesystem implementation that first check if the file is available in the primary FS and if not, falls back to a secondary FS.
func StaticFS ¶ added in v3.25.2
func StaticFS(files map[string]string) Filesystem
StaticFS implements filesystem interface by serving string values form the provided map.
func WorkingDir ¶ added in v3.25.2
func WorkingDir(wd string, fs Filesystem) Filesystem
WorkingDir is a filesystem implementation that resolves paths relative to a given directory. If filesystem is not specified, the local one will be used.
type Float128Value ¶
func (*Float128Value) IsConst ¶ added in v3.33.6
func (v *Float128Value) IsConst() bool
func (*Float128Value) IsNonZero ¶ added in v3.33.6
func (v *Float128Value) IsNonZero() bool
func (*Float128Value) IsZero ¶ added in v3.33.6
func (v *Float128Value) IsZero() bool
func (*Float128Value) String ¶
func (v *Float128Value) String() string
type Float32Value ¶
type Float32Value float32
func (Float32Value) IsConst ¶ added in v3.33.6
func (v Float32Value) IsConst() bool
func (Float32Value) IsNonZero ¶ added in v3.33.6
func (v Float32Value) IsNonZero() bool
func (Float32Value) IsZero ¶ added in v3.33.6
func (v Float32Value) IsZero() bool
type Float64Value ¶
type Float64Value float64
func (Float64Value) IsConst ¶ added in v3.33.6
func (v Float64Value) IsConst() bool
func (Float64Value) IsNonZero ¶ added in v3.33.6
func (v Float64Value) IsNonZero() bool
func (Float64Value) IsZero ¶ added in v3.33.6
func (v Float64Value) IsZero() bool
type FunctionDefinition ¶
type FunctionDefinition struct { CallSiteComplexExpr []*AssignmentExpression CompositeLiterals []*PostfixExpression ComputedGotos map[StringID]*UnaryExpression Gotos map[StringID]*JumpStatement InitDeclarators []*InitDeclarator Labels map[StringID]*LabeledStatement ReturnComplexExpr []*Expression VLAs []*Declarator CompoundStatement *CompoundStatement DeclarationList *DeclarationList DeclarationSpecifiers *DeclarationSpecifiers Declarator *Declarator // contains filtered or unexported fields }
FunctionDefinition represents data reduced by production:
FunctionDefinition: DeclarationSpecifiers Declarator DeclarationList CompoundStatement
Example (Case0) ¶
fmt.Println(exampleAST(250, "int f() {}"))
Output: &cc.FunctionDefinition{ · CompoundStatement: &cc.CompoundStatement{ · · Token: example.c:1:9: '{' "{", · · Token2: example.c:1:10: '}' "}", · }, · DeclarationSpecifiers: &cc.DeclarationSpecifiers{ · · Case: DeclarationSpecifiersTypeSpec, · · TypeSpecifier: &cc.TypeSpecifier{ · · · Case: TypeSpecifierInt, · · · Token: example.c:1:1: INT "int", · · }, · }, · Declarator: &cc.Declarator{ · · DirectDeclarator: &cc.DirectDeclarator{ · · · Case: DirectDeclaratorFuncIdent, · · · DirectDeclarator: &cc.DirectDeclarator{ · · · · Case: DirectDeclaratorIdent, · · · · Token: example.c:1:5: IDENTIFIER "f", · · · }, · · · Token: example.c:1:6: '(' "(", · · · Token2: example.c:1:7: ')' ")", · · }, · }, }
func (*FunctionDefinition) CompoundStatements ¶
func (n *FunctionDefinition) CompoundStatements() []*CompoundStatement
CompoundStatements returns the list of compound statements in n.
func (*FunctionDefinition) Position ¶
func (n *FunctionDefinition) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*FunctionDefinition) String ¶
func (n *FunctionDefinition) String() string
String implements fmt.Stringer.
type FunctionSpecifier ¶
type FunctionSpecifier struct { Case FunctionSpecifierCase `PrettyPrint:"stringer,zero"` Token Token }
FunctionSpecifier represents data reduced by productions:
FunctionSpecifier: "inline" // Case FunctionSpecifierInline | "_Noreturn" // Case FunctionSpecifierNoreturn
Example (Inline) ¶
fmt.Println(exampleAST(164, "inline int f() {}"))
Output: &cc.FunctionSpecifier{ · Case: FunctionSpecifierInline, · Token: example.c:1:1: INLINE "inline", }
Example (Noreturn) ¶
fmt.Println(exampleAST(165, "_Noreturn int f() {}"))
Output: &cc.FunctionSpecifier{ · Case: FunctionSpecifierNoreturn, · Token: example.c:1:1: NORETURN "_Noreturn", }
func (*FunctionSpecifier) Position ¶
func (n *FunctionSpecifier) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*FunctionSpecifier) String ¶
func (n *FunctionSpecifier) String() string
String implements fmt.Stringer.
type FunctionSpecifierCase ¶
type FunctionSpecifierCase int
FunctionSpecifierCase represents case numbers of production FunctionSpecifier
const ( FunctionSpecifierInline FunctionSpecifierCase = iota FunctionSpecifierNoreturn )
Values of type FunctionSpecifierCase
func (FunctionSpecifierCase) String ¶
func (n FunctionSpecifierCase) String() string
String implements fmt.Stringer
type IdentifierList ¶
type IdentifierList struct { IdentifierList *IdentifierList Token Token Token2 Token // contains filtered or unexported fields }
IdentifierList represents data reduced by productions:
IdentifierList: IDENTIFIER | IdentifierList ',' IDENTIFIER
Example (Case0) ¶
fmt.Println(exampleAST(189, "int f(i) int i; {}"))
Output: &cc.IdentifierList{ · Token: example.c:1:7: IDENTIFIER "i", }
Example (Case1) ¶
fmt.Println(exampleAST(190, "int f(i, j) int i, j; {}"))
Output: &cc.IdentifierList{ · IdentifierList: &cc.IdentifierList{ · · Token: example.c:1:8: ',' ",", · · Token2: example.c:1:10: IDENTIFIER "j", · }, · Token: example.c:1:7: IDENTIFIER "i", }
func (*IdentifierList) Position ¶
func (n *IdentifierList) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*IdentifierList) String ¶
func (n *IdentifierList) String() string
String implements fmt.Stringer.
type InclusiveOrExpression ¶
type InclusiveOrExpression struct { Operand Operand IsSideEffectsFree bool Case InclusiveOrExpressionCase `PrettyPrint:"stringer,zero"` ExclusiveOrExpression *ExclusiveOrExpression InclusiveOrExpression *InclusiveOrExpression Token Token // contains filtered or unexported fields }
InclusiveOrExpression represents data reduced by productions:
InclusiveOrExpression: ExclusiveOrExpression // Case InclusiveOrExpressionXor | InclusiveOrExpression '|' ExclusiveOrExpression // Case InclusiveOrExpressionOr
Example (Or) ¶
fmt.Println(exampleAST(64, "int i = x|y;"))
Output: &cc.InclusiveOrExpression{ · Case: InclusiveOrExpressionOr, · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · AndExpression: &cc.AndExpression{ · · · Case: AndExpressionEq, · · · EqualityExpression: &cc.EqualityExpression{ · · · · Case: EqualityExpressionRel, · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · Case: RelationalExpressionShift, · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · Case: AdditiveExpressionMul, · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · Token: example.c:1:11: IDENTIFIER "y", · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · · Case: ShiftExpressionAdd, · · · · · }, · · · · }, · · · }, · · }, · · Case: ExclusiveOrExpressionAnd, · }, · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · Case: InclusiveOrExpressionXor, · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · AndExpression: &cc.AndExpression{ · · · · Case: AndExpressionEq, · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · Case: EqualityExpressionRel, · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · Case: RelationalExpressionShift, · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · Token: example.c:1:9: IDENTIFIER "x", · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · · Case: ShiftExpressionAdd, · · · · · · }, · · · · · }, · · · · }, · · · }, · · · Case: ExclusiveOrExpressionAnd, · · }, · }, · Token: example.c:1:10: '|' "|", }
Example (Xor) ¶
fmt.Println(exampleAST(63, "int i = x;"))
Output: &cc.InclusiveOrExpression{ · Case: InclusiveOrExpressionXor, · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · AndExpression: &cc.AndExpression{ · · · Case: AndExpressionEq, · · · EqualityExpression: &cc.EqualityExpression{ · · · · Case: EqualityExpressionRel, · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · Case: RelationalExpressionShift, · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · Case: AdditiveExpressionMul, · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · Token: example.c:1:9: IDENTIFIER "x", · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · · Case: ShiftExpressionAdd, · · · · · }, · · · · }, · · · }, · · }, · · Case: ExclusiveOrExpressionAnd, · }, }
func (*InclusiveOrExpression) Declarator ¶
func (n *InclusiveOrExpression) Declarator() *Declarator
func (*InclusiveOrExpression) Position ¶
func (n *InclusiveOrExpression) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*InclusiveOrExpression) Promote ¶ added in v3.25.2
func (n *InclusiveOrExpression) Promote() Type
Promote returns the type the operands of the binary operation are promoted to.
func (*InclusiveOrExpression) String ¶
func (n *InclusiveOrExpression) String() string
String implements fmt.Stringer.
type InclusiveOrExpressionCase ¶
type InclusiveOrExpressionCase int
InclusiveOrExpressionCase represents case numbers of production InclusiveOrExpression
const ( InclusiveOrExpressionXor InclusiveOrExpressionCase = iota InclusiveOrExpressionOr )
Values of type InclusiveOrExpressionCase
func (InclusiveOrExpressionCase) String ¶
func (n InclusiveOrExpressionCase) String() string
String implements fmt.Stringer
type InitDeclarator ¶
type InitDeclarator struct { AttributeSpecifierList *AttributeSpecifierList Case InitDeclaratorCase `PrettyPrint:"stringer,zero"` Declarator *Declarator Initializer *Initializer Token Token // contains filtered or unexported fields }
InitDeclarator represents data reduced by productions:
InitDeclarator: Declarator AttributeSpecifierList // Case InitDeclaratorDecl | Declarator AttributeSpecifierList '=' Initializer // Case InitDeclaratorInit
Example (Decl) ¶
fmt.Println(exampleAST(95, "int i;"))
Output: &cc.InitDeclarator{ · Case: InitDeclaratorDecl, · Declarator: &cc.Declarator{ · · DirectDeclarator: &cc.DirectDeclarator{ · · · Case: DirectDeclaratorIdent, · · · Token: example.c:1:5: IDENTIFIER "i", · · }, · }, }
Example (Init) ¶
fmt.Println(exampleAST(96, "int i = x;"))
Output: &cc.InitDeclarator{ · Case: InitDeclaratorInit, · Declarator: &cc.Declarator{ · · DirectDeclarator: &cc.DirectDeclarator{ · · · Case: DirectDeclaratorIdent, · · · Token: example.c:1:5: IDENTIFIER "i", · · }, · }, · Initializer: &cc.Initializer{ · · AssignmentExpression: &cc.AssignmentExpression{ · · · Case: AssignmentExpressionCond, · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · Case: ConditionalExpressionLOr, · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · Case: LogicalOrExpressionLAnd, · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · Case: LogicalAndExpressionOr, · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · Token: example.c:1:9: IDENTIFIER "x", · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · · Case: InitializerExpr, · }, · Token: example.c:1:7: '=' "=", }
func (*InitDeclarator) Position ¶
func (n *InitDeclarator) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*InitDeclarator) String ¶
func (n *InitDeclarator) String() string
String implements fmt.Stringer.
func (*InitDeclarator) Value ¶
func (n *InitDeclarator) Value() *InitializerValue
type InitDeclaratorCase ¶
type InitDeclaratorCase int
InitDeclaratorCase represents case numbers of production InitDeclarator
const ( InitDeclaratorDecl InitDeclaratorCase = iota InitDeclaratorInit )
Values of type InitDeclaratorCase
func (InitDeclaratorCase) String ¶
func (n InitDeclaratorCase) String() string
String implements fmt.Stringer
type InitDeclaratorList ¶
type InitDeclaratorList struct { AttributeSpecifierList *AttributeSpecifierList InitDeclarator *InitDeclarator InitDeclaratorList *InitDeclaratorList Token Token }
InitDeclaratorList represents data reduced by productions:
InitDeclaratorList: InitDeclarator | InitDeclaratorList ',' AttributeSpecifierList InitDeclarator
Example (Case0) ¶
fmt.Println(exampleAST(93, "int i;"))
Output: &cc.InitDeclaratorList{ · InitDeclarator: &cc.InitDeclarator{ · · Case: InitDeclaratorDecl, · · Declarator: &cc.Declarator{ · · · DirectDeclarator: &cc.DirectDeclarator{ · · · · Case: DirectDeclaratorIdent, · · · · Token: example.c:1:5: IDENTIFIER "i", · · · }, · · }, · }, }
Example (Case1) ¶
fmt.Println(exampleAST(94, "int i, j;"))
Output: &cc.InitDeclaratorList{ · InitDeclarator: &cc.InitDeclarator{ · · Case: InitDeclaratorDecl, · · Declarator: &cc.Declarator{ · · · DirectDeclarator: &cc.DirectDeclarator{ · · · · Case: DirectDeclaratorIdent, · · · · Token: example.c:1:5: IDENTIFIER "i", · · · }, · · }, · }, · InitDeclaratorList: &cc.InitDeclaratorList{ · · InitDeclarator: &cc.InitDeclarator{ · · · Case: InitDeclaratorDecl, · · · Declarator: &cc.Declarator{ · · · · DirectDeclarator: &cc.DirectDeclarator{ · · · · · Case: DirectDeclaratorIdent, · · · · · Token: example.c:1:8: IDENTIFIER "j", · · · · }, · · · }, · · }, · · Token: example.c:1:6: ',' ",", · }, }
Example (UCN) ¶
fmt.Println(exampleAST(0, `int a·z, a\u00b7z;`))
Output: &cc.InitDeclaratorList{ · InitDeclarator: &cc.InitDeclarator{ · · Case: InitDeclaratorDecl, · · Declarator: &cc.Declarator{ · · · DirectDeclarator: &cc.DirectDeclarator{ · · · · Case: DirectDeclaratorIdent, · · · · Token: example.c:1:5: IDENTIFIER "a·z", · · · }, · · }, · }, · InitDeclaratorList: &cc.InitDeclaratorList{ · · InitDeclarator: &cc.InitDeclarator{ · · · Case: InitDeclaratorDecl, · · · Declarator: &cc.Declarator{ · · · · DirectDeclarator: &cc.DirectDeclarator{ · · · · · Case: DirectDeclaratorIdent, · · · · · Token: example.c:1:11: IDENTIFIER "a·z", · · · · }, · · · }, · · }, · · Token: example.c:1:9: ',' ",", · }, }
func (*InitDeclaratorList) Position ¶
func (n *InitDeclaratorList) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*InitDeclaratorList) String ¶
func (n *InitDeclaratorList) String() string
String implements fmt.Stringer.
type Initializer ¶
type Initializer struct { Field Field // Where aplicable Offset uintptr // Case Expr AssignmentExpression *AssignmentExpression Case InitializerCase `PrettyPrint:"stringer,zero"` InitializerList *InitializerList Token Token Token2 Token Token3 Token // contains filtered or unexported fields }
Initializer represents data reduced by productions:
Initializer: AssignmentExpression // Case InitializerExpr | '{' InitializerList ',' '}' // Case InitializerInitList
Example (Expr) ¶
fmt.Println(exampleAST(200, "int i = x;"))
Output: &cc.Initializer{ · AssignmentExpression: &cc.AssignmentExpression{ · · Case: AssignmentExpressionCond, · · ConditionalExpression: &cc.ConditionalExpression{ · · · Case: ConditionalExpressionLOr, · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · Case: LogicalOrExpressionLAnd, · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · Case: LogicalAndExpressionOr, · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · Case: InclusiveOrExpressionXor, · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · Case: AndExpressionEq, · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · Token: example.c:1:9: IDENTIFIER "x", · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · }, · Case: InitializerExpr, }
Example (InitList) ¶
fmt.Println(exampleAST(201, "int i[] = { x };"))
Output: &cc.Initializer{ · Case: InitializerInitList, · InitializerList: &cc.InitializerList{ · · Initializer: &cc.Initializer{ · · · AssignmentExpression: &cc.AssignmentExpression{ · · · · Case: AssignmentExpressionCond, · · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · · Case: ConditionalExpressionLOr, · · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · · Case: LogicalOrExpressionLAnd, · · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · · Case: LogicalAndExpressionOr, · · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · · Token: example.c:1:13: IDENTIFIER "x", · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · · Case: InitializerExpr, · · }, · }, · Token: example.c:1:11: '{' "{", · Token3: example.c:1:15: '}' "}", }
func (*Initializer) Dump ¶ added in v3.35.13
func (n *Initializer) Dump() string
Dump returns a debug form of n.
func (*Initializer) FirstDesignatorField ¶ added in v3.31.0
func (n *Initializer) FirstDesignatorField() Field
FirstDesignatorField returns the first field a designator of an union type denotes, if any.
func (*Initializer) IsConst ¶
func (n *Initializer) IsConst() bool
IsConst reports whether n is constant.
func (*Initializer) IsZero ¶ added in v3.27.0
func (n *Initializer) IsZero() bool
IsZero reports whether n is a zero value.
func (*Initializer) List ¶
func (n *Initializer) List() []*Initializer
List returns n as a flattened list of all items that are case InitializerExpr.
func (*Initializer) Parent ¶ added in v3.31.0
func (n *Initializer) Parent() *Initializer
Parent returns the parent of n, if any.
func (*Initializer) Position ¶
func (n *Initializer) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*Initializer) TrailingComma ¶ added in v3.31.0
func (n *Initializer) TrailingComma() *Token
TrailingComma returns the comma token following n, if any.
func (*Initializer) Type ¶
func (n *Initializer) Type() Type
Type returns the type this initializer initializes.
type InitializerCase ¶
type InitializerCase int
InitializerCase represents case numbers of production Initializer
const ( InitializerExpr InitializerCase = iota InitializerInitList )
Values of type InitializerCase
func (InitializerCase) String ¶
func (n InitializerCase) String() string
String implements fmt.Stringer
type InitializerList ¶
type InitializerList struct { Designation *Designation Initializer *Initializer InitializerList *InitializerList Token Token // contains filtered or unexported fields }
InitializerList represents data reduced by productions:
InitializerList: Designation Initializer | InitializerList ',' Designation Initializer
Example (Case0) ¶
fmt.Println(exampleAST(202, "int i[] = { [10] = x };"))
Output: &cc.InitializerList{ · Designation: &cc.Designation{ · · DesignatorList: &cc.DesignatorList{ · · · Designator: &cc.Designator{ · · · · Case: DesignatorIndex, · · · · ConstantExpression: &cc.ConstantExpression{ · · · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · · · Case: ConditionalExpressionLOr, · · · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · · · Case: LogicalOrExpressionLAnd, · · · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · · · Case: LogicalAndExpressionOr, · · · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionInt, · · · · · · · · · · · · · · · · · · · · Token: example.c:1:14: INTCONST "10", · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · · Token: example.c:1:13: '[' "[", · · · · Token2: example.c:1:16: ']' "]", · · · }, · · }, · · Token: example.c:1:18: '=' "=", · }, · Initializer: &cc.Initializer{ · · AssignmentExpression: &cc.AssignmentExpression{ · · · Case: AssignmentExpressionCond, · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · Case: ConditionalExpressionLOr, · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · Case: LogicalOrExpressionLAnd, · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · Case: LogicalAndExpressionOr, · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · Token: example.c:1:20: IDENTIFIER "x", · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · · Case: InitializerExpr, · }, }
Example (Case1) ¶
fmt.Println(exampleAST(203, "int i[] = { [10] = x, [20] = y };"))
Output: &cc.InitializerList{ · Designation: &cc.Designation{ · · DesignatorList: &cc.DesignatorList{ · · · Designator: &cc.Designator{ · · · · Case: DesignatorIndex, · · · · ConstantExpression: &cc.ConstantExpression{ · · · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · · · Case: ConditionalExpressionLOr, · · · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · · · Case: LogicalOrExpressionLAnd, · · · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · · · Case: LogicalAndExpressionOr, · · · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionInt, · · · · · · · · · · · · · · · · · · · · Token: example.c:1:14: INTCONST "10", · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · · Token: example.c:1:13: '[' "[", · · · · Token2: example.c:1:16: ']' "]", · · · }, · · }, · · Token: example.c:1:18: '=' "=", · }, · Initializer: &cc.Initializer{ · · AssignmentExpression: &cc.AssignmentExpression{ · · · Case: AssignmentExpressionCond, · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · Case: ConditionalExpressionLOr, · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · Case: LogicalOrExpressionLAnd, · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · Case: LogicalAndExpressionOr, · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · Token: example.c:1:20: IDENTIFIER "x", · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · · Case: InitializerExpr, · }, · InitializerList: &cc.InitializerList{ · · Designation: &cc.Designation{ · · · DesignatorList: &cc.DesignatorList{ · · · · Designator: &cc.Designator{ · · · · · Case: DesignatorIndex, · · · · · ConstantExpression: &cc.ConstantExpression{ · · · · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · · · · Case: ConditionalExpressionLOr, · · · · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · · · · Case: LogicalOrExpressionLAnd, · · · · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · · · · Case: LogicalAndExpressionOr, · · · · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionInt, · · · · · · · · · · · · · · · · · · · · · Token: example.c:1:24: INTCONST "20", · · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · · Token: example.c:1:23: '[' "[", · · · · · Token2: example.c:1:26: ']' "]", · · · · }, · · · }, · · · Token: example.c:1:28: '=' "=", · · }, · · Initializer: &cc.Initializer{ · · · AssignmentExpression: &cc.AssignmentExpression{ · · · · Case: AssignmentExpressionCond, · · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · · Case: ConditionalExpressionLOr, · · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · · Case: LogicalOrExpressionLAnd, · · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · · Case: LogicalAndExpressionOr, · · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · · Token: example.c:1:30: IDENTIFIER "y", · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · · Case: InitializerExpr, · · }, · · Token: example.c:1:21: ',' ",", · }, }
func (*InitializerList) Dump ¶ added in v3.35.13
func (n *InitializerList) Dump() string
Dump returns a debug form of n.
func (*InitializerList) IsConst ¶
func (n *InitializerList) IsConst() bool
IsConst reports whether n is constant.
func (*InitializerList) IsEmpty ¶ added in v3.27.0
func (n *InitializerList) IsEmpty() bool
IsEmpty reprts whether n is an empty list.
func (*InitializerList) IsZero ¶ added in v3.27.0
func (n *InitializerList) IsZero() bool
IsZero reports whether n is a zero value.
func (*InitializerList) List ¶
func (n *InitializerList) List() []*Initializer
List returns n as a flattened list of all items that are case InitializerExpr.
func (*InitializerList) Position ¶
func (n *InitializerList) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*InitializerList) String ¶
func (n *InitializerList) String() string
String implements fmt.Stringer.
type InitializerValue ¶
type InitializerValue struct {
// contains filtered or unexported fields
}
func (*InitializerValue) IsConst ¶
func (v *InitializerValue) IsConst() bool
func (*InitializerValue) IsNonZero ¶ added in v3.33.6
func (v *InitializerValue) IsNonZero() bool
func (*InitializerValue) IsZero ¶ added in v3.33.6
func (v *InitializerValue) IsZero() bool
func (*InitializerValue) List ¶
func (v *InitializerValue) List() []*Initializer
func (*InitializerValue) Type ¶
func (v *InitializerValue) Type() Type
type Int64Value ¶
type Int64Value int64
func (Int64Value) IsConst ¶ added in v3.33.6
func (v Int64Value) IsConst() bool
func (Int64Value) IsNonZero ¶ added in v3.33.6
func (v Int64Value) IsNonZero() bool
func (Int64Value) IsZero ¶ added in v3.33.6
func (v Int64Value) IsZero() bool
type IterationStatement ¶
type IterationStatement struct { Case IterationStatementCase `PrettyPrint:"stringer,zero"` Declaration *Declaration Expression *Expression Expression2 *Expression Expression3 *Expression Statement *Statement Token Token Token2 Token Token3 Token Token4 Token Token5 Token }
IterationStatement represents data reduced by productions:
IterationStatement: "while" '(' Expression ')' Statement // Case IterationStatementWhile | "do" Statement "while" '(' Expression ')' ';' // Case IterationStatementDo | "for" '(' Expression ';' Expression ';' Expression ')' Statement // Case IterationStatementFor | "for" '(' Declaration Expression ';' Expression ')' Statement // Case IterationStatementForDecl
Example (Do) ¶
fmt.Println(exampleAST(234, "int f() { do x(); while(y); }"))
Output: &cc.IterationStatement{ · Case: IterationStatementDo, · Expression: &cc.Expression{ · · AssignmentExpression: &cc.AssignmentExpression{ · · · Case: AssignmentExpressionCond, · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · Case: ConditionalExpressionLOr, · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · Case: LogicalOrExpressionLAnd, · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · Case: LogicalAndExpressionOr, · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · Token: example.c:1:25: IDENTIFIER "y", · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · · Case: ExpressionAssign, · }, · Statement: &cc.Statement{ · · Case: StatementExpr, · · ExpressionStatement: &cc.ExpressionStatement{ · · · Expression: &cc.Expression{ · · · · AssignmentExpression: &cc.AssignmentExpression{ · · · · · Case: AssignmentExpressionCond, · · · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · · · Case: ConditionalExpressionLOr, · · · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · · · Case: LogicalOrExpressionLAnd, · · · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · · · Case: LogicalAndExpressionOr, · · · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · · Case: PostfixExpressionCall, · · · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · · · · Token: example.c:1:14: IDENTIFIER "x", · · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · · Token: example.c:1:15: '(' "(", · · · · · · · · · · · · · · · · · · · Token2: example.c:1:16: ')' ")", · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · · Case: ExpressionAssign, · · · }, · · · Token: example.c:1:17: ';' ";", · · }, · }, · Token: example.c:1:11: DO "do", · Token2: example.c:1:19: WHILE "while", · Token3: example.c:1:24: '(' "(", · Token4: example.c:1:26: ')' ")", · Token5: example.c:1:27: ';' ";", }
Example (For) ¶
fmt.Println(exampleAST(235, "int f() { for( i = 0; i < 10; i++) x(); }"))
Output: &cc.IterationStatement{ · Case: IterationStatementFor, · Expression: &cc.Expression{ · · AssignmentExpression: &cc.AssignmentExpression{ · · · AssignmentExpression: &cc.AssignmentExpression{ · · · · Case: AssignmentExpressionCond, · · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · · Case: ConditionalExpressionLOr, · · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · · Case: LogicalOrExpressionLAnd, · · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · · Case: LogicalAndExpressionOr, · · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionInt, · · · · · · · · · · · · · · · · · · · Token: example.c:1:20: INTCONST "0", · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · · Case: AssignmentExpressionAssign, · · · Token: example.c:1:18: '=' "=", · · · UnaryExpression: &cc.UnaryExpression{ · · · · Case: UnaryExpressionPostfix, · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · Case: PostfixExpressionPrimary, · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · Case: PrimaryExpressionIdent, · · · · · · Token: example.c:1:16: IDENTIFIER "i", · · · · · }, · · · · }, · · · }, · · }, · · Case: ExpressionAssign, · }, · Expression2: &cc.Expression{ · · AssignmentExpression: &cc.AssignmentExpression{ · · · Case: AssignmentExpressionCond, · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · Case: ConditionalExpressionLOr, · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · Case: LogicalOrExpressionLAnd, · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · Case: LogicalAndExpressionOr, · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · Case: RelationalExpressionLt, · · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · · Token: example.c:1:23: IDENTIFIER "i", · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionInt, · · · · · · · · · · · · · · · · · · Token: example.c:1:27: INTCONST "10", · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · }, · · · · · · · · · · · Token: example.c:1:25: '<' "<", · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · · Case: ExpressionAssign, · }, · Expression3: &cc.Expression{ · · AssignmentExpression: &cc.AssignmentExpression{ · · · Case: AssignmentExpressionCond, · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · Case: ConditionalExpressionLOr, · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · Case: LogicalOrExpressionLAnd, · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · Case: LogicalAndExpressionOr, · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · Case: PostfixExpressionInc, · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · · Token: example.c:1:31: IDENTIFIER "i", · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · Token: example.c:1:32: INC "++", · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · · Case: ExpressionAssign, · }, · Statement: &cc.Statement{ · · Case: StatementExpr, · · ExpressionStatement: &cc.ExpressionStatement{ · · · Expression: &cc.Expression{ · · · · AssignmentExpression: &cc.AssignmentExpression{ · · · · · Case: AssignmentExpressionCond, · · · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · · · Case: ConditionalExpressionLOr, · · · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · · · Case: LogicalOrExpressionLAnd, · · · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · · · Case: LogicalAndExpressionOr, · · · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · · Case: PostfixExpressionCall, · · · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · · · · Token: example.c:1:36: IDENTIFIER "x", · · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · · Token: example.c:1:37: '(' "(", · · · · · · · · · · · · · · · · · · · Token2: example.c:1:38: ')' ")", · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · · Case: ExpressionAssign, · · · }, · · · Token: example.c:1:39: ';' ";", · · }, · }, · Token: example.c:1:11: FOR "for", · Token2: example.c:1:14: '(' "(", · Token3: example.c:1:21: ';' ";", · Token4: example.c:1:29: ';' ";", · Token5: example.c:1:34: ')' ")", }
Example (ForDecl) ¶
fmt.Println(exampleAST(236, "int f() { for( int i = 0; i < 10; i++) x(); }"))
Output: &cc.IterationStatement{ · Case: IterationStatementForDecl, · Declaration: &cc.Declaration{ · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{ · · · Case: DeclarationSpecifiersTypeSpec, · · · TypeSpecifier: &cc.TypeSpecifier{ · · · · Case: TypeSpecifierInt, · · · · Token: example.c:1:16: INT "int", · · · }, · · }, · · InitDeclaratorList: &cc.InitDeclaratorList{ · · · InitDeclarator: &cc.InitDeclarator{ · · · · Case: InitDeclaratorInit, · · · · Declarator: &cc.Declarator{ · · · · · DirectDeclarator: &cc.DirectDeclarator{ · · · · · · Case: DirectDeclaratorIdent, · · · · · · Token: example.c:1:20: IDENTIFIER "i", · · · · · }, · · · · }, · · · · Initializer: &cc.Initializer{ · · · · · AssignmentExpression: &cc.AssignmentExpression{ · · · · · · Case: AssignmentExpressionCond, · · · · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · · · · Case: ConditionalExpressionLOr, · · · · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · · · · Case: LogicalOrExpressionLAnd, · · · · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · · · · Case: LogicalAndExpressionOr, · · · · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionInt, · · · · · · · · · · · · · · · · · · · · · Token: example.c:1:24: INTCONST "0", · · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · · Case: InitializerExpr, · · · · }, · · · · Token: example.c:1:22: '=' "=", · · · }, · · }, · · Token: example.c:1:25: ';' ";", · }, · Expression: &cc.Expression{ · · AssignmentExpression: &cc.AssignmentExpression{ · · · Case: AssignmentExpressionCond, · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · Case: ConditionalExpressionLOr, · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · Case: LogicalOrExpressionLAnd, · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · Case: LogicalAndExpressionOr, · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · Case: RelationalExpressionLt, · · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · · Token: example.c:1:27: IDENTIFIER "i", · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionInt, · · · · · · · · · · · · · · · · · · Token: example.c:1:31: INTCONST "10", · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · }, · · · · · · · · · · · Token: example.c:1:29: '<' "<", · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · · Case: ExpressionAssign, · }, · Expression2: &cc.Expression{ · · AssignmentExpression: &cc.AssignmentExpression{ · · · Case: AssignmentExpressionCond, · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · Case: ConditionalExpressionLOr, · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · Case: LogicalOrExpressionLAnd, · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · Case: LogicalAndExpressionOr, · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · Case: PostfixExpressionInc, · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · · Token: example.c:1:35: IDENTIFIER "i", · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · Token: example.c:1:36: INC "++", · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · · Case: ExpressionAssign, · }, · Statement: &cc.Statement{ · · Case: StatementExpr, · · ExpressionStatement: &cc.ExpressionStatement{ · · · Expression: &cc.Expression{ · · · · AssignmentExpression: &cc.AssignmentExpression{ · · · · · Case: AssignmentExpressionCond, · · · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · · · Case: ConditionalExpressionLOr, · · · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · · · Case: LogicalOrExpressionLAnd, · · · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · · · Case: LogicalAndExpressionOr, · · · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · · Case: PostfixExpressionCall, · · · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · · · · Token: example.c:1:40: IDENTIFIER "x", · · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · · Token: example.c:1:41: '(' "(", · · · · · · · · · · · · · · · · · · · Token2: example.c:1:42: ')' ")", · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · · Case: ExpressionAssign, · · · }, · · · Token: example.c:1:43: ';' ";", · · }, · }, · Token: example.c:1:11: FOR "for", · Token2: example.c:1:14: '(' "(", · Token3: example.c:1:33: ';' ";", · Token4: example.c:1:38: ')' ")", }
Example (While) ¶
fmt.Println(exampleAST(233, "int f() { while(x) y(); }"))
Output: &cc.IterationStatement{ · Case: IterationStatementWhile, · Expression: &cc.Expression{ · · AssignmentExpression: &cc.AssignmentExpression{ · · · Case: AssignmentExpressionCond, · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · Case: ConditionalExpressionLOr, · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · Case: LogicalOrExpressionLAnd, · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · Case: LogicalAndExpressionOr, · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · Token: example.c:1:17: IDENTIFIER "x", · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · · Case: ExpressionAssign, · }, · Statement: &cc.Statement{ · · Case: StatementExpr, · · ExpressionStatement: &cc.ExpressionStatement{ · · · Expression: &cc.Expression{ · · · · AssignmentExpression: &cc.AssignmentExpression{ · · · · · Case: AssignmentExpressionCond, · · · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · · · Case: ConditionalExpressionLOr, · · · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · · · Case: LogicalOrExpressionLAnd, · · · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · · · Case: LogicalAndExpressionOr, · · · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · · Case: PostfixExpressionCall, · · · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · · · · Token: example.c:1:20: IDENTIFIER "y", · · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · · Token: example.c:1:21: '(' "(", · · · · · · · · · · · · · · · · · · · Token2: example.c:1:22: ')' ")", · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · · Case: ExpressionAssign, · · · }, · · · Token: example.c:1:23: ';' ";", · · }, · }, · Token: example.c:1:11: WHILE "while", · Token2: example.c:1:16: '(' "(", · Token3: example.c:1:18: ')' ")", }
func (*IterationStatement) Position ¶
func (n *IterationStatement) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*IterationStatement) String ¶
func (n *IterationStatement) String() string
String implements fmt.Stringer.
type IterationStatementCase ¶
type IterationStatementCase int
IterationStatementCase represents case numbers of production IterationStatement
const ( IterationStatementWhile IterationStatementCase = iota IterationStatementDo IterationStatementFor IterationStatementForDecl )
Values of type IterationStatementCase
func (IterationStatementCase) String ¶
func (n IterationStatementCase) String() string
String implements fmt.Stringer
type JumpStatement ¶
type JumpStatement struct { Case JumpStatementCase `PrettyPrint:"stringer,zero"` Expression *Expression Token Token Token2 Token Token3 Token // contains filtered or unexported fields }
JumpStatement represents data reduced by productions:
JumpStatement: "goto" IDENTIFIER ';' // Case JumpStatementGoto | "goto" '*' Expression ';' // Case JumpStatementGotoExpr | "continue" ';' // Case JumpStatementContinue | "break" ';' // Case JumpStatementBreak | "return" Expression ';' // Case JumpStatementReturn
Example (Break) ¶
fmt.Println(exampleAST(240, "int f() { for(;;) if (i) break; }"))
Output: &cc.JumpStatement{ · Case: JumpStatementBreak, · Token: example.c:1:26: BREAK "break", · Token2: example.c:1:31: ';' ";", }
Example (Continue) ¶
fmt.Println(exampleAST(239, "int f() { for(;;) if (i) continue; }"))
Output: &cc.JumpStatement{ · Case: JumpStatementContinue, · Token: example.c:1:26: CONTINUE "continue", · Token2: example.c:1:34: ';' ";", }
Example (Goto) ¶
fmt.Println(exampleAST(237, "int f() { L: goto L; }"))
Output: &cc.JumpStatement{ · Case: JumpStatementGoto, · Token: example.c:1:14: GOTO "goto", · Token2: example.c:1:19: IDENTIFIER "L", · Token3: example.c:1:20: ';' ";", }
Example (GotoExpr) ¶
fmt.Println(exampleAST(238, "int f() { L: x(); void *p = &&L; goto *p; }"))
Output: &cc.JumpStatement{ · Case: JumpStatementGotoExpr, · Expression: &cc.Expression{ · · AssignmentExpression: &cc.AssignmentExpression{ · · · Case: AssignmentExpressionCond, · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · Case: ConditionalExpressionLOr, · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · Case: LogicalOrExpressionLAnd, · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · Case: LogicalAndExpressionOr, · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · Token: example.c:1:40: IDENTIFIER "p", · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · · Case: ExpressionAssign, · }, · Token: example.c:1:34: GOTO "goto", · Token2: example.c:1:39: '*' "*", · Token3: example.c:1:41: ';' ";", }
Example (Return) ¶
fmt.Println(exampleAST(241, "int f() { if (i) return x; }"))
Output: &cc.JumpStatement{ · Case: JumpStatementReturn, · Expression: &cc.Expression{ · · AssignmentExpression: &cc.AssignmentExpression{ · · · Case: AssignmentExpressionCond, · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · Case: ConditionalExpressionLOr, · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · Case: LogicalOrExpressionLAnd, · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · Case: LogicalAndExpressionOr, · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · Token: example.c:1:25: IDENTIFIER "x", · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · · Case: ExpressionAssign, · }, · Token: example.c:1:18: RETURN "return", · Token2: example.c:1:26: ';' ";", }
func (*JumpStatement) Context ¶
func (n *JumpStatement) Context() Node
Context reports the statement, if any, a break or continue belongs to. Valid only after typecheck and for n.Case == JumpStatementBreak or JumpStatementContinue.
func (*JumpStatement) LexicalScope ¶
func (n *JumpStatement) LexicalScope() Scope
LexicalScope returns the lexical scope of n.
func (*JumpStatement) Position ¶
func (n *JumpStatement) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*JumpStatement) String ¶
func (n *JumpStatement) String() string
String implements fmt.Stringer.
type JumpStatementCase ¶
type JumpStatementCase int
JumpStatementCase represents case numbers of production JumpStatement
const ( JumpStatementGoto JumpStatementCase = iota JumpStatementGotoExpr JumpStatementContinue JumpStatementBreak JumpStatementReturn )
Values of type JumpStatementCase
func (JumpStatementCase) String ¶
func (n JumpStatementCase) String() string
String implements fmt.Stringer
type Kind ¶
type Kind uint
A Kind represents the specific kind of type that a Type represents. The zero Kind is not a valid kind.
const ( Invalid Kind = iota Array // T[] Bool // _Bool Char // char ComplexChar // complex char ComplexDouble // complex double ComplexFloat // complex float ComplexInt // complex int ComplexLong // complex long ComplexLongDouble // complex long double ComplexLongLong // complex long long ComplexShort // complex short ComplexUInt // complex unsigned ComplexULong // complex unsigned long ComplexULongLong // complex unsigned long long ComplexUShort // complex shor Decimal128 // _Decimal128 Decimal32 // _Decimal32 Decimal64 // _Decimal64 Double // double Enum // enum Float // float Float128 // _Float128 Float32 // _Float32 Float32x // _Float32x Float64 // _Float64 Float64x // _Float64x Function // function Int // int Int8 // __int8 Int16 // __int16 Int32 // __int32 Int64 // __int64 Int128 // __int128 Long // long LongDouble // long double LongLong // long long Ptr // pointer SChar // signed char Short // short Struct // struct TypedefName // typedefname UChar // unsigned char UInt // unsigned UInt8 // unsigned __int8 UInt16 // unsigned __int16 UInt32 // unsigned __int32 UInt64 // unsigned __int64 UInt128 // unsigned __int128 ULong // unsigned long ULongLong // unsigned long long UShort // unsigned short Union // union Void // void Vector // vector )
Values of Kind
type LabelDeclaration ¶
type LabelDeclaration struct { IdentifierList *IdentifierList Token Token Token2 Token }
LabelDeclaration represents data reduced by production:
LabelDeclaration: "__label__" IdentifierList ';'
Example (Case0) ¶
fmt.Println(exampleAST(266, "int f() { __label__ L; L: x(); }"))
Output: &cc.LabelDeclaration{ · IdentifierList: &cc.IdentifierList{ · · Token: example.c:1:21: IDENTIFIER "L", · }, · Token: example.c:1:11: LABEL "__label__", · Token2: example.c:1:22: ';' ";", }
func (*LabelDeclaration) Position ¶
func (n *LabelDeclaration) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*LabelDeclaration) String ¶
func (n *LabelDeclaration) String() string
String implements fmt.Stringer.
type LabeledStatement ¶
type LabeledStatement struct { AttributeSpecifierList *AttributeSpecifierList Case LabeledStatementCase `PrettyPrint:"stringer,zero"` ConstantExpression *ConstantExpression ConstantExpression2 *ConstantExpression Statement *Statement Token Token Token2 Token Token3 Token // contains filtered or unexported fields }
LabeledStatement represents data reduced by productions:
LabeledStatement: IDENTIFIER ':' AttributeSpecifierList Statement // Case LabeledStatementLabel | "case" ConstantExpression ':' Statement // Case LabeledStatementCaseLabel | "case" ConstantExpression "..." ConstantExpression ':' Statement // Case LabeledStatementRange | "default" ':' Statement // Case LabeledStatementDefault
Example (CaseLabel) ¶
fmt.Println(exampleAST(218, "int f() { switch(i) case 42: x(); }"))
Output: &cc.LabeledStatement{ · Case: LabeledStatementCaseLabel, · ConstantExpression: &cc.ConstantExpression{ · · ConditionalExpression: &cc.ConditionalExpression{ · · · Case: ConditionalExpressionLOr, · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · Case: LogicalOrExpressionLAnd, · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · Case: LogicalAndExpressionOr, · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · Case: InclusiveOrExpressionXor, · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · Case: AndExpressionEq, · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · Case: PrimaryExpressionInt, · · · · · · · · · · · · · · · · · Token: example.c:1:26: INTCONST "42", · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · }, · Statement: &cc.Statement{ · · Case: StatementExpr, · · ExpressionStatement: &cc.ExpressionStatement{ · · · Expression: &cc.Expression{ · · · · AssignmentExpression: &cc.AssignmentExpression{ · · · · · Case: AssignmentExpressionCond, · · · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · · · Case: ConditionalExpressionLOr, · · · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · · · Case: LogicalOrExpressionLAnd, · · · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · · · Case: LogicalAndExpressionOr, · · · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · · Case: PostfixExpressionCall, · · · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · · · · Token: example.c:1:30: IDENTIFIER "x", · · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · · Token: example.c:1:31: '(' "(", · · · · · · · · · · · · · · · · · · · Token2: example.c:1:32: ')' ")", · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · · Case: ExpressionAssign, · · · }, · · · Token: example.c:1:33: ';' ";", · · }, · }, · Token: example.c:1:21: CASE "case", · Token2: example.c:1:28: ':' ":", }
Example (Default) ¶
fmt.Println(exampleAST(220, "int f() { switch(i) default: x(); }"))
Output: &cc.LabeledStatement{ · Case: LabeledStatementDefault, · Statement: &cc.Statement{ · · Case: StatementExpr, · · ExpressionStatement: &cc.ExpressionStatement{ · · · Expression: &cc.Expression{ · · · · AssignmentExpression: &cc.AssignmentExpression{ · · · · · Case: AssignmentExpressionCond, · · · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · · · Case: ConditionalExpressionLOr, · · · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · · · Case: LogicalOrExpressionLAnd, · · · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · · · Case: LogicalAndExpressionOr, · · · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · · Case: PostfixExpressionCall, · · · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · · · · Token: example.c:1:30: IDENTIFIER "x", · · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · · Token: example.c:1:31: '(' "(", · · · · · · · · · · · · · · · · · · · Token2: example.c:1:32: ')' ")", · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · · Case: ExpressionAssign, · · · }, · · · Token: example.c:1:33: ';' ";", · · }, · }, · Token: example.c:1:21: DEFAULT "default", · Token2: example.c:1:28: ':' ":", }
Example (Label) ¶
fmt.Println(exampleAST(217, "int f() { L: goto L; }"))
Output: &cc.LabeledStatement{ · Case: LabeledStatementLabel, · Statement: &cc.Statement{ · · Case: StatementJump, · · JumpStatement: &cc.JumpStatement{ · · · Case: JumpStatementGoto, · · · Token: example.c:1:14: GOTO "goto", · · · Token2: example.c:1:19: IDENTIFIER "L", · · · Token3: example.c:1:20: ';' ";", · · }, · }, · Token: example.c:1:11: IDENTIFIER "L", · Token2: example.c:1:12: ':' ":", }
Example (Range) ¶
fmt.Println(exampleAST(219, "int f() { switch(i) case 42 ... 56: x(); }"))
Output: &cc.LabeledStatement{ · Case: LabeledStatementRange, · ConstantExpression: &cc.ConstantExpression{ · · ConditionalExpression: &cc.ConditionalExpression{ · · · Case: ConditionalExpressionLOr, · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · Case: LogicalOrExpressionLAnd, · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · Case: LogicalAndExpressionOr, · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · Case: InclusiveOrExpressionXor, · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · Case: AndExpressionEq, · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · Case: PrimaryExpressionInt, · · · · · · · · · · · · · · · · · Token: example.c:1:26: INTCONST "42", · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · }, · ConstantExpression2: &cc.ConstantExpression{ · · ConditionalExpression: &cc.ConditionalExpression{ · · · Case: ConditionalExpressionLOr, · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · Case: LogicalOrExpressionLAnd, · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · Case: LogicalAndExpressionOr, · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · Case: InclusiveOrExpressionXor, · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · Case: AndExpressionEq, · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · Case: PrimaryExpressionInt, · · · · · · · · · · · · · · · · · Token: example.c:1:33: INTCONST "56", · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · }, · Statement: &cc.Statement{ · · Case: StatementExpr, · · ExpressionStatement: &cc.ExpressionStatement{ · · · Expression: &cc.Expression{ · · · · AssignmentExpression: &cc.AssignmentExpression{ · · · · · Case: AssignmentExpressionCond, · · · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · · · Case: ConditionalExpressionLOr, · · · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · · · Case: LogicalOrExpressionLAnd, · · · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · · · Case: LogicalAndExpressionOr, · · · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · · Case: PostfixExpressionCall, · · · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · · · · Token: example.c:1:37: IDENTIFIER "x", · · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · · Token: example.c:1:38: '(' "(", · · · · · · · · · · · · · · · · · · · Token2: example.c:1:39: ')' ")", · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · · Case: ExpressionAssign, · · · }, · · · Token: example.c:1:40: ';' ";", · · }, · }, · Token: example.c:1:21: CASE "case", · Token2: example.c:1:29: DDD "...", · Token3: example.c:1:35: ':' ":", }
func (*LabeledStatement) CompoundStatement ¶
func (n *LabeledStatement) CompoundStatement() *CompoundStatement
CompoundStatement returns the block containing n.
func (*LabeledStatement) LexicalScope ¶
func (n *LabeledStatement) LexicalScope() Scope
LexicalScope returns the lexical scope of n.
func (*LabeledStatement) Position ¶
func (n *LabeledStatement) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*LabeledStatement) String ¶
func (n *LabeledStatement) String() string
String implements fmt.Stringer.
type LabeledStatementCase ¶
type LabeledStatementCase int
LabeledStatementCase represents case numbers of production LabeledStatement
const ( LabeledStatementLabel LabeledStatementCase = iota LabeledStatementCaseLabel LabeledStatementRange LabeledStatementDefault )
Values of type LabeledStatementCase
func (LabeledStatementCase) String ¶
func (n LabeledStatementCase) String() string
String implements fmt.Stringer
type Linkage ¶
type Linkage int
Linkage represents identifier linkage.
[0]6.2.2: An identifier declared in different scopes or in the same scope more than once can be made to refer to the same object or function by a process called linkage. There are three kinds of linkage: External, Internal, and None.
type LogicalAndExpression ¶
type LogicalAndExpression struct { Operand Operand IsSideEffectsFree bool Case LogicalAndExpressionCase `PrettyPrint:"stringer,zero"` InclusiveOrExpression *InclusiveOrExpression LogicalAndExpression *LogicalAndExpression Token Token }
LogicalAndExpression represents data reduced by productions:
LogicalAndExpression: InclusiveOrExpression // Case LogicalAndExpressionOr | LogicalAndExpression "&&" InclusiveOrExpression // Case LogicalAndExpressionLAnd
Example (LAnd) ¶
fmt.Println(exampleAST(66, "int i = x && y;"))
Output: &cc.LogicalAndExpression{ · Case: LogicalAndExpressionLAnd, · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · Case: InclusiveOrExpressionXor, · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · AndExpression: &cc.AndExpression{ · · · · Case: AndExpressionEq, · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · Case: EqualityExpressionRel, · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · Case: RelationalExpressionShift, · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · Token: example.c:1:14: IDENTIFIER "y", · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · · Case: ShiftExpressionAdd, · · · · · · }, · · · · · }, · · · · }, · · · }, · · · Case: ExclusiveOrExpressionAnd, · · }, · }, · LogicalAndExpression: &cc.LogicalAndExpression{ · · Case: LogicalAndExpressionOr, · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · Case: InclusiveOrExpressionXor, · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · AndExpression: &cc.AndExpression{ · · · · · Case: AndExpressionEq, · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · Case: EqualityExpressionRel, · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · Case: RelationalExpressionShift, · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · Token: example.c:1:9: IDENTIFIER "x", · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · · Case: ExclusiveOrExpressionAnd, · · · }, · · }, · }, · Token: example.c:1:11: ANDAND "&&", }
Example (Or) ¶
fmt.Println(exampleAST(65, "int i = x;"))
Output: &cc.LogicalAndExpression{ · Case: LogicalAndExpressionOr, · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · Case: InclusiveOrExpressionXor, · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · AndExpression: &cc.AndExpression{ · · · · Case: AndExpressionEq, · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · Case: EqualityExpressionRel, · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · Case: RelationalExpressionShift, · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · Token: example.c:1:9: IDENTIFIER "x", · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · · Case: ShiftExpressionAdd, · · · · · · }, · · · · · }, · · · · }, · · · }, · · · Case: ExclusiveOrExpressionAnd, · · }, · }, }
func (*LogicalAndExpression) Declarator ¶
func (n *LogicalAndExpression) Declarator() *Declarator
func (*LogicalAndExpression) Position ¶
func (n *LogicalAndExpression) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*LogicalAndExpression) String ¶
func (n *LogicalAndExpression) String() string
String implements fmt.Stringer.
type LogicalAndExpressionCase ¶
type LogicalAndExpressionCase int
LogicalAndExpressionCase represents case numbers of production LogicalAndExpression
const ( LogicalAndExpressionOr LogicalAndExpressionCase = iota LogicalAndExpressionLAnd )
Values of type LogicalAndExpressionCase
func (LogicalAndExpressionCase) String ¶
func (n LogicalAndExpressionCase) String() string
String implements fmt.Stringer
type LogicalOrExpression ¶
type LogicalOrExpression struct { Operand Operand IsSideEffectsFree bool Case LogicalOrExpressionCase `PrettyPrint:"stringer,zero"` LogicalAndExpression *LogicalAndExpression LogicalOrExpression *LogicalOrExpression Token Token }
LogicalOrExpression represents data reduced by productions:
LogicalOrExpression: LogicalAndExpression // Case LogicalOrExpressionLAnd | LogicalOrExpression "||" LogicalAndExpression // Case LogicalOrExpressionLOr
Example (LAnd) ¶
fmt.Println(exampleAST(67, "int i = x;"))
Output: &cc.LogicalOrExpression{ · Case: LogicalOrExpressionLAnd, · LogicalAndExpression: &cc.LogicalAndExpression{ · · Case: LogicalAndExpressionOr, · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · Case: InclusiveOrExpressionXor, · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · AndExpression: &cc.AndExpression{ · · · · · Case: AndExpressionEq, · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · Case: EqualityExpressionRel, · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · Case: RelationalExpressionShift, · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · Token: example.c:1:9: IDENTIFIER "x", · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · · Case: ExclusiveOrExpressionAnd, · · · }, · · }, · }, }
Example (LOr) ¶
fmt.Println(exampleAST(68, "int i = x || y;"))
Output: &cc.LogicalOrExpression{ · Case: LogicalOrExpressionLOr, · LogicalAndExpression: &cc.LogicalAndExpression{ · · Case: LogicalAndExpressionOr, · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · Case: InclusiveOrExpressionXor, · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · AndExpression: &cc.AndExpression{ · · · · · Case: AndExpressionEq, · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · Case: EqualityExpressionRel, · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · Case: RelationalExpressionShift, · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · Token: example.c:1:14: IDENTIFIER "y", · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · · Case: ExclusiveOrExpressionAnd, · · · }, · · }, · }, · LogicalOrExpression: &cc.LogicalOrExpression{ · · Case: LogicalOrExpressionLAnd, · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · Case: LogicalAndExpressionOr, · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · Case: InclusiveOrExpressionXor, · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · AndExpression: &cc.AndExpression{ · · · · · · Case: AndExpressionEq, · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · Case: EqualityExpressionRel, · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · Token: example.c:1:9: IDENTIFIER "x", · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · · Case: ExclusiveOrExpressionAnd, · · · · }, · · · }, · · }, · }, · Token: example.c:1:11: OROR "||", }
func (*LogicalOrExpression) Declarator ¶
func (n *LogicalOrExpression) Declarator() *Declarator
func (*LogicalOrExpression) Position ¶
func (n *LogicalOrExpression) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*LogicalOrExpression) String ¶
func (n *LogicalOrExpression) String() string
String implements fmt.Stringer.
type LogicalOrExpressionCase ¶
type LogicalOrExpressionCase int
LogicalOrExpressionCase represents case numbers of production LogicalOrExpression
const ( LogicalOrExpressionLAnd LogicalOrExpressionCase = iota LogicalOrExpressionLOr )
Values of type LogicalOrExpressionCase
func (LogicalOrExpressionCase) String ¶
func (n LogicalOrExpressionCase) String() string
String implements fmt.Stringer
type Macro ¶
type Macro struct {
// contains filtered or unexported fields
}
Macro represents a preprocessor macro definition.
func (*Macro) Parameters ¶
Parameters return the list of function-like macro parameters.
func (*Macro) ReplacementTokens ¶
ReplacementTokens return the list of tokens m is replaced with. Tokens in the returned list have only the Rune and Value fields valid.
type MultiplicativeExpression ¶
type MultiplicativeExpression struct { Operand Operand IsSideEffectsFree bool Case MultiplicativeExpressionCase `PrettyPrint:"stringer,zero"` CastExpression *CastExpression MultiplicativeExpression *MultiplicativeExpression Token Token // contains filtered or unexported fields }
MultiplicativeExpression represents data reduced by productions:
MultiplicativeExpression: CastExpression // Case MultiplicativeExpressionCast | MultiplicativeExpression '*' CastExpression // Case MultiplicativeExpressionMul | MultiplicativeExpression '/' CastExpression // Case MultiplicativeExpressionDiv | MultiplicativeExpression '%' CastExpression // Case MultiplicativeExpressionMod
Example (Cast) ¶
fmt.Println(exampleAST(41, "int i = x;"))
Output: &cc.MultiplicativeExpression{ · Case: MultiplicativeExpressionCast, · CastExpression: &cc.CastExpression{ · · Case: CastExpressionUnary, · · UnaryExpression: &cc.UnaryExpression{ · · · Case: UnaryExpressionPostfix, · · · PostfixExpression: &cc.PostfixExpression{ · · · · Case: PostfixExpressionPrimary, · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · Case: PrimaryExpressionIdent, · · · · · Token: example.c:1:9: IDENTIFIER "x", · · · · }, · · · }, · · }, · }, }
Example (Div) ¶
fmt.Println(exampleAST(43, "int i = x / y;"))
Output: &cc.MultiplicativeExpression{ · Case: MultiplicativeExpressionDiv, · CastExpression: &cc.CastExpression{ · · Case: CastExpressionUnary, · · UnaryExpression: &cc.UnaryExpression{ · · · Case: UnaryExpressionPostfix, · · · PostfixExpression: &cc.PostfixExpression{ · · · · Case: PostfixExpressionPrimary, · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · Case: PrimaryExpressionIdent, · · · · · Token: example.c:1:13: IDENTIFIER "y", · · · · }, · · · }, · · }, · }, · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · Case: MultiplicativeExpressionCast, · · CastExpression: &cc.CastExpression{ · · · Case: CastExpressionUnary, · · · UnaryExpression: &cc.UnaryExpression{ · · · · Case: UnaryExpressionPostfix, · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · Case: PostfixExpressionPrimary, · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · Case: PrimaryExpressionIdent, · · · · · · Token: example.c:1:9: IDENTIFIER "x", · · · · · }, · · · · }, · · · }, · · }, · }, · Token: example.c:1:11: '/' "/", }
Example (Mod) ¶
fmt.Println(exampleAST(44, "int i = x % y;"))
Output: &cc.MultiplicativeExpression{ · Case: MultiplicativeExpressionMod, · CastExpression: &cc.CastExpression{ · · Case: CastExpressionUnary, · · UnaryExpression: &cc.UnaryExpression{ · · · Case: UnaryExpressionPostfix, · · · PostfixExpression: &cc.PostfixExpression{ · · · · Case: PostfixExpressionPrimary, · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · Case: PrimaryExpressionIdent, · · · · · Token: example.c:1:13: IDENTIFIER "y", · · · · }, · · · }, · · }, · }, · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · Case: MultiplicativeExpressionCast, · · CastExpression: &cc.CastExpression{ · · · Case: CastExpressionUnary, · · · UnaryExpression: &cc.UnaryExpression{ · · · · Case: UnaryExpressionPostfix, · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · Case: PostfixExpressionPrimary, · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · Case: PrimaryExpressionIdent, · · · · · · Token: example.c:1:9: IDENTIFIER "x", · · · · · }, · · · · }, · · · }, · · }, · }, · Token: example.c:1:11: '%' "%", }
Example (Mul) ¶
fmt.Println(exampleAST(42, "int i = x * y;"))
Output: &cc.MultiplicativeExpression{ · Case: MultiplicativeExpressionMul, · CastExpression: &cc.CastExpression{ · · Case: CastExpressionUnary, · · UnaryExpression: &cc.UnaryExpression{ · · · Case: UnaryExpressionPostfix, · · · PostfixExpression: &cc.PostfixExpression{ · · · · Case: PostfixExpressionPrimary, · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · Case: PrimaryExpressionIdent, · · · · · Token: example.c:1:13: IDENTIFIER "y", · · · · }, · · · }, · · }, · }, · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · Case: MultiplicativeExpressionCast, · · CastExpression: &cc.CastExpression{ · · · Case: CastExpressionUnary, · · · UnaryExpression: &cc.UnaryExpression{ · · · · Case: UnaryExpressionPostfix, · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · Case: PostfixExpressionPrimary, · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · Case: PrimaryExpressionIdent, · · · · · · Token: example.c:1:9: IDENTIFIER "x", · · · · · }, · · · · }, · · · }, · · }, · }, · Token: example.c:1:11: '*' "*", }
func (*MultiplicativeExpression) Declarator ¶
func (n *MultiplicativeExpression) Declarator() *Declarator
func (*MultiplicativeExpression) Position ¶
func (n *MultiplicativeExpression) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*MultiplicativeExpression) Promote ¶
func (n *MultiplicativeExpression) Promote() Type
Promote returns the type the operands of the binary operation are promoted to.
func (*MultiplicativeExpression) String ¶
func (n *MultiplicativeExpression) String() string
String implements fmt.Stringer.
type MultiplicativeExpressionCase ¶
type MultiplicativeExpressionCase int
MultiplicativeExpressionCase represents case numbers of production MultiplicativeExpression
const ( MultiplicativeExpressionCast MultiplicativeExpressionCase = iota MultiplicativeExpressionMul MultiplicativeExpressionDiv MultiplicativeExpressionMod )
Values of type MultiplicativeExpressionCase
func (MultiplicativeExpressionCase) String ¶
func (n MultiplicativeExpressionCase) String() string
String implements fmt.Stringer
type Operand ¶
type Operand interface { // IsAssingmentCompatible reports whether the operand can be // assigned to lhs. [0], 6.5.16.1. IsAssingmentCompatible(lhs Type) bool ConvertTo(Type) Operand Declarator() *Declarator IsConst() bool IsLValue() bool IsNonZero() bool IsZero() bool Offset() uintptr // Valid only for non nil Declarator() value Type() Type Value() Value // contains filtered or unexported methods }
type Parameter ¶
type Parameter struct {
// contains filtered or unexported fields
}
Parameter represents a function parameter.
func NewParameter ¶
func NewParameter(d *Declarator, t Type) *Parameter
NewParameter returns a newly created parameter
func (*Parameter) Declarator ¶
func (p *Parameter) Declarator() *Declarator
type ParameterDeclaration ¶
type ParameterDeclaration struct { AbstractDeclarator *AbstractDeclarator AttributeSpecifierList *AttributeSpecifierList Case ParameterDeclarationCase `PrettyPrint:"stringer,zero"` DeclarationSpecifiers *DeclarationSpecifiers Declarator *Declarator // contains filtered or unexported fields }
ParameterDeclaration represents data reduced by productions:
ParameterDeclaration: DeclarationSpecifiers Declarator AttributeSpecifierList // Case ParameterDeclarationDecl | DeclarationSpecifiers AbstractDeclarator // Case ParameterDeclarationAbstract
Example (Abstract) ¶
fmt.Println(exampleAST(188, "int f(int*) {}"))
Output: &cc.ParameterDeclaration{ · AbstractDeclarator: &cc.AbstractDeclarator{ · · Case: AbstractDeclaratorPtr, · · Pointer: &cc.Pointer{ · · · Case: PointerTypeQual, · · · Token: example.c:1:10: '*' "*", · · }, · }, · Case: ParameterDeclarationAbstract, · DeclarationSpecifiers: &cc.DeclarationSpecifiers{ · · Case: DeclarationSpecifiersTypeSpec, · · TypeSpecifier: &cc.TypeSpecifier{ · · · Case: TypeSpecifierInt, · · · Token: example.c:1:7: INT "int", · · }, · }, }
Example (Decl) ¶
fmt.Println(exampleAST(187, "int f(int i) {}"))
Output: &cc.ParameterDeclaration{ · Case: ParameterDeclarationDecl, · DeclarationSpecifiers: &cc.DeclarationSpecifiers{ · · Case: DeclarationSpecifiersTypeSpec, · · TypeSpecifier: &cc.TypeSpecifier{ · · · Case: TypeSpecifierInt, · · · Token: example.c:1:7: INT "int", · · }, · }, · Declarator: &cc.Declarator{ · · DirectDeclarator: &cc.DirectDeclarator{ · · · Case: DirectDeclaratorIdent, · · · Token: example.c:1:11: IDENTIFIER "i", · · }, · }, }
func (*ParameterDeclaration) Position ¶
func (n *ParameterDeclaration) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*ParameterDeclaration) String ¶
func (n *ParameterDeclaration) String() string
String implements fmt.Stringer.
func (*ParameterDeclaration) Type ¶
func (n *ParameterDeclaration) Type() Type
type ParameterDeclarationCase ¶
type ParameterDeclarationCase int
ParameterDeclarationCase represents case numbers of production ParameterDeclaration
const ( ParameterDeclarationDecl ParameterDeclarationCase = iota ParameterDeclarationAbstract )
Values of type ParameterDeclarationCase
func (ParameterDeclarationCase) String ¶
func (n ParameterDeclarationCase) String() string
String implements fmt.Stringer
type ParameterList ¶
type ParameterList struct { ParameterDeclaration *ParameterDeclaration ParameterList *ParameterList Token Token }
ParameterList represents data reduced by productions:
ParameterList: ParameterDeclaration | ParameterList ',' ParameterDeclaration
Example (Case0) ¶
fmt.Println(exampleAST(185, "int f(int i) {}"))
Output: &cc.ParameterList{ · ParameterDeclaration: &cc.ParameterDeclaration{ · · Case: ParameterDeclarationDecl, · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{ · · · Case: DeclarationSpecifiersTypeSpec, · · · TypeSpecifier: &cc.TypeSpecifier{ · · · · Case: TypeSpecifierInt, · · · · Token: example.c:1:7: INT "int", · · · }, · · }, · · Declarator: &cc.Declarator{ · · · DirectDeclarator: &cc.DirectDeclarator{ · · · · Case: DirectDeclaratorIdent, · · · · Token: example.c:1:11: IDENTIFIER "i", · · · }, · · }, · }, }
Example (Case1) ¶
fmt.Println(exampleAST(186, "int f(int i, int j) {}"))
Output: &cc.ParameterList{ · ParameterDeclaration: &cc.ParameterDeclaration{ · · Case: ParameterDeclarationDecl, · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{ · · · Case: DeclarationSpecifiersTypeSpec, · · · TypeSpecifier: &cc.TypeSpecifier{ · · · · Case: TypeSpecifierInt, · · · · Token: example.c:1:7: INT "int", · · · }, · · }, · · Declarator: &cc.Declarator{ · · · DirectDeclarator: &cc.DirectDeclarator{ · · · · Case: DirectDeclaratorIdent, · · · · Token: example.c:1:11: IDENTIFIER "i", · · · }, · · }, · }, · ParameterList: &cc.ParameterList{ · · ParameterDeclaration: &cc.ParameterDeclaration{ · · · Case: ParameterDeclarationDecl, · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{ · · · · Case: DeclarationSpecifiersTypeSpec, · · · · TypeSpecifier: &cc.TypeSpecifier{ · · · · · Case: TypeSpecifierInt, · · · · · Token: example.c:1:14: INT "int", · · · · }, · · · }, · · · Declarator: &cc.Declarator{ · · · · DirectDeclarator: &cc.DirectDeclarator{ · · · · · Case: DirectDeclaratorIdent, · · · · · Token: example.c:1:18: IDENTIFIER "j", · · · · }, · · · }, · · }, · · Token: example.c:1:12: ',' ",", · }, }
func (*ParameterList) Position ¶
func (n *ParameterList) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*ParameterList) String ¶
func (n *ParameterList) String() string
String implements fmt.Stringer.
type ParameterTypeList ¶
type ParameterTypeList struct { Case ParameterTypeListCase `PrettyPrint:"stringer,zero"` ParameterList *ParameterList Token Token Token2 Token }
ParameterTypeList represents data reduced by productions:
ParameterTypeList: ParameterList // Case ParameterTypeListList | ParameterList ',' "..." // Case ParameterTypeListVar
Example (List) ¶
fmt.Println(exampleAST(183, "int f(int i) {}"))
Output: &cc.ParameterTypeList{ · Case: ParameterTypeListList, · ParameterList: &cc.ParameterList{ · · ParameterDeclaration: &cc.ParameterDeclaration{ · · · Case: ParameterDeclarationDecl, · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{ · · · · Case: DeclarationSpecifiersTypeSpec, · · · · TypeSpecifier: &cc.TypeSpecifier{ · · · · · Case: TypeSpecifierInt, · · · · · Token: example.c:1:7: INT "int", · · · · }, · · · }, · · · Declarator: &cc.Declarator{ · · · · DirectDeclarator: &cc.DirectDeclarator{ · · · · · Case: DirectDeclaratorIdent, · · · · · Token: example.c:1:11: IDENTIFIER "i", · · · · }, · · · }, · · }, · }, }
Example (Var) ¶
fmt.Println(exampleAST(184, "int f(int i, ...) {}"))
Output: &cc.ParameterTypeList{ · Case: ParameterTypeListVar, · ParameterList: &cc.ParameterList{ · · ParameterDeclaration: &cc.ParameterDeclaration{ · · · Case: ParameterDeclarationDecl, · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{ · · · · Case: DeclarationSpecifiersTypeSpec, · · · · TypeSpecifier: &cc.TypeSpecifier{ · · · · · Case: TypeSpecifierInt, · · · · · Token: example.c:1:7: INT "int", · · · · }, · · · }, · · · Declarator: &cc.Declarator{ · · · · DirectDeclarator: &cc.DirectDeclarator{ · · · · · Case: DirectDeclaratorIdent, · · · · · Token: example.c:1:11: IDENTIFIER "i", · · · · }, · · · }, · · }, · }, · Token: example.c:1:12: ',' ",", · Token2: example.c:1:14: DDD "...", }
func (*ParameterTypeList) Position ¶
func (n *ParameterTypeList) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*ParameterTypeList) String ¶
func (n *ParameterTypeList) String() string
String implements fmt.Stringer.
type ParameterTypeListCase ¶
type ParameterTypeListCase int
ParameterTypeListCase represents case numbers of production ParameterTypeList
const ( ParameterTypeListList ParameterTypeListCase = iota ParameterTypeListVar )
Values of type ParameterTypeListCase
func (ParameterTypeListCase) String ¶
func (n ParameterTypeListCase) String() string
String implements fmt.Stringer
type Pointer ¶
type Pointer struct { Case PointerCase `PrettyPrint:"stringer,zero"` Pointer *Pointer Token Token TypeQualifiers *TypeQualifiers // contains filtered or unexported fields }
Pointer represents data reduced by productions:
Pointer: '*' TypeQualifiers // Case PointerTypeQual | '*' TypeQualifiers Pointer // Case PointerPtr
Example (Ptr) ¶
fmt.Println(exampleAST(178, "int **p;"))
Output: &cc.Pointer{ · Case: PointerPtr, · Pointer: &cc.Pointer{ · · Case: PointerTypeQual, · · Token: example.c:1:6: '*' "*", · }, · Token: example.c:1:5: '*' "*", }
Example (TypeQual) ¶
fmt.Println(exampleAST(177, "int *p;"))
Output: &cc.Pointer{ · Case: PointerTypeQual, · Token: example.c:1:5: '*' "*", }
func (*Pointer) TypeQualifier ¶
type PointerCase ¶
type PointerCase int
PointerCase represents case numbers of production Pointer
const ( PointerTypeQual PointerCase = iota PointerPtr )
Values of type PointerCase
type PostfixExpression ¶
type PostfixExpression struct { Operand Operand Field Field // Case Select, PSelect IsSideEffectsFree bool ArgumentExpressionList *ArgumentExpressionList AssignmentExpression *AssignmentExpression AssignmentExpression2 *AssignmentExpression AssignmentExpression3 *AssignmentExpression Case PostfixExpressionCase `PrettyPrint:"stringer,zero"` Expression *Expression InitializerList *InitializerList PostfixExpression *PostfixExpression PrimaryExpression *PrimaryExpression Token Token Token2 Token Token3 Token Token4 Token Token5 Token TypeName *TypeName TypeName2 *TypeName }
PostfixExpression represents data reduced by productions:
PostfixExpression: PrimaryExpression // Case PostfixExpressionPrimary | PostfixExpression '[' Expression ']' // Case PostfixExpressionIndex | PostfixExpression '(' ArgumentExpressionList ')' // Case PostfixExpressionCall | PostfixExpression '.' IDENTIFIER // Case PostfixExpressionSelect | PostfixExpression "->" IDENTIFIER // Case PostfixExpressionPSelect | PostfixExpression "++" // Case PostfixExpressionInc | PostfixExpression "--" // Case PostfixExpressionDec | '(' TypeName ')' '{' InitializerList ',' '}' // Case PostfixExpressionComplit | "__builtin_types_compatible_p" '(' TypeName ',' TypeName ')' // Case PostfixExpressionTypeCmp | "__builtin_choose_expr" '(' AssignmentExpression ',' AssignmentExpression ',' AssignmentExpression ')' // Case PostfixExpressionChooseExpr
Example (Call) ¶
fmt.Println(exampleAST(13, "int i = x(y);"))
Output: &cc.PostfixExpression{ · ArgumentExpressionList: &cc.ArgumentExpressionList{ · · AssignmentExpression: &cc.AssignmentExpression{ · · · Case: AssignmentExpressionCond, · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · Case: ConditionalExpressionLOr, · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · Case: LogicalOrExpressionLAnd, · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · Case: LogicalAndExpressionOr, · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · Token: example.c:1:11: IDENTIFIER "y", · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · }, · Case: PostfixExpressionCall, · PostfixExpression: &cc.PostfixExpression{ · · Case: PostfixExpressionPrimary, · · PrimaryExpression: &cc.PrimaryExpression{ · · · Case: PrimaryExpressionIdent, · · · Token: example.c:1:9: IDENTIFIER "x", · · }, · }, · Token: example.c:1:10: '(' "(", · Token2: example.c:1:12: ')' ")", }
Example (ChooseExpr) ¶
fmt.Println(exampleAST(20, "int i = __builtin_choose_expr(1, 2, \"foo\");"))
Output: &cc.PostfixExpression{ · AssignmentExpression: &cc.AssignmentExpression{ · · Case: AssignmentExpressionCond, · · ConditionalExpression: &cc.ConditionalExpression{ · · · Case: ConditionalExpressionLOr, · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · Case: LogicalOrExpressionLAnd, · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · Case: LogicalAndExpressionOr, · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · Case: InclusiveOrExpressionXor, · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · Case: AndExpressionEq, · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · Case: PrimaryExpressionInt, · · · · · · · · · · · · · · · · · Token: example.c:1:31: INTCONST "1", · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · }, · AssignmentExpression2: &cc.AssignmentExpression{ · · Case: AssignmentExpressionCond, · · ConditionalExpression: &cc.ConditionalExpression{ · · · Case: ConditionalExpressionLOr, · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · Case: LogicalOrExpressionLAnd, · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · Case: LogicalAndExpressionOr, · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · Case: InclusiveOrExpressionXor, · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · Case: AndExpressionEq, · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · Case: PrimaryExpressionInt, · · · · · · · · · · · · · · · · · Token: example.c:1:34: INTCONST "2", · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · }, · AssignmentExpression3: &cc.AssignmentExpression{ · · Case: AssignmentExpressionCond, · · ConditionalExpression: &cc.ConditionalExpression{ · · · Case: ConditionalExpressionLOr, · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · Case: LogicalOrExpressionLAnd, · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · Case: LogicalAndExpressionOr, · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · Case: InclusiveOrExpressionXor, · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · Case: AndExpressionEq, · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · Case: PrimaryExpressionString, · · · · · · · · · · · · · · · · · Token: example.c:1:37: STRINGLITERAL "foo", · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · }, · Case: PostfixExpressionChooseExpr, · Token: example.c:1:9: BUILTINCHOOSEEXPR "__builtin_choose_expr", · Token2: example.c:1:30: '(' "(", · Token3: example.c:1:32: ',' ",", · Token4: example.c:1:35: ',' ",", · Token5: example.c:1:42: ')' ")", }
Example (Complit) ¶
fmt.Println(exampleAST(18, "int i = (int[]){y};"))
Output: &cc.PostfixExpression{ · Case: PostfixExpressionComplit, · InitializerList: &cc.InitializerList{ · · Initializer: &cc.Initializer{ · · · AssignmentExpression: &cc.AssignmentExpression{ · · · · Case: AssignmentExpressionCond, · · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · · Case: ConditionalExpressionLOr, · · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · · Case: LogicalOrExpressionLAnd, · · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · · Case: LogicalAndExpressionOr, · · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · · Token: example.c:1:17: IDENTIFIER "y", · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · · Case: InitializerExpr, · · }, · }, · Token3: example.c:1:16: '{' "{", · Token5: example.c:1:18: '}' "}", · TypeName: &cc.TypeName{ · · AbstractDeclarator: &cc.AbstractDeclarator{ · · · Case: AbstractDeclaratorDecl, · · · DirectAbstractDeclarator: &cc.DirectAbstractDeclarator{ · · · · Case: DirectAbstractDeclaratorArr, · · · · Token: example.c:1:13: '[' "[", · · · · Token2: example.c:1:14: ']' "]", · · · }, · · }, · · SpecifierQualifierList: &cc.SpecifierQualifierList{ · · · Case: SpecifierQualifierListTypeSpec, · · · TypeSpecifier: &cc.TypeSpecifier{ · · · · Case: TypeSpecifierInt, · · · · Token: example.c:1:10: INT "int", · · · }, · · }, · }, }
Example (Dec) ¶
fmt.Println(exampleAST(17, "int i = x--;"))
Output: &cc.PostfixExpression{ · Case: PostfixExpressionDec, · PostfixExpression: &cc.PostfixExpression{ · · Case: PostfixExpressionPrimary, · · PrimaryExpression: &cc.PrimaryExpression{ · · · Case: PrimaryExpressionIdent, · · · Token: example.c:1:9: IDENTIFIER "x", · · }, · }, · Token: example.c:1:10: DEC "--", }
Example (Inc) ¶
fmt.Println(exampleAST(16, "int i = x++;"))
Output: &cc.PostfixExpression{ · Case: PostfixExpressionInc, · PostfixExpression: &cc.PostfixExpression{ · · Case: PostfixExpressionPrimary, · · PrimaryExpression: &cc.PrimaryExpression{ · · · Case: PrimaryExpressionIdent, · · · Token: example.c:1:9: IDENTIFIER "x", · · }, · }, · Token: example.c:1:10: INC "++", }
Example (Index) ¶
fmt.Println(exampleAST(12, "int i = x[y];"))
Output: &cc.PostfixExpression{ · Case: PostfixExpressionIndex, · Expression: &cc.Expression{ · · AssignmentExpression: &cc.AssignmentExpression{ · · · Case: AssignmentExpressionCond, · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · Case: ConditionalExpressionLOr, · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · Case: LogicalOrExpressionLAnd, · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · Case: LogicalAndExpressionOr, · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · Token: example.c:1:11: IDENTIFIER "y", · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · · Case: ExpressionAssign, · }, · PostfixExpression: &cc.PostfixExpression{ · · Case: PostfixExpressionPrimary, · · PrimaryExpression: &cc.PrimaryExpression{ · · · Case: PrimaryExpressionIdent, · · · Token: example.c:1:9: IDENTIFIER "x", · · }, · }, · Token: example.c:1:10: '[' "[", · Token2: example.c:1:12: ']' "]", }
Example (PSelect) ¶
fmt.Println(exampleAST(15, "int i = x->y;"))
Output: &cc.PostfixExpression{ · Case: PostfixExpressionPSelect, · PostfixExpression: &cc.PostfixExpression{ · · Case: PostfixExpressionPrimary, · · PrimaryExpression: &cc.PrimaryExpression{ · · · Case: PrimaryExpressionIdent, · · · Token: example.c:1:9: IDENTIFIER "x", · · }, · }, · Token: example.c:1:10: ARROW "->", · Token2: example.c:1:12: IDENTIFIER "y", }
Example (Primary) ¶
fmt.Println(exampleAST(11, "int i = x;"))
Output: &cc.PostfixExpression{ · Case: PostfixExpressionPrimary, · PrimaryExpression: &cc.PrimaryExpression{ · · Case: PrimaryExpressionIdent, · · Token: example.c:1:9: IDENTIFIER "x", · }, }
Example (Select) ¶
fmt.Println(exampleAST(14, "int i = x.y;"))
Output: &cc.PostfixExpression{ · Case: PostfixExpressionSelect, · PostfixExpression: &cc.PostfixExpression{ · · Case: PostfixExpressionPrimary, · · PrimaryExpression: &cc.PrimaryExpression{ · · · Case: PrimaryExpressionIdent, · · · Token: example.c:1:9: IDENTIFIER "x", · · }, · }, · Token: example.c:1:10: '.' ".", · Token2: example.c:1:11: IDENTIFIER "y", }
Example (TypeCmp) ¶
fmt.Println(exampleAST(19, "int i = __builtin_types_compatible_p(int, double);"))
Output: &cc.PostfixExpression{ · Case: PostfixExpressionTypeCmp, · Token: example.c:1:9: BUILTINTYPESCOMPATIBLE "__builtin_types_compatible_p", · Token2: example.c:1:37: '(' "(", · Token3: example.c:1:41: ',' ",", · Token4: example.c:1:49: ')' ")", · TypeName: &cc.TypeName{ · · SpecifierQualifierList: &cc.SpecifierQualifierList{ · · · Case: SpecifierQualifierListTypeSpec, · · · TypeSpecifier: &cc.TypeSpecifier{ · · · · Case: TypeSpecifierInt, · · · · Token: example.c:1:38: INT "int", · · · }, · · }, · }, · TypeName2: &cc.TypeName{ · · SpecifierQualifierList: &cc.SpecifierQualifierList{ · · · Case: SpecifierQualifierListTypeSpec, · · · TypeSpecifier: &cc.TypeSpecifier{ · · · · Case: TypeSpecifierDouble, · · · · Token: example.c:1:43: DOUBLE "double", · · · }, · · }, · }, }
func (*PostfixExpression) Declarator ¶
func (n *PostfixExpression) Declarator() *Declarator
func (*PostfixExpression) Position ¶
func (n *PostfixExpression) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*PostfixExpression) String ¶
func (n *PostfixExpression) String() string
String implements fmt.Stringer.
type PostfixExpressionCase ¶
type PostfixExpressionCase int
PostfixExpressionCase represents case numbers of production PostfixExpression
const ( PostfixExpressionPrimary PostfixExpressionCase = iota PostfixExpressionIndex PostfixExpressionCall PostfixExpressionSelect PostfixExpressionPSelect PostfixExpressionInc PostfixExpressionDec PostfixExpressionComplit PostfixExpressionTypeCmp PostfixExpressionChooseExpr )
Values of type PostfixExpressionCase
func (PostfixExpressionCase) String ¶
func (n PostfixExpressionCase) String() string
String implements fmt.Stringer
type Pragma ¶
type Pragma interface { Error(msg string, args ...interface{}) // Report error. MaxAligment() int // Returns the current maximum alignment. May return zero. MaxInitialAligment() int // Support #pragma pack(). Returns the maximum alignment in effect at start. May return zero. PopMacro(string) PushMacro(string) SetAlignment(n int) // Support #pragma pack(n) }
Pragma defines behavior of the object passed to Config.PragmaHandler.
type PragmaSTDC ¶
PragmaSTDC represents data reduced by production:
PragmaSTDC: "__pragma_stdc" IDENTIFIER IDENTIFIER IDENTIFIER
Example (Case0) ¶
fmt.Println(exampleAST(276, "_Pragma(\"STDC FP_CONTRACT ON\")"))
Output: &cc.PragmaSTDC{ · Token: example.c:1:9: PPPRAGMASTDC "__pragma_stdc", · Token2: example.c:1:9: IDENTIFIER "STDC", · Token3: example.c:1:9: IDENTIFIER "FP_CONTRACT", · Token4: example.c:1:9: IDENTIFIER "ON", }
func (*PragmaSTDC) Position ¶
func (n *PragmaSTDC) Position() (r token.Position)
Position reports the position of the first component of n, if available.
type PrimaryExpression ¶
type PrimaryExpression struct { Operand Operand IsSideEffectsFree bool Case PrimaryExpressionCase `PrettyPrint:"stringer,zero"` CompoundStatement *CompoundStatement Expression *Expression Token Token Token2 Token // contains filtered or unexported fields }
PrimaryExpression represents data reduced by productions:
PrimaryExpression: IDENTIFIER // Case PrimaryExpressionIdent | INTCONST // Case PrimaryExpressionInt | FLOATCONST // Case PrimaryExpressionFloat | ENUMCONST // Case PrimaryExpressionEnum | CHARCONST // Case PrimaryExpressionChar | LONGCHARCONST // Case PrimaryExpressionLChar | STRINGLITERAL // Case PrimaryExpressionString | LONGSTRINGLITERAL // Case PrimaryExpressionLString | '(' Expression ')' // Case PrimaryExpressionExpr | '(' CompoundStatement ')' // Case PrimaryExpressionStmt
Example (Char) ¶
fmt.Println(exampleAST(5, "int i = 'x';"))
Output: &cc.PrimaryExpression{ · Case: PrimaryExpressionChar, · Token: example.c:1:9: CHARCONST "x", }
Example (Enum) ¶
fmt.Println(exampleAST(4, "enum e {a}; int i = a;"))
Output: &cc.PrimaryExpression{ · Case: PrimaryExpressionEnum, · Token: example.c:1:21: ENUMCONST "a", }
Example (Expr) ¶
fmt.Println(exampleAST(9, "int i = (x+y);"))
Output: &cc.PrimaryExpression{ · Case: PrimaryExpressionExpr, · Expression: &cc.Expression{ · · AssignmentExpression: &cc.AssignmentExpression{ · · · Case: AssignmentExpressionCond, · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · Case: ConditionalExpressionLOr, · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · Case: LogicalOrExpressionLAnd, · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · Case: LogicalAndExpressionOr, · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · · Token: example.c:1:10: IDENTIFIER "x", · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · · Case: AdditiveExpressionAdd, · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · Token: example.c:1:12: IDENTIFIER "y", · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · · Token: example.c:1:11: '+' "+", · · · · · · · · · · · · }, · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · · Case: ExpressionAssign, · }, · Token: example.c:1:9: '(' "(", · Token2: example.c:1:13: ')' ")", }
Example (Float) ¶
fmt.Println(exampleAST(3, "int i = 3.14;"))
Output: &cc.PrimaryExpression{ · Case: PrimaryExpressionFloat, · Token: example.c:1:9: FLOATCONST "3.14", }
Example (Ident) ¶
fmt.Println(exampleAST(1, "int i = x;"))
Output: &cc.PrimaryExpression{ · Case: PrimaryExpressionIdent, · Token: example.c:1:9: IDENTIFIER "x", }
Example (Int) ¶
fmt.Println(exampleAST(2, "int i = 42;"))
Output: &cc.PrimaryExpression{ · Case: PrimaryExpressionInt, · Token: example.c:1:9: INTCONST "42", }
Example (LChar) ¶
fmt.Println(exampleAST(6, "int i = L'x';"))
Output: &cc.PrimaryExpression{ · Case: PrimaryExpressionLChar, · Token: example.c:1:9: LONGCHARCONST "x", }
Example (LString) ¶
fmt.Println(exampleAST(8, "char *c = L\"x\";"))
Output: &cc.PrimaryExpression{ · Case: PrimaryExpressionLString, · Token: example.c:1:11: LONGSTRINGLITERAL "x", }
Example (Stmt) ¶
fmt.Println(exampleAST(10, "int i = ({x();});"))
Output: &cc.PrimaryExpression{ · Case: PrimaryExpressionStmt, · CompoundStatement: &cc.CompoundStatement{ · · BlockItemList: &cc.BlockItemList{ · · · BlockItem: &cc.BlockItem{ · · · · Case: BlockItemStmt, · · · · Statement: &cc.Statement{ · · · · · Case: StatementExpr, · · · · · ExpressionStatement: &cc.ExpressionStatement{ · · · · · · Expression: &cc.Expression{ · · · · · · · AssignmentExpression: &cc.AssignmentExpression{ · · · · · · · · Case: AssignmentExpressionCond, · · · · · · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · · · · · · Case: ConditionalExpressionLOr, · · · · · · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · · · · · · Case: LogicalOrExpressionLAnd, · · · · · · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · · · · · · Case: LogicalAndExpressionOr, · · · · · · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · · · · · Case: PostfixExpressionCall, · · · · · · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · · · · · · · Token: example.c:1:11: IDENTIFIER "x", · · · · · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · · · · · Token: example.c:1:12: '(' "(", · · · · · · · · · · · · · · · · · · · · · · Token2: example.c:1:13: ')' ")", · · · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · · Case: ExpressionAssign, · · · · · · }, · · · · · · Token: example.c:1:14: ';' ";", · · · · · }, · · · · }, · · · }, · · }, · · Token: example.c:1:10: '{' "{", · · Token2: example.c:1:15: '}' "}", · }, · Token: example.c:1:9: '(' "(", · Token2: example.c:1:16: ')' ")", }
Example (String) ¶
fmt.Println(exampleAST(7, "char *c = \"x\";"))
Output: &cc.PrimaryExpression{ · Case: PrimaryExpressionString, · Token: example.c:1:11: STRINGLITERAL "x", }
Example (StringLiteral) ¶
fmt.Println(exampleAST(0, "char s[] = \"a\"\n\"b\"\n\"c\";"))
Output: &cc.PrimaryExpression{ · Case: PrimaryExpressionString, · Token: example.c:1:12: STRINGLITERAL "abc", }
func (*PrimaryExpression) Declarator ¶
func (n *PrimaryExpression) Declarator() *Declarator
func (*PrimaryExpression) Position ¶
func (n *PrimaryExpression) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*PrimaryExpression) ResolvedIn ¶
func (n *PrimaryExpression) ResolvedIn() Scope
ResolvedIn reports which scope the identifier of cases PrimaryExpressionIdent, PrimaryExpressionEnum were resolved in, if any.
func (*PrimaryExpression) ResolvedTo ¶ added in v3.25.2
func (n *PrimaryExpression) ResolvedTo() Node
ResolvedTo reports which Node the identifier of cases PrimaryExpressionIdent, PrimaryExpressionEnum resolved to, if any.
func (*PrimaryExpression) String ¶
func (n *PrimaryExpression) String() string
String implements fmt.Stringer.
type PrimaryExpressionCase ¶
type PrimaryExpressionCase int
PrimaryExpressionCase represents case numbers of production PrimaryExpression
const ( PrimaryExpressionIdent PrimaryExpressionCase = iota PrimaryExpressionInt PrimaryExpressionFloat PrimaryExpressionEnum PrimaryExpressionChar PrimaryExpressionLChar PrimaryExpressionString PrimaryExpressionLString PrimaryExpressionExpr PrimaryExpressionStmt )
Values of type PrimaryExpressionCase
func (PrimaryExpressionCase) String ¶
func (n PrimaryExpressionCase) String() string
String implements fmt.Stringer
type RelationalExpression ¶
type RelationalExpression struct { Operand Operand IsSideEffectsFree bool Case RelationalExpressionCase `PrettyPrint:"stringer,zero"` RelationalExpression *RelationalExpression ShiftExpression *ShiftExpression Token Token // contains filtered or unexported fields }
RelationalExpression represents data reduced by productions:
RelationalExpression: ShiftExpression // Case RelationalExpressionShift | RelationalExpression '<' ShiftExpression // Case RelationalExpressionLt | RelationalExpression '>' ShiftExpression // Case RelationalExpressionGt | RelationalExpression "<=" ShiftExpression // Case RelationalExpressionLeq | RelationalExpression ">=" ShiftExpression // Case RelationalExpressionGeq
Example (Geq) ¶
fmt.Println(exampleAST(55, "int i = x >= y;"))
Output: &cc.RelationalExpression{ · Case: RelationalExpressionGeq, · RelationalExpression: &cc.RelationalExpression{ · · Case: RelationalExpressionShift, · · ShiftExpression: &cc.ShiftExpression{ · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · Case: AdditiveExpressionMul, · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · Case: MultiplicativeExpressionCast, · · · · · CastExpression: &cc.CastExpression{ · · · · · · Case: CastExpressionUnary, · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · Token: example.c:1:9: IDENTIFIER "x", · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · · Case: ShiftExpressionAdd, · · }, · }, · ShiftExpression: &cc.ShiftExpression{ · · AdditiveExpression: &cc.AdditiveExpression{ · · · Case: AdditiveExpressionMul, · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · Case: MultiplicativeExpressionCast, · · · · CastExpression: &cc.CastExpression{ · · · · · Case: CastExpressionUnary, · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · Case: UnaryExpressionPostfix, · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · Token: example.c:1:14: IDENTIFIER "y", · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · · Case: ShiftExpressionAdd, · }, · Token: example.c:1:11: GEQ ">=", }
Example (Gt) ¶
fmt.Println(exampleAST(53, "int i = x > y;"))
Output: &cc.RelationalExpression{ · Case: RelationalExpressionGt, · RelationalExpression: &cc.RelationalExpression{ · · Case: RelationalExpressionShift, · · ShiftExpression: &cc.ShiftExpression{ · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · Case: AdditiveExpressionMul, · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · Case: MultiplicativeExpressionCast, · · · · · CastExpression: &cc.CastExpression{ · · · · · · Case: CastExpressionUnary, · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · Token: example.c:1:9: IDENTIFIER "x", · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · · Case: ShiftExpressionAdd, · · }, · }, · ShiftExpression: &cc.ShiftExpression{ · · AdditiveExpression: &cc.AdditiveExpression{ · · · Case: AdditiveExpressionMul, · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · Case: MultiplicativeExpressionCast, · · · · CastExpression: &cc.CastExpression{ · · · · · Case: CastExpressionUnary, · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · Case: UnaryExpressionPostfix, · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · Token: example.c:1:13: IDENTIFIER "y", · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · · Case: ShiftExpressionAdd, · }, · Token: example.c:1:11: '>' ">", }
Example (Leq) ¶
fmt.Println(exampleAST(54, "int i = x <= y;"))
Output: &cc.RelationalExpression{ · Case: RelationalExpressionLeq, · RelationalExpression: &cc.RelationalExpression{ · · Case: RelationalExpressionShift, · · ShiftExpression: &cc.ShiftExpression{ · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · Case: AdditiveExpressionMul, · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · Case: MultiplicativeExpressionCast, · · · · · CastExpression: &cc.CastExpression{ · · · · · · Case: CastExpressionUnary, · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · Token: example.c:1:9: IDENTIFIER "x", · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · · Case: ShiftExpressionAdd, · · }, · }, · ShiftExpression: &cc.ShiftExpression{ · · AdditiveExpression: &cc.AdditiveExpression{ · · · Case: AdditiveExpressionMul, · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · Case: MultiplicativeExpressionCast, · · · · CastExpression: &cc.CastExpression{ · · · · · Case: CastExpressionUnary, · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · Case: UnaryExpressionPostfix, · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · Token: example.c:1:14: IDENTIFIER "y", · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · · Case: ShiftExpressionAdd, · }, · Token: example.c:1:11: LEQ "<=", }
Example (Lt) ¶
fmt.Println(exampleAST(52, "int i = x < y;"))
Output: &cc.RelationalExpression{ · Case: RelationalExpressionLt, · RelationalExpression: &cc.RelationalExpression{ · · Case: RelationalExpressionShift, · · ShiftExpression: &cc.ShiftExpression{ · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · Case: AdditiveExpressionMul, · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · Case: MultiplicativeExpressionCast, · · · · · CastExpression: &cc.CastExpression{ · · · · · · Case: CastExpressionUnary, · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · Token: example.c:1:9: IDENTIFIER "x", · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · · Case: ShiftExpressionAdd, · · }, · }, · ShiftExpression: &cc.ShiftExpression{ · · AdditiveExpression: &cc.AdditiveExpression{ · · · Case: AdditiveExpressionMul, · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · Case: MultiplicativeExpressionCast, · · · · CastExpression: &cc.CastExpression{ · · · · · Case: CastExpressionUnary, · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · Case: UnaryExpressionPostfix, · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · Token: example.c:1:13: IDENTIFIER "y", · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · · Case: ShiftExpressionAdd, · }, · Token: example.c:1:11: '<' "<", }
Example (Shift) ¶
fmt.Println(exampleAST(51, "int i = x;"))
Output: &cc.RelationalExpression{ · Case: RelationalExpressionShift, · ShiftExpression: &cc.ShiftExpression{ · · AdditiveExpression: &cc.AdditiveExpression{ · · · Case: AdditiveExpressionMul, · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · Case: MultiplicativeExpressionCast, · · · · CastExpression: &cc.CastExpression{ · · · · · Case: CastExpressionUnary, · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · Case: UnaryExpressionPostfix, · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · Token: example.c:1:9: IDENTIFIER "x", · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · · Case: ShiftExpressionAdd, · }, }
func (*RelationalExpression) Declarator ¶
func (n *RelationalExpression) Declarator() *Declarator
func (*RelationalExpression) Position ¶
func (n *RelationalExpression) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*RelationalExpression) Promote ¶
func (n *RelationalExpression) Promote() Type
Promote returns the type the operands of the binary operation are promoted to.
func (*RelationalExpression) String ¶
func (n *RelationalExpression) String() string
String implements fmt.Stringer.
type RelationalExpressionCase ¶
type RelationalExpressionCase int
RelationalExpressionCase represents case numbers of production RelationalExpression
const ( RelationalExpressionShift RelationalExpressionCase = iota RelationalExpressionLt RelationalExpressionGt RelationalExpressionLeq RelationalExpressionGeq )
Values of type RelationalExpressionCase
func (RelationalExpressionCase) String ¶
func (n RelationalExpressionCase) String() string
String implements fmt.Stringer
type SelectionStatement ¶
type SelectionStatement struct { Case SelectionStatementCase `PrettyPrint:"stringer,zero"` Expression *Expression Statement *Statement Statement2 *Statement Token Token Token2 Token Token3 Token Token4 Token // contains filtered or unexported fields }
SelectionStatement represents data reduced by productions:
SelectionStatement: "if" '(' Expression ')' Statement // Case SelectionStatementIf | "if" '(' Expression ')' Statement "else" Statement // Case SelectionStatementIfElse | "switch" '(' Expression ')' Statement // Case SelectionStatementSwitch
Example (If) ¶
fmt.Println(exampleAST(230, "int f() { if(x) y(); }"))
Output: &cc.SelectionStatement{ · Case: SelectionStatementIf, · Expression: &cc.Expression{ · · AssignmentExpression: &cc.AssignmentExpression{ · · · Case: AssignmentExpressionCond, · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · Case: ConditionalExpressionLOr, · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · Case: LogicalOrExpressionLAnd, · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · Case: LogicalAndExpressionOr, · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · Token: example.c:1:14: IDENTIFIER "x", · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · · Case: ExpressionAssign, · }, · Statement: &cc.Statement{ · · Case: StatementExpr, · · ExpressionStatement: &cc.ExpressionStatement{ · · · Expression: &cc.Expression{ · · · · AssignmentExpression: &cc.AssignmentExpression{ · · · · · Case: AssignmentExpressionCond, · · · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · · · Case: ConditionalExpressionLOr, · · · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · · · Case: LogicalOrExpressionLAnd, · · · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · · · Case: LogicalAndExpressionOr, · · · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · · Case: PostfixExpressionCall, · · · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · · · · Token: example.c:1:17: IDENTIFIER "y", · · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · · Token: example.c:1:18: '(' "(", · · · · · · · · · · · · · · · · · · · Token2: example.c:1:19: ')' ")", · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · · Case: ExpressionAssign, · · · }, · · · Token: example.c:1:20: ';' ";", · · }, · }, · Token: example.c:1:11: IF "if", · Token2: example.c:1:13: '(' "(", · Token3: example.c:1:15: ')' ")", }
Example (IfElse) ¶
fmt.Println(exampleAST(231, "int f() { if(x) y(); else z(); }"))
Output: &cc.SelectionStatement{ · Case: SelectionStatementIfElse, · Expression: &cc.Expression{ · · AssignmentExpression: &cc.AssignmentExpression{ · · · Case: AssignmentExpressionCond, · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · Case: ConditionalExpressionLOr, · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · Case: LogicalOrExpressionLAnd, · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · Case: LogicalAndExpressionOr, · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · Token: example.c:1:14: IDENTIFIER "x", · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · · Case: ExpressionAssign, · }, · Statement: &cc.Statement{ · · Case: StatementExpr, · · ExpressionStatement: &cc.ExpressionStatement{ · · · Expression: &cc.Expression{ · · · · AssignmentExpression: &cc.AssignmentExpression{ · · · · · Case: AssignmentExpressionCond, · · · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · · · Case: ConditionalExpressionLOr, · · · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · · · Case: LogicalOrExpressionLAnd, · · · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · · · Case: LogicalAndExpressionOr, · · · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · · Case: PostfixExpressionCall, · · · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · · · · Token: example.c:1:17: IDENTIFIER "y", · · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · · Token: example.c:1:18: '(' "(", · · · · · · · · · · · · · · · · · · · Token2: example.c:1:19: ')' ")", · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · · Case: ExpressionAssign, · · · }, · · · Token: example.c:1:20: ';' ";", · · }, · }, · Statement2: &cc.Statement{ · · Case: StatementExpr, · · ExpressionStatement: &cc.ExpressionStatement{ · · · Expression: &cc.Expression{ · · · · AssignmentExpression: &cc.AssignmentExpression{ · · · · · Case: AssignmentExpressionCond, · · · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · · · Case: ConditionalExpressionLOr, · · · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · · · Case: LogicalOrExpressionLAnd, · · · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · · · Case: LogicalAndExpressionOr, · · · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · · Case: PostfixExpressionCall, · · · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · · · · Token: example.c:1:27: IDENTIFIER "z", · · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · · Token: example.c:1:28: '(' "(", · · · · · · · · · · · · · · · · · · · Token2: example.c:1:29: ')' ")", · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · · Case: ExpressionAssign, · · · }, · · · Token: example.c:1:30: ';' ";", · · }, · }, · Token: example.c:1:11: IF "if", · Token2: example.c:1:13: '(' "(", · Token3: example.c:1:15: ')' ")", · Token4: example.c:1:22: ELSE "else", }
Example (Switch) ¶
fmt.Println(exampleAST(232, "int f() { switch(i) case 42: x(); }"))
Output: &cc.SelectionStatement{ · Case: SelectionStatementSwitch, · Expression: &cc.Expression{ · · AssignmentExpression: &cc.AssignmentExpression{ · · · Case: AssignmentExpressionCond, · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · Case: ConditionalExpressionLOr, · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · Case: LogicalOrExpressionLAnd, · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · Case: LogicalAndExpressionOr, · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · Token: example.c:1:18: IDENTIFIER "i", · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · · Case: ExpressionAssign, · }, · Statement: &cc.Statement{ · · Case: StatementLabeled, · · LabeledStatement: &cc.LabeledStatement{ · · · Case: LabeledStatementCaseLabel, · · · ConstantExpression: &cc.ConstantExpression{ · · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · · Case: ConditionalExpressionLOr, · · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · · Case: LogicalOrExpressionLAnd, · · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · · Case: LogicalAndExpressionOr, · · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionInt, · · · · · · · · · · · · · · · · · · · Token: example.c:1:26: INTCONST "42", · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · · Statement: &cc.Statement{ · · · · Case: StatementExpr, · · · · ExpressionStatement: &cc.ExpressionStatement{ · · · · · Expression: &cc.Expression{ · · · · · · AssignmentExpression: &cc.AssignmentExpression{ · · · · · · · Case: AssignmentExpressionCond, · · · · · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · · · · · Case: ConditionalExpressionLOr, · · · · · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · · · · · Case: LogicalOrExpressionLAnd, · · · · · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · · · · · Case: LogicalAndExpressionOr, · · · · · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · · · · Case: PostfixExpressionCall, · · · · · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · · · · · · Token: example.c:1:30: IDENTIFIER "x", · · · · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · · · · Token: example.c:1:31: '(' "(", · · · · · · · · · · · · · · · · · · · · · Token2: example.c:1:32: ')' ")", · · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · · Case: ExpressionAssign, · · · · · }, · · · · · Token: example.c:1:33: ';' ";", · · · · }, · · · }, · · · Token: example.c:1:21: CASE "case", · · · Token2: example.c:1:28: ':' ":", · · }, · }, · Token: example.c:1:11: SWITCH "switch", · Token2: example.c:1:17: '(' "(", · Token3: example.c:1:19: ')' ")", }
func (*SelectionStatement) Cases ¶
func (n *SelectionStatement) Cases() []*LabeledStatement
Cases returns the cases a switch statement consist of, in source order.
func (*SelectionStatement) Position ¶
func (n *SelectionStatement) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*SelectionStatement) Promote ¶
func (n *SelectionStatement) Promote() Type
Promote returns the type the type the switch expression is promoted to.
func (*SelectionStatement) String ¶
func (n *SelectionStatement) String() string
String implements fmt.Stringer.
type SelectionStatementCase ¶
type SelectionStatementCase int
SelectionStatementCase represents case numbers of production SelectionStatement
const ( SelectionStatementIf SelectionStatementCase = iota SelectionStatementIfElse SelectionStatementSwitch )
Values of type SelectionStatementCase
func (SelectionStatementCase) String ¶
func (n SelectionStatementCase) String() string
String implements fmt.Stringer
type SharedFunctionDefinitions ¶ added in v3.27.0
type SharedFunctionDefinitions struct { // contains filtered or unexported fields }
type ShiftExpression ¶
type ShiftExpression struct { Operand Operand IsSideEffectsFree bool AdditiveExpression *AdditiveExpression Case ShiftExpressionCase `PrettyPrint:"stringer,zero"` ShiftExpression *ShiftExpression Token Token // contains filtered or unexported fields }
ShiftExpression represents data reduced by productions:
ShiftExpression: AdditiveExpression // Case ShiftExpressionAdd | ShiftExpression "<<" AdditiveExpression // Case ShiftExpressionLsh | ShiftExpression ">>" AdditiveExpression // Case ShiftExpressionRsh
Example (Add) ¶
fmt.Println(exampleAST(48, "int i = x;"))
Output: &cc.ShiftExpression{ · AdditiveExpression: &cc.AdditiveExpression{ · · Case: AdditiveExpressionMul, · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · Case: MultiplicativeExpressionCast, · · · CastExpression: &cc.CastExpression{ · · · · Case: CastExpressionUnary, · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · Case: UnaryExpressionPostfix, · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · Case: PostfixExpressionPrimary, · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · Token: example.c:1:9: IDENTIFIER "x", · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · }, · Case: ShiftExpressionAdd, }
Example (Lsh) ¶
fmt.Println(exampleAST(49, "int i = x << y;"))
Output: &cc.ShiftExpression{ · AdditiveExpression: &cc.AdditiveExpression{ · · Case: AdditiveExpressionMul, · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · Case: MultiplicativeExpressionCast, · · · CastExpression: &cc.CastExpression{ · · · · Case: CastExpressionUnary, · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · Case: UnaryExpressionPostfix, · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · Case: PostfixExpressionPrimary, · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · Token: example.c:1:14: IDENTIFIER "y", · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · }, · Case: ShiftExpressionLsh, · ShiftExpression: &cc.ShiftExpression{ · · AdditiveExpression: &cc.AdditiveExpression{ · · · Case: AdditiveExpressionMul, · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · Case: MultiplicativeExpressionCast, · · · · CastExpression: &cc.CastExpression{ · · · · · Case: CastExpressionUnary, · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · Case: UnaryExpressionPostfix, · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · Token: example.c:1:9: IDENTIFIER "x", · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · · Case: ShiftExpressionAdd, · }, · Token: example.c:1:11: LSH "<<", }
Example (Rsh) ¶
fmt.Println(exampleAST(50, "int i = x >> y;"))
Output: &cc.ShiftExpression{ · AdditiveExpression: &cc.AdditiveExpression{ · · Case: AdditiveExpressionMul, · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · Case: MultiplicativeExpressionCast, · · · CastExpression: &cc.CastExpression{ · · · · Case: CastExpressionUnary, · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · Case: UnaryExpressionPostfix, · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · Case: PostfixExpressionPrimary, · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · Token: example.c:1:14: IDENTIFIER "y", · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · }, · Case: ShiftExpressionRsh, · ShiftExpression: &cc.ShiftExpression{ · · AdditiveExpression: &cc.AdditiveExpression{ · · · Case: AdditiveExpressionMul, · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · Case: MultiplicativeExpressionCast, · · · · CastExpression: &cc.CastExpression{ · · · · · Case: CastExpressionUnary, · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · Case: UnaryExpressionPostfix, · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · Token: example.c:1:9: IDENTIFIER "x", · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · · Case: ShiftExpressionAdd, · }, · Token: example.c:1:11: RSH ">>", }
func (*ShiftExpression) Declarator ¶
func (n *ShiftExpression) Declarator() *Declarator
func (*ShiftExpression) Position ¶
func (n *ShiftExpression) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*ShiftExpression) Promote ¶
func (n *ShiftExpression) Promote() Type
Promote returns the type the shift count operand is promoted to.
func (*ShiftExpression) String ¶
func (n *ShiftExpression) String() string
String implements fmt.Stringer.
type ShiftExpressionCase ¶
type ShiftExpressionCase int
ShiftExpressionCase represents case numbers of production ShiftExpression
const ( ShiftExpressionAdd ShiftExpressionCase = iota ShiftExpressionLsh ShiftExpressionRsh )
Values of type ShiftExpressionCase
func (ShiftExpressionCase) String ¶
func (n ShiftExpressionCase) String() string
String implements fmt.Stringer
type Source ¶
Source is a named part of a translation unit. If Value is empty, Name is interpreted as a path to file containing the source code.
type SpecifierQualifierList ¶
type SpecifierQualifierList struct { AlignmentSpecifier *AlignmentSpecifier AttributeSpecifier *AttributeSpecifier Case SpecifierQualifierListCase `PrettyPrint:"stringer,zero"` SpecifierQualifierList *SpecifierQualifierList TypeQualifier *TypeQualifier TypeSpecifier *TypeSpecifier // contains filtered or unexported fields }
SpecifierQualifierList represents data reduced by productions:
SpecifierQualifierList: TypeSpecifier SpecifierQualifierList // Case SpecifierQualifierListTypeSpec | TypeQualifier SpecifierQualifierList // Case SpecifierQualifierListTypeQual | AlignmentSpecifier SpecifierQualifierList // Case SpecifierQualifierListAlignSpec | AttributeSpecifier SpecifierQualifierList // Case SpecifierQualifierListAttribute
Example (AlignSpec) ¶
fmt.Println(exampleAST(147, "struct {_Alignas(double) int i;};"))
Output: &cc.SpecifierQualifierList{ · AlignmentSpecifier: &cc.AlignmentSpecifier{ · · Case: AlignmentSpecifierAlignasType, · · Token: example.c:1:9: ALIGNAS "_Alignas", · · Token2: example.c:1:17: '(' "(", · · Token3: example.c:1:24: ')' ")", · · TypeName: &cc.TypeName{ · · · SpecifierQualifierList: &cc.SpecifierQualifierList{ · · · · Case: SpecifierQualifierListTypeSpec, · · · · TypeSpecifier: &cc.TypeSpecifier{ · · · · · Case: TypeSpecifierDouble, · · · · · Token: example.c:1:18: DOUBLE "double", · · · · }, · · · }, · · }, · }, · Case: SpecifierQualifierListAlignSpec, · SpecifierQualifierList: &cc.SpecifierQualifierList{ · · Case: SpecifierQualifierListTypeSpec, · · TypeSpecifier: &cc.TypeSpecifier{ · · · Case: TypeSpecifierInt, · · · Token: example.c:1:26: INT "int", · · }, · }, }
Example (Attribute) ¶
fmt.Println(exampleAST(148, "struct {__attribute__((a)) int i;};"))
Output: &cc.SpecifierQualifierList{ · AttributeSpecifier: &cc.AttributeSpecifier{ · · AttributeValueList: &cc.AttributeValueList{ · · · AttributeValue: &cc.AttributeValue{ · · · · Case: AttributeValueIdent, · · · · Token: example.c:1:24: IDENTIFIER "a", · · · }, · · }, · · Token: example.c:1:9: ATTRIBUTE "__attribute__", · · Token2: example.c:1:22: '(' "(", · · Token3: example.c:1:23: '(' "(", · · Token4: example.c:1:25: ')' ")", · · Token5: example.c:1:26: ')' ")", · }, · Case: SpecifierQualifierListAttribute, · SpecifierQualifierList: &cc.SpecifierQualifierList{ · · Case: SpecifierQualifierListTypeSpec, · · TypeSpecifier: &cc.TypeSpecifier{ · · · Case: TypeSpecifierInt, · · · Token: example.c:1:28: INT "int", · · }, · }, }
Example (TypeQual) ¶
fmt.Println(exampleAST(146, "struct {const int i;};"))
Output: &cc.SpecifierQualifierList{ · Case: SpecifierQualifierListTypeQual, · SpecifierQualifierList: &cc.SpecifierQualifierList{ · · Case: SpecifierQualifierListTypeSpec, · · TypeSpecifier: &cc.TypeSpecifier{ · · · Case: TypeSpecifierInt, · · · Token: example.c:1:15: INT "int", · · }, · }, · TypeQualifier: &cc.TypeQualifier{ · · Case: TypeQualifierConst, · · Token: example.c:1:9: CONST "const", · }, }
Example (TypeSpec) ¶
fmt.Println(exampleAST(145, "struct {int i;};"))
Output: &cc.SpecifierQualifierList{ · Case: SpecifierQualifierListTypeSpec, · TypeSpecifier: &cc.TypeSpecifier{ · · Case: TypeSpecifierInt, · · Token: example.c:1:9: INT "int", · }, }
func (*SpecifierQualifierList) Position ¶
func (n *SpecifierQualifierList) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*SpecifierQualifierList) String ¶
func (n *SpecifierQualifierList) String() string
String implements fmt.Stringer.
type SpecifierQualifierListCase ¶
type SpecifierQualifierListCase int
SpecifierQualifierListCase represents case numbers of production SpecifierQualifierList
const ( SpecifierQualifierListTypeSpec SpecifierQualifierListCase = iota SpecifierQualifierListTypeQual SpecifierQualifierListAlignSpec SpecifierQualifierListAttribute )
Values of type SpecifierQualifierListCase
func (SpecifierQualifierListCase) String ¶
func (n SpecifierQualifierListCase) String() string
String implements fmt.Stringer
type Statement ¶
type Statement struct { Operand Operand // Case CompoundStatement, ExpressionStatement AsmStatement *AsmStatement Case StatementCase `PrettyPrint:"stringer,zero"` CompoundStatement *CompoundStatement ExpressionStatement *ExpressionStatement IterationStatement *IterationStatement JumpStatement *JumpStatement LabeledStatement *LabeledStatement SelectionStatement *SelectionStatement }
Statement represents data reduced by productions:
Statement: LabeledStatement // Case StatementLabeled | CompoundStatement // Case StatementCompound | ExpressionStatement // Case StatementExpr | SelectionStatement // Case StatementSelection | IterationStatement // Case StatementIteration | JumpStatement // Case StatementJump | AsmStatement // Case StatementAsm
Example (Asm) ¶
fmt.Println(exampleAST(216, "int f() { __asm__(\"nop\"); }"))
Output: &cc.Statement{ · AsmStatement: &cc.AsmStatement{ · · Asm: &cc.Asm{ · · · Token: example.c:1:11: ASM "__asm__", · · · Token2: example.c:1:18: '(' "(", · · · Token3: example.c:1:19: STRINGLITERAL "nop", · · · Token4: example.c:1:24: ')' ")", · · }, · · Token: example.c:1:25: ';' ";", · }, · Case: StatementAsm, }
Example (Compound) ¶
fmt.Println(exampleAST(211, "int f() { { y(); } }"))
Output: &cc.Statement{ · Case: StatementCompound, · CompoundStatement: &cc.CompoundStatement{ · · BlockItemList: &cc.BlockItemList{ · · · BlockItem: &cc.BlockItem{ · · · · Case: BlockItemStmt, · · · · Statement: &cc.Statement{ · · · · · Case: StatementExpr, · · · · · ExpressionStatement: &cc.ExpressionStatement{ · · · · · · Expression: &cc.Expression{ · · · · · · · AssignmentExpression: &cc.AssignmentExpression{ · · · · · · · · Case: AssignmentExpressionCond, · · · · · · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · · · · · · Case: ConditionalExpressionLOr, · · · · · · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · · · · · · Case: LogicalOrExpressionLAnd, · · · · · · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · · · · · · Case: LogicalAndExpressionOr, · · · · · · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · · · · · Case: PostfixExpressionCall, · · · · · · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · · · · · · · Token: example.c:1:13: IDENTIFIER "y", · · · · · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · · · · · Token: example.c:1:14: '(' "(", · · · · · · · · · · · · · · · · · · · · · · Token2: example.c:1:15: ')' ")", · · · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · · Case: ExpressionAssign, · · · · · · }, · · · · · · Token: example.c:1:16: ';' ";", · · · · · }, · · · · }, · · · }, · · }, · · Token: example.c:1:11: '{' "{", · · Token2: example.c:1:18: '}' "}", · }, }
Example (Expr) ¶
fmt.Println(exampleAST(212, "int f() { x(); }"))
Output: &cc.Statement{ · Case: StatementExpr, · ExpressionStatement: &cc.ExpressionStatement{ · · Expression: &cc.Expression{ · · · AssignmentExpression: &cc.AssignmentExpression{ · · · · Case: AssignmentExpressionCond, · · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · · Case: ConditionalExpressionLOr, · · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · · Case: LogicalOrExpressionLAnd, · · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · · Case: LogicalAndExpressionOr, · · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · Case: PostfixExpressionCall, · · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · · · Token: example.c:1:11: IDENTIFIER "x", · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · Token: example.c:1:12: '(' "(", · · · · · · · · · · · · · · · · · · Token2: example.c:1:13: ')' ")", · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · · Case: ExpressionAssign, · · }, · · Token: example.c:1:14: ';' ";", · }, }
Example (Iteration) ¶
fmt.Println(exampleAST(214, "int f() { for(;;) x(); }"))
Output: &cc.Statement{ · Case: StatementIteration, · IterationStatement: &cc.IterationStatement{ · · Case: IterationStatementFor, · · Statement: &cc.Statement{ · · · Case: StatementExpr, · · · ExpressionStatement: &cc.ExpressionStatement{ · · · · Expression: &cc.Expression{ · · · · · AssignmentExpression: &cc.AssignmentExpression{ · · · · · · Case: AssignmentExpressionCond, · · · · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · · · · Case: ConditionalExpressionLOr, · · · · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · · · · Case: LogicalOrExpressionLAnd, · · · · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · · · · Case: LogicalAndExpressionOr, · · · · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · · · Case: PostfixExpressionCall, · · · · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · · · · · Token: example.c:1:19: IDENTIFIER "x", · · · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · · · Token: example.c:1:20: '(' "(", · · · · · · · · · · · · · · · · · · · · Token2: example.c:1:21: ')' ")", · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · · Case: ExpressionAssign, · · · · }, · · · · Token: example.c:1:22: ';' ";", · · · }, · · }, · · Token: example.c:1:11: FOR "for", · · Token2: example.c:1:14: '(' "(", · · Token3: example.c:1:15: ';' ";", · · Token4: example.c:1:16: ';' ";", · · Token5: example.c:1:17: ')' ")", · }, }
Example (Jump) ¶
fmt.Println(exampleAST(215, "int f() { return x; }"))
Output: &cc.Statement{ · Case: StatementJump, · JumpStatement: &cc.JumpStatement{ · · Case: JumpStatementReturn, · · Expression: &cc.Expression{ · · · AssignmentExpression: &cc.AssignmentExpression{ · · · · Case: AssignmentExpressionCond, · · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · · Case: ConditionalExpressionLOr, · · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · · Case: LogicalOrExpressionLAnd, · · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · · Case: LogicalAndExpressionOr, · · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · · Token: example.c:1:18: IDENTIFIER "x", · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · · Case: ExpressionAssign, · · }, · · Token: example.c:1:11: RETURN "return", · · Token2: example.c:1:19: ';' ";", · }, }
Example (Labeled) ¶
fmt.Println(exampleAST(210, "int f() { L: x(); }"))
Output: &cc.Statement{ · Case: StatementLabeled, · LabeledStatement: &cc.LabeledStatement{ · · Case: LabeledStatementLabel, · · Statement: &cc.Statement{ · · · Case: StatementExpr, · · · ExpressionStatement: &cc.ExpressionStatement{ · · · · Expression: &cc.Expression{ · · · · · AssignmentExpression: &cc.AssignmentExpression{ · · · · · · Case: AssignmentExpressionCond, · · · · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · · · · Case: ConditionalExpressionLOr, · · · · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · · · · Case: LogicalOrExpressionLAnd, · · · · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · · · · Case: LogicalAndExpressionOr, · · · · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · · · Case: PostfixExpressionCall, · · · · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · · · · · Token: example.c:1:14: IDENTIFIER "x", · · · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · · · Token: example.c:1:15: '(' "(", · · · · · · · · · · · · · · · · · · · · Token2: example.c:1:16: ')' ")", · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · · Case: ExpressionAssign, · · · · }, · · · · Token: example.c:1:17: ';' ";", · · · }, · · }, · · Token: example.c:1:11: IDENTIFIER "L", · · Token2: example.c:1:12: ':' ":", · }, }
Example (Selection) ¶
fmt.Println(exampleAST(213, "int f() { if(x) y(); }"))
Output: &cc.Statement{ · Case: StatementSelection, · SelectionStatement: &cc.SelectionStatement{ · · Case: SelectionStatementIf, · · Expression: &cc.Expression{ · · · AssignmentExpression: &cc.AssignmentExpression{ · · · · Case: AssignmentExpressionCond, · · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · · Case: ConditionalExpressionLOr, · · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · · Case: LogicalOrExpressionLAnd, · · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · · Case: LogicalAndExpressionOr, · · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · · Token: example.c:1:14: IDENTIFIER "x", · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · · Case: ExpressionAssign, · · }, · · Statement: &cc.Statement{ · · · Case: StatementExpr, · · · ExpressionStatement: &cc.ExpressionStatement{ · · · · Expression: &cc.Expression{ · · · · · AssignmentExpression: &cc.AssignmentExpression{ · · · · · · Case: AssignmentExpressionCond, · · · · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · · · · Case: ConditionalExpressionLOr, · · · · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · · · · Case: LogicalOrExpressionLAnd, · · · · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · · · · Case: LogicalAndExpressionOr, · · · · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · · · Case: PostfixExpressionCall, · · · · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · · · · · Token: example.c:1:17: IDENTIFIER "y", · · · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · · · Token: example.c:1:18: '(' "(", · · · · · · · · · · · · · · · · · · · · Token2: example.c:1:19: ')' ")", · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · · Case: ExpressionAssign, · · · · }, · · · · Token: example.c:1:20: ';' ";", · · · }, · · }, · · Token: example.c:1:11: IF "if", · · Token2: example.c:1:13: '(' "(", · · Token3: example.c:1:15: ')' ")", · }, }
type StatementCase ¶
type StatementCase int
StatementCase represents case numbers of production Statement
const ( StatementLabeled StatementCase = iota StatementCompound StatementExpr StatementSelection StatementIteration StatementJump StatementAsm )
Values of type StatementCase
type StorageClass ¶ added in v3.25.2
type StorageClass int
StorageClass determines storage duration.
[0]6.2.4: An object has a storage duration that determines its lifetime. There are three storage durations: Static, Automatic, and Allocated.
const ( Static StorageClass = iota Automatic Allocated )
Values of StorageClass
type StorageClassSpecifier ¶
type StorageClassSpecifier struct { Case StorageClassSpecifierCase `PrettyPrint:"stringer,zero"` Token Token }
StorageClassSpecifier represents data reduced by productions:
StorageClassSpecifier: "typedef" // Case StorageClassSpecifierTypedef | "extern" // Case StorageClassSpecifierExtern | "static" // Case StorageClassSpecifierStatic | "auto" // Case StorageClassSpecifierAuto | "register" // Case StorageClassSpecifierRegister | "_Thread_local" // Case StorageClassSpecifierThreadLocal
Example (Auto) ¶
fmt.Println(exampleAST(100, "auto int i;"))
Output: &cc.StorageClassSpecifier{ · Case: StorageClassSpecifierAuto, · Token: example.c:1:1: AUTO "auto", }
Example (Extern) ¶
fmt.Println(exampleAST(98, "extern int i;"))
Output: &cc.StorageClassSpecifier{ · Case: StorageClassSpecifierExtern, · Token: example.c:1:1: EXTERN "extern", }
Example (Register) ¶
fmt.Println(exampleAST(101, "register int i;"))
Output: &cc.StorageClassSpecifier{ · Case: StorageClassSpecifierRegister, · Token: example.c:1:1: REGISTER "register", }
Example (Static) ¶
fmt.Println(exampleAST(99, "static int i;"))
Output: &cc.StorageClassSpecifier{ · Case: StorageClassSpecifierStatic, · Token: example.c:1:1: STATIC "static", }
Example (ThreadLocal) ¶
fmt.Println(exampleAST(102, "_Thread_local int i;"))
Output: &cc.StorageClassSpecifier{ · Case: StorageClassSpecifierThreadLocal, · Token: example.c:1:1: THREADLOCAL "_Thread_local", }
Example (Typedef) ¶
fmt.Println(exampleAST(97, "typedef int int_t;"))
Output: &cc.StorageClassSpecifier{ · Case: StorageClassSpecifierTypedef, · Token: example.c:1:1: TYPEDEF "typedef", }
func (*StorageClassSpecifier) Position ¶
func (n *StorageClassSpecifier) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*StorageClassSpecifier) String ¶
func (n *StorageClassSpecifier) String() string
String implements fmt.Stringer.
type StorageClassSpecifierCase ¶
type StorageClassSpecifierCase int
StorageClassSpecifierCase represents case numbers of production StorageClassSpecifier
const ( StorageClassSpecifierTypedef StorageClassSpecifierCase = iota StorageClassSpecifierExtern StorageClassSpecifierStatic StorageClassSpecifierAuto StorageClassSpecifierRegister StorageClassSpecifierThreadLocal )
Values of type StorageClassSpecifierCase
func (StorageClassSpecifierCase) String ¶
func (n StorageClassSpecifierCase) String() string
String implements fmt.Stringer
type StringID ¶
type StringID int32
StringID is a process-unique string numeric identifier. Its zero value represents an empty string.
type StringValue ¶
type StringValue StringID
func (StringValue) IsConst ¶ added in v3.33.6
func (v StringValue) IsConst() bool
func (StringValue) IsNonZero ¶ added in v3.33.6
func (v StringValue) IsNonZero() bool
func (StringValue) IsZero ¶ added in v3.33.6
func (v StringValue) IsZero() bool
type StructDeclaration ¶
type StructDeclaration struct { Empty bool // TCC extension SpecifierQualifierList *SpecifierQualifierList StructDeclaratorList *StructDeclaratorList Token Token }
StructDeclaration represents data reduced by production:
StructDeclaration: SpecifierQualifierList StructDeclaratorList ';'
Example (Case0) ¶
fmt.Println(exampleAST(144, "struct{ int i; }"))
Output: &cc.StructDeclaration{ · SpecifierQualifierList: &cc.SpecifierQualifierList{ · · Case: SpecifierQualifierListTypeSpec, · · TypeSpecifier: &cc.TypeSpecifier{ · · · Case: TypeSpecifierInt, · · · Token: example.c:1:9: INT "int", · · }, · }, · StructDeclaratorList: &cc.StructDeclaratorList{ · · StructDeclarator: &cc.StructDeclarator{ · · · Case: StructDeclaratorDecl, · · · Declarator: &cc.Declarator{ · · · · DirectDeclarator: &cc.DirectDeclarator{ · · · · · Case: DirectDeclaratorIdent, · · · · · Token: example.c:1:13: IDENTIFIER "i", · · · · }, · · · }, · · }, · }, · Token: example.c:1:14: ';' ";", }
func (*StructDeclaration) Position ¶
func (n *StructDeclaration) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*StructDeclaration) String ¶
func (n *StructDeclaration) String() string
String implements fmt.Stringer.
type StructDeclarationList ¶
type StructDeclarationList struct { StructDeclaration *StructDeclaration StructDeclarationList *StructDeclarationList }
StructDeclarationList represents data reduced by productions:
StructDeclarationList: StructDeclaration | StructDeclarationList StructDeclaration
Example (Case0) ¶
fmt.Println(exampleAST(142, "struct{ int i; }"))
Output: &cc.StructDeclarationList{ · StructDeclaration: &cc.StructDeclaration{ · · SpecifierQualifierList: &cc.SpecifierQualifierList{ · · · Case: SpecifierQualifierListTypeSpec, · · · TypeSpecifier: &cc.TypeSpecifier{ · · · · Case: TypeSpecifierInt, · · · · Token: example.c:1:9: INT "int", · · · }, · · }, · · StructDeclaratorList: &cc.StructDeclaratorList{ · · · StructDeclarator: &cc.StructDeclarator{ · · · · Case: StructDeclaratorDecl, · · · · Declarator: &cc.Declarator{ · · · · · DirectDeclarator: &cc.DirectDeclarator{ · · · · · · Case: DirectDeclaratorIdent, · · · · · · Token: example.c:1:13: IDENTIFIER "i", · · · · · }, · · · · }, · · · }, · · }, · · Token: example.c:1:14: ';' ";", · }, }
Example (Case1) ¶
fmt.Println(exampleAST(143, "struct{ int i; double d; }"))
Output: &cc.StructDeclarationList{ · StructDeclaration: &cc.StructDeclaration{ · · SpecifierQualifierList: &cc.SpecifierQualifierList{ · · · Case: SpecifierQualifierListTypeSpec, · · · TypeSpecifier: &cc.TypeSpecifier{ · · · · Case: TypeSpecifierInt, · · · · Token: example.c:1:9: INT "int", · · · }, · · }, · · StructDeclaratorList: &cc.StructDeclaratorList{ · · · StructDeclarator: &cc.StructDeclarator{ · · · · Case: StructDeclaratorDecl, · · · · Declarator: &cc.Declarator{ · · · · · DirectDeclarator: &cc.DirectDeclarator{ · · · · · · Case: DirectDeclaratorIdent, · · · · · · Token: example.c:1:13: IDENTIFIER "i", · · · · · }, · · · · }, · · · }, · · }, · · Token: example.c:1:14: ';' ";", · }, · StructDeclarationList: &cc.StructDeclarationList{ · · StructDeclaration: &cc.StructDeclaration{ · · · SpecifierQualifierList: &cc.SpecifierQualifierList{ · · · · Case: SpecifierQualifierListTypeSpec, · · · · TypeSpecifier: &cc.TypeSpecifier{ · · · · · Case: TypeSpecifierDouble, · · · · · Token: example.c:1:16: DOUBLE "double", · · · · }, · · · }, · · · StructDeclaratorList: &cc.StructDeclaratorList{ · · · · StructDeclarator: &cc.StructDeclarator{ · · · · · Case: StructDeclaratorDecl, · · · · · Declarator: &cc.Declarator{ · · · · · · DirectDeclarator: &cc.DirectDeclarator{ · · · · · · · Case: DirectDeclaratorIdent, · · · · · · · Token: example.c:1:23: IDENTIFIER "d", · · · · · · }, · · · · · }, · · · · }, · · · }, · · · Token: example.c:1:24: ';' ";", · · }, · }, }
func (*StructDeclarationList) Position ¶
func (n *StructDeclarationList) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*StructDeclarationList) String ¶
func (n *StructDeclarationList) String() string
String implements fmt.Stringer.
type StructDeclarator ¶
type StructDeclarator struct { AttributeSpecifierList *AttributeSpecifierList Case StructDeclaratorCase `PrettyPrint:"stringer,zero"` ConstantExpression *ConstantExpression Declarator *Declarator Token Token // contains filtered or unexported fields }
StructDeclarator represents data reduced by productions:
StructDeclarator: Declarator // Case StructDeclaratorDecl | Declarator ':' ConstantExpression AttributeSpecifierList // Case StructDeclaratorBitField
Example (BitField) ¶
fmt.Println(exampleAST(152, "struct{ int i:3; }"))
Output: &cc.StructDeclarator{ · Case: StructDeclaratorBitField, · ConstantExpression: &cc.ConstantExpression{ · · ConditionalExpression: &cc.ConditionalExpression{ · · · Case: ConditionalExpressionLOr, · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · Case: LogicalOrExpressionLAnd, · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · Case: LogicalAndExpressionOr, · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · Case: InclusiveOrExpressionXor, · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · Case: AndExpressionEq, · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · Case: PrimaryExpressionInt, · · · · · · · · · · · · · · · · · Token: example.c:1:15: INTCONST "3", · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · }, · Declarator: &cc.Declarator{ · · DirectDeclarator: &cc.DirectDeclarator{ · · · Case: DirectDeclaratorIdent, · · · Token: example.c:1:13: IDENTIFIER "i", · · }, · }, · Token: example.c:1:14: ':' ":", }
Example (Decl) ¶
fmt.Println(exampleAST(151, "struct{ int i; }"))
Output: &cc.StructDeclarator{ · Case: StructDeclaratorDecl, · Declarator: &cc.Declarator{ · · DirectDeclarator: &cc.DirectDeclarator{ · · · Case: DirectDeclaratorIdent, · · · Token: example.c:1:13: IDENTIFIER "i", · · }, · }, }
func (*StructDeclarator) Position ¶
func (n *StructDeclarator) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*StructDeclarator) String ¶
func (n *StructDeclarator) String() string
String implements fmt.Stringer.
func (*StructDeclarator) StructDeclaration ¶ added in v3.25.2
func (n *StructDeclarator) StructDeclaration() *StructDeclaration
StructDeclaration returns the struct declaration associated with n.
type StructDeclaratorCase ¶
type StructDeclaratorCase int
StructDeclaratorCase represents case numbers of production StructDeclarator
const ( StructDeclaratorDecl StructDeclaratorCase = iota StructDeclaratorBitField )
Values of type StructDeclaratorCase
func (StructDeclaratorCase) String ¶
func (n StructDeclaratorCase) String() string
String implements fmt.Stringer
type StructDeclaratorList ¶
type StructDeclaratorList struct { StructDeclarator *StructDeclarator StructDeclaratorList *StructDeclaratorList Token Token }
StructDeclaratorList represents data reduced by productions:
StructDeclaratorList: StructDeclarator | StructDeclaratorList ',' StructDeclarator
Example (Case0) ¶
fmt.Println(exampleAST(149, "struct{ int i; }"))
Output: &cc.StructDeclaratorList{ · StructDeclarator: &cc.StructDeclarator{ · · Case: StructDeclaratorDecl, · · Declarator: &cc.Declarator{ · · · DirectDeclarator: &cc.DirectDeclarator{ · · · · Case: DirectDeclaratorIdent, · · · · Token: example.c:1:13: IDENTIFIER "i", · · · }, · · }, · }, }
Example (Case1) ¶
fmt.Println(exampleAST(150, "struct{ int i, j; }"))
Output: &cc.StructDeclaratorList{ · StructDeclarator: &cc.StructDeclarator{ · · Case: StructDeclaratorDecl, · · Declarator: &cc.Declarator{ · · · DirectDeclarator: &cc.DirectDeclarator{ · · · · Case: DirectDeclaratorIdent, · · · · Token: example.c:1:13: IDENTIFIER "i", · · · }, · · }, · }, · StructDeclaratorList: &cc.StructDeclaratorList{ · · StructDeclarator: &cc.StructDeclarator{ · · · Case: StructDeclaratorDecl, · · · Declarator: &cc.Declarator{ · · · · DirectDeclarator: &cc.DirectDeclarator{ · · · · · Case: DirectDeclaratorIdent, · · · · · Token: example.c:1:16: IDENTIFIER "j", · · · · }, · · · }, · · }, · · Token: example.c:1:14: ',' ",", · }, }
func (*StructDeclaratorList) Position ¶
func (n *StructDeclaratorList) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*StructDeclaratorList) String ¶
func (n *StructDeclaratorList) String() string
String implements fmt.Stringer.
type StructInfo ¶
type StructLayout ¶ added in v3.32.2
type StructLayout struct { Offsets []uintptr // In field order. OffsetToFields map[uintptr][]Field PaddingsBefore map[Field]int PaddingAfter int NeedExplicitAlign bool // contains filtered or unexported fields }
Struct layout describes storage details of a struct/union type.
func NewStructLayout ¶ added in v3.32.2
func NewStructLayout(t Type) *StructLayout
NewStructLayout returns a newly created StructLayout for t, or nil if t is not a struct/union type.
func (*StructLayout) String ¶ added in v3.32.2
func (x *StructLayout) String() string
type StructOrUnion ¶
type StructOrUnion struct { Case StructOrUnionCase `PrettyPrint:"stringer,zero"` Token Token }
StructOrUnion represents data reduced by productions:
StructOrUnion: "struct" // Case StructOrUnionStruct | "union" // Case StructOrUnionUnion
Example (Struct) ¶
fmt.Println(exampleAST(140, "struct { int i; } s;"))
Output: &cc.StructOrUnion{ · Case: StructOrUnionStruct, · Token: example.c:1:1: STRUCT "struct", }
Example (Union) ¶
fmt.Println(exampleAST(141, "union { int i; double d; } u;"))
Output: &cc.StructOrUnion{ · Case: StructOrUnionUnion, · Token: example.c:1:1: UNION "union", }
func (*StructOrUnion) Position ¶
func (n *StructOrUnion) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*StructOrUnion) String ¶
func (n *StructOrUnion) String() string
String implements fmt.Stringer.
type StructOrUnionCase ¶
type StructOrUnionCase int
StructOrUnionCase represents case numbers of production StructOrUnion
const ( StructOrUnionStruct StructOrUnionCase = iota StructOrUnionUnion )
Values of type StructOrUnionCase
func (StructOrUnionCase) String ¶
func (n StructOrUnionCase) String() string
String implements fmt.Stringer
type StructOrUnionSpecifier ¶
type StructOrUnionSpecifier struct { AttributeSpecifierList *AttributeSpecifierList Case StructOrUnionSpecifierCase `PrettyPrint:"stringer,zero"` StructDeclarationList *StructDeclarationList StructOrUnion *StructOrUnion Token Token Token2 Token Token3 Token // contains filtered or unexported fields }
StructOrUnionSpecifier represents data reduced by productions:
StructOrUnionSpecifier: StructOrUnion AttributeSpecifierList IDENTIFIER '{' StructDeclarationList '}' // Case StructOrUnionSpecifierDef | StructOrUnion AttributeSpecifierList IDENTIFIER // Case StructOrUnionSpecifierTag
Example (Def) ¶
fmt.Println(exampleAST(138, "struct s { int i; };"))
Output: &cc.StructOrUnionSpecifier{ · Case: StructOrUnionSpecifierDef, · StructDeclarationList: &cc.StructDeclarationList{ · · StructDeclaration: &cc.StructDeclaration{ · · · SpecifierQualifierList: &cc.SpecifierQualifierList{ · · · · Case: SpecifierQualifierListTypeSpec, · · · · TypeSpecifier: &cc.TypeSpecifier{ · · · · · Case: TypeSpecifierInt, · · · · · Token: example.c:1:12: INT "int", · · · · }, · · · }, · · · StructDeclaratorList: &cc.StructDeclaratorList{ · · · · StructDeclarator: &cc.StructDeclarator{ · · · · · Case: StructDeclaratorDecl, · · · · · Declarator: &cc.Declarator{ · · · · · · DirectDeclarator: &cc.DirectDeclarator{ · · · · · · · Case: DirectDeclaratorIdent, · · · · · · · Token: example.c:1:16: IDENTIFIER "i", · · · · · · }, · · · · · }, · · · · }, · · · }, · · · Token: example.c:1:17: ';' ";", · · }, · }, · StructOrUnion: &cc.StructOrUnion{ · · Case: StructOrUnionStruct, · · Token: example.c:1:1: STRUCT "struct", · }, · Token: example.c:1:8: IDENTIFIER "s", · Token2: example.c:1:10: '{' "{", · Token3: example.c:1:19: '}' "}", }
Example (Tag) ¶
fmt.Println(exampleAST(139, "struct s v;"))
Output: &cc.StructOrUnionSpecifier{ · Case: StructOrUnionSpecifierTag, · StructOrUnion: &cc.StructOrUnion{ · · Case: StructOrUnionStruct, · · Token: example.c:1:1: STRUCT "struct", · }, · Token: example.c:1:8: IDENTIFIER "s", }
func (*StructOrUnionSpecifier) Position ¶
func (n *StructOrUnionSpecifier) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*StructOrUnionSpecifier) String ¶
func (n *StructOrUnionSpecifier) String() string
String implements fmt.Stringer.
func (*StructOrUnionSpecifier) Type ¶
func (n *StructOrUnionSpecifier) Type() Type
type StructOrUnionSpecifierCase ¶
type StructOrUnionSpecifierCase int
StructOrUnionSpecifierCase represents case numbers of production StructOrUnionSpecifier
const ( StructOrUnionSpecifierDef StructOrUnionSpecifierCase = iota StructOrUnionSpecifierTag )
Values of type StructOrUnionSpecifierCase
func (StructOrUnionSpecifierCase) String ¶
func (n StructOrUnionSpecifierCase) String() string
String implements fmt.Stringer
type Token ¶
type Token struct { Rune rune // ';' or IDENTIFIER etc. Sep StringID // If Config3.PreserveWhiteSpace is in effect: All preceding white space combined, including comments. Value StringID // ";" or "foo" etc. Src StringID // contains filtered or unexported fields }
Token is a grammar terminal.
func (*Token) Macro ¶ added in v3.31.0
Macro returns the name of a macro that expanded to this token, if any.
func (Token) Seq ¶
Seq returns t's sequential number.
Comparing positions as in 'before', 'after' is complicated as tokens in a translation unit usually come from more than one source file. Macro expansion further complicates that. The solution is sequentially numbering the tokens as they are finally seen by the parser, so the usual arithmetic '<', '>' operators can be used for that purpose.
type TranslationUnit ¶
type TranslationUnit struct { ExternalDeclaration *ExternalDeclaration TranslationUnit *TranslationUnit }
TranslationUnit represents data reduced by productions:
TranslationUnit: ExternalDeclaration | TranslationUnit ExternalDeclaration
Example (Case0) ¶
fmt.Println(exampleAST(242, "int i;"))
Output: &cc.TranslationUnit{ · ExternalDeclaration: &cc.ExternalDeclaration{ · · Case: ExternalDeclarationDecl, · · Declaration: &cc.Declaration{ · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{ · · · · Case: DeclarationSpecifiersTypeSpec, · · · · TypeSpecifier: &cc.TypeSpecifier{ · · · · · Case: TypeSpecifierInt, · · · · · Token: example.c:1:1: INT "int", · · · · }, · · · }, · · · InitDeclaratorList: &cc.InitDeclaratorList{ · · · · InitDeclarator: &cc.InitDeclarator{ · · · · · Case: InitDeclaratorDecl, · · · · · Declarator: &cc.Declarator{ · · · · · · DirectDeclarator: &cc.DirectDeclarator{ · · · · · · · Case: DirectDeclaratorIdent, · · · · · · · Token: example.c:1:5: IDENTIFIER "i", · · · · · · }, · · · · · }, · · · · }, · · · }, · · · Token: example.c:1:6: ';' ";", · · }, · }, }
Example (Case1) ¶
fmt.Println(exampleAST(243, "int i; int j;"))
Output: &cc.TranslationUnit{ · ExternalDeclaration: &cc.ExternalDeclaration{ · · Case: ExternalDeclarationDecl, · · Declaration: &cc.Declaration{ · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{ · · · · Case: DeclarationSpecifiersTypeSpec, · · · · TypeSpecifier: &cc.TypeSpecifier{ · · · · · Case: TypeSpecifierInt, · · · · · Token: example.c:1:1: INT "int", · · · · }, · · · }, · · · InitDeclaratorList: &cc.InitDeclaratorList{ · · · · InitDeclarator: &cc.InitDeclarator{ · · · · · Case: InitDeclaratorDecl, · · · · · Declarator: &cc.Declarator{ · · · · · · DirectDeclarator: &cc.DirectDeclarator{ · · · · · · · Case: DirectDeclaratorIdent, · · · · · · · Token: example.c:1:5: IDENTIFIER "i", · · · · · · }, · · · · · }, · · · · }, · · · }, · · · Token: example.c:1:6: ';' ";", · · }, · }, · TranslationUnit: &cc.TranslationUnit{ · · ExternalDeclaration: &cc.ExternalDeclaration{ · · · Case: ExternalDeclarationDecl, · · · Declaration: &cc.Declaration{ · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{ · · · · · Case: DeclarationSpecifiersTypeSpec, · · · · · TypeSpecifier: &cc.TypeSpecifier{ · · · · · · Case: TypeSpecifierInt, · · · · · · Token: example.c:1:8: INT "int", · · · · · }, · · · · }, · · · · InitDeclaratorList: &cc.InitDeclaratorList{ · · · · · InitDeclarator: &cc.InitDeclarator{ · · · · · · Case: InitDeclaratorDecl, · · · · · · Declarator: &cc.Declarator{ · · · · · · · DirectDeclarator: &cc.DirectDeclarator{ · · · · · · · · Case: DirectDeclaratorIdent, · · · · · · · · Token: example.c:1:12: IDENTIFIER "j", · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · · Token: example.c:1:13: ';' ";", · · · }, · · }, · }, }
func (*TranslationUnit) Position ¶
func (n *TranslationUnit) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*TranslationUnit) String ¶
func (n *TranslationUnit) String() string
String implements fmt.Stringer.
type Type ¶
type Type interface { // Alias returns the type this type aliases. Non typedef types return // themselves. Alias() Type // Align returns the alignment in bytes of a value of this type when // allocated in memory. Align() int // Attributes returns type's attributes, if any. Attributes() []*AttributeSpecifier // UnionCommon reports the kind that unifies all union members, if any, // or Invalid. For example // // union { int i; double d; } // // Has no unifying kind and will report kind Invalid, but // // union { int *p; double *p; } // // will report kind Ptr. // // UnionCommon panics if the type's Kind is valid but not Enum. UnionCommon() Kind // Decay returns itself for non array types and the pointer to array // element otherwise. Decay() Type // Elem returns a type's element type. It panics if the type's Kind is // valid but not Array or Ptr. Elem() Type // EnumType returns the undelying integer type of an enumerated type. It // panics if the type's Kind is valid but not Enum. EnumType() Type // BitField returns the associated Field of a type. It panics if the // type IsBitFieldType returns false. BitField() Field // FieldAlign returns the alignment in bytes of a value of this type // when used as a field in a struct. FieldAlign() int // FieldByIndex returns the nested field corresponding to the index // sequence. It is equivalent to calling Field successively for each // index i. It panics if the type's Kind is valid but not Struct or // any complex kind. FieldByIndex(index []int) Field // FieldByName returns the struct field with the given name and a // boolean indicating if the field was found. FieldByName(name StringID) (Field, bool) // FieldByName2 is like FieldByName but additionally returns the // indices that form the path to the field. FieldByName2(name StringID) (Field, []int, bool) // IsAggregate reports whether type is an aggregate type, [0]6.2.5. // // 21) Array and structure types are collectively called aggregate types. // // 37) Note that aggregate type does not include union type because an object // with union type can only contain one member at a time. IsAggregate() bool // IsPacked reports whether type is packed. It panics if the type's // Kind is valid but not Struct or Union. IsPacked() bool // IsIncomplete reports whether type is incomplete. IsIncomplete() bool // IsComplexIntegerType report whether a type is an integer complex // type. IsComplexIntegerType() bool // IsComplexType report whether a type is a complex type. IsComplexType() bool // IsArithmeticType report whether a type is an arithmetic type. IsArithmeticType() bool // IsBitFieldType report whether a type is for a bit field. IsBitFieldType() bool // IsIntegerType report whether a type is an integer type. IsIntegerType() bool // IsRealType report whether a type is a real type. IsRealType() bool // IsScalarType report whether a type is a scalar type. IsScalarType() bool // HasFlexibleMember reports whether a struct has a flexible array // member. It panics if the type's Kind is valid but not Struct or // Union. // // https://en.wikipedia.org/wiki/Flexible_array_member HasFlexibleMember() bool // IsAliasType returns whether a type is an alias name of another type // For eample // // typedef int foo; // foo x; // The type of x reports true from IsAliasType(). IsAliasType() bool // IsAssingmentCompatible reports whether a type can be assigned from rhs. [0], 6.5.16.1. IsAssingmentCompatible(rhs Type) bool // IsCompatible reports whether the two types are compatible. [0], 6.2.7. IsCompatible(Type) bool // IsCompatibleLayout reports whether the two types have identical layouts. IsCompatibleLayout(Type) bool // AliasDeclarator returns the typedef declarator of the alias type. It panics // if the type is not an alias type. AliasDeclarator() *Declarator // IsTaggedType returns whether a type is a tagged reference of a enum, // struct or union type. For example // // struct s { int x; } y; // The type of y reports false from IsTaggedType. // struct s z; // The type of z reports true from IsTaggedType. IsTaggedType() bool // IsVariadic reports whether a function type is variadic. It panics if // the type's Kind is valid but not Function. IsVariadic() bool // IsVLA reports whether array is a variable length array. It panics if // the type's Kind is valid but not Array. IsVLA() bool // Kind returns the specific kind of this type. Kind() Kind // Len returns an array type's length for array types and vector size // for vector types. It panics if the type's Kind is valid but not // Array or Vector. Len() uintptr // LenExpr returns an array type's length expression. It panics if the // type's Kind is valid but not Array or the array is not a VLA. LenExpr() *AssignmentExpression // NumField returns a struct type's field count. It panics if the // type's Kind is valid but not Struct or any complex kind. NumField() int // Parameters returns the parameters of a function type. It panics if // the type's Kind is valid but not Function. Parameters() []*Parameter // Real returns the real field of a type. It panics if the type's Kind // is valid but not a complex kind. Real() Field // Imag returns the imaginary field of a type. It panics if the type's // Kind is valid but not a complex kind. Imag() Field // Result returns the result type of a function type. It panics if the // type's Kind is valid but not Function. Result() Type // Size returns the number of bytes needed to store a value of the // given type. It panics if type is valid but incomplete. Size() uintptr // String implements fmt.Stringer. String() string // Tag returns the tag, of a tagged type or of a struct or union type. // Tag panics if the type is not tagged type or a struct or union type. Tag() StringID // Name returns type name, if any. Name() StringID // IsAtomic reports whether type has type qualifier "_Atomic". IsAtomic() bool // Inline reports whether type has function specifier "inline". Inline() bool IsSignedType() bool // IsVolatile reports whether type has type qualifier "volatile". IsVolatile() bool // contains filtered or unexported methods }
Type is the representation of a C type.
Not all methods apply to all kinds of types. Restrictions, if any, are noted in the documentation for each method. Use the Kind method to find out the kind of type before calling kind-specific methods. Calling a method inappropriate to the kind of type causes a run-time panic.
Calling a method on a type of kind Invalid yields an undefined result, but does not panic.
type TypeName ¶
type TypeName struct { AbstractDeclarator *AbstractDeclarator SpecifierQualifierList *SpecifierQualifierList // contains filtered or unexported fields }
TypeName represents data reduced by production:
TypeName: SpecifierQualifierList AbstractDeclarator
Example (Case0) ¶
fmt.Println(exampleAST(191, "int i = (int)x;"))
Output: &cc.TypeName{ · SpecifierQualifierList: &cc.SpecifierQualifierList{ · · Case: SpecifierQualifierListTypeSpec, · · TypeSpecifier: &cc.TypeSpecifier{ · · · Case: TypeSpecifierInt, · · · Token: example.c:1:10: INT "int", · · }, · }, }
type TypeQualifier ¶
type TypeQualifier struct { Case TypeQualifierCase `PrettyPrint:"stringer,zero"` Token Token }
TypeQualifier represents data reduced by productions:
TypeQualifier: "const" // Case TypeQualifierConst | "restrict" // Case TypeQualifierRestrict | "volatile" // Case TypeQualifierVolatile | "_Atomic" // Case TypeQualifierAtomic
Example (Atomic) ¶
fmt.Println(exampleAST(163, "_Atomic int i;"))
Output: &cc.TypeQualifier{ · Case: TypeQualifierAtomic, · Token: example.c:1:1: ATOMIC "_Atomic", }
Example (Const) ¶
fmt.Println(exampleAST(160, "const int i;"))
Output: &cc.TypeQualifier{ · Case: TypeQualifierConst, · Token: example.c:1:1: CONST "const", }
Example (Restrict) ¶
fmt.Println(exampleAST(161, "restrict int i;"))
Output: &cc.TypeQualifier{ · Case: TypeQualifierRestrict, · Token: example.c:1:1: RESTRICT "restrict", }
Example (Volatile) ¶
fmt.Println(exampleAST(162, "volatile int i;"))
Output: &cc.TypeQualifier{ · Case: TypeQualifierVolatile, · Token: example.c:1:1: VOLATILE "volatile", }
func (*TypeQualifier) Position ¶
func (n *TypeQualifier) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*TypeQualifier) String ¶
func (n *TypeQualifier) String() string
String implements fmt.Stringer.
type TypeQualifierCase ¶
type TypeQualifierCase int
TypeQualifierCase represents case numbers of production TypeQualifier
const ( TypeQualifierConst TypeQualifierCase = iota TypeQualifierRestrict TypeQualifierVolatile TypeQualifierAtomic )
Values of type TypeQualifierCase
func (TypeQualifierCase) String ¶
func (n TypeQualifierCase) String() string
String implements fmt.Stringer
type TypeQualifiers ¶
type TypeQualifiers struct { AttributeSpecifier *AttributeSpecifier Case TypeQualifiersCase `PrettyPrint:"stringer,zero"` TypeQualifier *TypeQualifier TypeQualifiers *TypeQualifiers // contains filtered or unexported fields }
TypeQualifiers represents data reduced by productions:
TypeQualifiers: TypeQualifier // Case TypeQualifiersTypeQual | AttributeSpecifier // Case TypeQualifiersAttribute | TypeQualifiers TypeQualifier // Case 2 | TypeQualifiers AttributeSpecifier // Case 3
Example (Attribute) ¶
fmt.Println(exampleAST(180, "int * __attribute__((a)) i;"))
Output: &cc.TypeQualifiers{ · AttributeSpecifier: &cc.AttributeSpecifier{ · · AttributeValueList: &cc.AttributeValueList{ · · · AttributeValue: &cc.AttributeValue{ · · · · Case: AttributeValueIdent, · · · · Token: example.c:1:22: IDENTIFIER "a", · · · }, · · }, · · Token: example.c:1:7: ATTRIBUTE "__attribute__", · · Token2: example.c:1:20: '(' "(", · · Token3: example.c:1:21: '(' "(", · · Token4: example.c:1:23: ')' ")", · · Token5: example.c:1:24: ')' ")", · }, · Case: TypeQualifiersAttribute, }
Example (Case2) ¶
fmt.Println(exampleAST(181, "int * const volatile i;"))
Output: &cc.TypeQualifiers{ · Case: TypeQualifiersTypeQual, · TypeQualifier: &cc.TypeQualifier{ · · Case: TypeQualifierConst, · · Token: example.c:1:7: CONST "const", · }, · TypeQualifiers: &cc.TypeQualifiers{ · · Case: TypeQualifiersTypeQual, · · TypeQualifier: &cc.TypeQualifier{ · · · Case: TypeQualifierVolatile, · · · Token: example.c:1:13: VOLATILE "volatile", · · }, · }, }
Example (Case3) ¶
fmt.Println(exampleAST(182, "int * __attribute__((a)) __attribute__((b)) i;"))
Output: &cc.TypeQualifiers{ · AttributeSpecifier: &cc.AttributeSpecifier{ · · AttributeValueList: &cc.AttributeValueList{ · · · AttributeValue: &cc.AttributeValue{ · · · · Case: AttributeValueIdent, · · · · Token: example.c:1:22: IDENTIFIER "a", · · · }, · · }, · · Token: example.c:1:7: ATTRIBUTE "__attribute__", · · Token2: example.c:1:20: '(' "(", · · Token3: example.c:1:21: '(' "(", · · Token4: example.c:1:23: ')' ")", · · Token5: example.c:1:24: ')' ")", · }, · Case: TypeQualifiersAttribute, · TypeQualifiers: &cc.TypeQualifiers{ · · AttributeSpecifier: &cc.AttributeSpecifier{ · · · AttributeValueList: &cc.AttributeValueList{ · · · · AttributeValue: &cc.AttributeValue{ · · · · · Case: AttributeValueIdent, · · · · · Token: example.c:1:41: IDENTIFIER "b", · · · · }, · · · }, · · · Token: example.c:1:26: ATTRIBUTE "__attribute__", · · · Token2: example.c:1:39: '(' "(", · · · Token3: example.c:1:40: '(' "(", · · · Token4: example.c:1:42: ')' ")", · · · Token5: example.c:1:43: ')' ")", · · }, · · Case: TypeQualifiersAttribute, · }, }
Example (TypeQual) ¶
fmt.Println(exampleAST(179, "int * const i;"))
Output: &cc.TypeQualifiers{ · Case: TypeQualifiersTypeQual, · TypeQualifier: &cc.TypeQualifier{ · · Case: TypeQualifierConst, · · Token: example.c:1:7: CONST "const", · }, }
func (*TypeQualifiers) Position ¶
func (n *TypeQualifiers) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*TypeQualifiers) String ¶
func (n *TypeQualifiers) String() string
String implements fmt.Stringer.
type TypeQualifiersCase ¶
type TypeQualifiersCase int
TypeQualifiersCase represents case numbers of production TypeQualifiers
const ( TypeQualifiersTypeQual TypeQualifiersCase = iota TypeQualifiersAttribute )
Values of type TypeQualifiersCase
func (TypeQualifiersCase) String ¶
func (n TypeQualifiersCase) String() string
String implements fmt.Stringer
type TypeSpecifier ¶
type TypeSpecifier struct { AtomicTypeSpecifier *AtomicTypeSpecifier Case TypeSpecifierCase `PrettyPrint:"stringer,zero"` EnumSpecifier *EnumSpecifier Expression *Expression StructOrUnionSpecifier *StructOrUnionSpecifier Token Token Token2 Token Token3 Token TypeName *TypeName // contains filtered or unexported fields }
TypeSpecifier represents data reduced by productions:
TypeSpecifier: "void" // Case TypeSpecifierVoid | "char" // Case TypeSpecifierChar | "short" // Case TypeSpecifierShort | "int" // Case TypeSpecifierInt | "__int8" // Case TypeSpecifierInt8 | "__int16" // Case TypeSpecifierInt16 | "__int32" // Case TypeSpecifierInt32 | "__int64" // Case TypeSpecifierInt64 | "__int128" // Case TypeSpecifierInt128 | "long" // Case TypeSpecifierLong | "float" // Case TypeSpecifierFloat | "__fp16" // Case TypeSpecifierFloat16 | "_Decimal32" // Case TypeSpecifierDecimal32 | "_Decimal64" // Case TypeSpecifierDecimal64 | "_Decimal128" // Case TypeSpecifierDecimal128 | "_Float128" // Case TypeSpecifierFloat128 | "__float80" // Case TypeSpecifierFloat80 | "double" // Case TypeSpecifierDouble | "signed" // Case TypeSpecifierSigned | "unsigned" // Case TypeSpecifierUnsigned | "_Bool" // Case TypeSpecifierBool | "_Complex" // Case TypeSpecifierComplex | StructOrUnionSpecifier // Case TypeSpecifierStructOrUnion | EnumSpecifier // Case TypeSpecifierEnum | TYPEDEFNAME // Case TypeSpecifierTypedefName | "typeof" '(' Expression ')' // Case TypeSpecifierTypeofExpr | "typeof" '(' TypeName ')' // Case TypeSpecifierTypeofType | AtomicTypeSpecifier // Case TypeSpecifierAtomic | "_Fract" // Case TypeSpecifierFract | "_Sat" // Case TypeSpecifierSat | "_Accum" // Case TypeSpecifierAccum | "_Float32" // Case TypeSpecifierFloat32 | "_Float64" // Case TypeSpecifierFloat64 | "_Float32x" // Case TypeSpecifierFloat32x | "_Float64x" // Case TypeSpecifierFloat64x
Example (Accum) ¶
fmt.Println(exampleAST(133, "_Accum i;"))
Output: &cc.TypeSpecifier{ · Case: TypeSpecifierAccum, · Token: example.c:1:1: ACCUM "_Accum", }
Example (Atomic) ¶
fmt.Println(exampleAST(130, "_Atomic(int) i;"))
Output: &cc.TypeSpecifier{ · AtomicTypeSpecifier: &cc.AtomicTypeSpecifier{ · · Token: example.c:1:1: ATOMIC "_Atomic", · · Token2: example.c:1:8: '(' "(", · · Token3: example.c:1:12: ')' ")", · · TypeName: &cc.TypeName{ · · · SpecifierQualifierList: &cc.SpecifierQualifierList{ · · · · Case: SpecifierQualifierListTypeSpec, · · · · TypeSpecifier: &cc.TypeSpecifier{ · · · · · Case: TypeSpecifierInt, · · · · · Token: example.c:1:9: INT "int", · · · · }, · · · }, · · }, · }, · Case: TypeSpecifierAtomic, }
Example (Bool) ¶
fmt.Println(exampleAST(123, "_Bool i;"))
Output: &cc.TypeSpecifier{ · Case: TypeSpecifierBool, · Token: example.c:1:1: BOOL "_Bool", }
Example (Char) ¶
fmt.Println(exampleAST(104, "char i;"))
Output: &cc.TypeSpecifier{ · Case: TypeSpecifierChar, · Token: example.c:1:1: CHAR "char", }
Example (Complex) ¶
fmt.Println(exampleAST(124, "_Complex i;"))
Output: &cc.TypeSpecifier{ · Case: TypeSpecifierComplex, · Token: example.c:1:1: COMPLEX "_Complex", }
Example (Decimal128) ¶
fmt.Println(exampleAST(117, "_Decimal128 i;"))
Output: &cc.TypeSpecifier{ · Case: TypeSpecifierDecimal128, · Token: example.c:1:1: DECIMAL128 "_Decimal128", }
Example (Decimal32) ¶
fmt.Println(exampleAST(115, "_Decimal32 i;"))
Output: &cc.TypeSpecifier{ · Case: TypeSpecifierDecimal32, · Token: example.c:1:1: DECIMAL32 "_Decimal32", }
Example (Decimal64) ¶
fmt.Println(exampleAST(116, "_Decimal64 i;"))
Output: &cc.TypeSpecifier{ · Case: TypeSpecifierDecimal64, · Token: example.c:1:1: DECIMAL64 "_Decimal64", }
Example (Double) ¶
fmt.Println(exampleAST(120, "double i;"))
Output: &cc.TypeSpecifier{ · Case: TypeSpecifierDouble, · Token: example.c:1:1: DOUBLE "double", }
Example (Enum) ¶
fmt.Println(exampleAST(126, "enum e i;"))
Output: &cc.TypeSpecifier{ · Case: TypeSpecifierEnum, · EnumSpecifier: &cc.EnumSpecifier{ · · Case: EnumSpecifierTag, · · Token: example.c:1:1: ENUM "enum", · · Token2: example.c:1:6: IDENTIFIER "e", · }, }
Example (Float) ¶
fmt.Println(exampleAST(113, "float i;"))
Output: &cc.TypeSpecifier{ · Case: TypeSpecifierFloat, · Token: example.c:1:1: FLOAT "float", }
Example (Float128) ¶
fmt.Println(exampleAST(118, "_Float128 i;"))
Output: &cc.TypeSpecifier{ · Case: TypeSpecifierFloat128, · Token: example.c:1:1: FLOAT128 "_Float128", }
Example (Float16) ¶
fmt.Println(exampleAST(114, "__fp16 i;"))
Output: &cc.TypeSpecifier{ · Case: TypeSpecifierFloat16, · Token: example.c:1:1: FLOAT16 "__fp16", }
Example (Float32) ¶
fmt.Println(exampleAST(134, "_Float32 i;"))
Output: &cc.TypeSpecifier{ · Case: TypeSpecifierFloat32, · Token: example.c:1:1: FLOAT32 "_Float32", }
Example (Float32x) ¶
fmt.Println(exampleAST(136, "_Float32x i;"))
Output: &cc.TypeSpecifier{ · Case: TypeSpecifierFloat32x, · Token: example.c:1:1: FLOAT32X "_Float32x", }
Example (Float64) ¶
fmt.Println(exampleAST(135, "_Float64 i;"))
Output: &cc.TypeSpecifier{ · Case: TypeSpecifierFloat64, · Token: example.c:1:1: FLOAT64 "_Float64", }
Example (Float64x) ¶
fmt.Println(exampleAST(137, "_Float64x i;"))
Output: &cc.TypeSpecifier{ · Case: TypeSpecifierFloat64x, · Token: example.c:1:1: FLOAT64X "_Float64x", }
Example (Float80) ¶
fmt.Println(exampleAST(119, "__float80 i;"))
Output: &cc.TypeSpecifier{ · Case: TypeSpecifierFloat80, · Token: example.c:1:1: FLOAT80 "__float80", }
Example (Fract) ¶
fmt.Println(exampleAST(131, "_Fract i;"))
Output: &cc.TypeSpecifier{ · Case: TypeSpecifierFract, · Token: example.c:1:1: FRACT "_Fract", }
Example (Int) ¶
fmt.Println(exampleAST(106, "int i;"))
Output: &cc.TypeSpecifier{ · Case: TypeSpecifierInt, · Token: example.c:1:1: INT "int", }
Example (Int128) ¶
fmt.Println(exampleAST(111, "__int128 i;"))
Output: &cc.TypeSpecifier{ · Case: TypeSpecifierInt128, · Token: example.c:1:1: INT128 "__int128", }
Example (Int16) ¶
fmt.Println(exampleAST(108, "__int16 i;"))
Output: &cc.TypeSpecifier{ · Case: TypeSpecifierInt16, · Token: example.c:1:1: INT16 "__int16", }
Example (Int32) ¶
fmt.Println(exampleAST(109, "__int32 i;"))
Output: &cc.TypeSpecifier{ · Case: TypeSpecifierInt32, · Token: example.c:1:1: INT32 "__int32", }
Example (Int64) ¶
fmt.Println(exampleAST(110, "__int64 i;"))
Output: &cc.TypeSpecifier{ · Case: TypeSpecifierInt64, · Token: example.c:1:1: INT64 "__int64", }
Example (Int8) ¶
fmt.Println(exampleAST(107, "__int8 i;"))
Output: &cc.TypeSpecifier{ · Case: TypeSpecifierInt8, · Token: example.c:1:1: INT8 "__int8", }
Example (Long) ¶
fmt.Println(exampleAST(112, "long i;"))
Output: &cc.TypeSpecifier{ · Case: TypeSpecifierLong, · Token: example.c:1:1: LONG "long", }
Example (Sat) ¶
fmt.Println(exampleAST(132, "_Sat i;"))
Output: &cc.TypeSpecifier{ · Case: TypeSpecifierSat, · Token: example.c:1:1: SAT "_Sat", }
Example (Short) ¶
fmt.Println(exampleAST(105, "short i;"))
Output: &cc.TypeSpecifier{ · Case: TypeSpecifierShort, · Token: example.c:1:1: SHORT "short", }
Example (Signed) ¶
fmt.Println(exampleAST(121, "signed i;"))
Output: &cc.TypeSpecifier{ · Case: TypeSpecifierSigned, · Token: example.c:1:1: SIGNED "signed", }
Example (StructOrUnion) ¶
fmt.Println(exampleAST(125, "struct s i;"))
Output: &cc.TypeSpecifier{ · Case: TypeSpecifierStructOrUnion, · StructOrUnionSpecifier: &cc.StructOrUnionSpecifier{ · · Case: StructOrUnionSpecifierTag, · · StructOrUnion: &cc.StructOrUnion{ · · · Case: StructOrUnionStruct, · · · Token: example.c:1:1: STRUCT "struct", · · }, · · Token: example.c:1:8: IDENTIFIER "s", · }, }
Example (TypedefName) ¶
fmt.Println(exampleAST(127, "typedef const T; T i;"))
Output: &cc.TypeSpecifier{ · Case: TypeSpecifierTypedefName, · Token: example.c:1:18: TYPEDEFNAME "T", }
Example (TypeofExpr) ¶
fmt.Println(exampleAST(128, "typeof(42) i;"))
Output: &cc.TypeSpecifier{ · Case: TypeSpecifierTypeofExpr, · Expression: &cc.Expression{ · · AssignmentExpression: &cc.AssignmentExpression{ · · · Case: AssignmentExpressionCond, · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · Case: ConditionalExpressionLOr, · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · Case: LogicalOrExpressionLAnd, · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · Case: LogicalAndExpressionOr, · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionInt, · · · · · · · · · · · · · · · · · · Token: example.c:1:8: INTCONST "42", · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · }, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · }, · · · · · · }, · · · · · }, · · · · }, · · · }, · · }, · · Case: ExpressionAssign, · }, · Token: example.c:1:1: TYPEOF "typeof", · Token2: example.c:1:7: '(' "(", · Token3: example.c:1:10: ')' ")", }
Example (TypeofType) ¶
fmt.Println(exampleAST(129, "typedef const T; typeof(T) i;"))
Output: &cc.TypeSpecifier{ · Case: TypeSpecifierTypeofType, · Token: example.c:1:18: TYPEOF "typeof", · Token2: example.c:1:24: '(' "(", · Token3: example.c:1:26: ')' ")", · TypeName: &cc.TypeName{ · · SpecifierQualifierList: &cc.SpecifierQualifierList{ · · · Case: SpecifierQualifierListTypeSpec, · · · TypeSpecifier: &cc.TypeSpecifier{ · · · · Case: TypeSpecifierTypedefName, · · · · Token: example.c:1:25: TYPEDEFNAME "T", · · · }, · · }, · }, }
Example (Unsigned) ¶
fmt.Println(exampleAST(122, "unsigned i;"))
Output: &cc.TypeSpecifier{ · Case: TypeSpecifierUnsigned, · Token: example.c:1:1: UNSIGNED "unsigned", }
Example (Void) ¶
fmt.Println(exampleAST(103, "void i();"))
Output: &cc.TypeSpecifier{ · Case: TypeSpecifierVoid, · Token: example.c:1:1: VOID "void", }
func (*TypeSpecifier) Position ¶
func (n *TypeSpecifier) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*TypeSpecifier) String ¶
func (n *TypeSpecifier) String() string
String implements fmt.Stringer.
type TypeSpecifierCase ¶
type TypeSpecifierCase int
TypeSpecifierCase represents case numbers of production TypeSpecifier
const ( TypeSpecifierVoid TypeSpecifierCase = iota TypeSpecifierChar TypeSpecifierShort TypeSpecifierInt TypeSpecifierInt8 TypeSpecifierInt16 TypeSpecifierInt32 TypeSpecifierInt64 TypeSpecifierInt128 TypeSpecifierLong TypeSpecifierFloat TypeSpecifierFloat16 TypeSpecifierDecimal32 TypeSpecifierDecimal64 TypeSpecifierDecimal128 TypeSpecifierFloat128 TypeSpecifierFloat80 TypeSpecifierDouble TypeSpecifierSigned TypeSpecifierUnsigned TypeSpecifierBool TypeSpecifierComplex TypeSpecifierStructOrUnion TypeSpecifierEnum TypeSpecifierTypedefName TypeSpecifierTypeofExpr TypeSpecifierTypeofType TypeSpecifierAtomic TypeSpecifierFract TypeSpecifierSat TypeSpecifierAccum TypeSpecifierFloat32 TypeSpecifierFloat64 TypeSpecifierFloat32x TypeSpecifierFloat64x )
Values of type TypeSpecifierCase
func (TypeSpecifierCase) String ¶
func (n TypeSpecifierCase) String() string
String implements fmt.Stringer
type Uint64Value ¶
type Uint64Value uint64
func (Uint64Value) IsConst ¶ added in v3.33.6
func (v Uint64Value) IsConst() bool
func (Uint64Value) IsNonZero ¶ added in v3.33.6
func (v Uint64Value) IsNonZero() bool
func (Uint64Value) IsZero ¶ added in v3.33.6
func (v Uint64Value) IsZero() bool
type UnaryExpression ¶
type UnaryExpression struct { Operand Operand IsSideEffectsFree bool Case UnaryExpressionCase `PrettyPrint:"stringer,zero"` CastExpression *CastExpression PostfixExpression *PostfixExpression Token Token Token2 Token Token3 Token TypeName *TypeName UnaryExpression *UnaryExpression // contains filtered or unexported fields }
UnaryExpression represents data reduced by productions:
UnaryExpression: PostfixExpression // Case UnaryExpressionPostfix | "++" UnaryExpression // Case UnaryExpressionInc | "--" UnaryExpression // Case UnaryExpressionDec | '&' CastExpression // Case UnaryExpressionAddrof | '*' CastExpression // Case UnaryExpressionDeref | '+' CastExpression // Case UnaryExpressionPlus | '-' CastExpression // Case UnaryExpressionMinus | '~' CastExpression // Case UnaryExpressionCpl | '!' CastExpression // Case UnaryExpressionNot | "sizeof" UnaryExpression // Case UnaryExpressionSizeofExpr | "sizeof" '(' TypeName ')' // Case UnaryExpressionSizeofType | "&&" IDENTIFIER // Case UnaryExpressionLabelAddr | "_Alignof" UnaryExpression // Case UnaryExpressionAlignofExpr | "_Alignof" '(' TypeName ')' // Case UnaryExpressionAlignofType | "__imag__" UnaryExpression // Case UnaryExpressionImag | "__real__" UnaryExpression // Case UnaryExpressionReal
Example (Addrof) ¶
fmt.Println(exampleAST(26, "int *i = &x;"))
Output: &cc.UnaryExpression{ · Case: UnaryExpressionAddrof, · CastExpression: &cc.CastExpression{ · · Case: CastExpressionUnary, · · UnaryExpression: &cc.UnaryExpression{ · · · Case: UnaryExpressionPostfix, · · · PostfixExpression: &cc.PostfixExpression{ · · · · Case: PostfixExpressionPrimary, · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · Case: PrimaryExpressionIdent, · · · · · Token: example.c:1:11: IDENTIFIER "x", · · · · }, · · · }, · · }, · }, · Token: example.c:1:10: '&' "&", }
Example (AlignofExpr) ¶
fmt.Println(exampleAST(35, "int i = _Alignof(x);"))
Output: &cc.UnaryExpression{ · Case: UnaryExpressionAlignofExpr, · Token: example.c:1:9: ALIGNOF "_Alignof", · UnaryExpression: &cc.UnaryExpression{ · · Case: UnaryExpressionPostfix, · · PostfixExpression: &cc.PostfixExpression{ · · · Case: PostfixExpressionPrimary, · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · Case: PrimaryExpressionExpr, · · · · Expression: &cc.Expression{ · · · · · AssignmentExpression: &cc.AssignmentExpression{ · · · · · · Case: AssignmentExpressionCond, · · · · · · ConditionalExpression: &cc.ConditionalExpression{ · · · · · · · Case: ConditionalExpressionLOr, · · · · · · · LogicalOrExpression: &cc.LogicalOrExpression{ · · · · · · · · Case: LogicalOrExpressionLAnd, · · · · · · · · LogicalAndExpression: &cc.LogicalAndExpression{ · · · · · · · · · Case: LogicalAndExpressionOr, · · · · · · · · · InclusiveOrExpression: &cc.InclusiveOrExpression{ · · · · · · · · · · Case: InclusiveOrExpressionXor, · · · · · · · · · · ExclusiveOrExpression: &cc.ExclusiveOrExpression{ · · · · · · · · · · · AndExpression: &cc.AndExpression{ · · · · · · · · · · · · Case: AndExpressionEq, · · · · · · · · · · · · EqualityExpression: &cc.EqualityExpression{ · · · · · · · · · · · · · Case: EqualityExpressionRel, · · · · · · · · · · · · · RelationalExpression: &cc.RelationalExpression{ · · · · · · · · · · · · · · Case: RelationalExpressionShift, · · · · · · · · · · · · · · ShiftExpression: &cc.ShiftExpression{ · · · · · · · · · · · · · · · AdditiveExpression: &cc.AdditiveExpression{ · · · · · · · · · · · · · · · · Case: AdditiveExpressionMul, · · · · · · · · · · · · · · · · MultiplicativeExpression: &cc.MultiplicativeExpression{ · · · · · · · · · · · · · · · · · Case: MultiplicativeExpressionCast, · · · · · · · · · · · · · · · · · CastExpression: &cc.CastExpression{ · · · · · · · · · · · · · · · · · · Case: CastExpressionUnary, · · · · · · · · · · · · · · · · · · UnaryExpression: &cc.UnaryExpression{ · · · · · · · · · · · · · · · · · · · Case: UnaryExpressionPostfix, · · · · · · · · · · · · · · · · · · · PostfixExpression: &cc.PostfixExpression{ · · · · · · · · · · · · · · · · · · · · Case: PostfixExpressionPrimary, · · · · · · · · · · · · · · · · · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · · · · · · · · · · · · · · · · · Case: PrimaryExpressionIdent, · · · · · · · · · · · · · · · · · · · · · Token: example.c:1:18: IDENTIFIER "x", · · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · }, · · · · · · · · · · · · · · · Case: ShiftExpressionAdd, · · · · · · · · · · · · · · }, · · · · · · · · · · · · · }, · · · · · · · · · · · · }, · · · · · · · · · · · }, · · · · · · · · · · · Case: ExclusiveOrExpressionAnd, · · · · · · · · · · }, · · · · · · · · · }, · · · · · · · · }, · · · · · · · }, · · · · · · }, · · · · · }, · · · · · Case: ExpressionAssign, · · · · }, · · · · Token: example.c:1:17: '(' "(", · · · · Token2: example.c:1:19: ')' ")", · · · }, · · }, · }, }
Example (AlignofType) ¶
fmt.Println(exampleAST(36, "int i = _Alignof(int);"))
Output: &cc.UnaryExpression{ · Case: UnaryExpressionAlignofType, · Token: example.c:1:9: ALIGNOF "_Alignof", · Token2: example.c:1:17: '(' "(", · Token3: example.c:1:17: '(' "(", · TypeName: &cc.TypeName{ · · SpecifierQualifierList: &cc.SpecifierQualifierList{ · · · Case: SpecifierQualifierListTypeSpec, · · · TypeSpecifier: &cc.TypeSpecifier{ · · · · Case: TypeSpecifierInt, · · · · Token: example.c:1:18: INT "int", · · · }, · · }, · }, }
Example (Cpl) ¶
fmt.Println(exampleAST(30, "int i = ~x;"))
Output: &cc.UnaryExpression{ · Case: UnaryExpressionCpl, · CastExpression: &cc.CastExpression{ · · Case: CastExpressionUnary, · · UnaryExpression: &cc.UnaryExpression{ · · · Case: UnaryExpressionPostfix, · · · PostfixExpression: &cc.PostfixExpression{ · · · · Case: PostfixExpressionPrimary, · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · Case: PrimaryExpressionIdent, · · · · · Token: example.c:1:10: IDENTIFIER "x", · · · · }, · · · }, · · }, · }, · Token: example.c:1:9: '~' "~", }
Example (Dec) ¶
fmt.Println(exampleAST(25, "int i = --x;"))
Output: &cc.UnaryExpression{ · Case: UnaryExpressionDec, · Token: example.c:1:9: DEC "--", · UnaryExpression: &cc.UnaryExpression{ · · Case: UnaryExpressionPostfix, · · PostfixExpression: &cc.PostfixExpression{ · · · Case: PostfixExpressionPrimary, · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · Case: PrimaryExpressionIdent, · · · · Token: example.c:1:11: IDENTIFIER "x", · · · }, · · }, · }, }
Example (Deref) ¶
fmt.Println(exampleAST(27, "int i = *x;"))
Output: &cc.UnaryExpression{ · Case: UnaryExpressionDeref, · CastExpression: &cc.CastExpression{ · · Case: CastExpressionUnary, · · UnaryExpression: &cc.UnaryExpression{ · · · Case: UnaryExpressionPostfix, · · · PostfixExpression: &cc.PostfixExpression{ · · · · Case: PostfixExpressionPrimary, · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · Case: PrimaryExpressionIdent, · · · · · Token: example.c:1:10: IDENTIFIER "x", · · · · }, · · · }, · · }, · }, · Token: example.c:1:9: '*' "*", }
Example (Imag) ¶
fmt.Println(exampleAST(37, "double i = __imag__ x;"))
Output: &cc.UnaryExpression{ · Case: UnaryExpressionImag, · Token: example.c:1:12: IMAG "__imag__", · UnaryExpression: &cc.UnaryExpression{ · · Case: UnaryExpressionPostfix, · · PostfixExpression: &cc.PostfixExpression{ · · · Case: PostfixExpressionPrimary, · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · Case: PrimaryExpressionIdent, · · · · Token: example.c:1:21: IDENTIFIER "x", · · · }, · · }, · }, }
Example (Inc) ¶
fmt.Println(exampleAST(24, "int i = ++x;"))
Output: &cc.UnaryExpression{ · Case: UnaryExpressionInc, · Token: example.c:1:9: INC "++", · UnaryExpression: &cc.UnaryExpression{ · · Case: UnaryExpressionPostfix, · · PostfixExpression: &cc.PostfixExpression{ · · · Case: PostfixExpressionPrimary, · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · Case: PrimaryExpressionIdent, · · · · Token: example.c:1:11: IDENTIFIER "x", · · · }, · · }, · }, }
Example (LabelAddr) ¶
fmt.Println(exampleAST(34, "int f() { L: &&L; }"))
Output: &cc.UnaryExpression{ · Case: UnaryExpressionLabelAddr, · Token: example.c:1:14: ANDAND "&&", · Token2: example.c:1:16: IDENTIFIER "L", }
Example (Minus) ¶
fmt.Println(exampleAST(29, "int i = -x;"))
Output: &cc.UnaryExpression{ · Case: UnaryExpressionMinus, · CastExpression: &cc.CastExpression{ · · Case: CastExpressionUnary, · · UnaryExpression: &cc.UnaryExpression{ · · · Case: UnaryExpressionPostfix, · · · PostfixExpression: &cc.PostfixExpression{ · · · · Case: PostfixExpressionPrimary, · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · Case: PrimaryExpressionIdent, · · · · · Token: example.c:1:10: IDENTIFIER "x", · · · · }, · · · }, · · }, · }, · Token: example.c:1:9: '-' "-", }
Example (Not) ¶
fmt.Println(exampleAST(31, "int i = !x;"))
Output: &cc.UnaryExpression{ · Case: UnaryExpressionNot, · CastExpression: &cc.CastExpression{ · · Case: CastExpressionUnary, · · UnaryExpression: &cc.UnaryExpression{ · · · Case: UnaryExpressionPostfix, · · · PostfixExpression: &cc.PostfixExpression{ · · · · Case: PostfixExpressionPrimary, · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · Case: PrimaryExpressionIdent, · · · · · Token: example.c:1:10: IDENTIFIER "x", · · · · }, · · · }, · · }, · }, · Token: example.c:1:9: '!' "!", }
Example (Plus) ¶
fmt.Println(exampleAST(28, "int i = +x;"))
Output: &cc.UnaryExpression{ · Case: UnaryExpressionPlus, · CastExpression: &cc.CastExpression{ · · Case: CastExpressionUnary, · · UnaryExpression: &cc.UnaryExpression{ · · · Case: UnaryExpressionPostfix, · · · PostfixExpression: &cc.PostfixExpression{ · · · · Case: PostfixExpressionPrimary, · · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · · Case: PrimaryExpressionIdent, · · · · · Token: example.c:1:10: IDENTIFIER "x", · · · · }, · · · }, · · }, · }, · Token: example.c:1:9: '+' "+", }
Example (Postfix) ¶
fmt.Println(exampleAST(23, "int i = x;"))
Output: &cc.UnaryExpression{ · Case: UnaryExpressionPostfix, · PostfixExpression: &cc.PostfixExpression{ · · Case: PostfixExpressionPrimary, · · PrimaryExpression: &cc.PrimaryExpression{ · · · Case: PrimaryExpressionIdent, · · · Token: example.c:1:9: IDENTIFIER "x", · · }, · }, }
Example (Real) ¶
fmt.Println(exampleAST(38, "double i = __real__ x;"))
Output: &cc.UnaryExpression{ · Case: UnaryExpressionReal, · Token: example.c:1:12: REAL "__real__", · UnaryExpression: &cc.UnaryExpression{ · · Case: UnaryExpressionPostfix, · · PostfixExpression: &cc.PostfixExpression{ · · · Case: PostfixExpressionPrimary, · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · Case: PrimaryExpressionIdent, · · · · Token: example.c:1:21: IDENTIFIER "x", · · · }, · · }, · }, }
Example (SizeofExpr) ¶
fmt.Println(exampleAST(32, "int i = sizeof x;"))
Output: &cc.UnaryExpression{ · Case: UnaryExpressionSizeofExpr, · Token: example.c:1:9: SIZEOF "sizeof", · UnaryExpression: &cc.UnaryExpression{ · · Case: UnaryExpressionPostfix, · · PostfixExpression: &cc.PostfixExpression{ · · · Case: PostfixExpressionPrimary, · · · PrimaryExpression: &cc.PrimaryExpression{ · · · · Case: PrimaryExpressionIdent, · · · · Token: example.c:1:16: IDENTIFIER "x", · · · }, · · }, · }, }
Example (SizeofType) ¶
fmt.Println(exampleAST(33, "int i = sizeof(int);"))
Output: &cc.UnaryExpression{ · Case: UnaryExpressionSizeofType, · Token: example.c:1:9: SIZEOF "sizeof", · Token2: example.c:1:15: '(' "(", · Token3: example.c:1:19: ')' ")", · TypeName: &cc.TypeName{ · · SpecifierQualifierList: &cc.SpecifierQualifierList{ · · · Case: SpecifierQualifierListTypeSpec, · · · TypeSpecifier: &cc.TypeSpecifier{ · · · · Case: TypeSpecifierInt, · · · · Token: example.c:1:16: INT "int", · · · }, · · }, · }, }
func (*UnaryExpression) Declarator ¶
func (n *UnaryExpression) Declarator() *Declarator
func (*UnaryExpression) Position ¶
func (n *UnaryExpression) Position() (r token.Position)
Position reports the position of the first component of n, if available.
func (*UnaryExpression) String ¶
func (n *UnaryExpression) String() string
String implements fmt.Stringer.
type UnaryExpressionCase ¶
type UnaryExpressionCase int
UnaryExpressionCase represents case numbers of production UnaryExpression
const ( UnaryExpressionPostfix UnaryExpressionCase = iota UnaryExpressionInc UnaryExpressionDec UnaryExpressionAddrof UnaryExpressionDeref UnaryExpressionPlus UnaryExpressionMinus UnaryExpressionCpl UnaryExpressionNot UnaryExpressionSizeofExpr UnaryExpressionSizeofType UnaryExpressionLabelAddr UnaryExpressionAlignofExpr UnaryExpressionAlignofType UnaryExpressionImag UnaryExpressionReal )
Values of type UnaryExpressionCase
func (UnaryExpressionCase) String ¶
func (n UnaryExpressionCase) String() string
String implements fmt.Stringer
type WideStringValue ¶
type WideStringValue StringID
func (WideStringValue) IsConst ¶ added in v3.33.6
func (v WideStringValue) IsConst() bool
func (WideStringValue) IsNonZero ¶ added in v3.33.6
func (v WideStringValue) IsNonZero() bool
func (WideStringValue) IsZero ¶ added in v3.33.6
func (v WideStringValue) IsZero() bool