cc

package module
v0.0.0-...-0339ae4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2016 License: BSD-3-Clause Imports: 20 Imported by: 0

README

cc

Package CC is a C99 compiler front end.

Installation

$ go get github.com/cznic/cc

Documentation: godoc.org/github.com/cznic/cc

Documentation

Overview

Package cc is a C99 compiler front end.

Index

Examples

Constants

View Source
const (
	ADDASSIGN           = 57346
	ANDAND              = 57347
	ANDASSIGN           = 57348
	ARROW               = 57349
	AUTO                = 57350
	BOOL                = 57351
	BREAK               = 57352
	CASE                = 57353
	CAST                = 57354
	CHAR                = 57355
	CHARCONST           = 57356
	COMPLEX             = 57357
	CONST               = 57358
	CONSTANT_EXPRESSION = 1048577
	CONTINUE            = 57359
	DDD                 = 57360
	DEC                 = 57361
	DEFAULT             = 57362
	DIVASSIGN           = 57363
	DO                  = 57364
	DOUBLE              = 57365
	ELSE                = 57366
	ENUM                = 57367
	EQ                  = 57368
	EXTERN              = 57369
	FLOAT               = 57370
	FLOATCONST          = 57371
	FOR                 = 57372
	GEQ                 = 57373
	GOTO                = 57374
	IDENTIFIER          = 57375
	IDENTIFIER_LPAREN   = 57376
	IDENTIFIER_NONREPL  = 57377
	IF                  = 57378
	INC                 = 57379
	INLINE              = 57380
	INT                 = 57381
	INTCONST            = 57382
	LEQ                 = 57383
	LONG                = 57384
	LONGCHARCONST       = 57385
	LONGSTRINGLITERAL   = 57386
	LSH                 = 57387
	LSHASSIGN           = 57388
	MODASSIGN           = 57389
	MULASSIGN           = 57390
	NEQ                 = 57391
	NOELSE              = 57392
	ORASSIGN            = 57393
	OROR                = 57394
	PPDEFINE            = 57395
	PPELIF              = 57396
	PPELSE              = 57397
	PPENDIF             = 57398
	PPERROR             = 57399
	PPHASH_NL           = 57400
	PPHEADER_NAME       = 57401
	PPIF                = 57402
	PPIFDEF             = 57403
	PPIFNDEF            = 57404
	PPINCLUDE           = 57405
	PPINCLUDE_NEXT      = 57406
	PPLINE              = 57407
	PPNONDIRECTIVE      = 57408
	PPNUMBER            = 57409
	PPOTHER             = 57410
	PPPASTE             = 57411
	PPPRAGMA            = 57412
	PPUNDEF             = 57413
	PREPROCESSING_FILE  = 1048576
	REGISTER            = 57414
	RESTRICT            = 57415
	RETURN              = 57416
	RSH                 = 57417
	RSHASSIGN           = 57418
	SHORT               = 57419
	SIGNED              = 57420
	SIZEOF              = 57421
	STATIC              = 57422
	STRINGLITERAL       = 57423
	STRUCT              = 57424
	SUBASSIGN           = 57425
	SWITCH              = 57426
	TRANSLATION_UNIT    = 1048578
	TYPEDEF             = 57427
	TYPEDEFNAME         = 57428
	TYPEOF              = 57429
	UNARY               = 57430
	UNION               = 57431
	UNSIGNED            = 57432
	VOID                = 57433
	VOLATILE            = 57434
	WHILE               = 57435
	XORASSIGN           = 57436
)

Variables

This section is empty.

Functions

func IsArithmeticType

func IsArithmeticType(t Type) bool

IsArithmeticType reports wheter t.Kind() is one of UintPtr, Char, SChar, UChar, Short, UShort, Int, UInt, Long, ULong, LongLong, ULongLong, Float, Double, LongDouble, FloatComplex, DoubleComplex or LongDoubleComplex.

func IsIntType

func IsIntType(t Type) bool

IsIntType reports t.Kind() is one of Char, SChar, UChar, Short, UShort, Int, UInt, Long, ULong, LongLong, ULongLong or Enum.

func PrettyString

func PrettyString(v interface{}) string

PrettyString pretty prints things produced by this package.

func TokSrc

func TokSrc(t xc.Token) string

TokSrc returns t in its source form.

Types

type AbstractDeclarator

type AbstractDeclarator struct {
	Case                     int
	DirectAbstractDeclarator *DirectAbstractDeclarator
	Pointer                  *Pointer
	PointerOpt               *PointerOpt
	// contains filtered or unexported fields
}

AbstractDeclarator represents data reduced by productions:

AbstractDeclarator:
        Pointer
|       PointerOpt DirectAbstractDeclarator  // Case 1
Example
fmt.Println(exampleAST(178, "\U00100001 ( _Bool * )"))
Output:

&cc.AbstractDeclarator{
· Pointer: &cc.Pointer{
· · Token: example178.c:1:14: '*',
· },
}
Example (Case1)
fmt.Println(exampleAST(179, "\U00100001 ( _Bool ( ) )"))
Output:

&cc.AbstractDeclarator{
· Case: 1,
· DirectAbstractDeclarator: &cc.DirectAbstractDeclarator{
· · Case: 6,
· · Token: example179.c:1:14: '(',
· · Token2: example179.c:1:16: ')',
· },
}

func (*AbstractDeclarator) Pos

func (n *AbstractDeclarator) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*AbstractDeclarator) String

func (n *AbstractDeclarator) String() string

String implements fmt.Stringer.

type AbstractDeclaratorOpt

type AbstractDeclaratorOpt struct {
	AbstractDeclarator *AbstractDeclarator
}

AbstractDeclaratorOpt represents data reduced by productions:

AbstractDeclaratorOpt:
        /* empty */
|       AbstractDeclarator  // Case 1
Example
fmt.Println(exampleAST(180, "\U00100001 ( _Bool )") == (*AbstractDeclaratorOpt)(nil))
Output:

true
Example (Case1)
fmt.Println(exampleAST(181, "\U00100001 ( _Bool * )"))
Output:

&cc.AbstractDeclaratorOpt{
· AbstractDeclarator: &cc.AbstractDeclarator{
· · Pointer: &cc.Pointer{
· · · Token: example181.c:1:14: '*',
· · },
· },
}

func (*AbstractDeclaratorOpt) Pos

func (n *AbstractDeclaratorOpt) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*AbstractDeclaratorOpt) String

func (n *AbstractDeclaratorOpt) String() string

String implements fmt.Stringer.

type ArgumentExpressionList

type ArgumentExpressionList struct {
	ArgumentExpressionList *ArgumentExpressionList
	Case                   int
	Expression             *Expression
	Token                  xc.Token
}

ArgumentExpressionList represents data reduced by productions:

ArgumentExpressionList:
        Expression
|       ArgumentExpressionList ',' Expression  // Case 1
Example
fmt.Println(exampleAST(8, "\U00100001 'a' ( 'b' )"))
Output:

&cc.ArgumentExpressionList{
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example8.c:1:12: CHARCONST "'b'",
· },
}
Example (Case1)
fmt.Println(exampleAST(9, "\U00100001 'a' ( 'b' , 'c' )"))
Output:

&cc.ArgumentExpressionList{
· ArgumentExpressionList: &cc.ArgumentExpressionList{
· · Case: 1,
· · Expression: &cc.Expression{
· · · Case: 1,
· · · Token: example9.c:1:18: CHARCONST "'c'",
· · },
· · Token: example9.c:1:16: ',',
· },
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example9.c:1:12: CHARCONST "'b'",
· },
}

func (*ArgumentExpressionList) Pos

func (n *ArgumentExpressionList) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*ArgumentExpressionList) String

func (n *ArgumentExpressionList) String() string

String implements fmt.Stringer.

type ArgumentExpressionListOpt

type ArgumentExpressionListOpt struct {
	ArgumentExpressionList *ArgumentExpressionList
}

ArgumentExpressionListOpt represents data reduced by productions:

ArgumentExpressionListOpt:
        /* empty */
|       ArgumentExpressionList  // Case 1
Example
fmt.Println(exampleAST(10, "\U00100001 'a' ( )") == (*ArgumentExpressionListOpt)(nil))
Output:

true
Example (Case1)
fmt.Println(exampleAST(11, "\U00100001 'a' ( 'b' )"))
Output:

&cc.ArgumentExpressionListOpt{
· ArgumentExpressionList: &cc.ArgumentExpressionList{
· · Expression: &cc.Expression{
· · · Case: 1,
· · · Token: example11.c:1:12: CHARCONST "'b'",
· · },
· },
}

func (*ArgumentExpressionListOpt) Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*ArgumentExpressionListOpt) String

func (n *ArgumentExpressionListOpt) String() string

String implements fmt.Stringer.

type Binding

type Binding struct {
	Node Node
	// contains filtered or unexported fields
}

Binding records the declaration Node of a declared name.

In the NSIdentifiers namespace the dynamic type of Node for deckared names is always *DirectDeclarator. The *Declarator associated with the direct declarator is available via (*DirectDeclarator).TopDeclarator().

int* p;

In the NSTags namespace the dynamic type of Node is xc.Token when a tag is declared:

struct foo;
enum bar;

When a tag is defined, the dynamic type of Node is *EnumSpecifier or *StructOrUnionSpecifier:

struct foo { int i; };
enum bar { a = 1 };

type Bindings

type Bindings struct {
	Identifiers map[int]Binding // NSIdentifiers name space bindings.
	Tags        map[int]Binding // NSTags name space bindings.
	// contains filtered or unexported fields
}

Bindings record names declared in a scope.

func (*Bindings) Lookup

func (b *Bindings) Lookup(ns Namespace, id int) Binding

Lookup returns the Binding of id in ns or any of its parents. If id is undeclared, the returned Binding has its Node field set to nil.

func (*Bindings) Lookup2

func (b *Bindings) Lookup2(ns Namespace, id int) (Binding, *Bindings)

Lookup2 is like Lookup but addionally it returns also the scope in which id was found.

func (*Bindings) Scope

func (b *Bindings) Scope() Scope

Scope retuns the kind of b.

type BlockItem

type BlockItem struct {
	Case        int
	Declaration *Declaration
	Statement   *Statement
}

BlockItem represents data reduced by productions:

BlockItem:
        Declaration
|       Statement    // Case 1
Example
fmt.Println(exampleAST(220, "\U00100002 auto a { auto ; !"))
Output:

&cc.BlockItem{
· Declaration: &cc.Declaration{
· · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · StorageClassSpecifier: &cc.StorageClassSpecifier{
· · · · Case: 3,
· · · · Token: example220.c:1:15: AUTO "auto",
· · · },
· · },
· · Token: example220.c:1:20: ';',
· },
}
Example (Case1)
fmt.Println(exampleAST(221, "\U00100002 auto a { ; !"))
Output:

&cc.BlockItem{
· Case: 1,
· Statement: &cc.Statement{
· · Case: 2,
· · ExpressionStatement: &cc.ExpressionStatement{
· · · Token: example221.c:1:15: ';',
· · },
· },
}

func (*BlockItem) Pos

func (n *BlockItem) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*BlockItem) String

func (n *BlockItem) String() string

String implements fmt.Stringer.

type BlockItemList

type BlockItemList struct {
	BlockItem     *BlockItem
	BlockItemList *BlockItemList
	Case          int
}

BlockItemList represents data reduced by productions:

BlockItemList:
        BlockItem
|       BlockItemList BlockItem  // Case 1
Example
fmt.Println(exampleAST(216, "\U00100002 auto a { ; !"))
Output:

&cc.BlockItemList{
· BlockItem: &cc.BlockItem{
· · Case: 1,
· · Statement: &cc.Statement{
· · · Case: 2,
· · · ExpressionStatement: &cc.ExpressionStatement{
· · · · Token: example216.c:1:15: ';',
· · · },
· · },
· },
}
Example (Case1)
fmt.Println(exampleAST(217, "\U00100002 auto a { ; ; !"))
Output:

&cc.BlockItemList{
· BlockItem: &cc.BlockItem{
· · Case: 1,
· · Statement: &cc.Statement{
· · · Case: 2,
· · · ExpressionStatement: &cc.ExpressionStatement{
· · · · Token: example217.c:1:15: ';',
· · · },
· · },
· },
· BlockItemList: &cc.BlockItemList{
· · BlockItem: &cc.BlockItem{
· · · Case: 1,
· · · Statement: &cc.Statement{
· · · · Case: 2,
· · · · ExpressionStatement: &cc.ExpressionStatement{
· · · · · Token: example217.c:1:17: ';',
· · · · },
· · · },
· · },
· · Case: 1,
· },
}

func (*BlockItemList) Pos

func (n *BlockItemList) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*BlockItemList) String

func (n *BlockItemList) String() string

String implements fmt.Stringer.

type BlockItemListOpt

type BlockItemListOpt struct {
	BlockItemList *BlockItemList
}

BlockItemListOpt represents data reduced by productions:

BlockItemListOpt:
        /* empty */
|       BlockItemList  // Case 1
Example
fmt.Println(exampleAST(218, "\U00100002 auto a { }") == (*BlockItemListOpt)(nil))
Output:

true
Example (Case1)
fmt.Println(exampleAST(219, "\U00100002 auto a { ; }"))
Output:

&cc.BlockItemListOpt{
· BlockItemList: &cc.BlockItemList{
· · BlockItem: &cc.BlockItem{
· · · Case: 1,
· · · Statement: &cc.Statement{
· · · · Case: 2,
· · · · ExpressionStatement: &cc.ExpressionStatement{
· · · · · Token: example219.c:1:15: ';',
· · · · },
· · · },
· · },
· },
}

func (*BlockItemListOpt) Pos

func (n *BlockItemListOpt) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*BlockItemListOpt) String

func (n *BlockItemListOpt) String() string

String implements fmt.Stringer.

type CommaOpt

type CommaOpt struct {
	Token xc.Token
}

CommaOpt represents data reduced by productions:

CommaOpt:
        /* empty */
|       ','          // Case 1
Example
fmt.Println(exampleAST(129, "\U00100002 enum { a }") == (*CommaOpt)(nil))
Output:

true
Example (Case1)
fmt.Println(exampleAST(130, "\U00100001 ( _Bool ) { 'a' , }"))
Output:

&cc.CommaOpt{
· Token: example130.c:1:22: ',',
}

func (*CommaOpt) Pos

func (n *CommaOpt) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*CommaOpt) String

func (n *CommaOpt) String() string

String implements fmt.Stringer.

type CompoundStatement

type CompoundStatement struct {
	BlockItemListOpt *BlockItemListOpt
	Token            xc.Token
	Token2           xc.Token
	// contains filtered or unexported fields
}

CompoundStatement represents data reduced by production:

CompoundStatement:
        '{' BlockItemListOpt '}'
Example
fmt.Println(exampleAST(215, "\U00100002 auto a { }"))
Output:

&cc.CompoundStatement{
· Token: example215.c:1:13: '{',
· Token2: example215.c:1:15: '}',
}

func (*CompoundStatement) Pos

func (n *CompoundStatement) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*CompoundStatement) Scope

func (n *CompoundStatement) Scope() *Bindings

Scope returns n's scope.

func (*CompoundStatement) String

func (n *CompoundStatement) String() string

String implements fmt.Stringer.

type ConstantExpression

type ConstantExpression struct {
	Type  Type        // Type of expression.
	Value interface{} // Non nil for certain constant expressions.

	Expression *Expression
	// contains filtered or unexported fields
}

ConstantExpression represents data reduced by production:

ConstantExpression:
        Expression
Example
fmt.Println(exampleAST(75, "\U00100001 'a'"))
Output:

&cc.ConstantExpression{
· Type: int,
· Value: 97,
· Expression: &cc.Expression{
· · Type: int,
· · Value: 97,
· · Case: 1,
· · Token: example75.c:1:6: CHARCONST "'a'",
· },
}

func (*ConstantExpression) Pos

func (n *ConstantExpression) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*ConstantExpression) String

func (n *ConstantExpression) String() string

String implements fmt.Stringer.

type ControlLine

type ControlLine struct {
	Case              int
	IdentifierList    *IdentifierList
	IdentifierListOpt *IdentifierListOpt
	PPTokenList       PPTokenList
	PPTokenListOpt    PPTokenList
	ReplacementList   PPTokenList
	Token             xc.Token
	Token2            xc.Token
	Token3            xc.Token
	Token4            xc.Token
	Token5            xc.Token
	Token6            xc.Token
}

ControlLine represents data reduced by productions:

ControlLine:
        PPDEFINE IDENTIFIER ReplacementList
|       PPDEFINE IDENTIFIER_LPAREN "..." ')' ReplacementList                                // Case 1
|       PPDEFINE IDENTIFIER_LPAREN IdentifierList ',' "..." ')' ReplacementList             // Case 2
|       PPDEFINE IDENTIFIER_LPAREN IdentifierListOpt ')' ReplacementList                    // Case 3
|       PPERROR PPTokenListOpt                                                              // Case 4
|       PPHASH_NL                                                                           // Case 5
|       PPINCLUDE PPTokenList '\n'                                                          // Case 6
|       PPLINE PPTokenList '\n'                                                             // Case 7
|       PPPRAGMA PPTokenListOpt                                                             // Case 8
|       PPUNDEF IDENTIFIER '\n'                                                             // Case 9
|       PPDEFINE IDENTIFIER_LPAREN IDENTIFIER "..." ')' ReplacementList                     // Case 10
|       PPDEFINE IDENTIFIER_LPAREN IdentifierList ',' IDENTIFIER "..." ')' ReplacementList  // Case 11
|       PPDEFINE '\n'                                                                       // Case 12
|       PPUNDEF IDENTIFIER PPTokenList '\n'                                                 // Case 13
|       PPINCLUDE_NEXT PPTokenList '\n'                                                     // Case 14
Example
fmt.Println(exampleAST(267, "\U00100000 \n#define a "))
Output:

&cc.ControlLine{
· ReplacementList: []xc.Token{ // len 1
· · 0: example267.c:2:10: ' ',
· },
· Token: example267.c:2:2: PPDEFINE,
· Token2: example267.c:2:9: IDENTIFIER "a",
}
Example (Case01)
fmt.Println(exampleAST(268, "\U00100000 \n#define a( ... ) "))
Output:

&cc.ControlLine{
· Case: 1,
· ReplacementList: []xc.Token{ // len 1
· · 0: example268.c:2:17: ' ',
· },
· Token: example268.c:2:2: PPDEFINE,
· Token2: example268.c:2:9: IDENTIFIER_LPAREN "a(",
· Token3: example268.c:2:12: DDD,
· Token4: example268.c:2:16: ')',
}
Example (Case02)
fmt.Println(exampleAST(269, "\U00100000 \n#define a( b , ... ) "))
Output:

&cc.ControlLine{
· Case: 2,
· IdentifierList: &cc.IdentifierList{
· · Token: example269.c:2:12: IDENTIFIER "b",
· },
· ReplacementList: []xc.Token{ // len 1
· · 0: example269.c:2:21: ' ',
· },
· Token: example269.c:2:2: PPDEFINE,
· Token2: example269.c:2:9: IDENTIFIER_LPAREN "a(",
· Token3: example269.c:2:14: ',',
· Token4: example269.c:2:16: DDD,
· Token5: example269.c:2:20: ')',
}
Example (Case03)
fmt.Println(exampleAST(270, "\U00100000 \n#define a( ) "))
Output:

&cc.ControlLine{
· Case: 3,
· ReplacementList: []xc.Token{ // len 1
· · 0: example270.c:2:13: ' ',
· },
· Token: example270.c:2:2: PPDEFINE,
· Token2: example270.c:2:9: IDENTIFIER_LPAREN "a(",
· Token3: example270.c:2:12: ')',
}
Example (Case04)
fmt.Println(exampleAST(271, "\U00100000 \n#error "))
Output:

&cc.ControlLine{
· Case: 4,
· PPTokenListOpt: []xc.Token{ // len 1
· · 0: example271.c:2:7: ' ',
· },
· Token: example271.c:2:2: PPERROR,
}
Example (Case05)
fmt.Println(exampleAST(272, "\U00100000 \n#"))
Output:

&cc.ControlLine{
· Case: 5,
· Token: example272.c:2:2: PPHASH_NL,
}
Example (Case06)
fmt.Println(exampleAST(273, "\U00100000 \n#include other_a "))
Output:

&cc.ControlLine{
· Case: 6,
· PPTokenList: []xc.Token{ // len 3
· · 0: example273.c:2:9: ' ',
· · 1: example273.c:2:10: IDENTIFIER "other_a",
· · 2: example273.c:2:17: ' ',
· },
· Token: example273.c:2:2: PPINCLUDE,
· Token2: example273.c:2:18: '\n',
}
Example (Case07)
fmt.Println(exampleAST(274, "\U00100000 \n#line other_a "))
Output:

&cc.ControlLine{
· Case: 7,
· PPTokenList: []xc.Token{ // len 3
· · 0: example274.c:2:6: ' ',
· · 1: example274.c:2:7: IDENTIFIER "other_a",
· · 2: example274.c:2:14: ' ',
· },
· Token: example274.c:2:2: PPLINE,
· Token2: example274.c:2:15: '\n',
}
Example (Case08)
fmt.Println(exampleAST(275, "\U00100000 \n#pragma "))
Output:

&cc.ControlLine{
· Case: 8,
· PPTokenListOpt: []xc.Token{ // len 1
· · 0: example275.c:2:8: ' ',
· },
· Token: example275.c:2:2: PPPRAGMA,
}
Example (Case09)
fmt.Println(exampleAST(276, "\U00100000 \n#undef foo"))
Output:

&cc.ControlLine{
· Case: 9,
· Token: example276.c:2:2: PPUNDEF,
· Token2: example276.c:2:8: IDENTIFIER "foo",
· Token3: example276.c:2:11: '\n',
}
Example (Case10)
fmt.Println(exampleAST(277, "\U00100000 \n#define a( b ... ) "))
Output:

&cc.ControlLine{
· Case: 10,
· ReplacementList: []xc.Token{ // len 1
· · 0: example277.c:2:19: ' ',
· },
· Token: example277.c:2:2: PPDEFINE,
· Token2: example277.c:2:9: IDENTIFIER_LPAREN "a(",
· Token3: example277.c:2:12: IDENTIFIER "b",
· Token4: example277.c:2:14: DDD,
· Token5: example277.c:2:18: ')',
}
Example (Case11)
fmt.Println(exampleAST(278, "\U00100000 \n#define a( b , c ... ) "))
Output:

&cc.ControlLine{
· Case: 11,
· IdentifierList: &cc.IdentifierList{
· · Token: example278.c:2:12: IDENTIFIER "b",
· },
· ReplacementList: []xc.Token{ // len 1
· · 0: example278.c:2:23: ' ',
· },
· Token: example278.c:2:2: PPDEFINE,
· Token2: example278.c:2:9: IDENTIFIER_LPAREN "a(",
· Token3: example278.c:2:14: ',',
· Token4: example278.c:2:16: IDENTIFIER "c",
· Token5: example278.c:2:18: DDD,
· Token6: example278.c:2:22: ')',
}
Example (Case12)
fmt.Println(exampleAST(279, "\U00100000 \n#define "))
Output:

&cc.ControlLine{
· Case: 12,
· Token: example279.c:2:2: PPDEFINE,
· Token2: example279.c:2:9: '\n',
}
Example (Case13)
fmt.Println(exampleAST(280, "\U00100000 \n#undef foo(bar)"))
Output:

&cc.ControlLine{
· Case: 13,
· PPTokenList: []xc.Token{ // len 3
· · 0: example280.c:2:11: '(',
· · 1: example280.c:2:12: IDENTIFIER "bar",
· · 2: example280.c:2:15: ')',
· },
· Token: example280.c:2:2: PPUNDEF,
· Token2: example280.c:2:8: IDENTIFIER "foo",
· Token3: example280.c:2:16: '\n',
}
Example (Case14)
fmt.Println(exampleAST(281, "\U00100000 \n#include_next other_a "))
Output:

&cc.ControlLine{
· Case: 14,
· PPTokenList: []xc.Token{ // len 3
· · 0: example281.c:2:14: ' ',
· · 1: example281.c:2:15: IDENTIFIER "other_a",
· · 2: example281.c:2:22: ' ',
· },
· Token: example281.c:2:2: PPINCLUDE_NEXT,
· Token2: example281.c:2:23: '\n',
}

func (*ControlLine) Pos

func (n *ControlLine) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*ControlLine) String

func (n *ControlLine) String() string

String implements fmt.Stringer.

type Declaration

type Declaration struct {
	DeclarationSpecifiers *DeclarationSpecifiers
	InitDeclaratorListOpt *InitDeclaratorListOpt
	Token                 xc.Token
	// contains filtered or unexported fields
}

Declaration represents data reduced by production:

Declaration:
        DeclarationSpecifiers InitDeclaratorListOpt ';'
Example
fmt.Println(exampleAST(76, "\U00100002 auto ;"))
Output:

&cc.Declaration{
· DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · StorageClassSpecifier: &cc.StorageClassSpecifier{
· · · Case: 3,
· · · Token: example76.c:1:6: AUTO "auto",
· · },
· },
· Token: example76.c:1:11: ';',
}

func (*Declaration) Declarator

func (n *Declaration) Declarator() *Declarator

Declarator returns a synthetic Declarator when n.InitDeclaratorListOpt is nil.

func (*Declaration) Pos

func (n *Declaration) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*Declaration) String

func (n *Declaration) String() string

String implements fmt.Stringer.

type DeclarationList

type DeclarationList struct {
	Case            int
	Declaration     *Declaration
	DeclarationList *DeclarationList
}

DeclarationList represents data reduced by productions:

DeclarationList:
        Declaration
|       DeclarationList Declaration  // Case 1
Example
fmt.Println(exampleAST(240, "\U00100002 auto a auto ; {"))
Output:

&cc.DeclarationList{
· Declaration: &cc.Declaration{
· · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · StorageClassSpecifier: &cc.StorageClassSpecifier{
· · · · Case: 3,
· · · · Token: example240.c:1:13: AUTO "auto",
· · · },
· · },
· · Token: example240.c:1:18: ';',
· },
}
Example (Case1)
fmt.Println(exampleAST(241, "\U00100002 auto a auto ; auto ; {"))
Output:

&cc.DeclarationList{
· Declaration: &cc.Declaration{
· · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · StorageClassSpecifier: &cc.StorageClassSpecifier{
· · · · Case: 3,
· · · · Token: example241.c:1:13: AUTO "auto",
· · · },
· · },
· · Token: example241.c:1:18: ';',
· },
· DeclarationList: &cc.DeclarationList{
· · Case: 1,
· · Declaration: &cc.Declaration{
· · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · StorageClassSpecifier: &cc.StorageClassSpecifier{
· · · · · Case: 3,
· · · · · Token: example241.c:1:20: AUTO "auto",
· · · · },
· · · },
· · · Token: example241.c:1:25: ';',
· · },
· },
}

func (*DeclarationList) Pos

func (n *DeclarationList) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*DeclarationList) String

func (n *DeclarationList) String() string

String implements fmt.Stringer.

type DeclarationListOpt

type DeclarationListOpt struct {
	DeclarationList *DeclarationList
	// contains filtered or unexported fields
}

DeclarationListOpt represents data reduced by productions:

DeclarationListOpt:
        /* empty */
|       DeclarationList  // Case 1
Example
fmt.Println(exampleAST(242, "\U00100002 auto a {") == (*DeclarationListOpt)(nil))
Output:

true
Example (Case1)
fmt.Println(exampleAST(244, "\U00100002 auto a auto ; {"))
Output:

&cc.DeclarationListOpt{
· DeclarationList: &cc.DeclarationList{
· · Declaration: &cc.Declaration{
· · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · StorageClassSpecifier: &cc.StorageClassSpecifier{
· · · · · Case: 3,
· · · · · Token: example244.c:1:13: AUTO "auto",
· · · · },
· · · },
· · · Token: example244.c:1:18: ';',
· · },
· },
}

func (*DeclarationListOpt) Pos

func (n *DeclarationListOpt) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*DeclarationListOpt) String

func (n *DeclarationListOpt) String() string

String implements fmt.Stringer.

type DeclarationSpecifiers

type DeclarationSpecifiers struct {
	Case                     int
	DeclarationSpecifiersOpt *DeclarationSpecifiersOpt
	FunctionSpecifier        *FunctionSpecifier
	StorageClassSpecifier    *StorageClassSpecifier
	TypeQualifier            *TypeQualifier
	TypeSpecifier            *TypeSpecifier
	// contains filtered or unexported fields
}

DeclarationSpecifiers represents data reduced by productions:

DeclarationSpecifiers:
        StorageClassSpecifier DeclarationSpecifiersOpt
|       TypeSpecifier DeclarationSpecifiersOpt          // Case 1
|       TypeQualifier DeclarationSpecifiersOpt          // Case 2
|       FunctionSpecifier DeclarationSpecifiersOpt      // Case 3
Example
fmt.Println(exampleAST(77, "\U00100002 auto ("))
Output:

&cc.DeclarationSpecifiers{
· StorageClassSpecifier: &cc.StorageClassSpecifier{
· · Case: 3,
· · Token: example77.c:1:6: AUTO "auto",
· },
}
Example (Case1)
fmt.Println(exampleAST(78, "\U00100002 _Bool ("))
Output:

&cc.DeclarationSpecifiers{
· Case: 1,
· TypeSpecifier: &cc.TypeSpecifier{
· · Case: 9,
· · Token: example78.c:1:6: BOOL "_Bool",
· },
}
Example (Case2)
fmt.Println(exampleAST(79, "\U00100002 const ("))
Output:

&cc.DeclarationSpecifiers{
· Case: 2,
· TypeQualifier: &cc.TypeQualifier{
· · Token: example79.c:1:6: CONST "const",
· },
}
Example (Case3)
fmt.Println(exampleAST(80, "\U00100002 inline ("))
Output:

&cc.DeclarationSpecifiers{
· Case: 3,
· FunctionSpecifier: &cc.FunctionSpecifier{
· · Token: example80.c:1:6: INLINE "inline",
· },
}

func (*DeclarationSpecifiers) IsConst

func (n *DeclarationSpecifiers) IsConst() bool

IsConst returns whether n includes the 'const' type qualifier.

func (*DeclarationSpecifiers) IsStatic

func (n *DeclarationSpecifiers) IsStatic() bool

IsStatic implements specifier.

func (*DeclarationSpecifiers) IsTypedef

func (n *DeclarationSpecifiers) IsTypedef() bool

IsTypedef implements specifier.

func (*DeclarationSpecifiers) Pos

func (n *DeclarationSpecifiers) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*DeclarationSpecifiers) String

func (n *DeclarationSpecifiers) String() string

String implements fmt.Stringer.

func (*DeclarationSpecifiers) TypedefName

func (n *DeclarationSpecifiers) TypedefName() int

TypedefName implements Specifier.

type DeclarationSpecifiersOpt

type DeclarationSpecifiersOpt struct {
	DeclarationSpecifiers *DeclarationSpecifiers
	// contains filtered or unexported fields
}

DeclarationSpecifiersOpt represents data reduced by productions:

DeclarationSpecifiersOpt:
        /* empty */
|       DeclarationSpecifiers  // Case 1
Example
fmt.Println(exampleAST(81, "\U00100002 auto (") == (*DeclarationSpecifiersOpt)(nil))
Output:

true
Example (Case1)
fmt.Println(exampleAST(82, "\U00100002 inline auto ("))
Output:

&cc.DeclarationSpecifiersOpt{
· DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · StorageClassSpecifier: &cc.StorageClassSpecifier{
· · · Case: 3,
· · · Token: example82.c:1:13: AUTO "auto",
· · },
· },
}

func (*DeclarationSpecifiersOpt) Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*DeclarationSpecifiersOpt) String

func (n *DeclarationSpecifiersOpt) String() string

String implements fmt.Stringer.

type Declarator

type Declarator struct {
	Linkage Linkage
	Type    Type

	DirectDeclarator *DirectDeclarator
	PointerOpt       *PointerOpt
	// contains filtered or unexported fields
}

Declarator represents data reduced by production:

Declarator:
        PointerOpt DirectDeclarator
Example
fmt.Println(exampleAST(142, "\U00100002 auto a )"))
Output:

&cc.Declarator{
· Linkage: None,
· DirectDeclarator: &cc.DirectDeclarator{
· · Token: example142.c:1:11: IDENTIFIER "a",
· },
}

func (*Declarator) Identifier

func (n *Declarator) Identifier() (int, *Bindings)

Identifier returns the ID of the name declared by n and the scope the name is declared in.

func (*Declarator) Pos

func (n *Declarator) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*Declarator) RawSpecifier

func (n *Declarator) RawSpecifier() Specifier

RawSpecifier returns the raw Specifier associated with n before expanding typedefs. The effective Specifier is accessible via the Type field of n.

func (*Declarator) String

func (n *Declarator) String() string

String implements fmt.Stringer.

type DeclaratorOpt

type DeclaratorOpt struct {
	Declarator *Declarator
}

DeclaratorOpt represents data reduced by productions:

DeclaratorOpt:
        /* empty */
|       Declarator   // Case 1
Example
fmt.Println(exampleAST(143, "\U00100002 struct { _Bool :") == (*DeclaratorOpt)(nil))
Output:

true
Example (Case1)
fmt.Println(exampleAST(144, "\U00100002 struct { _Bool a :"))
Output:

&cc.DeclaratorOpt{
· Declarator: &cc.Declarator{
· · Linkage: None,
· · DirectDeclarator: &cc.DirectDeclarator{
· · · Token: example144.c:1:21: IDENTIFIER "a",
· · },
· },
}

func (*DeclaratorOpt) Pos

func (n *DeclaratorOpt) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*DeclaratorOpt) String

func (n *DeclaratorOpt) String() string

String implements fmt.Stringer.

type Designation

type Designation struct {
	DesignatorList *DesignatorList
	Token          xc.Token
}

Designation represents data reduced by production:

Designation:
        DesignatorList '='
Example
fmt.Println(exampleAST(198, "\U00100001 ( _Bool ) { . a = !"))
Output:

&cc.Designation{
· DesignatorList: &cc.DesignatorList{
· · Designator: &cc.Designator{
· · · Case: 1,
· · · Token: example198.c:1:18: '.',
· · · Token2: example198.c:1:20: IDENTIFIER "a",
· · },
· },
· Token: example198.c:1:22: '=',
}

func (*Designation) Pos

func (n *Designation) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*Designation) String

func (n *Designation) String() string

String implements fmt.Stringer.

type DesignationOpt

type DesignationOpt struct {
	Designation *Designation
}

DesignationOpt represents data reduced by productions:

DesignationOpt:
        /* empty */
|       Designation  // Case 1
Example
fmt.Println(exampleAST(199, "\U00100001 ( _Bool ) { !") == (*DesignationOpt)(nil))
Output:

true
Example (Case1)
fmt.Println(exampleAST(200, "\U00100001 ( _Bool ) { . a = !"))
Output:

&cc.DesignationOpt{
· Designation: &cc.Designation{
· · DesignatorList: &cc.DesignatorList{
· · · Designator: &cc.Designator{
· · · · Case: 1,
· · · · Token: example200.c:1:18: '.',
· · · · Token2: example200.c:1:20: IDENTIFIER "a",
· · · },
· · },
· · Token: example200.c:1:22: '=',
· },
}

func (*DesignationOpt) Pos

func (n *DesignationOpt) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*DesignationOpt) String

func (n *DesignationOpt) String() string

String implements fmt.Stringer.

type Designator

type Designator struct {
	Case               int
	ConstantExpression *ConstantExpression
	Token              xc.Token
	Token2             xc.Token
}

Designator represents data reduced by productions:

Designator:
        '[' ConstantExpression ']'
|       '.' IDENTIFIER              // Case 1
Example
fmt.Println(exampleAST(203, "\U00100001 ( _Bool ) { [ 'a' ] ."))
Output:

&cc.Designator{
· ConstantExpression: &cc.ConstantExpression{
· · Type: int,
· · Value: 97,
· · Expression: &cc.Expression{
· · · Type: int,
· · · Value: 97,
· · · Case: 1,
· · · Token: example203.c:1:20: CHARCONST "'a'",
· · },
· },
· Token: example203.c:1:18: '[',
· Token2: example203.c:1:24: ']',
}
Example (Case1)
fmt.Println(exampleAST(204, "\U00100001 ( _Bool ) { . a ."))
Output:

&cc.Designator{
· Case: 1,
· Token: example204.c:1:18: '.',
· Token2: example204.c:1:20: IDENTIFIER "a",
}

func (*Designator) Pos

func (n *Designator) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*Designator) String

func (n *Designator) String() string

String implements fmt.Stringer.

type DesignatorList

type DesignatorList struct {
	Case           int
	Designator     *Designator
	DesignatorList *DesignatorList
}

DesignatorList represents data reduced by productions:

DesignatorList:
        Designator
|       DesignatorList Designator  // Case 1
Example
fmt.Println(exampleAST(201, "\U00100001 ( _Bool ) { . a ."))
Output:

&cc.DesignatorList{
· Designator: &cc.Designator{
· · Case: 1,
· · Token: example201.c:1:18: '.',
· · Token2: example201.c:1:20: IDENTIFIER "a",
· },
}
Example (Case1)
fmt.Println(exampleAST(202, "\U00100001 ( _Bool ) { . a . b ."))
Output:

&cc.DesignatorList{
· Designator: &cc.Designator{
· · Case: 1,
· · Token: example202.c:1:18: '.',
· · Token2: example202.c:1:20: IDENTIFIER "a",
· },
· DesignatorList: &cc.DesignatorList{
· · Case: 1,
· · Designator: &cc.Designator{
· · · Case: 1,
· · · Token: example202.c:1:22: '.',
· · · Token2: example202.c:1:24: IDENTIFIER "b",
· · },
· },
}

func (*DesignatorList) Pos

func (n *DesignatorList) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*DesignatorList) String

func (n *DesignatorList) String() string

String implements fmt.Stringer.

type DirectAbstractDeclarator

type DirectAbstractDeclarator struct {
	AbstractDeclarator          *AbstractDeclarator
	Case                        int
	DirectAbstractDeclarator    *DirectAbstractDeclarator
	DirectAbstractDeclaratorOpt *DirectAbstractDeclaratorOpt
	Expression                  *Expression
	ExpressionOpt               *ExpressionOpt
	ParameterTypeListOpt        *ParameterTypeListOpt
	Token                       xc.Token
	Token2                      xc.Token
	Token3                      xc.Token
	TypeQualifierList           *TypeQualifierList
	TypeQualifierListOpt        *TypeQualifierListOpt
	// contains filtered or unexported fields
}

DirectAbstractDeclarator represents data reduced by productions:

DirectAbstractDeclarator:
        '(' AbstractDeclarator ')'
|       DirectAbstractDeclaratorOpt '[' ExpressionOpt ']'                             // Case 1
|       DirectAbstractDeclaratorOpt '[' TypeQualifierList ExpressionOpt ']'           // Case 2
|       DirectAbstractDeclaratorOpt '[' "static" TypeQualifierListOpt Expression ']'  // Case 3
|       DirectAbstractDeclaratorOpt '[' TypeQualifierList "static" Expression ']'     // Case 4
|       DirectAbstractDeclaratorOpt '[' '*' ']'                                       // Case 5
|       '(' ParameterTypeListOpt ')'                                                  // Case 6
|       DirectAbstractDeclarator '(' ParameterTypeListOpt ')'                         // Case 7
Example
fmt.Println(exampleAST(182, "\U00100001 ( _Bool ( * ) ("))
Output:

&cc.DirectAbstractDeclarator{
· AbstractDeclarator: &cc.AbstractDeclarator{
· · Pointer: &cc.Pointer{
· · · Token: example182.c:1:16: '*',
· · },
· },
· Token: example182.c:1:14: '(',
· Token2: example182.c:1:18: ')',
}
Example (Case1)
fmt.Println(exampleAST(183, "\U00100001 ( _Bool [ ] ("))
Output:

&cc.DirectAbstractDeclarator{
· Case: 1,
· Token: example183.c:1:14: '[',
· Token2: example183.c:1:16: ']',
}
Example (Case2)
fmt.Println(exampleAST(184, "\U00100001 ( _Bool [ const ] ("))
Output:

&cc.DirectAbstractDeclarator{
· Case: 2,
· Token: example184.c:1:14: '[',
· Token2: example184.c:1:22: ']',
· TypeQualifierList: &cc.TypeQualifierList{
· · TypeQualifier: &cc.TypeQualifier{
· · · Token: example184.c:1:16: CONST "const",
· · },
· },
}
Example (Case3)
fmt.Println(exampleAST(185, "\U00100001 ( _Bool [ static 'a' ] ("))
Output:

&cc.DirectAbstractDeclarator{
· Case: 3,
· Expression: &cc.Expression{
· · Type: int,
· · Value: 97,
· · Case: 1,
· · Token: example185.c:1:23: CHARCONST "'a'",
· },
· Token: example185.c:1:14: '[',
· Token2: example185.c:1:16: STATIC "static",
· Token3: example185.c:1:27: ']',
}
Example (Case4)
fmt.Println(exampleAST(186, "\U00100001 ( _Bool [ const static 'a' ] ("))
Output:

&cc.DirectAbstractDeclarator{
· Case: 4,
· Expression: &cc.Expression{
· · Type: int,
· · Value: 97,
· · Case: 1,
· · Token: example186.c:1:29: CHARCONST "'a'",
· },
· Token: example186.c:1:14: '[',
· Token2: example186.c:1:22: STATIC "static",
· Token3: example186.c:1:33: ']',
· TypeQualifierList: &cc.TypeQualifierList{
· · TypeQualifier: &cc.TypeQualifier{
· · · Token: example186.c:1:16: CONST "const",
· · },
· },
}
Example (Case5)
fmt.Println(exampleAST(187, "\U00100001 ( _Bool [ * ] ("))
Output:

&cc.DirectAbstractDeclarator{
· Case: 5,
· Token: example187.c:1:14: '[',
· Token2: example187.c:1:16: '*',
· Token3: example187.c:1:18: ']',
}
Example (Case6)
fmt.Println(exampleAST(189, "\U00100001 ( _Bool ( ) ("))
Output:

&cc.DirectAbstractDeclarator{
· Case: 6,
· Token: example189.c:1:14: '(',
· Token2: example189.c:1:16: ')',
}
Example (Case7)
fmt.Println(exampleAST(191, "\U00100001 ( _Bool ( ) ( ) ("))
Output:

&cc.DirectAbstractDeclarator{
· Case: 7,
· DirectAbstractDeclarator: &cc.DirectAbstractDeclarator{
· · Case: 6,
· · Token: example191.c:1:14: '(',
· · Token2: example191.c:1:16: ')',
· },
· Token: example191.c:1:18: '(',
· Token2: example191.c:1:20: ')',
}

func (*DirectAbstractDeclarator) Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*DirectAbstractDeclarator) String

func (n *DirectAbstractDeclarator) String() string

String implements fmt.Stringer.

type DirectAbstractDeclaratorOpt

type DirectAbstractDeclaratorOpt struct {
	DirectAbstractDeclarator *DirectAbstractDeclarator
}

DirectAbstractDeclaratorOpt represents data reduced by productions:

DirectAbstractDeclaratorOpt:
        /* empty */
|       DirectAbstractDeclarator  // Case 1
Example
fmt.Println(exampleAST(192, "\U00100001 ( _Bool [") == (*DirectAbstractDeclaratorOpt)(nil))
Output:

true
Example (Case1)
fmt.Println(exampleAST(193, "\U00100001 ( _Bool ( ) ["))
Output:

&cc.DirectAbstractDeclaratorOpt{
· DirectAbstractDeclarator: &cc.DirectAbstractDeclarator{
· · Case: 6,
· · Token: example193.c:1:14: '(',
· · Token2: example193.c:1:16: ')',
· },
}

func (*DirectAbstractDeclaratorOpt) Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*DirectAbstractDeclaratorOpt) String

func (n *DirectAbstractDeclaratorOpt) String() string

String implements fmt.Stringer.

type DirectDeclarator

type DirectDeclarator struct {
	EnumVal interface{} // Non nil if DD declares an enumeration constant.

	Case                 int
	Declarator           *Declarator
	DirectDeclarator     *DirectDeclarator
	Expression           *Expression
	ExpressionOpt        *ExpressionOpt
	IdentifierListOpt    *IdentifierListOpt
	ParameterTypeList    *ParameterTypeList
	Token                xc.Token
	Token2               xc.Token
	Token3               xc.Token
	TypeQualifierList    *TypeQualifierList
	TypeQualifierListOpt *TypeQualifierListOpt
	// contains filtered or unexported fields
}

DirectDeclarator represents data reduced by productions:

DirectDeclarator:
        IDENTIFIER
|       '(' Declarator ')'                                                 // Case 1
|       DirectDeclarator '[' TypeQualifierListOpt ExpressionOpt ']'        // Case 2
|       DirectDeclarator '[' "static" TypeQualifierListOpt Expression ']'  // Case 3
|       DirectDeclarator '[' TypeQualifierList "static" Expression ']'     // Case 4
|       DirectDeclarator '[' TypeQualifierListOpt '*' ']'                  // Case 5
|       DirectDeclarator '(' ParameterTypeList ')'                         // Case 6
|       DirectDeclarator '(' IdentifierListOpt ')'                         // Case 7
Example
fmt.Println(exampleAST(145, "\U00100002 auto a ("))
Output:

&cc.DirectDeclarator{
· Token: example145.c:1:11: IDENTIFIER "a",
}
Example (Case1)
fmt.Println(exampleAST(146, "\U00100002 auto ( a ) ("))
Output:

&cc.DirectDeclarator{
· Case: 1,
· Declarator: &cc.Declarator{
· · Linkage: None,
· · DirectDeclarator: &cc.DirectDeclarator{
· · · Token: example146.c:1:13: IDENTIFIER "a",
· · },
· },
· Token: example146.c:1:11: '(',
· Token2: example146.c:1:15: ')',
}
Example (Case2)
fmt.Println(exampleAST(147, "\U00100002 auto a [ ] ("))
Output:

&cc.DirectDeclarator{
· Case: 2,
· DirectDeclarator: &cc.DirectDeclarator{
· · Token: example147.c:1:11: IDENTIFIER "a",
· },
· Token: example147.c:1:13: '[',
· Token2: example147.c:1:15: ']',
}
Example (Case3)
fmt.Println(exampleAST(148, "\U00100002 auto a [ static 'b' ] ("))
Output:

&cc.DirectDeclarator{
· Case: 3,
· DirectDeclarator: &cc.DirectDeclarator{
· · Token: example148.c:1:11: IDENTIFIER "a",
· },
· Expression: &cc.Expression{
· · Type: int,
· · Value: 98,
· · Case: 1,
· · Token: example148.c:1:22: CHARCONST "'b'",
· },
· Token: example148.c:1:13: '[',
· Token2: example148.c:1:15: STATIC "static",
· Token3: example148.c:1:26: ']',
}
Example (Case4)
fmt.Println(exampleAST(149, "\U00100002 auto a [ const static 'b' ] ("))
Output:

&cc.DirectDeclarator{
· Case: 4,
· DirectDeclarator: &cc.DirectDeclarator{
· · Token: example149.c:1:11: IDENTIFIER "a",
· },
· Expression: &cc.Expression{
· · Type: int,
· · Value: 98,
· · Case: 1,
· · Token: example149.c:1:28: CHARCONST "'b'",
· },
· Token: example149.c:1:13: '[',
· Token2: example149.c:1:21: STATIC "static",
· Token3: example149.c:1:32: ']',
· TypeQualifierList: &cc.TypeQualifierList{
· · TypeQualifier: &cc.TypeQualifier{
· · · Token: example149.c:1:15: CONST "const",
· · },
· },
}
Example (Case5)
fmt.Println(exampleAST(150, "\U00100002 auto a [ * ] ("))
Output:

&cc.DirectDeclarator{
· Case: 5,
· DirectDeclarator: &cc.DirectDeclarator{
· · Token: example150.c:1:11: IDENTIFIER "a",
· },
· Token: example150.c:1:13: '[',
· Token2: example150.c:1:15: '*',
· Token3: example150.c:1:17: ']',
}
Example (Case6)
fmt.Println(exampleAST(152, "\U00100002 auto a ( auto ) ("))
Output:

&cc.DirectDeclarator{
· Case: 6,
· DirectDeclarator: &cc.DirectDeclarator{
· · Token: example152.c:1:11: IDENTIFIER "a",
· },
· ParameterTypeList: &cc.ParameterTypeList{
· · ParameterList: &cc.ParameterList{
· · · ParameterDeclaration: &cc.ParameterDeclaration{
· · · · Case: 1,
· · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · StorageClassSpecifier: &cc.StorageClassSpecifier{
· · · · · · Case: 3,
· · · · · · Token: example152.c:1:15: AUTO "auto",
· · · · · },
· · · · },
· · · },
· · },
· },
· Token: example152.c:1:13: '(',
· Token2: example152.c:1:20: ')',
}
Example (Case7)
fmt.Println(exampleAST(153, "\U00100002 auto a ( ) ("))
Output:

&cc.DirectDeclarator{
· Case: 7,
· DirectDeclarator: &cc.DirectDeclarator{
· · Token: example153.c:1:11: IDENTIFIER "a",
· },
· Token: example153.c:1:13: '(',
· Token2: example153.c:1:15: ')',
}

func (*DirectDeclarator) DeclarationScope

func (n *DirectDeclarator) DeclarationScope() *Bindings

DeclarationScope returns the scope a name declared by n is in. If n does not declare a name or n declares a name of a built in type, DeclarationScope returns nil.

func (*DirectDeclarator) Pos

func (n *DirectDeclarator) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*DirectDeclarator) String

func (n *DirectDeclarator) String() string

String implements fmt.Stringer.

func (*DirectDeclarator) TopDeclarator

func (n *DirectDeclarator) TopDeclarator() *Declarator

TopDeclarator returns the top level Declarator associated with n.

type ElifGroup

type ElifGroup struct {
	GroupListOpt *GroupListOpt
	PPTokenList  PPTokenList
	Token        xc.Token
	Token2       xc.Token
}

ElifGroup represents data reduced by production:

ElifGroup:
        PPELIF PPTokenList '\n' GroupListOpt
Example
fmt.Println(exampleAST(262, "\U00100000 \n#if other_a  \n#elif other_b  \n#elif"))
Output:

&cc.ElifGroup{
· PPTokenList: []xc.Token{ // len 3
· · 0: example262.c:3:6: ' ',
· · 1: example262.c:3:7: IDENTIFIER "other_b",
· · 2: example262.c:3:14: ' ',
· },
· Token: example262.c:3:2: PPELIF,
· Token2: example262.c:3:16: '\n',
}

func (*ElifGroup) Pos

func (n *ElifGroup) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*ElifGroup) String

func (n *ElifGroup) String() string

String implements fmt.Stringer.

type ElifGroupList

type ElifGroupList struct {
	Case          int
	ElifGroup     *ElifGroup
	ElifGroupList *ElifGroupList
}

ElifGroupList represents data reduced by productions:

ElifGroupList:
        ElifGroup
|       ElifGroupList ElifGroup  // Case 1
Example
fmt.Println(exampleAST(258, "\U00100000 \n#if other_a  \n#elif other_b  \n#elif"))
Output:

&cc.ElifGroupList{
· ElifGroup: &cc.ElifGroup{
· · PPTokenList: []xc.Token{ // len 3
· · · 0: example258.c:3:6: ' ',
· · · 1: example258.c:3:7: IDENTIFIER "other_b",
· · · 2: example258.c:3:14: ' ',
· · },
· · Token: example258.c:3:2: PPELIF,
· · Token2: example258.c:3:16: '\n',
· },
}
Example (Case1)
fmt.Println(exampleAST(259, "\U00100000 \n#if other_a  \n#elif other_b  \n#elif other_c  \n#elif"))
Output:

&cc.ElifGroupList{
· ElifGroup: &cc.ElifGroup{
· · PPTokenList: []xc.Token{ // len 3
· · · 0: example259.c:3:6: ' ',
· · · 1: example259.c:3:7: IDENTIFIER "other_b",
· · · 2: example259.c:3:14: ' ',
· · },
· · Token: example259.c:3:2: PPELIF,
· · Token2: example259.c:3:16: '\n',
· },
· ElifGroupList: &cc.ElifGroupList{
· · Case: 1,
· · ElifGroup: &cc.ElifGroup{
· · · PPTokenList: []xc.Token{ // len 3
· · · · 0: example259.c:4:6: ' ',
· · · · 1: example259.c:4:7: IDENTIFIER "other_c",
· · · · 2: example259.c:4:14: ' ',
· · · },
· · · Token: example259.c:4:2: PPELIF,
· · · Token2: example259.c:4:16: '\n',
· · },
· },
}

func (*ElifGroupList) Pos

func (n *ElifGroupList) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*ElifGroupList) String

func (n *ElifGroupList) String() string

String implements fmt.Stringer.

type ElifGroupListOpt

type ElifGroupListOpt struct {
	ElifGroupList *ElifGroupList
}

ElifGroupListOpt represents data reduced by productions:

ElifGroupListOpt:
        /* empty */
|       ElifGroupList  // Case 1
Example
fmt.Println(exampleAST(260, "\U00100000 \n#if other_a  \n#else") == (*ElifGroupListOpt)(nil))
Output:

true
Example (Case1)
fmt.Println(exampleAST(261, "\U00100000 \n#if other_a  \n#elif other_b  \n#else"))
Output:

&cc.ElifGroupListOpt{
· ElifGroupList: &cc.ElifGroupList{
· · ElifGroup: &cc.ElifGroup{
· · · PPTokenList: []xc.Token{ // len 3
· · · · 0: example261.c:3:6: ' ',
· · · · 1: example261.c:3:7: IDENTIFIER "other_b",
· · · · 2: example261.c:3:14: ' ',
· · · },
· · · Token: example261.c:3:2: PPELIF,
· · · Token2: example261.c:3:16: '\n',
· · },
· },
}

func (*ElifGroupListOpt) Pos

func (n *ElifGroupListOpt) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*ElifGroupListOpt) String

func (n *ElifGroupListOpt) String() string

String implements fmt.Stringer.

type ElseGroup

type ElseGroup struct {
	GroupListOpt *GroupListOpt
	Token        xc.Token
	Token2       xc.Token
}

ElseGroup represents data reduced by production:

ElseGroup:
        PPELSE '\n' GroupListOpt
Example
fmt.Println(exampleAST(263, "\U00100000 \n#if other_a  \n#else  \n#endif"))
Output:

&cc.ElseGroup{
· Token: example263.c:3:2: PPELSE,
· Token2: example263.c:3:8: '\n',
}

func (*ElseGroup) Pos

func (n *ElseGroup) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*ElseGroup) String

func (n *ElseGroup) String() string

String implements fmt.Stringer.

type ElseGroupOpt

type ElseGroupOpt struct {
	ElseGroup *ElseGroup
}

ElseGroupOpt represents data reduced by productions:

ElseGroupOpt:
        /* empty */
|       ElseGroup    // Case 1
Example
fmt.Println(exampleAST(264, "\U00100000 \n#if other_a  \n#endif") == (*ElseGroupOpt)(nil))
Output:

true
Example (Case1)
fmt.Println(exampleAST(265, "\U00100000 \n#if other_a  \n#else  \n#endif"))
Output:

&cc.ElseGroupOpt{
· ElseGroup: &cc.ElseGroup{
· · Token: example265.c:3:2: PPELSE,
· · Token2: example265.c:3:8: '\n',
· },
}

func (*ElseGroupOpt) Pos

func (n *ElseGroupOpt) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*ElseGroupOpt) String

func (n *ElseGroupOpt) String() string

String implements fmt.Stringer.

type EndifLine

type EndifLine struct {
	Token xc.Token
}

EndifLine represents data reduced by production:

EndifLine:
        PPENDIF
Example
fmt.Println(exampleAST(266, "\U00100000 \n#if other_a  \n#endif"))
Output:

&cc.EndifLine{
· Token: example266.c:3:2: PPENDIF,
}

func (*EndifLine) Pos

func (n *EndifLine) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*EndifLine) String

func (n *EndifLine) String() string

String implements fmt.Stringer.

type EnumConstant

type EnumConstant struct {
	DefTok xc.Token    // Enumeration constant name definition token.
	Value  interface{} // Value represented by name. Type of Value is C int.
	Tokens []xc.Token  // The tokens the constant expression consists of.
}

EnumConstant represents the name/value pair defined by an Enumerator.

type EnumSpecifier

type EnumSpecifier struct {
	Case           int
	CommaOpt       *CommaOpt
	EnumeratorList *EnumeratorList
	IdentifierOpt  *IdentifierOpt
	Token          xc.Token
	Token2         xc.Token
	Token3         xc.Token
}

EnumSpecifier represents data reduced by productions:

EnumSpecifier:
        "enum" IdentifierOpt '{' EnumeratorList CommaOpt '}'
|       "enum" IDENTIFIER                                     // Case 1
Example
fmt.Println(exampleAST(132, "\U00100002 enum { a } ("))
Output:

&cc.EnumSpecifier{
· EnumeratorList: &cc.EnumeratorList{
· · Enumerator: &cc.Enumerator{
· · · EnumerationConstant: &cc.EnumerationConstant{
· · · · Token: example132.c:1:13: IDENTIFIER "a",
· · · },
· · },
· },
· Token: example132.c:1:6: ENUM "enum",
· Token2: example132.c:1:11: '{',
· Token3: example132.c:1:15: '}',
}
Example (Case1)
fmt.Println(exampleAST(133, "\U00100002 enum a ("))
Output:

&cc.EnumSpecifier{
· Case: 1,
· Token: example133.c:1:6: ENUM "enum",
· Token2: example133.c:1:11: IDENTIFIER "a",
}

func (*EnumSpecifier) Pos

func (n *EnumSpecifier) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*EnumSpecifier) String

func (n *EnumSpecifier) String() string

String implements fmt.Stringer.

type EnumerationConstant

type EnumerationConstant struct {
	Token xc.Token
}

EnumerationConstant represents data reduced by production:

EnumerationConstant:
        IDENTIFIER
Example
fmt.Println(exampleAST(7, "\U00100002 enum { a ,"))
Output:

&cc.EnumerationConstant{
· Token: example7.c:1:13: IDENTIFIER "a",
}

func (*EnumerationConstant) Pos

func (n *EnumerationConstant) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*EnumerationConstant) String

func (n *EnumerationConstant) String() string

String implements fmt.Stringer.

type Enumerator

type Enumerator struct {
	Case                int
	ConstantExpression  *ConstantExpression
	EnumerationConstant *EnumerationConstant
	Token               xc.Token
	// contains filtered or unexported fields
}

Enumerator represents data reduced by productions:

Enumerator:
        EnumerationConstant
|       EnumerationConstant '=' ConstantExpression  // Case 1
Example
fmt.Println(exampleAST(136, "\U00100002 enum { a ,"))
Output:

&cc.Enumerator{
· EnumerationConstant: &cc.EnumerationConstant{
· · Token: example136.c:1:13: IDENTIFIER "a",
· },
}
Example (Case1)
fmt.Println(exampleAST(137, "\U00100002 enum { a = 'b' ,"))
Output:

&cc.Enumerator{
· Case: 1,
· ConstantExpression: &cc.ConstantExpression{
· · Type: int,
· · Value: 98,
· · Expression: &cc.Expression{
· · · Type: int,
· · · Value: 98,
· · · Case: 1,
· · · Token: example137.c:1:17: CHARCONST "'b'",
· · },
· },
· EnumerationConstant: &cc.EnumerationConstant{
· · Token: example137.c:1:13: IDENTIFIER "a",
· },
· Token: example137.c:1:15: '=',
}

func (*Enumerator) Pos

func (n *Enumerator) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*Enumerator) String

func (n *Enumerator) String() string

String implements fmt.Stringer.

type EnumeratorList

type EnumeratorList struct {
	Case           int
	Enumerator     *Enumerator
	EnumeratorList *EnumeratorList
	Token          xc.Token
}

EnumeratorList represents data reduced by productions:

EnumeratorList:
        Enumerator
|       EnumeratorList ',' Enumerator  // Case 1
Example
fmt.Println(exampleAST(134, "\U00100002 enum { a ,"))
Output:

&cc.EnumeratorList{
· Enumerator: &cc.Enumerator{
· · EnumerationConstant: &cc.EnumerationConstant{
· · · Token: example134.c:1:13: IDENTIFIER "a",
· · },
· },
}
Example (Case1)
fmt.Println(exampleAST(135, "\U00100002 enum { a , b ,"))
Output:

&cc.EnumeratorList{
· Enumerator: &cc.Enumerator{
· · EnumerationConstant: &cc.EnumerationConstant{
· · · Token: example135.c:1:13: IDENTIFIER "a",
· · },
· },
· EnumeratorList: &cc.EnumeratorList{
· · Case: 1,
· · Enumerator: &cc.Enumerator{
· · · EnumerationConstant: &cc.EnumerationConstant{
· · · · Token: example135.c:1:17: IDENTIFIER "b",
· · · },
· · },
· · Token: example135.c:1:15: ',',
· },
}

func (*EnumeratorList) Pos

func (n *EnumeratorList) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*EnumeratorList) String

func (n *EnumeratorList) String() string

String implements fmt.Stringer.

type Expression

type Expression struct {
	BinOpType Type        // The type operands of binary expression are coerced into, if different from Type.
	Type      Type        // Type of expression.
	Value     interface{} // Non nil for certain constant expressions.

	ArgumentExpressionListOpt *ArgumentExpressionListOpt
	Case                      int
	CommaOpt                  *CommaOpt
	Expression                *Expression
	Expression2               *Expression
	ExpressionList            *ExpressionList
	InitializerList           *InitializerList
	Token                     xc.Token
	Token2                    xc.Token
	Token3                    xc.Token
	Token4                    xc.Token
	TypeName                  *TypeName
	// contains filtered or unexported fields
}

Expression represents data reduced by productions:

Expression:
        IDENTIFIER
|       CHARCONST                                          // Case 1
|       FLOATCONST                                         // Case 2
|       INTCONST                                           // Case 3
|       LONGCHARCONST                                      // Case 4
|       LONGSTRINGLITERAL                                  // Case 5
|       STRINGLITERAL                                      // Case 6
|       '(' ExpressionList ')'                             // Case 7
|       Expression '[' ExpressionList ']'                  // Case 8
|       Expression '(' ArgumentExpressionListOpt ')'       // Case 9
|       Expression '.' IDENTIFIER                          // Case 10
|       Expression "->" IDENTIFIER                         // Case 11
|       Expression "++"                                    // Case 12
|       Expression "--"                                    // Case 13
|       '(' TypeName ')' '{' InitializerList CommaOpt '}'  // Case 14
|       "++" Expression                                    // Case 15
|       "--" Expression                                    // Case 16
|       '&' Expression                                     // Case 17
|       '*' Expression                                     // Case 18
|       '+' Expression                                     // Case 19
|       '-' Expression                                     // Case 20
|       '~' Expression                                     // Case 21
|       '!' Expression                                     // Case 22
|       "sizeof" Expression                                // Case 23
|       "sizeof" '(' TypeName ')'                          // Case 24
|       '(' TypeName ')' Expression                        // Case 25
|       Expression '*' Expression                          // Case 26
|       Expression '/' Expression                          // Case 27
|       Expression '%' Expression                          // Case 28
|       Expression '+' Expression                          // Case 29
|       Expression '-' Expression                          // Case 30
|       Expression "<<" Expression                         // Case 31
|       Expression ">>" Expression                         // Case 32
|       Expression '<' Expression                          // Case 33
|       Expression '>' Expression                          // Case 34
|       Expression "<=" Expression                         // Case 35
|       Expression ">=" Expression                         // Case 36
|       Expression "==" Expression                         // Case 37
|       Expression "!=" Expression                         // Case 38
|       Expression '&' Expression                          // Case 39
|       Expression '^' Expression                          // Case 40
|       Expression '|' Expression                          // Case 41
|       Expression "&&" Expression                         // Case 42
|       Expression "||" Expression                         // Case 43
|       Expression '?' ExpressionList ':' Expression       // Case 44
|       Expression '=' Expression                          // Case 45
|       Expression "*=" Expression                         // Case 46
|       Expression "/=" Expression                         // Case 47
|       Expression "%=" Expression                         // Case 48
|       Expression "+=" Expression                         // Case 49
|       Expression "-=" Expression                         // Case 50
|       Expression "<<=" Expression                        // Case 51
|       Expression ">>=" Expression                        // Case 52
|       Expression "&=" Expression                         // Case 53
|       Expression "^=" Expression                         // Case 54
|       Expression "|=" Expression                         // Case 55
Example
fmt.Println(exampleAST(12, "\U00100001 a"))
Output:

&cc.Expression{
· Token: example12.c:1:6: IDENTIFIER "a",
}
Example (Case01)
fmt.Println(exampleAST(13, "\U00100001 'a'"))
Output:

&cc.Expression{
· Case: 1,
· Token: example13.c:1:6: CHARCONST "'a'",
}
Example (Case02)
fmt.Println(exampleAST(14, "\U00100001 1.97"))
Output:

&cc.Expression{
· Case: 2,
· Token: example14.c:1:6: FLOATCONST "1.97",
}
Example (Case03)
fmt.Println(exampleAST(15, "\U00100001 97"))
Output:

&cc.Expression{
· Case: 3,
· Token: example15.c:1:6: INTCONST "97",
}
Example (Case04)
fmt.Println(exampleAST(16, "\U00100001 L'a'"))
Output:

&cc.Expression{
· Case: 4,
· Token: example16.c:1:6: LONGCHARCONST "L'a'",
}
Example (Case05)
fmt.Println(exampleAST(17, "\U00100001 L\"a\""))
Output:

&cc.Expression{
· Case: 5,
· Token: example17.c:1:6: LONGSTRINGLITERAL "L\"a\"",
}
Example (Case06)
fmt.Println(exampleAST(18, "\U00100001 \"a\""))
Output:

&cc.Expression{
· Case: 6,
· Token: example18.c:1:6: STRINGLITERAL "\"a\"",
}
Example (Case07)
fmt.Println(exampleAST(19, "\U00100001 ( 'a' )"))
Output:

&cc.Expression{
· Case: 7,
· ExpressionList: &cc.ExpressionList{
· · Expression: &cc.Expression{
· · · Case: 1,
· · · Token: example19.c:1:8: CHARCONST "'a'",
· · },
· },
· Token: example19.c:1:6: '(',
· Token2: example19.c:1:12: ')',
}
Example (Case08)
fmt.Println(exampleAST(20, "\U00100001 'a' [ 'b' ]"))
Output:

&cc.Expression{
· Case: 8,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example20.c:1:6: CHARCONST "'a'",
· },
· ExpressionList: &cc.ExpressionList{
· · Expression: &cc.Expression{
· · · Case: 1,
· · · Token: example20.c:1:12: CHARCONST "'b'",
· · },
· },
· Token: example20.c:1:10: '[',
· Token2: example20.c:1:16: ']',
}
Example (Case09)
fmt.Println(exampleAST(21, "\U00100001 'a' ( )"))
Output:

&cc.Expression{
· Case: 9,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example21.c:1:6: CHARCONST "'a'",
· },
· Token: example21.c:1:10: '(',
· Token2: example21.c:1:12: ')',
}
Example (Case10)
fmt.Println(exampleAST(22, "\U00100001 'a' . b"))
Output:

&cc.Expression{
· Case: 10,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example22.c:1:6: CHARCONST "'a'",
· },
· Token: example22.c:1:10: '.',
· Token2: example22.c:1:12: IDENTIFIER "b",
}
Example (Case11)
fmt.Println(exampleAST(23, "\U00100001 'a' -> b"))
Output:

&cc.Expression{
· Case: 11,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example23.c:1:6: CHARCONST "'a'",
· },
· Token: example23.c:1:10: ARROW,
· Token2: example23.c:1:13: IDENTIFIER "b",
}
Example (Case12)
fmt.Println(exampleAST(24, "\U00100001 'a' ++"))
Output:

&cc.Expression{
· Case: 12,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example24.c:1:6: CHARCONST "'a'",
· },
· Token: example24.c:1:10: INC,
}
Example (Case13)
fmt.Println(exampleAST(25, "\U00100001 'a' --"))
Output:

&cc.Expression{
· Case: 13,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example25.c:1:6: CHARCONST "'a'",
· },
· Token: example25.c:1:10: DEC,
}
Example (Case14)
fmt.Println(exampleAST(26, "\U00100001 ( _Bool ) { 'a' }"))
Output:

&cc.Expression{
· Case: 14,
· InitializerList: &cc.InitializerList{
· · Initializer: &cc.Initializer{
· · · Expression: &cc.Expression{
· · · · Type: int,
· · · · Value: 97,
· · · · Case: 1,
· · · · Token: example26.c:1:18: CHARCONST "'a'",
· · · },
· · },
· },
· Token: example26.c:1:6: '(',
· Token2: example26.c:1:14: ')',
· Token3: example26.c:1:16: '{',
· Token4: example26.c:1:22: '}',
· TypeName: &cc.TypeName{
· · Type: bool,
· · SpecifierQualifierList: &cc.SpecifierQualifierList{
· · · TypeSpecifier: &cc.TypeSpecifier{
· · · · Case: 9,
· · · · Token: example26.c:1:8: BOOL "_Bool",
· · · },
· · },
· },
}
Example (Case15)
fmt.Println(exampleAST(27, "\U00100001 ++ 'a'"))
Output:

&cc.Expression{
· Case: 15,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example27.c:1:9: CHARCONST "'a'",
· },
· Token: example27.c:1:6: INC,
}
Example (Case16)
fmt.Println(exampleAST(28, "\U00100001 -- 'a'"))
Output:

&cc.Expression{
· Case: 16,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example28.c:1:9: CHARCONST "'a'",
· },
· Token: example28.c:1:6: DEC,
}
Example (Case17)
fmt.Println(exampleAST(29, "\U00100001 & 'a'"))
Output:

&cc.Expression{
· Case: 17,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example29.c:1:8: CHARCONST "'a'",
· },
· Token: example29.c:1:6: '&',
}
Example (Case18)
fmt.Println(exampleAST(30, "\U00100001 * 'a'"))
Output:

&cc.Expression{
· Case: 18,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example30.c:1:8: CHARCONST "'a'",
· },
· Token: example30.c:1:6: '*',
}
Example (Case19)
fmt.Println(exampleAST(31, "\U00100001 + 'a'"))
Output:

&cc.Expression{
· Case: 19,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example31.c:1:8: CHARCONST "'a'",
· },
· Token: example31.c:1:6: '+',
}
Example (Case20)
fmt.Println(exampleAST(32, "\U00100001 - 'a'"))
Output:

&cc.Expression{
· Case: 20,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example32.c:1:8: CHARCONST "'a'",
· },
· Token: example32.c:1:6: '-',
}
Example (Case21)
fmt.Println(exampleAST(33, "\U00100001 ~ 'a'"))
Output:

&cc.Expression{
· Case: 21,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example33.c:1:8: CHARCONST "'a'",
· },
· Token: example33.c:1:6: '~',
}
Example (Case22)
fmt.Println(exampleAST(34, "\U00100001 ! 'a'"))
Output:

&cc.Expression{
· Case: 22,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example34.c:1:8: CHARCONST "'a'",
· },
· Token: example34.c:1:6: '!',
}
Example (Case23)
fmt.Println(exampleAST(35, "\U00100001 sizeof 'a'"))
Output:

&cc.Expression{
· Case: 23,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example35.c:1:13: CHARCONST "'a'",
· },
· Token: example35.c:1:6: SIZEOF "sizeof",
}
Example (Case24)
fmt.Println(exampleAST(36, "\U00100001 sizeof ( _Bool )"))
Output:

&cc.Expression{
· Case: 24,
· Token: example36.c:1:6: SIZEOF "sizeof",
· Token2: example36.c:1:13: '(',
· Token3: example36.c:1:21: ')',
· TypeName: &cc.TypeName{
· · Type: bool,
· · SpecifierQualifierList: &cc.SpecifierQualifierList{
· · · TypeSpecifier: &cc.TypeSpecifier{
· · · · Case: 9,
· · · · Token: example36.c:1:15: BOOL "_Bool",
· · · },
· · },
· },
}
Example (Case25)
fmt.Println(exampleAST(37, "\U00100001 ( _Bool ) 'a'"))
Output:

&cc.Expression{
· Case: 25,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example37.c:1:16: CHARCONST "'a'",
· },
· Token: example37.c:1:6: '(',
· Token2: example37.c:1:14: ')',
· TypeName: &cc.TypeName{
· · Type: bool,
· · SpecifierQualifierList: &cc.SpecifierQualifierList{
· · · TypeSpecifier: &cc.TypeSpecifier{
· · · · Case: 9,
· · · · Token: example37.c:1:8: BOOL "_Bool",
· · · },
· · },
· },
}
Example (Case26)
fmt.Println(exampleAST(38, "\U00100001 'a' * 'b'"))
Output:

&cc.Expression{
· Case: 26,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example38.c:1:6: CHARCONST "'a'",
· },
· Expression2: &cc.Expression{
· · Case: 1,
· · Token: example38.c:1:12: CHARCONST "'b'",
· },
· Token: example38.c:1:10: '*',
}
Example (Case27)
fmt.Println(exampleAST(39, "\U00100001 'a' / 'b'"))
Output:

&cc.Expression{
· Case: 27,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example39.c:1:6: CHARCONST "'a'",
· },
· Expression2: &cc.Expression{
· · Case: 1,
· · Token: example39.c:1:12: CHARCONST "'b'",
· },
· Token: example39.c:1:10: '/',
}
Example (Case28)
fmt.Println(exampleAST(40, "\U00100001 'a' % 'b'"))
Output:

&cc.Expression{
· Case: 28,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example40.c:1:6: CHARCONST "'a'",
· },
· Expression2: &cc.Expression{
· · Case: 1,
· · Token: example40.c:1:12: CHARCONST "'b'",
· },
· Token: example40.c:1:10: '%',
}
Example (Case29)
fmt.Println(exampleAST(41, "\U00100001 'a' + 'b'"))
Output:

&cc.Expression{
· Case: 29,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example41.c:1:6: CHARCONST "'a'",
· },
· Expression2: &cc.Expression{
· · Case: 1,
· · Token: example41.c:1:12: CHARCONST "'b'",
· },
· Token: example41.c:1:10: '+',
}
Example (Case30)
fmt.Println(exampleAST(42, "\U00100001 'a' - 'b'"))
Output:

&cc.Expression{
· Case: 30,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example42.c:1:6: CHARCONST "'a'",
· },
· Expression2: &cc.Expression{
· · Case: 1,
· · Token: example42.c:1:12: CHARCONST "'b'",
· },
· Token: example42.c:1:10: '-',
}
Example (Case31)
fmt.Println(exampleAST(43, "\U00100001 'a' << 'b'"))
Output:

&cc.Expression{
· Case: 31,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example43.c:1:6: CHARCONST "'a'",
· },
· Expression2: &cc.Expression{
· · Case: 1,
· · Token: example43.c:1:13: CHARCONST "'b'",
· },
· Token: example43.c:1:10: LSH,
}
Example (Case32)
fmt.Println(exampleAST(44, "\U00100001 'a' >> 'b'"))
Output:

&cc.Expression{
· Case: 32,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example44.c:1:6: CHARCONST "'a'",
· },
· Expression2: &cc.Expression{
· · Case: 1,
· · Token: example44.c:1:13: CHARCONST "'b'",
· },
· Token: example44.c:1:10: RSH,
}
Example (Case33)
fmt.Println(exampleAST(45, "\U00100001 'a' < 'b'"))
Output:

&cc.Expression{
· Case: 33,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example45.c:1:6: CHARCONST "'a'",
· },
· Expression2: &cc.Expression{
· · Case: 1,
· · Token: example45.c:1:12: CHARCONST "'b'",
· },
· Token: example45.c:1:10: '<',
}
Example (Case34)
fmt.Println(exampleAST(46, "\U00100001 'a' > 'b'"))
Output:

&cc.Expression{
· Case: 34,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example46.c:1:6: CHARCONST "'a'",
· },
· Expression2: &cc.Expression{
· · Case: 1,
· · Token: example46.c:1:12: CHARCONST "'b'",
· },
· Token: example46.c:1:10: '>',
}
Example (Case35)
fmt.Println(exampleAST(47, "\U00100001 'a' <= 'b'"))
Output:

&cc.Expression{
· Case: 35,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example47.c:1:6: CHARCONST "'a'",
· },
· Expression2: &cc.Expression{
· · Case: 1,
· · Token: example47.c:1:13: CHARCONST "'b'",
· },
· Token: example47.c:1:10: LEQ,
}
Example (Case36)
fmt.Println(exampleAST(48, "\U00100001 'a' >= 'b'"))
Output:

&cc.Expression{
· Case: 36,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example48.c:1:6: CHARCONST "'a'",
· },
· Expression2: &cc.Expression{
· · Case: 1,
· · Token: example48.c:1:13: CHARCONST "'b'",
· },
· Token: example48.c:1:10: GEQ,
}
Example (Case37)
fmt.Println(exampleAST(49, "\U00100001 'a' == 'b'"))
Output:

&cc.Expression{
· Case: 37,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example49.c:1:6: CHARCONST "'a'",
· },
· Expression2: &cc.Expression{
· · Case: 1,
· · Token: example49.c:1:13: CHARCONST "'b'",
· },
· Token: example49.c:1:10: EQ,
}
Example (Case38)
fmt.Println(exampleAST(50, "\U00100001 'a' != 'b'"))
Output:

&cc.Expression{
· Case: 38,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example50.c:1:6: CHARCONST "'a'",
· },
· Expression2: &cc.Expression{
· · Case: 1,
· · Token: example50.c:1:13: CHARCONST "'b'",
· },
· Token: example50.c:1:10: NEQ,
}
Example (Case39)
fmt.Println(exampleAST(51, "\U00100001 'a' & 'b'"))
Output:

&cc.Expression{
· Case: 39,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example51.c:1:6: CHARCONST "'a'",
· },
· Expression2: &cc.Expression{
· · Case: 1,
· · Token: example51.c:1:12: CHARCONST "'b'",
· },
· Token: example51.c:1:10: '&',
}
Example (Case40)
fmt.Println(exampleAST(52, "\U00100001 'a' ^ 'b'"))
Output:

&cc.Expression{
· Case: 40,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example52.c:1:6: CHARCONST "'a'",
· },
· Expression2: &cc.Expression{
· · Case: 1,
· · Token: example52.c:1:12: CHARCONST "'b'",
· },
· Token: example52.c:1:10: '^',
}
Example (Case41)
fmt.Println(exampleAST(53, "\U00100001 'a' | 'b'"))
Output:

&cc.Expression{
· Case: 41,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example53.c:1:6: CHARCONST "'a'",
· },
· Expression2: &cc.Expression{
· · Case: 1,
· · Token: example53.c:1:12: CHARCONST "'b'",
· },
· Token: example53.c:1:10: '|',
}
Example (Case42)
fmt.Println(exampleAST(54, "\U00100001 'a' && 'b'"))
Output:

&cc.Expression{
· Case: 42,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example54.c:1:6: CHARCONST "'a'",
· },
· Expression2: &cc.Expression{
· · Case: 1,
· · Token: example54.c:1:13: CHARCONST "'b'",
· },
· Token: example54.c:1:10: ANDAND,
}
Example (Case43)
fmt.Println(exampleAST(55, "\U00100001 'a' || 'b'"))
Output:

&cc.Expression{
· Case: 43,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example55.c:1:6: CHARCONST "'a'",
· },
· Expression2: &cc.Expression{
· · Case: 1,
· · Token: example55.c:1:13: CHARCONST "'b'",
· },
· Token: example55.c:1:10: OROR,
}
Example (Case44)
fmt.Println(exampleAST(56, "\U00100001 'a' ? 'b' : 'c'"))
Output:

&cc.Expression{
· Case: 44,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example56.c:1:6: CHARCONST "'a'",
· },
· Expression2: &cc.Expression{
· · Case: 1,
· · Token: example56.c:1:18: CHARCONST "'c'",
· },
· ExpressionList: &cc.ExpressionList{
· · Expression: &cc.Expression{
· · · Case: 1,
· · · Token: example56.c:1:12: CHARCONST "'b'",
· · },
· },
· Token: example56.c:1:10: '?',
· Token2: example56.c:1:16: ':',
}
Example (Case45)
fmt.Println(exampleAST(57, "\U00100001 'a' = 'b'"))
Output:

&cc.Expression{
· Case: 45,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example57.c:1:6: CHARCONST "'a'",
· },
· Expression2: &cc.Expression{
· · Case: 1,
· · Token: example57.c:1:12: CHARCONST "'b'",
· },
· Token: example57.c:1:10: '=',
}
Example (Case46)
fmt.Println(exampleAST(58, "\U00100001 'a' *= 'b'"))
Output:

&cc.Expression{
· Case: 46,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example58.c:1:6: CHARCONST "'a'",
· },
· Expression2: &cc.Expression{
· · Case: 1,
· · Token: example58.c:1:13: CHARCONST "'b'",
· },
· Token: example58.c:1:10: MULASSIGN,
}
Example (Case47)
fmt.Println(exampleAST(59, "\U00100001 'a' /= 'b'"))
Output:

&cc.Expression{
· Case: 47,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example59.c:1:6: CHARCONST "'a'",
· },
· Expression2: &cc.Expression{
· · Case: 1,
· · Token: example59.c:1:13: CHARCONST "'b'",
· },
· Token: example59.c:1:10: DIVASSIGN,
}
Example (Case48)
fmt.Println(exampleAST(60, "\U00100001 'a' %= 'b'"))
Output:

&cc.Expression{
· Case: 48,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example60.c:1:6: CHARCONST "'a'",
· },
· Expression2: &cc.Expression{
· · Case: 1,
· · Token: example60.c:1:13: CHARCONST "'b'",
· },
· Token: example60.c:1:10: MODASSIGN,
}
Example (Case49)
fmt.Println(exampleAST(61, "\U00100001 'a' += 'b'"))
Output:

&cc.Expression{
· Case: 49,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example61.c:1:6: CHARCONST "'a'",
· },
· Expression2: &cc.Expression{
· · Case: 1,
· · Token: example61.c:1:13: CHARCONST "'b'",
· },
· Token: example61.c:1:10: ADDASSIGN,
}
Example (Case50)
fmt.Println(exampleAST(62, "\U00100001 'a' -= 'b'"))
Output:

&cc.Expression{
· Case: 50,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example62.c:1:6: CHARCONST "'a'",
· },
· Expression2: &cc.Expression{
· · Case: 1,
· · Token: example62.c:1:13: CHARCONST "'b'",
· },
· Token: example62.c:1:10: SUBASSIGN,
}
Example (Case51)
fmt.Println(exampleAST(63, "\U00100001 'a' <<= 'b'"))
Output:

&cc.Expression{
· Case: 51,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example63.c:1:6: CHARCONST "'a'",
· },
· Expression2: &cc.Expression{
· · Case: 1,
· · Token: example63.c:1:14: CHARCONST "'b'",
· },
· Token: example63.c:1:10: LSHASSIGN,
}
Example (Case52)
fmt.Println(exampleAST(64, "\U00100001 'a' >>= 'b'"))
Output:

&cc.Expression{
· Case: 52,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example64.c:1:6: CHARCONST "'a'",
· },
· Expression2: &cc.Expression{
· · Case: 1,
· · Token: example64.c:1:14: CHARCONST "'b'",
· },
· Token: example64.c:1:10: RSHASSIGN,
}
Example (Case53)
fmt.Println(exampleAST(65, "\U00100001 'a' &= 'b'"))
Output:

&cc.Expression{
· Case: 53,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example65.c:1:6: CHARCONST "'a'",
· },
· Expression2: &cc.Expression{
· · Case: 1,
· · Token: example65.c:1:13: CHARCONST "'b'",
· },
· Token: example65.c:1:10: ANDASSIGN,
}
Example (Case54)
fmt.Println(exampleAST(66, "\U00100001 'a' ^= 'b'"))
Output:

&cc.Expression{
· Case: 54,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example66.c:1:6: CHARCONST "'a'",
· },
· Expression2: &cc.Expression{
· · Case: 1,
· · Token: example66.c:1:13: CHARCONST "'b'",
· },
· Token: example66.c:1:10: XORASSIGN,
}
Example (Case55)
fmt.Println(exampleAST(67, "\U00100001 'a' |= 'b'"))
Output:

&cc.Expression{
· Case: 55,
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example67.c:1:6: CHARCONST "'a'",
· },
· Expression2: &cc.Expression{
· · Case: 1,
· · Token: example67.c:1:13: CHARCONST "'b'",
· },
· Token: example67.c:1:10: ORASSIGN,
}

func (*Expression) IdentResolutionScope

func (n *Expression) IdentResolutionScope() *Bindings

IdentResolutionScope returns the scope an identifier is resolved in. If n is not an identifier (n.Case == 0), IdentResolutionScope returns nil.

func (*Expression) Pos

func (n *Expression) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*Expression) String

func (n *Expression) String() string

String implements fmt.Stringer.

type ExpressionList

type ExpressionList struct {
	Type           Type        // Type of expression.
	Value          interface{} // Non nil for certain constant expressions.
	Case           int
	Expression     *Expression
	ExpressionList *ExpressionList
	Token          xc.Token
}

ExpressionList represents data reduced by productions:

ExpressionList:
        Expression
|       ExpressionList ',' Expression  // Case 1
Example
fmt.Println(exampleAST(70, "\U00100001 ( 'a' )"))
Output:

&cc.ExpressionList{
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example70.c:1:8: CHARCONST "'a'",
· },
}
Example (Case1)
fmt.Println(exampleAST(71, "\U00100001 ( 'a' , 'b' )"))
Output:

&cc.ExpressionList{
· Expression: &cc.Expression{
· · Case: 1,
· · Token: example71.c:1:8: CHARCONST "'a'",
· },
· ExpressionList: &cc.ExpressionList{
· · Case: 1,
· · Expression: &cc.Expression{
· · · Case: 1,
· · · Token: example71.c:1:14: CHARCONST "'b'",
· · },
· · Token: example71.c:1:12: ',',
· },
}

func (*ExpressionList) Len

func (n *ExpressionList) Len() (r int)

Len returns the number of items in n.

func (*ExpressionList) Pos

func (n *ExpressionList) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*ExpressionList) String

func (n *ExpressionList) String() string

String implements fmt.Stringer.

type ExpressionListOpt

type ExpressionListOpt struct {
	ExpressionList *ExpressionList
}

ExpressionListOpt represents data reduced by productions:

ExpressionListOpt:
        /* empty */
|       ExpressionList  // Case 1
Example
fmt.Println(exampleAST(72, "\U00100002 auto a { ;") == (*ExpressionListOpt)(nil))
Output:

true
Example (Case1)
fmt.Println(exampleAST(73, "\U00100002 auto a { 'b' )"))
Output:

&cc.ExpressionListOpt{
· ExpressionList: &cc.ExpressionList{
· · Type: int,
· · Value: 98,
· · Expression: &cc.Expression{
· · · Type: int,
· · · Value: 98,
· · · Case: 1,
· · · Token: example73.c:1:15: CHARCONST "'b'",
· · },
· },
}

func (*ExpressionListOpt) Pos

func (n *ExpressionListOpt) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*ExpressionListOpt) String

func (n *ExpressionListOpt) String() string

String implements fmt.Stringer.

type ExpressionOpt

type ExpressionOpt struct {
	Expression *Expression
}

ExpressionOpt represents data reduced by productions:

ExpressionOpt:
        /* empty */
|       Expression   // Case 1
Example
fmt.Println(exampleAST(68, "\U00100001 ( _Bool [ ]") == (*ExpressionOpt)(nil))
Output:

true
Example (Case1)
fmt.Println(exampleAST(69, "\U00100001 ( _Bool [ 'a' ]"))
Output:

&cc.ExpressionOpt{
· Expression: &cc.Expression{
· · Type: int,
· · Value: 97,
· · Case: 1,
· · Token: example69.c:1:16: CHARCONST "'a'",
· },
}

func (*ExpressionOpt) Pos

func (n *ExpressionOpt) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*ExpressionOpt) String

func (n *ExpressionOpt) String() string

String implements fmt.Stringer.

type ExpressionStatement

type ExpressionStatement struct {
	ExpressionListOpt *ExpressionListOpt
	Token             xc.Token
}

ExpressionStatement represents data reduced by production:

ExpressionStatement:
        ExpressionListOpt ';'
Example
fmt.Println(exampleAST(222, "\U00100002 auto a { ; !"))
Output:

&cc.ExpressionStatement{
· Token: example222.c:1:15: ';',
}

func (*ExpressionStatement) Pos

func (n *ExpressionStatement) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*ExpressionStatement) String

func (n *ExpressionStatement) String() string

String implements fmt.Stringer.

type ExternalDeclaration

type ExternalDeclaration struct {
	Case               int
	Declaration        *Declaration
	FunctionDefinition *FunctionDefinition
}

ExternalDeclaration represents data reduced by productions:

ExternalDeclaration:
        FunctionDefinition
|       Declaration         // Case 1
Example
fmt.Println(exampleAST(236, "\U00100002 auto a { }"))
Output:

&cc.ExternalDeclaration{
· FunctionDefinition: &cc.FunctionDefinition{
· · CompoundStatement: &cc.CompoundStatement{
· · · Token: example236.c:1:13: '{',
· · · Token2: example236.c:1:15: '}',
· · },
· · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · StorageClassSpecifier: &cc.StorageClassSpecifier{
· · · · Case: 3,
· · · · Token: example236.c:1:6: AUTO "auto",
· · · },
· · },
· · Declarator: &cc.Declarator{
· · · Linkage: None,
· · · Type: auto undefined,
· · · DirectDeclarator: &cc.DirectDeclarator{
· · · · Token: example236.c:1:11: IDENTIFIER "a",
· · · },
· · },
· },
}
Example (Case1)
fmt.Println(exampleAST(237, "\U00100002 auto ;"))
Output:

&cc.ExternalDeclaration{
· Case: 1,
· Declaration: &cc.Declaration{
· · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · StorageClassSpecifier: &cc.StorageClassSpecifier{
· · · · Case: 3,
· · · · Token: example237.c:1:6: AUTO "auto",
· · · },
· · },
· · Token: example237.c:1:11: ';',
· },
}

func (*ExternalDeclaration) Pos

func (n *ExternalDeclaration) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*ExternalDeclaration) String

func (n *ExternalDeclaration) String() string

String implements fmt.Stringer.

type FunctionDefinition

type FunctionDefinition struct {
	CompoundStatement     *CompoundStatement
	DeclarationListOpt    *DeclarationListOpt
	DeclarationSpecifiers *DeclarationSpecifiers
	Declarator            *Declarator
}

FunctionDefinition represents data reduced by production:

FunctionDefinition:
        DeclarationSpecifiers Declarator DeclarationListOpt CompoundStatement
Example
fmt.Println(exampleAST(239, "\U00100002 auto a { }"))
Output:

&cc.FunctionDefinition{
· CompoundStatement: &cc.CompoundStatement{
· · Token: example239.c:1:13: '{',
· · Token2: example239.c:1:15: '}',
· },
· DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · StorageClassSpecifier: &cc.StorageClassSpecifier{
· · · Case: 3,
· · · Token: example239.c:1:6: AUTO "auto",
· · },
· },
· Declarator: &cc.Declarator{
· · Linkage: None,
· · Type: auto undefined,
· · DirectDeclarator: &cc.DirectDeclarator{
· · · Token: example239.c:1:11: IDENTIFIER "a",
· · },
· },
}

func (*FunctionDefinition) Pos

func (n *FunctionDefinition) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*FunctionDefinition) String

func (n *FunctionDefinition) String() string

String implements fmt.Stringer.

type FunctionSpecifier

type FunctionSpecifier struct {
	Token xc.Token
	// contains filtered or unexported fields
}

FunctionSpecifier represents data reduced by production:

FunctionSpecifier:
        "inline"
Example
fmt.Println(exampleAST(141, "\U00100002 inline ("))
Output:

&cc.FunctionSpecifier{
· Token: example141.c:1:6: INLINE "inline",
}

func (*FunctionSpecifier) Pos

func (n *FunctionSpecifier) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*FunctionSpecifier) String

func (n *FunctionSpecifier) String() string

String implements fmt.Stringer.

type GroupList

type GroupList struct {
	Case      int
	GroupList *GroupList
	GroupPart Node
}

GroupList represents data reduced by productions:

GroupList:
        GroupPart
|       GroupList GroupPart  // Case 1
Example
fmt.Println(exampleAST(246, "\U00100000 "))
Output:

&cc.GroupList{
}
Example (Case1)
fmt.Println(exampleAST(247, "\U00100000int\nf() {}"))
Output:

&cc.GroupList{
· GroupList: &cc.GroupList{
· · Case: 1,
· · GroupPart: []xc.Token{ // len 6
· · · 0: example247.c:2:1: IDENTIFIER "f",
· · · 1: example247.c:2:2: '(',
· · · 2: example247.c:2:3: ')',
· · · 3: example247.c:2:4: ' ',
· · · 4: example247.c:2:5: '{',
· · · 5: example247.c:2:6: '}',
· · },
· },
· GroupPart: []xc.Token{ // len 1
· · 0: example247.c:1:5: IDENTIFIER "int",
· },
}

func (*GroupList) Pos

func (n *GroupList) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*GroupList) String

func (n *GroupList) String() string

String implements fmt.Stringer.

type GroupListOpt

type GroupListOpt struct {
	GroupList *GroupList
}

GroupListOpt represents data reduced by productions:

GroupListOpt:
        /* empty */
|       GroupList    // Case 1
Example
fmt.Println(exampleAST(248, "\U00100000 \n#ifndef a  \n#elif") == (*GroupListOpt)(nil))
Output:

true
Example (Case1)
fmt.Println(exampleAST(249, "\U00100000 \n#ifndef a\nb\n#elif"))
Output:

&cc.GroupListOpt{
· GroupList: &cc.GroupList{
· · GroupPart: []xc.Token{ // len 1
· · · 0: example249.c:3:1: IDENTIFIER "b",
· · },
· },
}

func (*GroupListOpt) Pos

func (n *GroupListOpt) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*GroupListOpt) String

func (n *GroupListOpt) String() string

String implements fmt.Stringer.

type IdentifierList

type IdentifierList struct {
	Case           int
	IdentifierList *IdentifierList
	Token          xc.Token
	Token2         xc.Token
}

IdentifierList represents data reduced by productions:

IdentifierList:
        IDENTIFIER
|       IdentifierList ',' IDENTIFIER  // Case 1
Example
fmt.Println(exampleAST(170, "\U00100002 auto a ( b )"))
Output:

&cc.IdentifierList{
· Token: example170.c:1:15: IDENTIFIER "b",
}
Example (Case1)
fmt.Println(exampleAST(171, "\U00100002 auto a ( b , c )"))
Output:

&cc.IdentifierList{
· IdentifierList: &cc.IdentifierList{
· · Case: 1,
· · Token: example171.c:1:17: ',',
· · Token2: example171.c:1:19: IDENTIFIER "c",
· },
· Token: example171.c:1:15: IDENTIFIER "b",
}

func (*IdentifierList) Pos

func (n *IdentifierList) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*IdentifierList) String

func (n *IdentifierList) String() string

String implements fmt.Stringer.

type IdentifierListOpt

type IdentifierListOpt struct {
	IdentifierList *IdentifierList
	// contains filtered or unexported fields
}

IdentifierListOpt represents data reduced by productions:

IdentifierListOpt:
        /* empty */
|       IdentifierList  // Case 1
Example
fmt.Println(exampleAST(172, "\U00100002 auto a ( )") == (*IdentifierListOpt)(nil))
Output:

true
Example (Case1)
fmt.Println(exampleAST(173, "\U00100002 auto a ( b )"))
Output:

&cc.IdentifierListOpt{
· IdentifierList: &cc.IdentifierList{
· · Token: example173.c:1:15: IDENTIFIER "b",
· },
}

func (*IdentifierListOpt) Pos

func (n *IdentifierListOpt) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*IdentifierListOpt) String

func (n *IdentifierListOpt) String() string

String implements fmt.Stringer.

type IdentifierOpt

type IdentifierOpt struct {
	Token xc.Token
}

IdentifierOpt represents data reduced by productions:

IdentifierOpt:
        /* empty */
|       IDENTIFIER   // Case 1
Example
fmt.Println(exampleAST(174, "\U00100002 struct {") == (*IdentifierOpt)(nil))
Output:

true
Example (Case1)
fmt.Println(exampleAST(175, "\U00100002 enum a {"))
Output:

&cc.IdentifierOpt{
· Token: example175.c:1:11: IDENTIFIER "a",
}

func (*IdentifierOpt) Pos

func (n *IdentifierOpt) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*IdentifierOpt) String

func (n *IdentifierOpt) String() string

String implements fmt.Stringer.

type IfGroup

type IfGroup struct {
	Case         int
	GroupListOpt *GroupListOpt
	PPTokenList  PPTokenList
	Token        xc.Token
	Token2       xc.Token
	Token3       xc.Token
}

IfGroup represents data reduced by productions:

IfGroup:
        PPIF PPTokenList '\n' GroupListOpt
|       PPIFDEF IDENTIFIER '\n' GroupListOpt   // Case 1
|       PPIFNDEF IDENTIFIER '\n' GroupListOpt  // Case 2
Example
fmt.Println(exampleAST(255, "\U00100000 \n#if other_a  \n#elif"))
Output:

&cc.IfGroup{
· PPTokenList: []xc.Token{ // len 3
· · 0: example255.c:2:4: ' ',
· · 1: example255.c:2:5: IDENTIFIER "other_a",
· · 2: example255.c:2:12: ' ',
· },
· Token: example255.c:2:2: PPIF,
· Token2: example255.c:2:14: '\n',
}
Example (Case1)
fmt.Println(exampleAST(256, "\U00100000 \n#ifdef a  \n#elif"))
Output:

&cc.IfGroup{
· Case: 1,
· Token: example256.c:2:2: PPIFDEF,
· Token2: example256.c:2:8: IDENTIFIER "a",
· Token3: example256.c:2:11: '\n',
}
Example (Case2)
fmt.Println(exampleAST(257, "\U00100000 \n#ifndef a  \n#elif"))
Output:

&cc.IfGroup{
· Case: 2,
· Token: example257.c:2:2: PPIFNDEF,
· Token2: example257.c:2:9: IDENTIFIER "a",
· Token3: example257.c:2:12: '\n',
}

func (*IfGroup) Pos

func (n *IfGroup) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*IfGroup) String

func (n *IfGroup) String() string

String implements fmt.Stringer.

type IfSection

type IfSection struct {
	ElifGroupListOpt *ElifGroupListOpt
	ElseGroupOpt     *ElseGroupOpt
	EndifLine        *EndifLine
	IfGroup          *IfGroup
}

IfSection represents data reduced by production:

IfSection:
        IfGroup ElifGroupListOpt ElseGroupOpt EndifLine
Example
fmt.Println(exampleAST(254, "\U00100000 \n#if other_a  \n#endif"))
Output:

&cc.IfSection{
· EndifLine: &cc.EndifLine{
· · Token: example254.c:3:2: PPENDIF,
· },
· IfGroup: &cc.IfGroup{
· · PPTokenList: []xc.Token{ // len 3
· · · 0: example254.c:2:4: ' ',
· · · 1: example254.c:2:5: IDENTIFIER "other_a",
· · · 2: example254.c:2:12: ' ',
· · },
· · Token: example254.c:2:2: PPIF,
· · Token2: example254.c:2:14: '\n',
· },
}

func (*IfSection) Pos

func (n *IfSection) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*IfSection) String

func (n *IfSection) String() string

String implements fmt.Stringer.

type InitDeclarator

type InitDeclarator struct {
	Case        int
	Declarator  *Declarator
	Initializer *Initializer
	Token       xc.Token
}

InitDeclarator represents data reduced by productions:

InitDeclarator:
        Declarator
|       Declarator '=' Initializer  // Case 1
Example
fmt.Println(exampleAST(87, "\U00100002 auto a ,"))
Output:

&cc.InitDeclarator{
· Declarator: &cc.Declarator{
· · Linkage: None,
· · Type: auto undefined,
· · DirectDeclarator: &cc.DirectDeclarator{
· · · Token: example87.c:1:11: IDENTIFIER "a",
· · },
· },
}
Example (Case1)
fmt.Println(exampleAST(89, "\U00100002 auto a = 'b' ,"))
Output:

&cc.InitDeclarator{
· Case: 1,
· Declarator: &cc.Declarator{
· · Linkage: None,
· · Type: auto undefined,
· · DirectDeclarator: &cc.DirectDeclarator{
· · · Token: example89.c:1:11: IDENTIFIER "a",
· · },
· },
· Initializer: &cc.Initializer{
· · Expression: &cc.Expression{
· · · Type: int,
· · · Value: 98,
· · · Case: 1,
· · · Token: example89.c:1:15: CHARCONST "'b'",
· · },
· },
· Token: example89.c:1:13: '=',
}

func (*InitDeclarator) Pos

func (n *InitDeclarator) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*InitDeclarator) String

func (n *InitDeclarator) String() string

String implements fmt.Stringer.

type InitDeclaratorList

type InitDeclaratorList struct {
	Case               int
	InitDeclarator     *InitDeclarator
	InitDeclaratorList *InitDeclaratorList
	Token              xc.Token
}

InitDeclaratorList represents data reduced by productions:

InitDeclaratorList:
        InitDeclarator
|       InitDeclaratorList ',' InitDeclarator  // Case 1
Example
fmt.Println(exampleAST(83, "\U00100002 auto a ,"))
Output:

&cc.InitDeclaratorList{
· InitDeclarator: &cc.InitDeclarator{
· · Declarator: &cc.Declarator{
· · · Linkage: None,
· · · Type: auto undefined,
· · · DirectDeclarator: &cc.DirectDeclarator{
· · · · Token: example83.c:1:11: IDENTIFIER "a",
· · · },
· · },
· },
}
Example (Case1)
fmt.Println(exampleAST(84, "\U00100002 auto a , b ,"))
Output:

&cc.InitDeclaratorList{
· InitDeclarator: &cc.InitDeclarator{
· · Declarator: &cc.Declarator{
· · · Linkage: None,
· · · Type: auto undefined,
· · · DirectDeclarator: &cc.DirectDeclarator{
· · · · Token: example84.c:1:11: IDENTIFIER "a",
· · · },
· · },
· },
· InitDeclaratorList: &cc.InitDeclaratorList{
· · Case: 1,
· · InitDeclarator: &cc.InitDeclarator{
· · · Declarator: &cc.Declarator{
· · · · Linkage: None,
· · · · Type: auto undefined,
· · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · Token: example84.c:1:15: IDENTIFIER "b",
· · · · },
· · · },
· · },
· · Token: example84.c:1:13: ',',
· },
}

func (*InitDeclaratorList) Pos

func (n *InitDeclaratorList) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*InitDeclaratorList) String

func (n *InitDeclaratorList) String() string

String implements fmt.Stringer.

type InitDeclaratorListOpt

type InitDeclaratorListOpt struct {
	InitDeclaratorList *InitDeclaratorList
}

InitDeclaratorListOpt represents data reduced by productions:

InitDeclaratorListOpt:
        /* empty */
|       InitDeclaratorList  // Case 1
Example
fmt.Println(exampleAST(85, "\U00100002 auto ;") == (*InitDeclaratorListOpt)(nil))
Output:

true
Example (Case1)
fmt.Println(exampleAST(86, "\U00100002 auto a ;"))
Output:

&cc.InitDeclaratorListOpt{
· InitDeclaratorList: &cc.InitDeclaratorList{
· · InitDeclarator: &cc.InitDeclarator{
· · · Declarator: &cc.Declarator{
· · · · Linkage: None,
· · · · Type: auto undefined,
· · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · Token: example86.c:1:11: IDENTIFIER "a",
· · · · },
· · · },
· · },
· },
}

func (*InitDeclaratorListOpt) Pos

func (n *InitDeclaratorListOpt) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*InitDeclaratorListOpt) String

func (n *InitDeclaratorListOpt) String() string

String implements fmt.Stringer.

type Initializer

type Initializer struct {
	Case            int
	CommaOpt        *CommaOpt
	Expression      *Expression
	InitializerList *InitializerList
	Token           xc.Token
	Token2          xc.Token
}

Initializer represents data reduced by productions:

Initializer:
        Expression
|       '{' InitializerList CommaOpt '}'  // Case 1
Example
fmt.Println(exampleAST(194, "\U00100002 auto a = 'b' ,"))
Output:

&cc.Initializer{
· Expression: &cc.Expression{
· · Type: int,
· · Value: 98,
· · Case: 1,
· · Token: example194.c:1:15: CHARCONST "'b'",
· },
}
Example (Case1)
fmt.Println(exampleAST(195, "\U00100002 auto a = { 'b' } ,"))
Output:

&cc.Initializer{
· Case: 1,
· InitializerList: &cc.InitializerList{
· · Initializer: &cc.Initializer{
· · · Expression: &cc.Expression{
· · · · Type: int,
· · · · Value: 98,
· · · · Case: 1,
· · · · Token: example195.c:1:17: CHARCONST "'b'",
· · · },
· · },
· },
· Token: example195.c:1:15: '{',
· Token2: example195.c:1:21: '}',
}

func (*Initializer) Pos

func (n *Initializer) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*Initializer) String

func (n *Initializer) String() string

String implements fmt.Stringer.

type InitializerList

type InitializerList struct {
	Case            int
	DesignationOpt  *DesignationOpt
	Initializer     *Initializer
	InitializerList *InitializerList
	Token           xc.Token
}

InitializerList represents data reduced by productions:

InitializerList:
        DesignationOpt Initializer
|       InitializerList ',' DesignationOpt Initializer  // Case 1
Example
fmt.Println(exampleAST(196, "\U00100001 ( _Bool ) { 'a' ,"))
Output:

&cc.InitializerList{
· Initializer: &cc.Initializer{
· · Expression: &cc.Expression{
· · · Type: int,
· · · Value: 97,
· · · Case: 1,
· · · Token: example196.c:1:18: CHARCONST "'a'",
· · },
· },
}
Example (Case1)
fmt.Println(exampleAST(197, "\U00100001 ( _Bool ) { 'a' , 'b' ,"))
Output:

&cc.InitializerList{
· Initializer: &cc.Initializer{
· · Expression: &cc.Expression{
· · · Type: int,
· · · Value: 97,
· · · Case: 1,
· · · Token: example197.c:1:18: CHARCONST "'a'",
· · },
· },
· InitializerList: &cc.InitializerList{
· · Case: 1,
· · Initializer: &cc.Initializer{
· · · Expression: &cc.Expression{
· · · · Type: int,
· · · · Value: 98,
· · · · Case: 1,
· · · · Token: example197.c:1:24: CHARCONST "'b'",
· · · },
· · },
· · Token: example197.c:1:22: ',',
· },
}

func (*InitializerList) Len

func (n *InitializerList) Len() (r int)

Len returns the number of items in n.

func (*InitializerList) Pos

func (n *InitializerList) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*InitializerList) String

func (n *InitializerList) String() string

String implements fmt.Stringer.

type IterationStatement

type IterationStatement struct {
	Case               int
	Declaration        *Declaration
	ExpressionList     *ExpressionList
	ExpressionListOpt  *ExpressionListOpt
	ExpressionListOpt2 *ExpressionListOpt
	ExpressionListOpt3 *ExpressionListOpt
	Statement          *Statement
	Token              xc.Token
	Token2             xc.Token
	Token3             xc.Token
	Token4             xc.Token
	Token5             xc.Token
}

IterationStatement represents data reduced by productions:

IterationStatement:
        "while" '(' ExpressionList ')' Statement
|       "do" Statement "while" '(' ExpressionList ')' ';'                                      // Case 1
|       "for" '(' ExpressionListOpt ';' ExpressionListOpt ';' ExpressionListOpt ')' Statement  // Case 2
|       "for" '(' Declaration ExpressionListOpt ';' ExpressionListOpt ')' Statement            // Case 3
Example
fmt.Println(exampleAST(226, "\U00100002 auto a { while ( 'b' ) ; !"))
Output:

&cc.IterationStatement{
· ExpressionList: &cc.ExpressionList{
· · Type: int,
· · Value: 98,
· · Expression: &cc.Expression{
· · · Type: int,
· · · Value: 98,
· · · Case: 1,
· · · Token: example226.c:1:23: CHARCONST "'b'",
· · },
· },
· Statement: &cc.Statement{
· · Case: 2,
· · ExpressionStatement: &cc.ExpressionStatement{
· · · Token: example226.c:1:29: ';',
· · },
· },
· Token: example226.c:1:15: WHILE "while",
· Token2: example226.c:1:21: '(',
· Token3: example226.c:1:27: ')',
}
Example (Case1)
fmt.Println(exampleAST(227, "\U00100002 auto a { do ; while ( 'b' ) ; !"))
Output:

&cc.IterationStatement{
· Case: 1,
· ExpressionList: &cc.ExpressionList{
· · Type: int,
· · Value: 98,
· · Expression: &cc.Expression{
· · · Type: int,
· · · Value: 98,
· · · Case: 1,
· · · Token: example227.c:1:28: CHARCONST "'b'",
· · },
· },
· Statement: &cc.Statement{
· · Case: 2,
· · ExpressionStatement: &cc.ExpressionStatement{
· · · Token: example227.c:1:18: ';',
· · },
· },
· Token: example227.c:1:15: DO "do",
· Token2: example227.c:1:20: WHILE "while",
· Token3: example227.c:1:26: '(',
· Token4: example227.c:1:32: ')',
· Token5: example227.c:1:34: ';',
}
Example (Case2)
fmt.Println(exampleAST(228, "\U00100002 auto a { for ( ; ; ) ; !"))
Output:

&cc.IterationStatement{
· Case: 2,
· Statement: &cc.Statement{
· · Case: 2,
· · ExpressionStatement: &cc.ExpressionStatement{
· · · Token: example228.c:1:27: ';',
· · },
· },
· Token: example228.c:1:15: FOR "for",
· Token2: example228.c:1:19: '(',
· Token3: example228.c:1:21: ';',
· Token4: example228.c:1:23: ';',
· Token5: example228.c:1:25: ')',
}
Example (Case3)
fmt.Println(exampleAST(229, "\U00100002 auto a { for ( auto ; ; ) ; !"))
Output:

&cc.IterationStatement{
· Case: 3,
· Declaration: &cc.Declaration{
· · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · StorageClassSpecifier: &cc.StorageClassSpecifier{
· · · · Case: 3,
· · · · Token: example229.c:1:21: AUTO "auto",
· · · },
· · },
· · Token: example229.c:1:26: ';',
· },
· Statement: &cc.Statement{
· · Case: 2,
· · ExpressionStatement: &cc.ExpressionStatement{
· · · Token: example229.c:1:32: ';',
· · },
· },
· Token: example229.c:1:15: FOR "for",
· Token2: example229.c:1:19: '(',
· Token3: example229.c:1:28: ';',
· Token4: example229.c:1:30: ')',
}

func (*IterationStatement) Pos

func (n *IterationStatement) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*IterationStatement) String

func (n *IterationStatement) String() string

String implements fmt.Stringer.

type JumpStatement

type JumpStatement struct {
	Case              int
	ExpressionListOpt *ExpressionListOpt
	Token             xc.Token
	Token2            xc.Token
	Token3            xc.Token
}

JumpStatement represents data reduced by productions:

JumpStatement:
        "goto" IDENTIFIER ';'
|       "continue" ';'                  // Case 1
|       "break" ';'                     // Case 2
|       "return" ExpressionListOpt ';'  // Case 3
Example
fmt.Println(exampleAST(230, "\U00100002 auto a { goto b ; !"))
Output:

&cc.JumpStatement{
· Token: example230.c:1:15: GOTO "goto",
· Token2: example230.c:1:20: IDENTIFIER "b",
· Token3: example230.c:1:22: ';',
}
Example (Case1)
fmt.Println(exampleAST(231, "\U00100002 auto a { continue ; !"))
Output:

&cc.JumpStatement{
· Case: 1,
· Token: example231.c:1:15: CONTINUE "continue",
· Token2: example231.c:1:24: ';',
}
Example (Case2)
fmt.Println(exampleAST(232, "\U00100002 auto a { break ; !"))
Output:

&cc.JumpStatement{
· Case: 2,
· Token: example232.c:1:15: BREAK "break",
· Token2: example232.c:1:21: ';',
}
Example (Case3)
fmt.Println(exampleAST(233, "\U00100002 auto a { return ; !"))
Output:

&cc.JumpStatement{
· Case: 3,
· Token: example233.c:1:15: RETURN "return",
· Token2: example233.c:1:22: ';',
}

func (*JumpStatement) Pos

func (n *JumpStatement) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*JumpStatement) String

func (n *JumpStatement) String() string

String implements fmt.Stringer.

type Kind

type Kind int

Kind is a type category. Kind formally implements Type the only method returning a non nil value is Kind.

const (
	Undefined Kind = iota
	Void
	Ptr
	UintPtr // Type used for pointer arithmetic.
	Char
	SChar
	UChar
	Short
	UShort
	Int
	UInt
	Long
	ULong
	LongLong
	ULongLong
	Float
	Double
	LongDouble
	Bool
	FloatComplex
	DoubleComplex
	LongDoubleComplex
	Struct
	Union
	Enum
	TypedefName
	Function
	Array
)

Values of type Kind.

func (Kind) CString

func (k Kind) CString() string

func (Kind) String

func (i Kind) String() string

type LabeledStatement

type LabeledStatement struct {
	Case               int
	ConstantExpression *ConstantExpression
	Statement          *Statement
	Token              xc.Token
	Token2             xc.Token
}

LabeledStatement represents data reduced by productions:

LabeledStatement:
        IDENTIFIER ':' Statement
|       "case" ConstantExpression ':' Statement  // Case 1
|       "default" ':' Statement                  // Case 2
Example
fmt.Println(exampleAST(211, "\U00100002 auto a { b : ; !"))
Output:

&cc.LabeledStatement{
· Statement: &cc.Statement{
· · Case: 2,
· · ExpressionStatement: &cc.ExpressionStatement{
· · · Token: example211.c:1:19: ';',
· · },
· },
· Token: example211.c:1:15: IDENTIFIER "b",
· Token2: example211.c:1:17: ':',
}
Example (Case1)
fmt.Println(exampleAST(212, "\U00100002 auto a { case 'b' : ; !"))
Output:

&cc.LabeledStatement{
· Case: 1,
· ConstantExpression: &cc.ConstantExpression{
· · Type: int,
· · Value: 98,
· · Expression: &cc.Expression{
· · · Type: int,
· · · Value: 98,
· · · Case: 1,
· · · Token: example212.c:1:20: CHARCONST "'b'",
· · },
· },
· Statement: &cc.Statement{
· · Case: 2,
· · ExpressionStatement: &cc.ExpressionStatement{
· · · Token: example212.c:1:26: ';',
· · },
· },
· Token: example212.c:1:15: CASE "case",
· Token2: example212.c:1:24: ':',
}
Example (Case2)
fmt.Println(exampleAST(213, "\U00100002 auto a { default : ; !"))
Output:

&cc.LabeledStatement{
· Case: 2,
· Statement: &cc.Statement{
· · Case: 2,
· · ExpressionStatement: &cc.ExpressionStatement{
· · · Token: example213.c:1:25: ';',
· · },
· },
· Token: example213.c:1:15: DEFAULT "default",
· Token2: example213.c:1:23: ':',
}

func (*LabeledStatement) Pos

func (n *LabeledStatement) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*LabeledStatement) String

func (n *LabeledStatement) String() string

String implements fmt.Stringer.

type Linkage

type Linkage int

Linkage is a C linkage kind ([0], 6.2.2, p. 30)

const (
	None Linkage = iota
	Internal
	External
)

Values of type Linkage.

func (Linkage) String

func (i Linkage) String() string

type LongStringLitID

type LongStringLitID int

LongStringLitID is the type of an Expression.Value representing the numeric ID of a long string literal.

type Macro

type Macro struct {
	Args     []int       // Numeric IDs of argument identifiers.
	DefTok   xc.Token    // Macro name definition token.
	IsFnLike bool        // Whether the macro is function like.
	Type     Type        // Non nil if macro expands to a constant expression.
	Value    interface{} // Non nil if macro expands to a constant expression.
	// contains filtered or unexported fields
}

Macro represents a C preprocessor macro.

func (*Macro) ReplacementToks

func (m *Macro) ReplacementToks() (r []xc.Token)

ReplacementToks returns the tokens that replace m.

type Member

type Member struct {
	BitFieldType  Type
	BitFieldGroup int         // Ordinal number of the packed bits field.
	BitOffsetOf   int         // Bit field starting bit.
	Bits          int         // Size in bits for bit fields, 0 otherwise.
	Declarator    *Declarator // Possibly nil for bit fields.
	Name          int
	OffsetOf      int
	Padding       int // Number of unused bytes added to the end of the field to force proper alignment requirements.
	Type          Type
}

Member describes a member of a struct or union.

BitFieldGroup represents the ordinal number of the packed bit fields:

struct foo {
	int i;
	int j:1;	// BitFieldGroup: 0
	int k:2;	// BitFieldGroup: 0
	double l;
	int m:1;	// BitFieldGroup: 1
	int n:2;	// BitFieldGroup: 1
}

type Model

type Model struct {
	Items map[Kind]ModelItem

	BoolType       Type
	CharType       Type
	DoubleType     Type
	FloatType      Type
	IntType        Type
	LongDoubleType Type
	LongLongType   Type
	LongType       Type
	ShortType      Type
	UCharType      Type
	UIntType       Type
	ULongLongType  Type
	ULongType      Type
	UShortType     Type
	UintPtrType    Type
	VoidType       Type
	// contains filtered or unexported fields
}

Model describes size and align requirements of predeclared types.

func (*Model) MustConvert

func (m *Model) MustConvert(v interface{}, typ Type) interface{}

MustConvert returns v converted to the type of typ. If the conversion is impossible, the method panics.

Conversion an integer type to any pointer type yields an uintptr.

type ModelItem

type ModelItem struct {
	Size        int         // Size of the entity in bytes.
	Align       int         // Alignment of the entity when it's not a struct field. Cannot be smaller than Size.
	StructAlign int         // Alignment of the entity when it's a struct field. Can be smaller than Size.
	More        interface{} // Optional user data.
}

ModelItem is a single item of a model.

Note about StructAlign: To provide GCC ABI compatibility set, for example, Align of Double to 8 and StructAlign of Double to 4.

type Namespace

type Namespace int

Namespace is a binding category.

const (
	NSIdentifiers Namespace = iota
	NSTags
)

Values of type Namespace.

func (Namespace) String

func (i Namespace) String() string

type Node

type Node interface {
	Pos() token.Pos
}

Node represents an AST node.

type Opt

type Opt func(*lexer)

Opt is a configuration/setup function that can be passed to the Parser function.

func Cpp

func Cpp(f func([]xc.Token)) Opt

Cpp registers a preprocessor hook function which is called for every line, or group of lines the preprocessor produces before it is consumed by the parser. The token slice must not be modified by the hook.

func CrashOnError

func CrashOnError() Opt

CrashOnError is an debugging option.

func EnableAnonymousStructFields

func EnableAnonymousStructFields() Opt

EnableAnonymousStructFields makes the parser accept non standard

struct {
	int i;
	struct {
		int j;
	};
	int k;
};

func EnableDefineOmitCommaBeforeDDD

func EnableDefineOmitCommaBeforeDDD() Opt

EnableDefineOmitCommaBeforeDDD makes the parser accept non standard

#define foo(a, b...)

func EnableDlrInIdentifiers

func EnableDlrInIdentifiers() Opt

EnableDlrInIdentifiers makes the parser accept non standard

int foo$bar

func EnableEmptyDefine

func EnableEmptyDefine() Opt

EnableEmptyDefine makes the parser accept non standard

#define

func EnableIncludeNext

func EnableIncludeNext() Opt

EnableIncludeNext makes the parser accept non standard

#include_next "foo.h"

func EnableTypeOf

func EnableTypeOf() Opt

EnableTypeOf enables recognizing the reserved word typeof.

func EnableUndefExtraTokens

func EnableUndefExtraTokens() Opt

EnableUndefExtraTokens makes the parser accept non standard

#undef foo(bar)

func ErrLimit

func ErrLimit(n int) Opt

ErrLimit limits the number of calls to the error reporting methods. After the limit is reached, all errors are reported using log.Print and then log.Fatal() is called with a message about too many errors. To disable error limit, set ErrLimit to value less or equal zero. Default value is 10.

func IncludeLastTokenInfoInErrors

func IncludeLastTokenInfoInErrors() Opt

IncludeLastTokenInfoInErrors extends error messages with information about the last lexer token.

func IncludePaths

func IncludePaths(paths []string) Opt

IncludePaths option configures where to search for include files (eg. "name.h"). Multiple IncludePaths options may be used, the resulting search path list is the produce by appending the option arguments in order of appearance.

func SysIncludePaths

func SysIncludePaths(paths []string) Opt

SysIncludePaths option configures where to search for system include files (eg. <name.h>). Multiple SysIncludePaths options may be used, the resulting search path list is produced by appending the option arguments in order of appearance.

func Trigraphs

func Trigraphs() Opt

Trigraphs enables processing of trigraphs.

func YyDebug

func YyDebug(n int) Opt

YyDebug sets the parser debug level.

type PPTokenList

type PPTokenList int

PPTokenList represents a sequence of tokens.

func (PPTokenList) Pos

func (p PPTokenList) Pos() token.Pos

type Parameter

type Parameter struct {
	Declarator *Declarator
	Name       int
	Type       Type
}

Parameter describes a function argument.

type ParameterDeclaration

type ParameterDeclaration struct {
	AbstractDeclaratorOpt *AbstractDeclaratorOpt
	Case                  int
	DeclarationSpecifiers *DeclarationSpecifiers
	Declarator            *Declarator
	// contains filtered or unexported fields
}

ParameterDeclaration represents data reduced by productions:

ParameterDeclaration:
        DeclarationSpecifiers Declarator
|       DeclarationSpecifiers AbstractDeclaratorOpt  // Case 1
Example
fmt.Println(exampleAST(168, "\U00100001 ( _Bool ( auto a )"))
Output:

&cc.ParameterDeclaration{
· DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · StorageClassSpecifier: &cc.StorageClassSpecifier{
· · · Case: 3,
· · · Token: example168.c:1:16: AUTO "auto",
· · },
· },
· Declarator: &cc.Declarator{
· · Linkage: None,
· · Type: auto undefined,
· · DirectDeclarator: &cc.DirectDeclarator{
· · · Token: example168.c:1:21: IDENTIFIER "a",
· · },
· },
}
Example (Case1)
fmt.Println(exampleAST(169, "\U00100001 ( _Bool ( auto )"))
Output:

&cc.ParameterDeclaration{
· Case: 1,
· DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · StorageClassSpecifier: &cc.StorageClassSpecifier{
· · · Case: 3,
· · · Token: example169.c:1:16: AUTO "auto",
· · },
· },
}

func (*ParameterDeclaration) Pos

func (n *ParameterDeclaration) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*ParameterDeclaration) String

func (n *ParameterDeclaration) String() string

String implements fmt.Stringer.

type ParameterList

type ParameterList struct {
	Case                 int
	ParameterDeclaration *ParameterDeclaration
	ParameterList        *ParameterList
	Token                xc.Token
}

ParameterList represents data reduced by productions:

ParameterList:
        ParameterDeclaration
|       ParameterList ',' ParameterDeclaration  // Case 1
Example
fmt.Println(exampleAST(166, "\U00100001 ( _Bool ( auto )"))
Output:

&cc.ParameterList{
· ParameterDeclaration: &cc.ParameterDeclaration{
· · Case: 1,
· · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · StorageClassSpecifier: &cc.StorageClassSpecifier{
· · · · Case: 3,
· · · · Token: example166.c:1:16: AUTO "auto",
· · · },
· · },
· },
}
Example (Case1)
fmt.Println(exampleAST(167, "\U00100001 ( _Bool ( auto , auto )"))
Output:

&cc.ParameterList{
· ParameterDeclaration: &cc.ParameterDeclaration{
· · Case: 1,
· · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · StorageClassSpecifier: &cc.StorageClassSpecifier{
· · · · Case: 3,
· · · · Token: example167.c:1:16: AUTO "auto",
· · · },
· · },
· },
· ParameterList: &cc.ParameterList{
· · Case: 1,
· · ParameterDeclaration: &cc.ParameterDeclaration{
· · · Case: 1,
· · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · StorageClassSpecifier: &cc.StorageClassSpecifier{
· · · · · Case: 3,
· · · · · Token: example167.c:1:23: AUTO "auto",
· · · · },
· · · },
· · },
· · Token: example167.c:1:21: ',',
· },
}

func (*ParameterList) Pos

func (n *ParameterList) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*ParameterList) String

func (n *ParameterList) String() string

String implements fmt.Stringer.

type ParameterTypeList

type ParameterTypeList struct {
	Case          int
	ParameterList *ParameterList
	Token         xc.Token
	Token2        xc.Token
	// contains filtered or unexported fields
}

ParameterTypeList represents data reduced by productions:

ParameterTypeList:
        ParameterList
|       ParameterList ',' "..."  // Case 1
Example
fmt.Println(exampleAST(162, "\U00100001 ( _Bool ( auto )"))
Output:

&cc.ParameterTypeList{
· ParameterList: &cc.ParameterList{
· · ParameterDeclaration: &cc.ParameterDeclaration{
· · · Case: 1,
· · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · StorageClassSpecifier: &cc.StorageClassSpecifier{
· · · · · Case: 3,
· · · · · Token: example162.c:1:16: AUTO "auto",
· · · · },
· · · },
· · },
· },
}
Example (Case1)
fmt.Println(exampleAST(163, "\U00100001 ( _Bool ( auto , ... )"))
Output:

&cc.ParameterTypeList{
· Case: 1,
· ParameterList: &cc.ParameterList{
· · ParameterDeclaration: &cc.ParameterDeclaration{
· · · Case: 1,
· · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · StorageClassSpecifier: &cc.StorageClassSpecifier{
· · · · · Case: 3,
· · · · · Token: example163.c:1:16: AUTO "auto",
· · · · },
· · · },
· · },
· },
· Token: example163.c:1:21: ',',
· Token2: example163.c:1:23: DDD,
}

func (*ParameterTypeList) Pos

func (n *ParameterTypeList) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*ParameterTypeList) String

func (n *ParameterTypeList) String() string

String implements fmt.Stringer.

type ParameterTypeListOpt

type ParameterTypeListOpt struct {
	ParameterTypeList *ParameterTypeList
}

ParameterTypeListOpt represents data reduced by productions:

ParameterTypeListOpt:
        /* empty */
|       ParameterTypeList  // Case 1
Example
fmt.Println(exampleAST(164, "\U00100001 ( _Bool ( )") == (*ParameterTypeListOpt)(nil))
Output:

true
Example (Case1)
fmt.Println(exampleAST(165, "\U00100001 ( _Bool ( auto )"))
Output:

&cc.ParameterTypeListOpt{
· ParameterTypeList: &cc.ParameterTypeList{
· · ParameterList: &cc.ParameterList{
· · · ParameterDeclaration: &cc.ParameterDeclaration{
· · · · Case: 1,
· · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · StorageClassSpecifier: &cc.StorageClassSpecifier{
· · · · · · Case: 3,
· · · · · · Token: example165.c:1:16: AUTO "auto",
· · · · · },
· · · · },
· · · },
· · },
· },
}

func (*ParameterTypeListOpt) Pos

func (n *ParameterTypeListOpt) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*ParameterTypeListOpt) String

func (n *ParameterTypeListOpt) String() string

String implements fmt.Stringer.

type Pointer

type Pointer struct {
	Case                 int
	Pointer              *Pointer
	Token                xc.Token
	TypeQualifierListOpt *TypeQualifierListOpt
}

Pointer represents data reduced by productions:

Pointer:
        '*' TypeQualifierListOpt
|       '*' TypeQualifierListOpt Pointer  // Case 1
Example
fmt.Println(exampleAST(154, "\U00100002 auto * ("))
Output:

&cc.Pointer{
· Token: example154.c:1:11: '*',
}
Example (Case1)
fmt.Println(exampleAST(155, "\U00100002 auto * * ("))
Output:

&cc.Pointer{
· Case: 1,
· Pointer: &cc.Pointer{
· · Token: example155.c:1:13: '*',
· },
· Token: example155.c:1:11: '*',
}

func (*Pointer) Pos

func (n *Pointer) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*Pointer) String

func (n *Pointer) String() string

String implements fmt.Stringer.

type PointerOpt

type PointerOpt struct {
	Pointer *Pointer
}

PointerOpt represents data reduced by productions:

PointerOpt:
        /* empty */
|       Pointer      // Case 1
Example
fmt.Println(exampleAST(156, "\U00100002 auto (") == (*PointerOpt)(nil))
Output:

true
Example (Case1)
fmt.Println(exampleAST(157, "\U00100001 ( _Bool * ("))
Output:

&cc.PointerOpt{
· Pointer: &cc.Pointer{
· · Token: example157.c:1:14: '*',
· },
}

func (*PointerOpt) Pos

func (n *PointerOpt) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*PointerOpt) String

func (n *PointerOpt) String() string

String implements fmt.Stringer.

type PreprocessingFile

type PreprocessingFile struct {
	GroupList *GroupList
	// contains filtered or unexported fields
}

PreprocessingFile represents data reduced by production:

PreprocessingFile:
        GroupList
Example
fmt.Println(exampleAST(245, "\U00100000 "))
Output:

&cc.PreprocessingFile{
· GroupList: &cc.GroupList{
· },
}

func (*PreprocessingFile) Pos

func (n *PreprocessingFile) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*PreprocessingFile) String

func (n *PreprocessingFile) String() string

String implements fmt.Stringer.

type Scope

type Scope int

Scope is a bindings category.

const (
	ScopeFile Scope = iota
	ScopeBlock
	ScopeMembers
	ScopeParams
)

Values of type Scope

func (Scope) String

func (i Scope) String() string

type SelectionStatement

type SelectionStatement struct {
	Case           int
	ExpressionList *ExpressionList
	Statement      *Statement
	Statement2     *Statement
	Token          xc.Token
	Token2         xc.Token
	Token3         xc.Token
	Token4         xc.Token
}

SelectionStatement represents data reduced by productions:

SelectionStatement:
        "if" '(' ExpressionList ')' Statement
|       "if" '(' ExpressionList ')' Statement "else" Statement  // Case 1
|       "switch" '(' ExpressionList ')' Statement               // Case 2
Example
fmt.Println(exampleAST(223, "\U00100002 auto a { if ( 'b' ) ; !"))
Output:

&cc.SelectionStatement{
· ExpressionList: &cc.ExpressionList{
· · Type: int,
· · Value: 98,
· · Expression: &cc.Expression{
· · · Type: int,
· · · Value: 98,
· · · Case: 1,
· · · Token: example223.c:1:20: CHARCONST "'b'",
· · },
· },
· Statement: &cc.Statement{
· · Case: 2,
· · ExpressionStatement: &cc.ExpressionStatement{
· · · Token: example223.c:1:26: ';',
· · },
· },
· Token: example223.c:1:15: IF "if",
· Token2: example223.c:1:18: '(',
· Token3: example223.c:1:24: ')',
}
Example (Case1)
fmt.Println(exampleAST(224, "\U00100002 auto a { if ( 'b' ) ; else ; !"))
Output:

&cc.SelectionStatement{
· Case: 1,
· ExpressionList: &cc.ExpressionList{
· · Type: int,
· · Value: 98,
· · Expression: &cc.Expression{
· · · Type: int,
· · · Value: 98,
· · · Case: 1,
· · · Token: example224.c:1:20: CHARCONST "'b'",
· · },
· },
· Statement: &cc.Statement{
· · Case: 2,
· · ExpressionStatement: &cc.ExpressionStatement{
· · · Token: example224.c:1:26: ';',
· · },
· },
· Statement2: &cc.Statement{
· · Case: 2,
· · ExpressionStatement: &cc.ExpressionStatement{
· · · Token: example224.c:1:33: ';',
· · },
· },
· Token: example224.c:1:15: IF "if",
· Token2: example224.c:1:18: '(',
· Token3: example224.c:1:24: ')',
· Token4: example224.c:1:28: ELSE "else",
}
Example (Case2)
fmt.Println(exampleAST(225, "\U00100002 auto a { switch ( 'b' ) ; !"))
Output:

&cc.SelectionStatement{
· Case: 2,
· ExpressionList: &cc.ExpressionList{
· · Type: int,
· · Value: 98,
· · Expression: &cc.Expression{
· · · Type: int,
· · · Value: 98,
· · · Case: 1,
· · · Token: example225.c:1:24: CHARCONST "'b'",
· · },
· },
· Statement: &cc.Statement{
· · Case: 2,
· · ExpressionStatement: &cc.ExpressionStatement{
· · · Token: example225.c:1:30: ';',
· · },
· },
· Token: example225.c:1:15: SWITCH "switch",
· Token2: example225.c:1:22: '(',
· Token3: example225.c:1:28: ')',
}

func (*SelectionStatement) Pos

func (n *SelectionStatement) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*SelectionStatement) String

func (n *SelectionStatement) String() string

String implements fmt.Stringer.

type Specifier

type Specifier interface {
	IsStatic() bool   // StorageClassSpecifier "static" present.
	IsTypedef() bool  // StorageClassSpecifier "typedef" present.
	TypedefName() int // TypedefName returns the typedef name ID used, if any, zero otherwise.

	IsConst() bool // TypeQualifier "const" present.
	// contains filtered or unexported methods
}

Specifier describes a combination of {Function,StorageClass,Type}Specifiers and TypeQualifiers.

type SpecifierQualifierList

type SpecifierQualifierList struct {
	Case                      int
	SpecifierQualifierListOpt *SpecifierQualifierListOpt
	TypeQualifier             *TypeQualifier
	TypeSpecifier             *TypeSpecifier
	// contains filtered or unexported fields
}

SpecifierQualifierList represents data reduced by productions:

SpecifierQualifierList:
        TypeSpecifier SpecifierQualifierListOpt
|       TypeQualifier SpecifierQualifierListOpt  // Case 1
Example
fmt.Println(exampleAST(121, "\U00100001 ( _Bool ("))
Output:

&cc.SpecifierQualifierList{
· TypeSpecifier: &cc.TypeSpecifier{
· · Case: 9,
· · Token: example121.c:1:8: BOOL "_Bool",
· },
}
Example (Case1)
fmt.Println(exampleAST(122, "\U00100001 ( const ("))
Output:

&cc.SpecifierQualifierList{
· Case: 1,
· TypeQualifier: &cc.TypeQualifier{
· · Token: example122.c:1:8: CONST "const",
· },
}

func (*SpecifierQualifierList) IsConst

func (n *SpecifierQualifierList) IsConst() bool

IsConst returns whether n includes the 'const' type qualifier.

func (*SpecifierQualifierList) IsStatic

func (n *SpecifierQualifierList) IsStatic() bool

IsStatic implements specifier.

func (*SpecifierQualifierList) IsTypedef

func (n *SpecifierQualifierList) IsTypedef() bool

IsTypedef implements specifier.

func (*SpecifierQualifierList) Pos

func (n *SpecifierQualifierList) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*SpecifierQualifierList) String

func (n *SpecifierQualifierList) String() string

String implements fmt.Stringer.

func (*SpecifierQualifierList) TypedefName

func (n *SpecifierQualifierList) TypedefName() int

TypedefName implements Specifier.

type SpecifierQualifierListOpt

type SpecifierQualifierListOpt struct {
	SpecifierQualifierList *SpecifierQualifierList
	// contains filtered or unexported fields
}

SpecifierQualifierListOpt represents data reduced by productions:

SpecifierQualifierListOpt:
        /* empty */
|       SpecifierQualifierList  // Case 1
Example
fmt.Println(exampleAST(123, "\U00100001 ( _Bool (") == (*SpecifierQualifierListOpt)(nil))
Output:

true
Example (Case1)
fmt.Println(exampleAST(124, "\U00100001 ( const _Bool ("))
Output:

&cc.SpecifierQualifierListOpt{
· SpecifierQualifierList: &cc.SpecifierQualifierList{
· · TypeSpecifier: &cc.TypeSpecifier{
· · · Case: 9,
· · · Token: example124.c:1:14: BOOL "_Bool",
· · },
· },
}

func (*SpecifierQualifierListOpt) Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*SpecifierQualifierListOpt) String

func (n *SpecifierQualifierListOpt) String() string

String implements fmt.Stringer.

type Statement

type Statement struct {
	Case                int
	CompoundStatement   *CompoundStatement
	ExpressionStatement *ExpressionStatement
	IterationStatement  *IterationStatement
	JumpStatement       *JumpStatement
	LabeledStatement    *LabeledStatement
	SelectionStatement  *SelectionStatement
}

Statement represents data reduced by productions:

Statement:
        LabeledStatement
|       CompoundStatement    // Case 1
|       ExpressionStatement  // Case 2
|       SelectionStatement   // Case 3
|       IterationStatement   // Case 4
|       JumpStatement        // Case 5
Example
fmt.Println(exampleAST(205, "\U00100002 auto a { default : ; !"))
Output:

&cc.Statement{
· LabeledStatement: &cc.LabeledStatement{
· · Case: 2,
· · Statement: &cc.Statement{
· · · Case: 2,
· · · ExpressionStatement: &cc.ExpressionStatement{
· · · · Token: example205.c:1:25: ';',
· · · },
· · },
· · Token: example205.c:1:15: DEFAULT "default",
· · Token2: example205.c:1:23: ':',
· },
}
Example (Case1)
fmt.Println(exampleAST(206, "\U00100002 auto a { { } !"))
Output:

&cc.Statement{
· Case: 1,
· CompoundStatement: &cc.CompoundStatement{
· · Token: example206.c:1:15: '{',
· · Token2: example206.c:1:17: '}',
· },
}
Example (Case2)
fmt.Println(exampleAST(207, "\U00100002 auto a { ; !"))
Output:

&cc.Statement{
· Case: 2,
· ExpressionStatement: &cc.ExpressionStatement{
· · Token: example207.c:1:15: ';',
· },
}
Example (Case3)
fmt.Println(exampleAST(208, "\U00100002 auto a { if ( 'b' ) ; !"))
Output:

&cc.Statement{
· Case: 3,
· SelectionStatement: &cc.SelectionStatement{
· · ExpressionList: &cc.ExpressionList{
· · · Type: int,
· · · Value: 98,
· · · Expression: &cc.Expression{
· · · · Type: int,
· · · · Value: 98,
· · · · Case: 1,
· · · · Token: example208.c:1:20: CHARCONST "'b'",
· · · },
· · },
· · Statement: &cc.Statement{
· · · Case: 2,
· · · ExpressionStatement: &cc.ExpressionStatement{
· · · · Token: example208.c:1:26: ';',
· · · },
· · },
· · Token: example208.c:1:15: IF "if",
· · Token2: example208.c:1:18: '(',
· · Token3: example208.c:1:24: ')',
· },
}
Example (Case4)
fmt.Println(exampleAST(209, "\U00100002 auto a { while ( 'b' ) ; !"))
Output:

&cc.Statement{
· Case: 4,
· IterationStatement: &cc.IterationStatement{
· · ExpressionList: &cc.ExpressionList{
· · · Type: int,
· · · Value: 98,
· · · Expression: &cc.Expression{
· · · · Type: int,
· · · · Value: 98,
· · · · Case: 1,
· · · · Token: example209.c:1:23: CHARCONST "'b'",
· · · },
· · },
· · Statement: &cc.Statement{
· · · Case: 2,
· · · ExpressionStatement: &cc.ExpressionStatement{
· · · · Token: example209.c:1:29: ';',
· · · },
· · },
· · Token: example209.c:1:15: WHILE "while",
· · Token2: example209.c:1:21: '(',
· · Token3: example209.c:1:27: ')',
· },
}
Example (Case5)
fmt.Println(exampleAST(210, "\U00100002 auto a { break ; !"))
Output:

&cc.Statement{
· Case: 5,
· JumpStatement: &cc.JumpStatement{
· · Case: 2,
· · Token: example210.c:1:15: BREAK "break",
· · Token2: example210.c:1:21: ';',
· },
}

func (*Statement) Pos

func (n *Statement) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*Statement) String

func (n *Statement) String() string

String implements fmt.Stringer.

type StorageClassSpecifier

type StorageClassSpecifier struct {
	Case  int
	Token xc.Token
	// contains filtered or unexported fields
}

StorageClassSpecifier represents data reduced by productions:

StorageClassSpecifier:
        "typedef"
|       "extern"    // Case 1
|       "static"    // Case 2
|       "auto"      // Case 3
|       "register"  // Case 4
Example
fmt.Println(exampleAST(90, "\U00100002 typedef ("))
Output:

&cc.StorageClassSpecifier{
· Token: example90.c:1:6: TYPEDEF "typedef",
}
Example (Case1)
fmt.Println(exampleAST(91, "\U00100002 extern ("))
Output:

&cc.StorageClassSpecifier{
· Case: 1,
· Token: example91.c:1:6: EXTERN "extern",
}
Example (Case2)
fmt.Println(exampleAST(92, "\U00100002 static ("))
Output:

&cc.StorageClassSpecifier{
· Case: 2,
· Token: example92.c:1:6: STATIC "static",
}
Example (Case3)
fmt.Println(exampleAST(93, "\U00100002 auto ("))
Output:

&cc.StorageClassSpecifier{
· Case: 3,
· Token: example93.c:1:6: AUTO "auto",
}
Example (Case4)
fmt.Println(exampleAST(94, "\U00100002 register ("))
Output:

&cc.StorageClassSpecifier{
· Case: 4,
· Token: example94.c:1:6: REGISTER "register",
}

func (*StorageClassSpecifier) Pos

func (n *StorageClassSpecifier) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*StorageClassSpecifier) String

func (n *StorageClassSpecifier) String() string

String implements fmt.Stringer.

type StringLitID

type StringLitID int

StringLitID is the type of an Expression.Value representing the numeric ID of a string literal.

type StructDeclaration

type StructDeclaration struct {
	Case                   int
	SpecifierQualifierList *SpecifierQualifierList
	StructDeclaratorList   *StructDeclaratorList
	Token                  xc.Token
}

StructDeclaration represents data reduced by productions:

StructDeclaration:
        SpecifierQualifierList StructDeclaratorList ';'
|       SpecifierQualifierList ';'                       // Case 1
Example
fmt.Println(exampleAST(119, "\U00100002 struct { _Bool a ; }"))
Output:

&cc.StructDeclaration{
· SpecifierQualifierList: &cc.SpecifierQualifierList{
· · TypeSpecifier: &cc.TypeSpecifier{
· · · Case: 9,
· · · Token: example119.c:1:15: BOOL "_Bool",
· · },
· },
· StructDeclaratorList: &cc.StructDeclaratorList{
· · StructDeclarator: &cc.StructDeclarator{
· · · Declarator: &cc.Declarator{
· · · · Linkage: None,
· · · · Type: bool,
· · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · Token: example119.c:1:21: IDENTIFIER "a",
· · · · },
· · · },
· · },
· },
· Token: example119.c:1:23: ';',
}
Example (Case1)
fmt.Println(exampleAST(120, "\U00100002 struct { _Bool ; }"))
Output:

&cc.StructDeclaration{
· Case: 1,
· SpecifierQualifierList: &cc.SpecifierQualifierList{
· · TypeSpecifier: &cc.TypeSpecifier{
· · · Case: 9,
· · · Token: example120.c:1:15: BOOL "_Bool",
· · },
· },
· Token: example120.c:1:21: ';',
}

func (*StructDeclaration) Pos

func (n *StructDeclaration) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*StructDeclaration) String

func (n *StructDeclaration) String() string

String implements fmt.Stringer.

type StructDeclarationList

type StructDeclarationList struct {
	Case                  int
	StructDeclaration     *StructDeclaration
	StructDeclarationList *StructDeclarationList
}

StructDeclarationList represents data reduced by productions:

StructDeclarationList:
        StructDeclaration
|       StructDeclarationList StructDeclaration  // Case 1
Example
fmt.Println(exampleAST(117, "\U00100002 struct { _Bool ; }"))
Output:

&cc.StructDeclarationList{
· StructDeclaration: &cc.StructDeclaration{
· · Case: 1,
· · SpecifierQualifierList: &cc.SpecifierQualifierList{
· · · TypeSpecifier: &cc.TypeSpecifier{
· · · · Case: 9,
· · · · Token: example117.c:1:15: BOOL "_Bool",
· · · },
· · },
· · Token: example117.c:1:21: ';',
· },
}
Example (Case1)
fmt.Println(exampleAST(118, "\U00100002 struct { _Bool ; _Bool ; }"))
Output:

&cc.StructDeclarationList{
· StructDeclaration: &cc.StructDeclaration{
· · Case: 1,
· · SpecifierQualifierList: &cc.SpecifierQualifierList{
· · · TypeSpecifier: &cc.TypeSpecifier{
· · · · Case: 9,
· · · · Token: example118.c:1:15: BOOL "_Bool",
· · · },
· · },
· · Token: example118.c:1:21: ';',
· },
· StructDeclarationList: &cc.StructDeclarationList{
· · Case: 1,
· · StructDeclaration: &cc.StructDeclaration{
· · · Case: 1,
· · · SpecifierQualifierList: &cc.SpecifierQualifierList{
· · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · Case: 9,
· · · · · Token: example118.c:1:23: BOOL "_Bool",
· · · · },
· · · },
· · · Token: example118.c:1:29: ';',
· · },
· },
}

func (*StructDeclarationList) Pos

func (n *StructDeclarationList) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*StructDeclarationList) String

func (n *StructDeclarationList) String() string

String implements fmt.Stringer.

type StructDeclarator

type StructDeclarator struct {
	Case               int
	ConstantExpression *ConstantExpression
	Declarator         *Declarator
	DeclaratorOpt      *DeclaratorOpt
	Token              xc.Token
}

StructDeclarator represents data reduced by productions:

StructDeclarator:
        Declarator
|       DeclaratorOpt ':' ConstantExpression  // Case 1
Example
fmt.Println(exampleAST(127, "\U00100002 struct { _Bool a ,"))
Output:

&cc.StructDeclarator{
· Declarator: &cc.Declarator{
· · Linkage: None,
· · Type: bool,
· · DirectDeclarator: &cc.DirectDeclarator{
· · · Token: example127.c:1:21: IDENTIFIER "a",
· · },
· },
}
Example (Case1)
fmt.Println(exampleAST(128, "\U00100002 struct { _Bool : 'a' ,"))
Output:

&cc.StructDeclarator{
· Case: 1,
· ConstantExpression: &cc.ConstantExpression{
· · Type: int,
· · Value: 97,
· · Expression: &cc.Expression{
· · · Type: int,
· · · Value: 97,
· · · Case: 1,
· · · Token: example128.c:1:23: CHARCONST "'a'",
· · },
· },
· Token: example128.c:1:21: ':',
}

func (*StructDeclarator) Pos

func (n *StructDeclarator) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*StructDeclarator) String

func (n *StructDeclarator) String() string

String implements fmt.Stringer.

type StructDeclaratorList

type StructDeclaratorList struct {
	Case                 int
	StructDeclarator     *StructDeclarator
	StructDeclaratorList *StructDeclaratorList
	Token                xc.Token
}

StructDeclaratorList represents data reduced by productions:

StructDeclaratorList:
        StructDeclarator
|       StructDeclaratorList ',' StructDeclarator  // Case 1
Example
fmt.Println(exampleAST(125, "\U00100002 struct { _Bool a ,"))
Output:

&cc.StructDeclaratorList{
· StructDeclarator: &cc.StructDeclarator{
· · Declarator: &cc.Declarator{
· · · Linkage: None,
· · · Type: bool,
· · · DirectDeclarator: &cc.DirectDeclarator{
· · · · Token: example125.c:1:21: IDENTIFIER "a",
· · · },
· · },
· },
}
Example (Case1)
fmt.Println(exampleAST(126, "\U00100002 struct { _Bool a , b ,"))
Output:

&cc.StructDeclaratorList{
· StructDeclarator: &cc.StructDeclarator{
· · Declarator: &cc.Declarator{
· · · Linkage: None,
· · · Type: bool,
· · · DirectDeclarator: &cc.DirectDeclarator{
· · · · Token: example126.c:1:21: IDENTIFIER "a",
· · · },
· · },
· },
· StructDeclaratorList: &cc.StructDeclaratorList{
· · Case: 1,
· · StructDeclarator: &cc.StructDeclarator{
· · · Declarator: &cc.Declarator{
· · · · Linkage: None,
· · · · Type: bool,
· · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · Token: example126.c:1:25: IDENTIFIER "b",
· · · · },
· · · },
· · },
· · Token: example126.c:1:23: ',',
· },
}

func (*StructDeclaratorList) Pos

func (n *StructDeclaratorList) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*StructDeclaratorList) String

func (n *StructDeclaratorList) String() string

String implements fmt.Stringer.

type StructOrUnion

type StructOrUnion struct {
	Case  int
	Token xc.Token
}

StructOrUnion represents data reduced by productions:

StructOrUnion:
        "struct"
|       "union"   // Case 1
Example
fmt.Println(exampleAST(115, "\U00100002 struct {"))
Output:

&cc.StructOrUnion{
· Token: example115.c:1:6: STRUCT "struct",
}
Example (Case1)
fmt.Println(exampleAST(116, "\U00100002 union {"))
Output:

&cc.StructOrUnion{
· Case: 1,
· Token: example116.c:1:6: UNION "union",
}

func (*StructOrUnion) Pos

func (n *StructOrUnion) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*StructOrUnion) String

func (n *StructOrUnion) String() string

String implements fmt.Stringer.

type StructOrUnionSpecifier

type StructOrUnionSpecifier struct {
	Case                  int
	IdentifierOpt         *IdentifierOpt
	StructDeclarationList *StructDeclarationList
	StructOrUnion         *StructOrUnion
	Token                 xc.Token
	Token2                xc.Token
	// contains filtered or unexported fields
}

StructOrUnionSpecifier represents data reduced by productions:

StructOrUnionSpecifier:
        StructOrUnion IdentifierOpt '{' StructDeclarationList '}'
|       StructOrUnion IDENTIFIER                                   // Case 1
Example
fmt.Println(exampleAST(113, "\U00100002 struct { int i; } ("))
Output:

&cc.StructOrUnionSpecifier{
· StructDeclarationList: &cc.StructDeclarationList{
· · StructDeclaration: &cc.StructDeclaration{
· · · SpecifierQualifierList: &cc.SpecifierQualifierList{
· · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · Case: 3,
· · · · · Token: example113.c:1:15: INT "int",
· · · · },
· · · },
· · · StructDeclaratorList: &cc.StructDeclaratorList{
· · · · StructDeclarator: &cc.StructDeclarator{
· · · · · Declarator: &cc.Declarator{
· · · · · · Linkage: None,
· · · · · · Type: int,
· · · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · · Token: example113.c:1:19: IDENTIFIER "i",
· · · · · · },
· · · · · },
· · · · },
· · · },
· · · Token: example113.c:1:20: ';',
· · },
· },
· StructOrUnion: &cc.StructOrUnion{
· · Token: example113.c:1:6: STRUCT "struct",
· },
· Token: example113.c:1:13: '{',
· Token2: example113.c:1:22: '}',
}
Example (Case1)
fmt.Println(exampleAST(114, "\U00100002 struct a ("))
Output:

&cc.StructOrUnionSpecifier{
· Case: 1,
· StructOrUnion: &cc.StructOrUnion{
· · Token: example114.c:1:6: STRUCT "struct",
· },
· Token: example114.c:1:13: IDENTIFIER "a",
}

func (*StructOrUnionSpecifier) Declarator

func (n *StructOrUnionSpecifier) Declarator() *Declarator

Declarator returns a synthetic Declarator when a tagged struc/union type is defined inline a declaration.

func (*StructOrUnionSpecifier) Pos

func (n *StructOrUnionSpecifier) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*StructOrUnionSpecifier) String

func (n *StructOrUnionSpecifier) String() string

String implements fmt.Stringer.

type TranslationUnit

type TranslationUnit struct {
	Declarations        *Bindings
	Macros              map[int]*Macro // Ident ID -> preprocessor macro defined by ident.
	Model               *Model         // Model used to parse the TranslationUnit.
	Case                int
	ExternalDeclaration *ExternalDeclaration
	TranslationUnit     *TranslationUnit
}

TranslationUnit represents data reduced by productions:

TranslationUnit:
        ExternalDeclaration
|       TranslationUnit ExternalDeclaration  // Case 1
Example
fmt.Println(exampleAST(234, "\U00100002 auto ;"))
Output:

&cc.TranslationUnit{
· ExternalDeclaration: &cc.ExternalDeclaration{
· · Case: 1,
· · Declaration: &cc.Declaration{
· · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · StorageClassSpecifier: &cc.StorageClassSpecifier{
· · · · · Case: 3,
· · · · · Token: example234.c:1:6: AUTO "auto",
· · · · },
· · · },
· · · Token: example234.c:1:11: ';',
· · },
· },
}
Example (Case1)
fmt.Println(exampleAST(235, "\U00100002 auto ; auto ;"))
Output:

&cc.TranslationUnit{
· ExternalDeclaration: &cc.ExternalDeclaration{
· · Case: 1,
· · Declaration: &cc.Declaration{
· · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · StorageClassSpecifier: &cc.StorageClassSpecifier{
· · · · · Case: 3,
· · · · · Token: example235.c:1:6: AUTO "auto",
· · · · },
· · · },
· · · Token: example235.c:1:11: ';',
· · },
· },
· TranslationUnit: &cc.TranslationUnit{
· · Case: 1,
· · ExternalDeclaration: &cc.ExternalDeclaration{
· · · Case: 1,
· · · Declaration: &cc.Declaration{
· · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · StorageClassSpecifier: &cc.StorageClassSpecifier{
· · · · · · Case: 3,
· · · · · · Token: example235.c:1:13: AUTO "auto",
· · · · · },
· · · · },
· · · · Token: example235.c:1:18: ';',
· · · },
· · },
· },
}

func Parse

func Parse(predefine string, paths []string, m *Model, opts ...Opt) (*TranslationUnit, error)

Parse defines any macros in predefine. Then Parse preprocesses and parses the translation unit consisting of files in paths. The m communicates the scalar types model and opts allow to amend parser behavior. m cannot be reused and passed to Parse again.

func (*TranslationUnit) Pos

func (n *TranslationUnit) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*TranslationUnit) String

func (n *TranslationUnit) String() string

String implements fmt.Stringer.

type Type

type Type interface {
	// AlignOf returns the alignment in bytes of a value of this type when
	// allocated in memory not as a struct field. Incomplete struct types
	// have no alignment and the value returned will be < 0.
	AlignOf() int

	// CanAssignTo returns whether this type can be assigned to dst.
	CanAssignTo(dst Type) bool

	// Declarator returns the full Declarator which defined an entity of
	// this type. The returned declarator is possibly artificial.
	Declarator() *Declarator

	// Element returns the type this Ptr type points to or the element type
	// of an Array type.
	Element() Type

	// Elements returns the number of elements an Array type has. The
	// returned value is < 0 if this type is not an Array or if the array
	// is not of a constant size.
	Elements() int

	// EnumeratorList returns the enumeration constants defined by an Enum
	// type, if any.
	EnumeratorList() []EnumConstant

	// Kind returns one of Ptr, Void, Int, ...
	Kind() Kind

	// Member returns the type of a member of this Struct or Union type,
	// having numeric name identifier nm.
	Member(nm int) (*Member, error)

	// Members returns the members of a Struct or Union type in declaration
	// order. Returned members are valid iff non nil.
	//
	// Note: Non nil members of length 0 means the struct/union has no
	// members or the type is incomplete, which is indicated by the
	// isIncomplete return value.
	//
	// Note 2: C99 standard does not allow empty structs/unions, but GCC
	// supports that as an extension.
	Members() (members []Member, isIncomplete bool)

	// Parameters returns the parameters of a Function type in declaration
	// order. Result is valid iff params is not nil.
	//
	// Note: len(params) == 0 is fine and just means the function has no
	// parameters.
	Parameters() (params []Parameter, isVariadic bool)

	// Pointer returns a type that points to this type.
	Pointer() Type

	// Result returns the result type of a Function type.
	Result() Type

	// Sizeof returns the number of bytes needed to store a value of this
	// type. Incomplete struct types have no size and the value returned
	// will be < 0.
	SizeOf() int

	// Specifier returns the Specifier of this type.
	Specifier() Specifier

	// String returns a C-like type specifier of this type.
	String() string

	// StructAlignOf returns the alignment in bytes of a value of this type
	// when allocated in memory as a struct field. Incomplete struct types
	// have no alignment and the value returned will be < 0.
	StructAlignOf() int

	// Tag returns the ID of a tag of a Struct, Union or Enum type, if any.
	// Otherwise the returned value is zero.
	Tag() int
}

Type decribes properties of a C type.

type TypeName

type TypeName struct {
	Type Type

	AbstractDeclaratorOpt  *AbstractDeclaratorOpt
	SpecifierQualifierList *SpecifierQualifierList
	// contains filtered or unexported fields
}

TypeName represents data reduced by production:

TypeName:
        SpecifierQualifierList AbstractDeclaratorOpt
Example
fmt.Println(exampleAST(177, "\U00100001 ( _Bool )"))
Output:

&cc.TypeName{
· Type: bool,
· SpecifierQualifierList: &cc.SpecifierQualifierList{
· · TypeSpecifier: &cc.TypeSpecifier{
· · · Case: 9,
· · · Token: example177.c:1:8: BOOL "_Bool",
· · },
· },
}

func (*TypeName) Pos

func (n *TypeName) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*TypeName) String

func (n *TypeName) String() string

String implements fmt.Stringer.

type TypeQualifier

type TypeQualifier struct {
	Case  int
	Token xc.Token
	// contains filtered or unexported fields
}

TypeQualifier represents data reduced by productions:

TypeQualifier:
        "const"
|       "restrict"  // Case 1
|       "volatile"  // Case 2
Example
fmt.Println(exampleAST(138, "\U00100002 const !"))
Output:

&cc.TypeQualifier{
· Token: example138.c:1:6: CONST "const",
}
Example (Case1)
fmt.Println(exampleAST(139, "\U00100002 restrict !"))
Output:

&cc.TypeQualifier{
· Case: 1,
· Token: example139.c:1:6: RESTRICT "restrict",
}
Example (Case2)
fmt.Println(exampleAST(140, "\U00100002 volatile !"))
Output:

&cc.TypeQualifier{
· Case: 2,
· Token: example140.c:1:6: VOLATILE "volatile",
}

func (*TypeQualifier) Pos

func (n *TypeQualifier) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*TypeQualifier) String

func (n *TypeQualifier) String() string

String implements fmt.Stringer.

type TypeQualifierList

type TypeQualifierList struct {
	Case              int
	TypeQualifier     *TypeQualifier
	TypeQualifierList *TypeQualifierList
	// contains filtered or unexported fields
}

TypeQualifierList represents data reduced by productions:

TypeQualifierList:
        TypeQualifier
|       TypeQualifierList TypeQualifier  // Case 1
Example
fmt.Println(exampleAST(158, "\U00100002 auto * const !"))
Output:

&cc.TypeQualifierList{
· TypeQualifier: &cc.TypeQualifier{
· · Token: example158.c:1:13: CONST "const",
· },
}
Example (Case1)
fmt.Println(exampleAST(159, "\U00100002 auto * const const !"))
Output:

&cc.TypeQualifierList{
· TypeQualifier: &cc.TypeQualifier{
· · Token: example159.c:1:13: CONST "const",
· },
· TypeQualifierList: &cc.TypeQualifierList{
· · Case: 1,
· · TypeQualifier: &cc.TypeQualifier{
· · · Token: example159.c:1:19: CONST "const",
· · },
· },
}

func (*TypeQualifierList) Pos

func (n *TypeQualifierList) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*TypeQualifierList) String

func (n *TypeQualifierList) String() string

String implements fmt.Stringer.

type TypeQualifierListOpt

type TypeQualifierListOpt struct {
	TypeQualifierList *TypeQualifierList
}

TypeQualifierListOpt represents data reduced by productions:

TypeQualifierListOpt:
        /* empty */
|       TypeQualifierList  // Case 1
Example
fmt.Println(exampleAST(160, "\U00100002 auto * (") == (*TypeQualifierListOpt)(nil))
Output:

true
Example (Case1)
fmt.Println(exampleAST(161, "\U00100002 auto * const !"))
Output:

&cc.TypeQualifierListOpt{
· TypeQualifierList: &cc.TypeQualifierList{
· · TypeQualifier: &cc.TypeQualifier{
· · · Token: example161.c:1:13: CONST "const",
· · },
· },
}

func (*TypeQualifierListOpt) Pos

func (n *TypeQualifierListOpt) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*TypeQualifierListOpt) String

func (n *TypeQualifierListOpt) String() string

String implements fmt.Stringer.

type TypeSpecifier

type TypeSpecifier struct {
	Type                   Type // Type of typeof.
	Case                   int
	EnumSpecifier          *EnumSpecifier
	Expression             *Expression
	StructOrUnionSpecifier *StructOrUnionSpecifier
	Token                  xc.Token
	Token2                 xc.Token
	Token3                 xc.Token
	TypeName               *TypeName
	// contains filtered or unexported fields
}

TypeSpecifier represents data reduced by productions:

TypeSpecifier:
        "void"
|       "char"                       // Case 1
|       "short"                      // Case 2
|       "int"                        // Case 3
|       "long"                       // Case 4
|       "float"                      // Case 5
|       "double"                     // Case 6
|       "signed"                     // Case 7
|       "unsigned"                   // Case 8
|       "_Bool"                      // Case 9
|       "_Complex"                   // Case 10
|       StructOrUnionSpecifier       // Case 11
|       EnumSpecifier                // Case 12
|       TYPEDEFNAME                  // Case 13
|       "typeof" '(' Expression ')'  // Case 14
|       "typeof" '(' TypeName ')'    // Case 15
Example
fmt.Println(exampleAST(95, "\U00100002 void ("))
Output:

&cc.TypeSpecifier{
· Token: example95.c:1:6: VOID "void",
}
Example (Case01)
fmt.Println(exampleAST(96, "\U00100002 char ("))
Output:

&cc.TypeSpecifier{
· Case: 1,
· Token: example96.c:1:6: CHAR "char",
}
Example (Case02)
fmt.Println(exampleAST(97, "\U00100002 short ("))
Output:

&cc.TypeSpecifier{
· Case: 2,
· Token: example97.c:1:6: SHORT "short",
}
Example (Case03)
fmt.Println(exampleAST(98, "\U00100002 int ("))
Output:

&cc.TypeSpecifier{
· Case: 3,
· Token: example98.c:1:6: INT "int",
}
Example (Case04)
fmt.Println(exampleAST(99, "\U00100002 long ("))
Output:

&cc.TypeSpecifier{
· Case: 4,
· Token: example99.c:1:6: LONG "long",
}
Example (Case05)
fmt.Println(exampleAST(100, "\U00100002 float ("))
Output:

&cc.TypeSpecifier{
· Case: 5,
· Token: example100.c:1:6: FLOAT "float",
}
Example (Case06)
fmt.Println(exampleAST(101, "\U00100002 double ("))
Output:

&cc.TypeSpecifier{
· Case: 6,
· Token: example101.c:1:6: DOUBLE "double",
}
Example (Case07)
fmt.Println(exampleAST(102, "\U00100002 signed ("))
Output:

&cc.TypeSpecifier{
· Case: 7,
· Token: example102.c:1:6: SIGNED "signed",
}
Example (Case08)
fmt.Println(exampleAST(103, "\U00100002 unsigned ("))
Output:

&cc.TypeSpecifier{
· Case: 8,
· Token: example103.c:1:6: UNSIGNED "unsigned",
}
Example (Case09)
fmt.Println(exampleAST(104, "\U00100002 _Bool ("))
Output:

&cc.TypeSpecifier{
· Case: 9,
· Token: example104.c:1:6: BOOL "_Bool",
}
Example (Case10)
fmt.Println(exampleAST(105, "\U00100002 _Complex ("))
Output:

&cc.TypeSpecifier{
· Case: 10,
· Token: example105.c:1:6: COMPLEX "_Complex",
}
Example (Case11)
fmt.Println(exampleAST(106, "\U00100002 struct a ("))
Output:

&cc.TypeSpecifier{
· Case: 11,
· StructOrUnionSpecifier: &cc.StructOrUnionSpecifier{
· · Case: 1,
· · StructOrUnion: &cc.StructOrUnion{
· · · Token: example106.c:1:6: STRUCT "struct",
· · },
· · Token: example106.c:1:13: IDENTIFIER "a",
· },
}
Example (Case12)
fmt.Println(exampleAST(107, "\U00100002 enum a ("))
Output:

&cc.TypeSpecifier{
· Case: 12,
· EnumSpecifier: &cc.EnumSpecifier{
· · Case: 1,
· · Token: example107.c:1:6: ENUM "enum",
· · Token2: example107.c:1:11: IDENTIFIER "a",
· },
}
Example (Case13)
fmt.Println(exampleAST(108, "\U00100002 typedef int i; i j;"))
Output:

&cc.TypeSpecifier{
· Case: 13,
· Token: example108.c:1:21: TYPEDEFNAME "i",
}
Example (Case14)
fmt.Println(exampleAST(109, "\U00100002 typeof ( 'a' ) ("))
Output:

&cc.TypeSpecifier{
· Type: int,
· Case: 14,
· Expression: &cc.Expression{
· · Type: int,
· · Value: 97,
· · Case: 1,
· · Token: example109.c:1:15: CHARCONST "'a'",
· },
· Token: example109.c:1:6: TYPEOF "typeof",
· Token2: example109.c:1:13: '(',
· Token3: example109.c:1:19: ')',
}
Example (Case15)
fmt.Println(exampleAST(110, "\U00100002 typeof ( _Bool ) ("))
Output:

&cc.TypeSpecifier{
· Type: bool,
· Case: 15,
· Token: example110.c:1:6: TYPEOF "typeof",
· Token2: example110.c:1:13: '(',
· Token3: example110.c:1:21: ')',
· TypeName: &cc.TypeName{
· · Type: bool,
· · SpecifierQualifierList: &cc.SpecifierQualifierList{
· · · TypeSpecifier: &cc.TypeSpecifier{
· · · · Case: 9,
· · · · Token: example110.c:1:15: BOOL "_Bool",
· · · },
· · },
· },
}

func (*TypeSpecifier) Pos

func (n *TypeSpecifier) Pos() token.Pos

Pos reports the position of the first component of n or zero if it's empty.

func (*TypeSpecifier) String

func (n *TypeSpecifier) String() string

String implements fmt.Stringer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL