cc

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2021 License: BSD-3-Clause, BSD-3-Clause Imports: 26 Imported by: 8

README

cc/v2

Package CC is a C99 compiler front end. Work In Progress. API unstable.


This package is no longer maintained. Please see the v3 version at

https://modernc.org/cc/v3


Installation

$ go get modernc.org/cc/v2

Documentation: godoc.org/modernc.org/cc/v2

Documentation

Overview

Package cc is a C99 compiler front end. Work In Progress. API unstable.

This package is no longer maintained. Please see the v3 version at

https://modernc.org/cc/v3

Index

Examples

Constants

View Source
const (
	ADDASSIGN           = 57346
	ALIGNAS             = 57347
	ALIGNOF             = 57348
	ANDAND              = 57349
	ANDASSIGN           = 57350
	ARROW               = 57351
	ATOMIC              = 57352
	ATOMIC_LPAREN       = 57353
	AUTO                = 57354
	BOOL                = 57355
	BREAK               = 57356
	CASE                = 57357
	CAST                = 57358
	CHAR                = 57359
	CHARCONST           = 57360
	COMPLEX             = 57361
	CONST               = 57362
	CONSTANT_EXPRESSION = 1048576
	CONTINUE            = 57363
	DDD                 = 57364
	DEC                 = 57365
	DEFAULT             = 57366
	DIRECTIVE           = 57367
	DIVASSIGN           = 57368
	DO                  = 57369
	DOUBLE              = 57370
	ELSE                = 57371
	ENUM                = 57372
	EQ                  = 57373
	EXTERN              = 57374
	FLOAT               = 57375
	FLOATCONST          = 57376
	FOR                 = 57377
	GENERIC             = 57378
	GEQ                 = 57379
	GOTO                = 57380
	IDENTIFIER          = 57381
	IF                  = 57382
	IMAGINARY           = 57383
	INC                 = 57384
	INLINE              = 57385
	INT                 = 57386
	INTCONST            = 57387
	LEQ                 = 57388
	LONG                = 57389
	LONGCHARCONST       = 57390
	LONGSTRINGLITERAL   = 57391
	LSH                 = 57392
	LSHASSIGN           = 57393
	MODASSIGN           = 57394
	MULASSIGN           = 57395
	NEQ                 = 57396
	NOELSE              = 57397
	NON_REPL            = 57398
	NORETURN            = 57399
	NOSEMI              = 57400
	ORASSIGN            = 57401
	OROR                = 57402
	PPNUMBER            = 57403
	PPPASTE             = 57404
	REGISTER            = 57405
	RESTRICT            = 57406
	RETURN              = 57407
	RSH                 = 57408
	RSHASSIGN           = 57409
	SHORT               = 57410
	SIGNED              = 57411
	SIZEOF              = 57412
	STATIC              = 57413
	STATIC_ASSERT       = 57414
	STRINGLITERAL       = 57415
	STRUCT              = 57416
	SUBASSIGN           = 57417
	SWITCH              = 57418
	THREAD_LOCAL        = 57419
	TRANSLATION_UNIT    = 1048577
	TYPEDEF             = 57420
	TYPEDEF_NAME        = 57421
	TYPEOF              = 57422
	UNARY               = 57423
	UNION               = 57424
	UNSIGNED            = 57425
	VOID                = 57426
	VOLATILE            = 57427
	WHILE               = 57428
	XORASSIGN           = 57429
)
View Source
const (
	// CRT0Source is the source code of the C startup code.
	CRT0Source = `` /* 297-byte string literal not displayed */

)

Variables

View Source
var (

	// Null pointer, [0]6.3.2.3-3.
	Null = &ir.AddressValue{}
)
View Source
var (

	// YYDebug points to parser's yyDebug variable.
	YYDebug = &yyDebug
)

Functions

func ConvertFloat64

func ConvertFloat64(v float64, t Type, m Model) int64

ConvertFloat64 converts v to t, which must be an integer type.

func ConvertInt64

func ConvertInt64(n int64, t Type, m Model) int64

ConvertInt64 converts n to t, which must be an integer or enum type, doing masking and/or sign extending as appropriate.

func ErrString

func ErrString(err error) string

ErrString is like error.Error() but expands scanner.ErrorList.

func FlushCache

func FlushCache()

FlushCache removes all items in the file cache used by instances of FileSource.

func HostConfig

func HostConfig(opts ...string) (predefined string, includePaths, sysIncludePaths []string, err error)

HostConfig executes HostCppConfig with the cpp argument set to "cpp". For more info please see the documentation of HostCppConfig.

func HostCppConfig

func HostCppConfig(cpp string, opts ...string) (predefined string, includePaths, sysIncludePaths []string, err error)

HostCppConfig returns the system C preprocessor configuration, or an error, if any. The configuration is obtained by running the cpp command. For the predefined macros list the '-dM' options is added. For the include paths lists, the option '-v' is added and the output is parsed to extract the "..." include and <...> include paths. To add any other options to cpp, list them in opts.

The function relies on a POSIX compatible C preprocessor installed. Execution of HostConfig is not free, so caching the results is recommended whenever possible.

func ImportPath

func ImportPath() string

ImportPath reports the import path of this package.

func IncompatibleTypeDiff

func IncompatibleTypeDiff(a, b Type)

IncompatibleTypeDiff is a debug helper.

func Paths

func Paths(local bool) ([]string, error)

Paths returns the system header search paths, or an error, if any. If local is true the package-local, cached header search paths are returned.

func PrettyString

func PrettyString(v interface{}) string

PrettyString returns pretty strings for things produced by this package.

func TokSrc

func TokSrc(t xc.Token) string

TokSrc returns t in its source form.

func UsualArithmeticConversions

func UsualArithmeticConversions(m Model, a, b Operand) (Operand, Operand)

UsualArithmeticConversions performs transformations of operands of a binary operation. The function panics if either of the operands is not an artithmetic type.

[0]6.3.1.8

Many operators that expect operands of arithmetic type cause conversions and yield result types in a similar way. The purpose is to determine a common real type for the operands and result. For the specified operands, each operand is converted, without change of type domain, to a type whose corresponding real type is the common real type. Unless explicitly stated otherwise, the common real type is also the corresponding real type of the result, whose type domain is the type domain of the operands if they are the same, and complex otherwise. This pattern is called the usual arithmetic conversions:

Types

type AbstractDeclarator

type AbstractDeclarator struct {
	DeclarationSpecifier     *DeclarationSpecifier
	Type                     Type
	TypeQualifiers           []*TypeQualifier // From the PointerOpt production, if any.
	Case                     AbstractDeclaratorCase
	DirectAbstractDeclarator *DirectAbstractDeclarator
	Pointer                  *Pointer
	PointerOpt               *PointerOpt
}

AbstractDeclarator represents data reduced by productions:

AbstractDeclarator:
        Pointer                              // Case AbstractDeclaratorPointer
|       PointerOpt DirectAbstractDeclarator  // Case AbstractDeclaratorAbstract
Example (Abstract)
fmt.Println(exampleAST(186, "\U00100000 ( _Atomic ( ) )"))
Output:

&cc.AbstractDeclarator{
· Case: 1,
· DirectAbstractDeclarator: &cc.DirectAbstractDeclarator{
· · Case: 1,
· · Token: '(',
· · Token2: ')',
· },
}
Example (Pointer)
fmt.Println(exampleAST(185, "\U00100000 ( _Atomic * )"))
Output:

&cc.AbstractDeclarator{
· Pointer: &cc.Pointer{
· · Token: '*',
· },
}

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 AbstractDeclaratorCase

type AbstractDeclaratorCase int

AbstractDeclaratorCase represents case numbers of production AbstractDeclarator

const (
	AbstractDeclaratorPointer AbstractDeclaratorCase = iota
	AbstractDeclaratorAbstract
)

Values of type AbstractDeclaratorCase

func (AbstractDeclaratorCase) String

func (n AbstractDeclaratorCase) String() string

String implements fmt.Stringer

type AbstractDeclaratorOpt

type AbstractDeclaratorOpt struct {
	AbstractDeclarator *AbstractDeclarator
}

AbstractDeclaratorOpt represents data reduced by productions:

AbstractDeclaratorOpt:
        /* empty */         // Case 0
|       AbstractDeclarator  // Case 1
Example (Case0)
fmt.Println(exampleAST(187, "\U00100000 ( _Atomic )") == (*AbstractDeclaratorOpt)(nil))
Output:

true
Example (Case1)
fmt.Println(exampleAST(188, "\U00100000 ( _Atomic * )"))
Output:

&cc.AbstractDeclaratorOpt{
· AbstractDeclarator: &cc.AbstractDeclarator{
· · Pointer: &cc.Pointer{
· · · Token: '*',
· · },
· },
}

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 Address

type Address struct {
	Declarator *Declarator
	Offset     uintptr
}

Address represents the address of a variable.

func (*Address) String

func (a *Address) String() string

type AlignmentSpecifier added in v1.0.1

type AlignmentSpecifier struct {
	Case      AlignmentSpecifierCase
	ConstExpr *ConstExpr
	Token     xc.Token
	Token2    xc.Token
	Token3    xc.Token
	TypeName  *TypeName
}

AlignmentSpecifier represents data reduced by productions:

AlignmentSpecifier:
        "_Alignas" '(' TypeName ')'   // Case AlignmentSpecifierTypeName
|       "_Alignas" '(' ConstExpr ')'  // Case AlignmentSpecifierConstExpr
Example (ConstExpr)
fmt.Println(exampleAST(5, "\U00100001 _Alignas ( 'a' ) ("))
Output:

&cc.AlignmentSpecifier{
· Case: 1,
· ConstExpr: &cc.ConstExpr{
· · Expr: &cc.Expr{
· · · Case: ExprChar,
· · · Token: CHARCONST "'a'",
· · },
· },
· Token: ALIGNAS "_Alignas",
· Token2: '(',
· Token3: ')',
}
Example (TypeName)
fmt.Println(exampleAST(4, "\U00100001 _Alignas ( _Atomic ) ("))
Output:

&cc.AlignmentSpecifier{
· Token: ALIGNAS "_Alignas",
· Token2: '(',
· Token3: ')',
· TypeName: &cc.TypeName{
· · SpecifierQualifierList: &cc.SpecifierQualifierList{
· · · TypeQualifier: &cc.TypeQualifier{
· · · · Case: 3,
· · · · Token: ATOMIC "_Atomic",
· · · },
· · },
· },
}

func (*AlignmentSpecifier) Pos added in v1.0.1

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

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

func (*AlignmentSpecifier) String added in v1.0.1

func (n *AlignmentSpecifier) String() string

String implements fmt.Stringer.

type AlignmentSpecifierCase added in v1.0.1

type AlignmentSpecifierCase int

AlignmentSpecifierCase represents case numbers of production AlignmentSpecifier

const (
	AlignmentSpecifierTypeName AlignmentSpecifierCase = iota
	AlignmentSpecifierConstExpr
)

Values of type AlignmentSpecifierCase

func (AlignmentSpecifierCase) String added in v1.0.1

func (n AlignmentSpecifierCase) String() string

String implements fmt.Stringer

type ArgumentExprList

type ArgumentExprList struct {
	ArgumentExprList *ArgumentExprList
	Case             int
	Expr             *Expr
	Token            xc.Token
}

ArgumentExprList represents data reduced by productions:

ArgumentExprList:
        Expr                       // Case 0
|       ArgumentExprList ',' Expr  // Case 1
Example (Case0)
fmt.Println(exampleAST(6, "\U00100000 'a' ( 'b' )"))
Output:

&cc.ArgumentExprList{
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'b'",
· },
}
Example (Case1)
fmt.Println(exampleAST(7, "\U00100000 'a' ( 'b' , 'c' )"))
Output:

&cc.ArgumentExprList{
· ArgumentExprList: &cc.ArgumentExprList{
· · Case: 1,
· · Expr: &cc.Expr{
· · · Case: ExprChar,
· · · Token: CHARCONST "'c'",
· · },
· · Token: ',',
· },
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'b'",
· },
}

func (*ArgumentExprList) Pos

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

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

func (*ArgumentExprList) String

func (n *ArgumentExprList) String() string

String implements fmt.Stringer.

type ArgumentExprListOpt

type ArgumentExprListOpt struct {
	ArgumentExprList *ArgumentExprList
}

ArgumentExprListOpt represents data reduced by productions:

ArgumentExprListOpt:
        /* empty */       // Case 0
|       ArgumentExprList  // Case 1
Example (Case0)
fmt.Println(exampleAST(8, "\U00100000 'a' ( )") == (*ArgumentExprListOpt)(nil))
Output:

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

&cc.ArgumentExprListOpt{
· ArgumentExprList: &cc.ArgumentExprList{
· · Expr: &cc.Expr{
· · · Case: ExprChar,
· · · Token: CHARCONST "'b'",
· · },
· },
}

func (*ArgumentExprListOpt) Pos

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

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

func (*ArgumentExprListOpt) String

func (n *ArgumentExprListOpt) String() string

String implements fmt.Stringer.

type ArrayType

type ArrayType struct {
	Item           Type
	Length         *Expr
	Size           Operand
	TypeQualifiers []*TypeQualifier // Eg. double a[restrict 3][5], see 6.7.5.3-21.
	// contains filtered or unexported fields
}

ArrayType type represents an array type.

func (*ArrayType) Equal

func (t *ArrayType) Equal(u Type) bool

Equal implements Type.

func (*ArrayType) IsArithmeticType

func (t *ArrayType) IsArithmeticType() bool

IsArithmeticType implements Type.

func (*ArrayType) IsCompatible

func (t *ArrayType) IsCompatible(u Type) bool

IsCompatible implements Type.

func (*ArrayType) IsIntegerType

func (t *ArrayType) IsIntegerType() bool

IsIntegerType implements Type.

func (*ArrayType) IsPointerType

func (t *ArrayType) IsPointerType() bool

IsPointerType implements Type.

func (*ArrayType) IsScalarType

func (t *ArrayType) IsScalarType() bool

IsScalarType implements Type.

func (*ArrayType) IsUnsigned

func (t *ArrayType) IsUnsigned() bool

IsUnsigned implements Type.

func (*ArrayType) IsVLA added in v1.0.1

func (t *ArrayType) IsVLA() bool

func (*ArrayType) IsVoidPointerType

func (t *ArrayType) IsVoidPointerType() bool

IsVoidPointerType implements Type.

func (*ArrayType) Kind

func (t *ArrayType) Kind() TypeKind

Kind implements Type.

func (*ArrayType) Pos added in v1.0.1

func (t *ArrayType) Pos() token.Pos

func (*ArrayType) String

func (t *ArrayType) String() string

type BlockItem

type BlockItem struct {
	Case        BlockItemCase
	Declaration *Declaration
	Stmt        *Stmt
}

BlockItem represents data reduced by productions:

BlockItem:
        Declaration  // Case BlockItemDecl
|       Stmt         // Case BlockItemStmt
Example (Decl)
fmt.Println(exampleAST(229, "\U00100001 a { _Atomic ; !"))
Output:

&cc.BlockItem{
· Declaration: &cc.Declaration{
· · Scope: &cc.Scope{
· · · Parent: &cc.Scope{
· · · },
· · },
· · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · Case: 1,
· · · DeclarationSpecifiersOpt: &cc.DeclarationSpecifiersOpt{
· · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · Case: 2,
· · · · · DeclarationSpecifiersOpt: &cc.DeclarationSpecifiersOpt{
· · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · · · Case: 3,
· · · · · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · · · · Case: 3,
· · · · · · · · Token: CHAR "char",
· · · · · · · },
· · · · · · },
· · · · · },
· · · · · TypeQualifier: &cc.TypeQualifier{
· · · · · · Token: CONST "const",
· · · · · },
· · · · },
· · · },
· · · StorageClassSpecifier: &cc.StorageClassSpecifier{
· · · · Case: 3,
· · · · Token: STATIC "static",
· · · },
· · },
· · InitDeclaratorListOpt: &cc.InitDeclaratorListOpt{
· · · InitDeclaratorList: &cc.InitDeclaratorList{
· · · · InitDeclarator: &cc.InitDeclarator{
· · · · · Case: 1,
· · · · · Declarator: &cc.Declarator{
· · · · · · Linkage: LinkageNone,
· · · · · · Scope: &cc.Scope{ /* recursive/repetitive pointee not shown */ },
· · · · · · StorageDuration: StorageDurationAutomatic,
· · · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · · Case: DirectDeclaratorArray,
· · · · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · · · Case: DirectDeclaratorIdent,
· · · · · · · · Token: IDENTIFIER "__func__",
· · · · · · · },
· · · · · · · Token: '[',
· · · · · · · Token2: ']',
· · · · · · },
· · · · · },
· · · · · Initializer: &cc.Initializer{
· · · · · · Case: 1,
· · · · · · Expr: &cc.Expr{
· · · · · · · Case: ExprString,
· · · · · · · Token: STRINGLITERAL "\"a\"",
· · · · · · },
· · · · · },
· · · · · Token: '=',
· · · · },
· · · },
· · },
· · Token: ';',
· },
}
Example (Stmt)
fmt.Println(exampleAST(230, "\U00100001 a { ; !"))
Output:

&cc.BlockItem{
· Case: 1,
· Stmt: &cc.Stmt{
· · Case: 1,
· · ExprStmt: &cc.ExprStmt{
· · · Token: ';',
· · },
· },
}

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 BlockItemCase

type BlockItemCase int

BlockItemCase represents case numbers of production BlockItem

const (
	BlockItemDecl BlockItemCase = iota
	BlockItemStmt
)

Values of type BlockItemCase

func (BlockItemCase) String

func (n BlockItemCase) 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                // Case 0
|       BlockItemList BlockItem  // Case 1
Example (Case0)
fmt.Println(exampleAST(225, "\U00100001 a { ; !"))
Output:

&cc.BlockItemList{
· BlockItem: &cc.BlockItem{
· · Declaration: &cc.Declaration{
· · · Scope: &cc.Scope{
· · · · Parent: &cc.Scope{
· · · · },
· · · },
· · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · Case: 1,
· · · · DeclarationSpecifiersOpt: &cc.DeclarationSpecifiersOpt{
· · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · · Case: 2,
· · · · · · DeclarationSpecifiersOpt: &cc.DeclarationSpecifiersOpt{
· · · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · · · · Case: 3,
· · · · · · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · · · · · Case: 3,
· · · · · · · · · Token: CHAR "char",
· · · · · · · · },
· · · · · · · },
· · · · · · },
· · · · · · TypeQualifier: &cc.TypeQualifier{
· · · · · · · Token: CONST "const",
· · · · · · },
· · · · · },
· · · · },
· · · · StorageClassSpecifier: &cc.StorageClassSpecifier{
· · · · · Case: 3,
· · · · · Token: STATIC "static",
· · · · },
· · · },
· · · InitDeclaratorListOpt: &cc.InitDeclaratorListOpt{
· · · · InitDeclaratorList: &cc.InitDeclaratorList{
· · · · · InitDeclarator: &cc.InitDeclarator{
· · · · · · Case: 1,
· · · · · · Declarator: &cc.Declarator{
· · · · · · · Linkage: LinkageNone,
· · · · · · · Scope: &cc.Scope{ /* recursive/repetitive pointee not shown */ },
· · · · · · · StorageDuration: StorageDurationAutomatic,
· · · · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · · · Case: DirectDeclaratorArray,
· · · · · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · · · · Case: DirectDeclaratorIdent,
· · · · · · · · · Token: IDENTIFIER "__func__",
· · · · · · · · },
· · · · · · · · Token: '[',
· · · · · · · · Token2: ']',
· · · · · · · },
· · · · · · },
· · · · · · Initializer: &cc.Initializer{
· · · · · · · Case: 1,
· · · · · · · Expr: &cc.Expr{
· · · · · · · · Case: ExprString,
· · · · · · · · Token: STRINGLITERAL "\"a\"",
· · · · · · · },
· · · · · · },
· · · · · · Token: '=',
· · · · · },
· · · · },
· · · },
· · · Token: ';',
· · },
· },
}
Example (Case1)
fmt.Println(exampleAST(226, "\U00100001 a { ; ; !"))
Output:

&cc.BlockItemList{
· BlockItem: &cc.BlockItem{
· · Declaration: &cc.Declaration{
· · · Scope: &cc.Scope{
· · · · Parent: &cc.Scope{
· · · · },
· · · },
· · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · Case: 1,
· · · · DeclarationSpecifiersOpt: &cc.DeclarationSpecifiersOpt{
· · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · · Case: 2,
· · · · · · DeclarationSpecifiersOpt: &cc.DeclarationSpecifiersOpt{
· · · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · · · · Case: 3,
· · · · · · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · · · · · Case: 3,
· · · · · · · · · Token: CHAR "char",
· · · · · · · · },
· · · · · · · },
· · · · · · },
· · · · · · TypeQualifier: &cc.TypeQualifier{
· · · · · · · Token: CONST "const",
· · · · · · },
· · · · · },
· · · · },
· · · · StorageClassSpecifier: &cc.StorageClassSpecifier{
· · · · · Case: 3,
· · · · · Token: STATIC "static",
· · · · },
· · · },
· · · InitDeclaratorListOpt: &cc.InitDeclaratorListOpt{
· · · · InitDeclaratorList: &cc.InitDeclaratorList{
· · · · · InitDeclarator: &cc.InitDeclarator{
· · · · · · Case: 1,
· · · · · · Declarator: &cc.Declarator{
· · · · · · · Linkage: LinkageNone,
· · · · · · · Scope: &cc.Scope{ /* recursive/repetitive pointee not shown */ },
· · · · · · · StorageDuration: StorageDurationAutomatic,
· · · · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · · · Case: DirectDeclaratorArray,
· · · · · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · · · · Case: DirectDeclaratorIdent,
· · · · · · · · · Token: IDENTIFIER "__func__",
· · · · · · · · },
· · · · · · · · Token: '[',
· · · · · · · · Token2: ']',
· · · · · · · },
· · · · · · },
· · · · · · Initializer: &cc.Initializer{
· · · · · · · Case: 1,
· · · · · · · Expr: &cc.Expr{
· · · · · · · · Case: ExprString,
· · · · · · · · Token: STRINGLITERAL "\"a\"",
· · · · · · · },
· · · · · · },
· · · · · · Token: '=',
· · · · · },
· · · · },
· · · },
· · · Token: ';',
· · },
· },
· BlockItemList: &cc.BlockItemList{
· · BlockItem: &cc.BlockItem{
· · · Case: 1,
· · · Stmt: &cc.Stmt{
· · · · Case: 1,
· · · · ExprStmt: &cc.ExprStmt{
· · · · · Token: ';',
· · · · },
· · · },
· · },
· · 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 */    // Case 0
|       BlockItemList  // Case 1
Example (Case0)
fmt.Println(exampleAST(227, "\U00100001 a { }") == (*BlockItemListOpt)(nil))
Output:

false
Example (Case1)
fmt.Println(exampleAST(228, "\U00100001 a { ; }"))
Output:

&cc.BlockItemListOpt{
· BlockItemList: &cc.BlockItemList{
· · BlockItem: &cc.BlockItem{
· · · Declaration: &cc.Declaration{
· · · · Scope: &cc.Scope{
· · · · · Parent: &cc.Scope{
· · · · · },
· · · · },
· · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · Case: 1,
· · · · · DeclarationSpecifiersOpt: &cc.DeclarationSpecifiersOpt{
· · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · · · Case: 2,
· · · · · · · DeclarationSpecifiersOpt: &cc.DeclarationSpecifiersOpt{
· · · · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · · · · · Case: 3,
· · · · · · · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · · · · · · Case: 3,
· · · · · · · · · · Token: CHAR "char",
· · · · · · · · · },
· · · · · · · · },
· · · · · · · },
· · · · · · · TypeQualifier: &cc.TypeQualifier{
· · · · · · · · Token: CONST "const",
· · · · · · · },
· · · · · · },
· · · · · },
· · · · · StorageClassSpecifier: &cc.StorageClassSpecifier{
· · · · · · Case: 3,
· · · · · · Token: STATIC "static",
· · · · · },
· · · · },
· · · · InitDeclaratorListOpt: &cc.InitDeclaratorListOpt{
· · · · · InitDeclaratorList: &cc.InitDeclaratorList{
· · · · · · InitDeclarator: &cc.InitDeclarator{
· · · · · · · Case: 1,
· · · · · · · Declarator: &cc.Declarator{
· · · · · · · · Linkage: LinkageNone,
· · · · · · · · Scope: &cc.Scope{ /* recursive/repetitive pointee not shown */ },
· · · · · · · · StorageDuration: StorageDurationAutomatic,
· · · · · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · · · · Case: DirectDeclaratorArray,
· · · · · · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · · · · · Case: DirectDeclaratorIdent,
· · · · · · · · · · Token: IDENTIFIER "__func__",
· · · · · · · · · },
· · · · · · · · · Token: '[',
· · · · · · · · · Token2: ']',
· · · · · · · · },
· · · · · · · },
· · · · · · · Initializer: &cc.Initializer{
· · · · · · · · Case: 1,
· · · · · · · · Expr: &cc.Expr{
· · · · · · · · · Case: ExprString,
· · · · · · · · · Token: STRINGLITERAL "\"a\"",
· · · · · · · · },
· · · · · · · },
· · · · · · · Token: '=',
· · · · · · },
· · · · · },
· · · · },
· · · · Token: ';',
· · · },
· · },
· · BlockItemList: &cc.BlockItemList{
· · · BlockItem: &cc.BlockItem{
· · · · Case: 1,
· · · · Stmt: &cc.Stmt{
· · · · · Case: 1,
· · · · · ExprStmt: &cc.ExprStmt{
· · · · · · Token: ';',
· · · · · },
· · · · },
· · · },
· · · Case: 1,
· · },
· },
}

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 0
|       ','          // Case 1
Example (Case0)
fmt.Println(exampleAST(134, "\U00100000 ( _Atomic ) { }") == (*CommaOpt)(nil))
Output:

true
Example (Case1)
fmt.Println(exampleAST(135, "\U00100000 ( _Atomic ) { , }"))
Output:

&cc.CommaOpt{
· Token: ',',
}

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 CompoundStmt

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

CompoundStmt represents data reduced by production:

CompoundStmt:
        '{' BlockItemListOpt statementEnd '}'  // Case 0
Example (Case0)
fmt.Println(exampleAST(224, "\U00100001 a { }"))
Output:

&cc.CompoundStmt{
· BlockItemListOpt: &cc.BlockItemListOpt{
· · BlockItemList: &cc.BlockItemList{
· · · BlockItem: &cc.BlockItem{
· · · · Declaration: &cc.Declaration{
· · · · · Scope: &cc.Scope{
· · · · · · Parent: &cc.Scope{
· · · · · · },
· · · · · },
· · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · · Case: 1,
· · · · · · DeclarationSpecifiersOpt: &cc.DeclarationSpecifiersOpt{
· · · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · · · · Case: 2,
· · · · · · · · DeclarationSpecifiersOpt: &cc.DeclarationSpecifiersOpt{
· · · · · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · · · · · · Case: 3,
· · · · · · · · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · · · · · · · Case: 3,
· · · · · · · · · · · Token: CHAR "char",
· · · · · · · · · · },
· · · · · · · · · },
· · · · · · · · },
· · · · · · · · TypeQualifier: &cc.TypeQualifier{
· · · · · · · · · Token: CONST "const",
· · · · · · · · },
· · · · · · · },
· · · · · · },
· · · · · · StorageClassSpecifier: &cc.StorageClassSpecifier{
· · · · · · · Case: 3,
· · · · · · · Token: STATIC "static",
· · · · · · },
· · · · · },
· · · · · InitDeclaratorListOpt: &cc.InitDeclaratorListOpt{
· · · · · · InitDeclaratorList: &cc.InitDeclaratorList{
· · · · · · · InitDeclarator: &cc.InitDeclarator{
· · · · · · · · Case: 1,
· · · · · · · · Declarator: &cc.Declarator{
· · · · · · · · · Linkage: LinkageNone,
· · · · · · · · · Scope: &cc.Scope{ /* recursive/repetitive pointee not shown */ },
· · · · · · · · · StorageDuration: StorageDurationAutomatic,
· · · · · · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · · · · · Case: DirectDeclaratorArray,
· · · · · · · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · · · · · · Case: DirectDeclaratorIdent,
· · · · · · · · · · · Token: IDENTIFIER "__func__",
· · · · · · · · · · },
· · · · · · · · · · Token: '[',
· · · · · · · · · · Token2: ']',
· · · · · · · · · },
· · · · · · · · },
· · · · · · · · Initializer: &cc.Initializer{
· · · · · · · · · Case: 1,
· · · · · · · · · Expr: &cc.Expr{
· · · · · · · · · · Case: ExprString,
· · · · · · · · · · Token: STRINGLITERAL "\"a\"",
· · · · · · · · · },
· · · · · · · · },
· · · · · · · · Token: '=',
· · · · · · · },
· · · · · · },
· · · · · },
· · · · · Token: ';',
· · · · },
· · · },
· · },
· },
· Token: '{',
· Token2: '}',
}

func (*CompoundStmt) Pos

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

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

func (*CompoundStmt) String

func (n *CompoundStmt) String() string

String implements fmt.Stringer.

type ConstExpr

type ConstExpr struct {
	Operand Operand
	Expr    *Expr
}

ConstExpr represents data reduced by production:

ConstExpr:
        Expr  // Case 0
Example (Case0)
fmt.Println(exampleAST(75, "\U00100000 'a'"))
Output:

&cc.ConstExpr{
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
}

func (*ConstExpr) Pos

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

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

func (*ConstExpr) String

func (n *ConstExpr) String() string

String implements fmt.Stringer.

type Declaration

type Declaration struct {
	Attributes            [][]xc.Token
	Scope                 *Scope
	DeclarationSpecifiers *DeclarationSpecifiers
	InitDeclaratorListOpt *InitDeclaratorListOpt
	Token                 xc.Token
}

Declaration represents data reduced by production:

Declaration:
        DeclarationSpecifiers InitDeclaratorListOpt ';'  // Case 0
Example (Case0)
fmt.Println(exampleAST(77, "\U00100001 _Atomic ;"))
Output:

&cc.Declaration{
· DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · Case: 2,
· · TypeQualifier: &cc.TypeQualifier{
· · · Case: 3,
· · · Token: ATOMIC "_Atomic",
· · },
· },
· Token: ';',
}

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                  // Case 0
|       DeclarationList Declaration  // Case 1
Example (Case0)
fmt.Println(exampleAST(253, "\U00100001 a _Atomic ; {"))
Output:

&cc.DeclarationList{
· Declaration: &cc.Declaration{
· · Scope: &cc.Scope{
· · },
· · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · Case: 2,
· · · TypeQualifier: &cc.TypeQualifier{
· · · · Case: 3,
· · · · Token: ATOMIC "_Atomic",
· · · },
· · },
· · Token: ';',
· },
}
Example (Case1)
fmt.Println(exampleAST(254, "\U00100001 a _Atomic ; _Atomic ; {"))
Output:

&cc.DeclarationList{
· Declaration: &cc.Declaration{
· · Scope: &cc.Scope{
· · },
· · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · Case: 2,
· · · TypeQualifier: &cc.TypeQualifier{
· · · · Case: 3,
· · · · Token: ATOMIC "_Atomic",
· · · },
· · },
· · Token: ';',
· },
· DeclarationList: &cc.DeclarationList{
· · Case: 1,
· · Declaration: &cc.Declaration{
· · · Scope: &cc.Scope{ /* recursive/repetitive pointee not shown */ },
· · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · Case: 2,
· · · · TypeQualifier: &cc.TypeQualifier{
· · · · · Case: 3,
· · · · · Token: ATOMIC "_Atomic",
· · · · },
· · · },
· · · Token: ';',
· · },
· },
}

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
}

DeclarationListOpt represents data reduced by productions:

DeclarationListOpt:
        /* empty */      // Case 0
|       DeclarationList  // Case 1
Example (Case0)
fmt.Println(exampleAST(255, "\U00100001 a {") == (*DeclarationListOpt)(nil))
Output:

true
Example (Case1)
fmt.Println(exampleAST(256, "\U00100001 a _Atomic ; {"))
Output:

&cc.DeclarationListOpt{
· DeclarationList: &cc.DeclarationList{
· · Declaration: &cc.Declaration{
· · · Scope: &cc.Scope{
· · · },
· · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · Case: 2,
· · · · TypeQualifier: &cc.TypeQualifier{
· · · · · Case: 3,
· · · · · Token: ATOMIC "_Atomic",
· · · · },
· · · },
· · · Token: ';',
· · },
· },
}

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 DeclarationSpecifier

type DeclarationSpecifier struct {
	Parent                 *DeclarationSpecifier
	AlignmentSpecifiers    []*AlignmentSpecifier
	FunctionSpecifiers     []*FunctionSpecifier
	StorageClassSpecifiers []*StorageClassSpecifier
	TypeQualifiers         []*TypeQualifier
	TypeSpecifiers         []*TypeSpecifier
	// contains filtered or unexported fields
}

DeclarationSpecifier describes declaration specifiers.

func (*DeclarationSpecifier) IsExtern

func (d *DeclarationSpecifier) IsExtern() bool

IsExtern reports whether the storage class specifier "extern" is present.

func (*DeclarationSpecifier) IsStatic

func (d *DeclarationSpecifier) IsStatic() bool

IsStatic reports whether the storage class specifier "static" is present.

func (*DeclarationSpecifier) IsTypedef

func (d *DeclarationSpecifier) IsTypedef() bool

IsTypedef reports whether the storage class specifier "typedef" is present.

func (*DeclarationSpecifier) IsVolatile added in v1.0.1

func (d *DeclarationSpecifier) IsVolatile() bool

IsVolatile reports whether the type qualifier specifier "volatile" is present.

type DeclarationSpecifiers

type DeclarationSpecifiers struct {
	AlignmentSpecifier       *AlignmentSpecifier
	Case                     DeclarationSpecifiersCase
	DeclarationSpecifiersOpt *DeclarationSpecifiersOpt
	FunctionSpecifier        *FunctionSpecifier
	StorageClassSpecifier    *StorageClassSpecifier
	TypeQualifier            *TypeQualifier
	TypeSpecifier            *TypeSpecifier
}

DeclarationSpecifiers represents data reduced by productions:

DeclarationSpecifiers:
        FunctionSpecifier DeclarationSpecifiersOpt      // Case DeclarationSpecifiersFunc
|       StorageClassSpecifier DeclarationSpecifiersOpt  // Case DeclarationSpecifiersStorage
|       TypeQualifier DeclarationSpecifiersOpt          // Case DeclarationSpecifiersQualifier
|       TypeSpecifier DeclarationSpecifiersOpt          // Case DeclarationSpecifiersSpecifier
|       AlignmentSpecifier DeclarationSpecifiersOpt     // Case DeclarationSpecifiersAlignment
Example (Alignment)
fmt.Println(exampleAST(82, "\U00100001 _Alignas ( _Atomic ) ("))
Output:

&cc.DeclarationSpecifiers{
· AlignmentSpecifier: &cc.AlignmentSpecifier{
· · Token: ALIGNAS "_Alignas",
· · Token2: '(',
· · Token3: ')',
· · TypeName: &cc.TypeName{
· · · SpecifierQualifierList: &cc.SpecifierQualifierList{
· · · · TypeQualifier: &cc.TypeQualifier{
· · · · · Case: 3,
· · · · · Token: ATOMIC "_Atomic",
· · · · },
· · · },
· · },
· },
· Case: 4,
}
Example (Func)
fmt.Println(exampleAST(78, "\U00100001 inline ("))
Output:

&cc.DeclarationSpecifiers{
· FunctionSpecifier: &cc.FunctionSpecifier{
· · Token: INLINE "inline",
· },
}
Example (Qualifier)
fmt.Println(exampleAST(80, "\U00100001 _Atomic ("))
Output:

&cc.DeclarationSpecifiers{
· Case: 2,
· TypeQualifier: &cc.TypeQualifier{
· · Case: 3,
· · Token: ATOMIC "_Atomic",
· },
}
Example (Specifier)
fmt.Println(exampleAST(81, "\U00100001 _Bool ("))
Output:

&cc.DeclarationSpecifiers{
· Case: 3,
· TypeSpecifier: &cc.TypeSpecifier{
· · Token: BOOL "_Bool",
· },
}
Example (Storage)
fmt.Println(exampleAST(79, "\U00100001 auto ("))
Output:

&cc.DeclarationSpecifiers{
· Case: 1,
· StorageClassSpecifier: &cc.StorageClassSpecifier{
· · Token: AUTO "auto",
· },
}

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.

type DeclarationSpecifiersCase

type DeclarationSpecifiersCase int

DeclarationSpecifiersCase represents case numbers of production DeclarationSpecifiers

const (
	DeclarationSpecifiersFunc DeclarationSpecifiersCase = iota
	DeclarationSpecifiersStorage
	DeclarationSpecifiersQualifier
	DeclarationSpecifiersSpecifier
	DeclarationSpecifiersAlignment
)

Values of type DeclarationSpecifiersCase

func (DeclarationSpecifiersCase) String

func (n DeclarationSpecifiersCase) String() string

String implements fmt.Stringer

type DeclarationSpecifiersOpt

type DeclarationSpecifiersOpt struct {
	DeclarationSpecifiers *DeclarationSpecifiers
}

DeclarationSpecifiersOpt represents data reduced by productions:

DeclarationSpecifiersOpt:
        /* empty */            // Case 0
|       DeclarationSpecifiers  // Case 1
Example (Case0)
fmt.Println(exampleAST(83, "\U00100001 inline (") == (*DeclarationSpecifiersOpt)(nil))
Output:

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

&cc.DeclarationSpecifiersOpt{
· DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · Case: 2,
· · TypeQualifier: &cc.TypeQualifier{
· · · Case: 3,
· · · Token: ATOMIC "_Atomic",
· · },
· },
}

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 {
	AssignedTo           int // Declarator appears at the left side of assignment.
	Attributes           [][]xc.Token
	Bits                 int                   // StructDeclarator: bit width when a bit field.
	DeclarationSpecifier *DeclarationSpecifier // Nil for embedded declarators.
	Definition           *Declarator           // Declaration -> definition.
	Field                int                   // Declaration order# if struct field declarator.
	FunctionDefinition   *FunctionDefinition   // When the declarator defines a function.
	Initializer          *Initializer          // Only when part of an InitDeclarator.
	Linkage              Linkage               // Linkage of the declared name, [0]6.2.2.
	Parameters           []*Declarator         // Of the function declarator.
	Referenced           int
	Scope                *Scope           // Declaration scope.
	ScopeNum             int              // Sequential scope number within function body.
	StorageDuration      StorageDuration  // Storage duration of the declared name, [0]6.2.4.
	Type                 Type             // Declared type.
	TypeQualifiers       []*TypeQualifier // From the PointerOpt production, if any.

	AddressTaken        bool
	Alloca              bool // Function declarator: Body calls __builtin_alloca
	Embedded            bool // [0]6.7.5-3: Not a full declarator.
	IsField             bool
	IsFunctionParameter bool
	IsBuiltin           bool
	DirectDeclarator    *DirectDeclarator
	PointerOpt          *PointerOpt
	// contains filtered or unexported fields
}

Declarator represents data reduced by production:

Declarator:
        PointerOpt DirectDeclarator  // Case 0
Example (Case0)
fmt.Println(exampleAST(148, "\U00100001 a )"))
Output:

&cc.Declarator{
· Linkage: LinkageNone,
· Scope: &cc.Scope{
· },
· StorageDuration: StorageDurationAutomatic,
· DirectDeclarator: &cc.DirectDeclarator{
· · Case: DirectDeclaratorIdent,
· · Token: IDENTIFIER "a",
· },
}

func (*Declarator) IsTLD

func (n *Declarator) IsTLD() bool

IsTLD reports whether n is declared in file scope.

func (*Declarator) IsVolatile added in v1.0.1

func (d *Declarator) IsVolatile() bool

func (*Declarator) Name

func (n *Declarator) Name() int

Name returns the ID of the declared name.

func (*Declarator) ParameterNames

func (n *Declarator) ParameterNames() []int

ParameterNames returns a list of IDs of names of parameters of n. The function panics if n is not function type.

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) 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 */  // Case 0
|       Declarator   // Case 1
Example (Case0)
fmt.Println(exampleAST(151, "\U00100001 struct { _Atomic :") == (*DeclaratorOpt)(nil))
Output:

true
Example (Case1)
fmt.Println(exampleAST(152, "\U00100001 struct { _Atomic a :"))
Output:

&cc.DeclaratorOpt{
· Declarator: &cc.Declarator{
· · Linkage: LinkageNone,
· · Scope: &cc.Scope{
· · },
· · StorageDuration: StorageDurationAutomatic,
· · DirectDeclarator: &cc.DirectDeclarator{
· · · Case: DirectDeclaratorIdent,
· · · Token: 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 {
	List           []int64
	Type           Type
	DesignatorList *DesignatorList
	Token          xc.Token
}

Designation represents data reduced by production:

Designation:
        DesignatorList '='  // Case 0
Example (Case0)
fmt.Println(exampleAST(206, "\U00100001 _Atomic a = { . b = !"))
Output:

&cc.Designation{
· DesignatorList: &cc.DesignatorList{
· · Designator: &cc.Designator{
· · · Token: '.',
· · · Token2: IDENTIFIER "b",
· · },
· },
· Token: '=',
}

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 Designator

type Designator struct {
	Case      DesignatorCase
	ConstExpr *ConstExpr
	Token     xc.Token
	Token2    xc.Token
}

Designator represents data reduced by productions:

Designator:
        '.' IDENTIFIER     // Case DesignatorField
|       '[' ConstExpr ']'  // Case DesignatorIndex
Example (Field)
fmt.Println(exampleAST(209, "\U00100000 ( _Atomic ) { . a ."))
Output:

&cc.Designator{
· Token: '.',
· Token2: IDENTIFIER "a",
}
Example (Index)
fmt.Println(exampleAST(210, "\U00100000 ( _Atomic ) { [ 'a' ] ."))
Output:

&cc.Designator{
· Case: 1,
· ConstExpr: &cc.ConstExpr{
· · Expr: &cc.Expr{
· · · Case: ExprChar,
· · · Token: CHARCONST "'a'",
· · },
· },
· Token: '[',
· Token2: ']',
}

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 DesignatorCase

type DesignatorCase int

DesignatorCase represents case numbers of production Designator

const (
	DesignatorField DesignatorCase = iota
	DesignatorIndex
)

Values of type DesignatorCase

func (DesignatorCase) String

func (n DesignatorCase) 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                 // Case 0
|       DesignatorList Designator  // Case 1
Example (Case0)
fmt.Println(exampleAST(207, "\U00100001 _Atomic a = { . b ."))
Output:

&cc.DesignatorList{
· Designator: &cc.Designator{
· · Token: '.',
· · Token2: IDENTIFIER "b",
· },
}
Example (Case1)
fmt.Println(exampleAST(208, "\U00100001 _Atomic a = { . b . c ."))
Output:

&cc.DesignatorList{
· Designator: &cc.Designator{
· · Token: '.',
· · Token2: IDENTIFIER "b",
· },
· DesignatorList: &cc.DesignatorList{
· · Case: 1,
· · Designator: &cc.Designator{
· · · Token: '.',
· · · Token2: IDENTIFIER "c",
· · },
· },
}

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                        DirectAbstractDeclaratorCase
	DirectAbstractDeclarator    *DirectAbstractDeclarator
	DirectAbstractDeclaratorOpt *DirectAbstractDeclaratorOpt
	Expr                        *Expr
	ExprOpt                     *ExprOpt
	ParameterTypeListOpt        *ParameterTypeListOpt
	Token                       xc.Token
	Token2                      xc.Token
	Token3                      xc.Token
	TypeQualifierList           *TypeQualifierList
	TypeQualifierListOpt        *TypeQualifierListOpt
}

DirectAbstractDeclarator represents data reduced by productions:

DirectAbstractDeclarator:
        '(' AbstractDeclarator ')'                                              // Case DirectAbstractDeclaratorAbstract
|       '(' ParameterTypeListOpt ')'                                            // Case DirectAbstractDeclaratorParamList
|       DirectAbstractDeclarator '(' ParameterTypeListOpt ')'                   // Case DirectAbstractDeclaratorDFn
|       DirectAbstractDeclaratorOpt '[' "static" TypeQualifierListOpt Expr ']'  // Case DirectAbstractDeclaratorDArrSize
|       DirectAbstractDeclaratorOpt '[' '*' ']'                                 // Case DirectAbstractDeclaratorDArrVL
|       DirectAbstractDeclaratorOpt '[' ExprOpt ']'                             // Case DirectAbstractDeclaratorDArr
|       DirectAbstractDeclaratorOpt '[' TypeQualifierList "static" Expr ']'     // Case DirectAbstractDeclaratorDArrSize2
|       DirectAbstractDeclaratorOpt '[' TypeQualifierList ExprOpt ']'           // Case DirectAbstractDeclaratorDArr2
Example (Abstract)
fmt.Println(exampleAST(189, "\U00100000 ( _Atomic ( * ) ("))
Output:

&cc.DirectAbstractDeclarator{
· AbstractDeclarator: &cc.AbstractDeclarator{
· · Pointer: &cc.Pointer{
· · · Token: '*',
· · },
· },
· Token: '(',
· Token2: ')',
}
Example (DArr)
fmt.Println(exampleAST(194, "\U00100000 ( _Atomic [ ] ("))
Output:

&cc.DirectAbstractDeclarator{
· Case: 5,
· Token: '[',
· Token2: ']',
}
Example (DArr2)
fmt.Println(exampleAST(196, "\U00100000 ( _Atomic [ _Atomic ] ("))
Output:

&cc.DirectAbstractDeclarator{
· Case: 7,
· Token: '[',
· Token2: ']',
· TypeQualifierList: &cc.TypeQualifierList{
· · TypeQualifier: &cc.TypeQualifier{
· · · Case: 3,
· · · Token: ATOMIC "_Atomic",
· · },
· },
}
Example (DArrSize)
fmt.Println(exampleAST(192, "\U00100000 ( _Atomic [ static 'a' ] ("))
Output:

&cc.DirectAbstractDeclarator{
· Case: 3,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Token: '[',
· Token2: STATIC "static",
· Token3: ']',
}
Example (DArrSize2)
fmt.Println(exampleAST(195, "\U00100000 ( _Atomic [ _Atomic static 'a' ] ("))
Output:

&cc.DirectAbstractDeclarator{
· Case: 6,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Token: '[',
· Token2: STATIC "static",
· Token3: ']',
· TypeQualifierList: &cc.TypeQualifierList{
· · TypeQualifier: &cc.TypeQualifier{
· · · Case: 3,
· · · Token: ATOMIC "_Atomic",
· · },
· },
}
Example (DArrVL)
fmt.Println(exampleAST(193, "\U00100000 ( _Atomic [ * ] ("))
Output:

&cc.DirectAbstractDeclarator{
· Case: 4,
· Token: '[',
· Token2: '*',
· Token3: ']',
}
Example (DFn)
fmt.Println(exampleAST(191, "\U00100000 ( _Atomic ( ) ( ) ("))
Output:

&cc.DirectAbstractDeclarator{
· Case: 2,
· DirectAbstractDeclarator: &cc.DirectAbstractDeclarator{
· · Case: 1,
· · Token: '(',
· · Token2: ')',
· },
· Token: '(',
· Token2: ')',
}
Example (ParamList)
fmt.Println(exampleAST(190, "\U00100000 ( _Atomic ( ) ("))
Output:

&cc.DirectAbstractDeclarator{
· Case: 1,
· Token: '(',
· Token2: ')',
}

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 DirectAbstractDeclaratorCase

type DirectAbstractDeclaratorCase int

DirectAbstractDeclaratorCase represents case numbers of production DirectAbstractDeclarator

const (
	DirectAbstractDeclaratorAbstract DirectAbstractDeclaratorCase = iota
	DirectAbstractDeclaratorParamList
	DirectAbstractDeclaratorDFn
	DirectAbstractDeclaratorDArrSize
	DirectAbstractDeclaratorDArrVL
	DirectAbstractDeclaratorDArr
	DirectAbstractDeclaratorDArrSize2
	DirectAbstractDeclaratorDArr2
)

Values of type DirectAbstractDeclaratorCase

func (DirectAbstractDeclaratorCase) String

String implements fmt.Stringer

type DirectAbstractDeclaratorOpt

type DirectAbstractDeclaratorOpt struct {
	DirectAbstractDeclarator *DirectAbstractDeclarator
}

DirectAbstractDeclaratorOpt represents data reduced by productions:

DirectAbstractDeclaratorOpt:
        /* empty */               // Case 0
|       DirectAbstractDeclarator  // Case 1
Example (Case0)
fmt.Println(exampleAST(197, "\U00100000 ( _Atomic [") == (*DirectAbstractDeclaratorOpt)(nil))
Output:

true
Example (Case1)
fmt.Println(exampleAST(198, "\U00100000 ( _Atomic ( ) ["))
Output:

&cc.DirectAbstractDeclaratorOpt{
· DirectAbstractDeclarator: &cc.DirectAbstractDeclarator{
· · Case: 1,
· · Token: '(',
· · Token2: ')',
· },
}

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 {
	Case                 DirectDeclaratorCase
	Declarator           *Declarator
	DirectDeclarator     *DirectDeclarator
	Expr                 *Expr
	ExprOpt              *ExprOpt
	Parameters           *Parameters
	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:
        '(' Declarator ')'                                           // Case DirectDeclaratorParen
|       DirectDeclarator '(' Parameters ')'                          // Case DirectDeclaratorParameters
|       DirectDeclarator '[' "static" TypeQualifierListOpt Expr ']'  // Case DirectDeclaratorArraySize
|       DirectDeclarator '[' TypeQualifierList "static" Expr ']'     // Case DirectDeclaratorArraySize2
|       DirectDeclarator '[' TypeQualifierListOpt '*' ']'            // Case DirectDeclaratorArrayVar
|       DirectDeclarator '[' TypeQualifierListOpt ExprOpt ']'        // Case DirectDeclaratorArray
|       IDENTIFIER                                                   // Case DirectDeclaratorIdent
Example (Array)
fmt.Println(exampleAST(160, "\U00100001 a [ ] ("))
Output:

&cc.DirectDeclarator{
· Case: DirectDeclaratorArray,
· DirectDeclarator: &cc.DirectDeclarator{
· · Case: DirectDeclaratorIdent,
· · Token: IDENTIFIER "a",
· },
· Token: '[',
· Token2: ']',
}
Example (ArraySize)
fmt.Println(exampleAST(157, "\U00100001 a [ static 'b' ] ("))
Output:

&cc.DirectDeclarator{
· Case: DirectDeclaratorArraySize,
· DirectDeclarator: &cc.DirectDeclarator{
· · Case: DirectDeclaratorIdent,
· · Token: IDENTIFIER "a",
· },
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'b'",
· },
· Token: '[',
· Token2: STATIC "static",
· Token3: ']',
}
Example (ArraySize2)
fmt.Println(exampleAST(158, "\U00100001 a [ _Atomic static 'b' ] ("))
Output:

&cc.DirectDeclarator{
· Case: DirectDeclaratorArraySize2,
· DirectDeclarator: &cc.DirectDeclarator{
· · Case: DirectDeclaratorIdent,
· · Token: IDENTIFIER "a",
· },
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'b'",
· },
· Token: '[',
· Token2: STATIC "static",
· Token3: ']',
· TypeQualifierList: &cc.TypeQualifierList{
· · TypeQualifier: &cc.TypeQualifier{
· · · Case: 3,
· · · Token: ATOMIC "_Atomic",
· · },
· },
}
Example (ArrayVar)
fmt.Println(exampleAST(159, "\U00100001 a [ * ] ("))
Output:

&cc.DirectDeclarator{
· Case: DirectDeclaratorArrayVar,
· DirectDeclarator: &cc.DirectDeclarator{
· · Case: DirectDeclaratorIdent,
· · Token: IDENTIFIER "a",
· },
· Token: '[',
· Token2: '*',
· Token3: ']',
}
Example (Ident)
fmt.Println(exampleAST(161, "\U00100001 a ("))
Output:

&cc.DirectDeclarator{
· Case: DirectDeclaratorIdent,
· Token: IDENTIFIER "a",
}
Example (Parameters)
fmt.Println(exampleAST(156, "\U00100001 a ( ) ("))
Output:

&cc.DirectDeclarator{
· Case: DirectDeclaratorParameters,
· DirectDeclarator: &cc.DirectDeclarator{
· · Case: DirectDeclaratorIdent,
· · Token: IDENTIFIER "a",
· },
· Token: '(',
· Token2: ')',
}
Example (Paren)
fmt.Println(exampleAST(153, "\U00100001 ( a ) ("))
Output:

&cc.DirectDeclarator{
· Case: DirectDeclaratorParen,
· Declarator: &cc.Declarator{
· · Linkage: LinkageNone,
· · Scope: &cc.Scope{
· · },
· · StorageDuration: StorageDurationAutomatic,
· · Embedded: true,
· · DirectDeclarator: &cc.DirectDeclarator{
· · · Case: DirectDeclaratorIdent,
· · · Token: IDENTIFIER "a",
· · },
· },
· Token: '(',
· Token2: ')',
}

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.

type DirectDeclaratorCase

type DirectDeclaratorCase int

DirectDeclaratorCase represents case numbers of production DirectDeclarator

const (
	DirectDeclaratorParen DirectDeclaratorCase = iota
	DirectDeclaratorParameters
	DirectDeclaratorArraySize
	DirectDeclaratorArraySize2
	DirectDeclaratorArrayVar
	DirectDeclaratorArray
	DirectDeclaratorIdent
)

Values of type DirectDeclaratorCase

func (DirectDeclaratorCase) String

func (n DirectDeclaratorCase) String() string

String implements fmt.Stringer

type EnumSpecifier

type EnumSpecifier struct {
	Tag int

	Case           EnumSpecifierCase
	CommaOpt       *CommaOpt
	EnumeratorList *EnumeratorList
	IdentifierOpt  *IdentifierOpt
	Token          xc.Token
	Token2         xc.Token
	Token3         xc.Token
	// contains filtered or unexported fields
}

EnumSpecifier represents data reduced by productions:

EnumSpecifier:
        "enum" IDENTIFIER                                     // Case EnumSpecifierTag
|       "enum" IdentifierOpt '{' EnumeratorList CommaOpt '}'  // Case EnumSpecifierDefine
Example (Define)
fmt.Println(exampleAST(137, "\U00100001 enum { a } ("))
Output:

&cc.EnumSpecifier{
· Case: 1,
· EnumeratorList: &cc.EnumeratorList{
· · Enumerator: &cc.Enumerator{
· · · EnumerationConstant: &cc.EnumerationConstant{
· · · · Token: IDENTIFIER "a",
· · · },
· · },
· },
· Token: ENUM "enum",
· Token2: '{',
· Token3: '}',
}
Example (Tag)
fmt.Println(exampleAST(136, "\U00100001 enum a ("))
Output:

&cc.EnumSpecifier{
· Token: ENUM "enum",
· Token2: 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 EnumSpecifierCase

type EnumSpecifierCase int

EnumSpecifierCase represents case numbers of production EnumSpecifier

const (
	EnumSpecifierTag EnumSpecifierCase = iota
	EnumSpecifierDefine
)

Values of type EnumSpecifierCase

func (EnumSpecifierCase) String

func (n EnumSpecifierCase) String() string

String implements fmt.Stringer

type EnumType

type EnumType struct {
	Tag   int
	Enums []*EnumerationConstant
	Min   int64
	Max   uint64
	// contains filtered or unexported fields
}

EnumType represents an enum type.

func (*EnumType) Equal

func (t *EnumType) Equal(u Type) bool

Equal implements Type.

func (*EnumType) IsArithmeticType

func (t *EnumType) IsArithmeticType() bool

IsArithmeticType implements Type.

func (*EnumType) IsCompatible

func (t *EnumType) IsCompatible(u Type) bool

IsCompatible implements Type.

func (*EnumType) IsIntegerType

func (t *EnumType) IsIntegerType() bool

IsIntegerType implements Type.

func (*EnumType) IsPointerType

func (t *EnumType) IsPointerType() bool

IsPointerType implements Type.

func (*EnumType) IsScalarType

func (t *EnumType) IsScalarType() bool

IsScalarType implements Type.

func (*EnumType) IsUnsigned

func (t *EnumType) IsUnsigned() bool

IsUnsigned implements Type.

func (*EnumType) IsVoidPointerType

func (t *EnumType) IsVoidPointerType() bool

IsVoidPointerType implements Type.

func (*EnumType) Kind

func (t *EnumType) Kind() TypeKind

Kind implements Type.

func (*EnumType) Pos added in v1.0.1

func (t *EnumType) Pos() token.Pos

func (*EnumType) String

func (t *EnumType) String() string

type EnumerationConstant

type EnumerationConstant struct {
	Operand Operand
	Token   xc.Token
}

EnumerationConstant represents data reduced by production:

EnumerationConstant:
        IDENTIFIER  // Case 0
Example (Case0)
fmt.Println(exampleAST(3, "\U00100001 enum { a ,"))
Output:

&cc.EnumerationConstant{
· Token: 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                EnumeratorCase
	ConstExpr           *ConstExpr
	EnumerationConstant *EnumerationConstant
	Token               xc.Token
}

Enumerator represents data reduced by productions:

Enumerator:
        EnumerationConstant                // Case EnumeratorBase
|       EnumerationConstant '=' ConstExpr  // Case EnumeratorInit
Example (Base)
fmt.Println(exampleAST(140, "\U00100001 enum { a ,"))
Output:

&cc.Enumerator{
· EnumerationConstant: &cc.EnumerationConstant{
· · Token: IDENTIFIER "a",
· },
}
Example (Init)
fmt.Println(exampleAST(141, "\U00100001 enum { a = 'b' ,"))
Output:

&cc.Enumerator{
· Case: 1,
· ConstExpr: &cc.ConstExpr{
· · Expr: &cc.Expr{
· · · Case: ExprChar,
· · · Token: CHARCONST "'b'",
· · },
· },
· EnumerationConstant: &cc.EnumerationConstant{
· · Token: IDENTIFIER "a",
· },
· Token: '=',
}

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 EnumeratorCase

type EnumeratorCase int

EnumeratorCase represents case numbers of production Enumerator

const (
	EnumeratorBase EnumeratorCase = iota
	EnumeratorInit
)

Values of type EnumeratorCase

func (EnumeratorCase) String

func (n EnumeratorCase) 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                     // Case 0
|       EnumeratorList ',' Enumerator  // Case 1
Example (Case0)
fmt.Println(exampleAST(138, "\U00100001 enum { a ,"))
Output:

&cc.EnumeratorList{
· Enumerator: &cc.Enumerator{
· · EnumerationConstant: &cc.EnumerationConstant{
· · · Token: IDENTIFIER "a",
· · },
· },
}
Example (Case1)
fmt.Println(exampleAST(139, "\U00100001 enum { a , b ,"))
Output:

&cc.EnumeratorList{
· Enumerator: &cc.Enumerator{
· · EnumerationConstant: &cc.EnumerationConstant{
· · · Token: IDENTIFIER "a",
· · },
· },
· EnumeratorList: &cc.EnumeratorList{
· · Case: 1,
· · Enumerator: &cc.Enumerator{
· · · EnumerationConstant: &cc.EnumerationConstant{
· · · · Token: IDENTIFIER "b",
· · · },
· · },
· · Token: ',',
· },
}

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 Expr

type Expr struct {
	CallArgs   []Operand   // Promoted arguments of Call.
	Declarator *Declarator // Case Ident.
	Operand    Operand
	Scope      *Scope // Case Ident, CompLit.

	AssignedTo          bool // Expression appears at the left side of assignment.
	UseGotos            bool
	ArgumentExprListOpt *ArgumentExprListOpt
	Case                ExprCase
	CommaOpt            *CommaOpt
	CompoundStmt        *CompoundStmt
	Expr                *Expr
	Expr2               *Expr
	ExprList            *ExprList
	InitializerList     *InitializerList
	Token               xc.Token
	Token2              xc.Token
	Token3              xc.Token
	Token4              xc.Token
	TypeName            *TypeName
	// contains filtered or unexported fields
}

Expr represents data reduced by productions:

Expr:
        "++" Expr                                          // Case ExprPreInc
|       "--" Expr                                          // Case ExprPreDec
|       "_Alignof" '(' TypeName ')'                        // Case ExprAlignofType
|       "_Alignof" Expr                                    // Case ExprAlignofExpr
|       "sizeof" '(' TypeName ')'                          // Case ExprSizeofType
|       "sizeof" Expr                                      // Case ExprSizeofExpr
|       '!' Expr                                           // Case ExprNot
|       '&' Expr                                           // Case ExprAddrof
|       '(' CompoundStmt ')'                               // Case ExprStatement
|       '(' ExprList ')'                                   // Case ExprPExprList
|       '(' TypeName ')' '{' InitializerList CommaOpt '}'  // Case ExprCompLit
|       '(' TypeName ')' Expr                              // Case ExprCast
|       '*' Expr                                           // Case ExprDeref
|       '+' Expr                                           // Case ExprUnaryPlus
|       '-' Expr                                           // Case ExprUnaryMinus
|       '~' Expr                                           // Case ExprCpl
|       CHARCONST                                          // Case ExprChar
|       Expr "!=" Expr                                     // Case ExprNe
|       Expr "%=" Expr                                     // Case ExprModAssign
|       Expr "&&" Expr                                     // Case ExprLAnd
|       Expr "&=" Expr                                     // Case ExprAndAssign
|       Expr "*=" Expr                                     // Case ExprMulAssign
|       Expr "++"                                          // Case ExprPostInc
|       Expr "+=" Expr                                     // Case ExprAddAssign
|       Expr "--"                                          // Case ExprPostDec
|       Expr "-=" Expr                                     // Case ExprSubAssign
|       Expr "->" IDENTIFIER                               // Case ExprPSelect
|       Expr "/=" Expr                                     // Case ExprDivAssign
|       Expr "<<" Expr                                     // Case ExprLsh
|       Expr "<<=" Expr                                    // Case ExprLshAssign
|       Expr "<=" Expr                                     // Case ExprLe
|       Expr "==" Expr                                     // Case ExprEq
|       Expr ">=" Expr                                     // Case ExprGe
|       Expr ">>" Expr                                     // Case ExprRsh
|       Expr ">>=" Expr                                    // Case ExprRshAssign
|       Expr "^=" Expr                                     // Case ExprXorAssign
|       Expr "|=" Expr                                     // Case ExprOrAssign
|       Expr "||" Expr                                     // Case ExprLOr
|       Expr '%' Expr                                      // Case ExprMod
|       Expr '&' Expr                                      // Case ExprAnd
|       Expr '(' ArgumentExprListOpt ')'                   // Case ExprCall
|       Expr '*' Expr                                      // Case ExprMul
|       Expr '+' Expr                                      // Case ExprAdd
|       Expr '-' Expr                                      // Case ExprSub
|       Expr '.' IDENTIFIER                                // Case ExprSelect
|       Expr '/' Expr                                      // Case ExprDiv
|       Expr '<' Expr                                      // Case ExprLt
|       Expr '=' Expr                                      // Case ExprAssign
|       Expr '>' Expr                                      // Case ExprGt
|       Expr '?' ExprList ':' Expr                         // Case ExprCond
|       Expr '[' ExprList ']'                              // Case ExprIndex
|       Expr '^' Expr                                      // Case ExprXor
|       Expr '|' Expr                                      // Case ExprOr
|       FLOATCONST                                         // Case ExprFloat
|       IDENTIFIER                                         // Case ExprIdent
|       INTCONST                                           // Case ExprInt
|       LONGCHARCONST                                      // Case ExprLChar
|       LONGSTRINGLITERAL                                  // Case ExprLString
|       STRINGLITERAL                                      // Case ExprString
Example (Add)
fmt.Println(exampleAST(52, "\U00100000 'a' + 'b'"))
Output:

&cc.Expr{
· Case: ExprAdd,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Expr2: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'b'",
· },
· Token: '+',
}
Example (AddAssign)
fmt.Println(exampleAST(33, "\U00100000 'a' += 'b'"))
Output:

&cc.Expr{
· Case: ExprAddAssign,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Expr2: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'b'",
· },
· Token: ADDASSIGN,
}
Example (Addrof)
fmt.Println(exampleAST(17, "\U00100000 & 'a'"))
Output:

&cc.Expr{
· Case: ExprAddrof,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Token: '&',
}
Example (AlignofExpr)
fmt.Println(exampleAST(13, "\U00100000 _Alignof 'a'"))
Output:

&cc.Expr{
· Case: ExprAlignofExpr,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Token: ALIGNOF "_Alignof",
}
Example (AlignofType)
fmt.Println(exampleAST(12, "\U00100000 _Alignof ( _Atomic )"))
Output:

&cc.Expr{
· Case: ExprAlignofType,
· Token: ALIGNOF "_Alignof",
· Token2: '(',
· Token3: ')',
· TypeName: &cc.TypeName{
· · SpecifierQualifierList: &cc.SpecifierQualifierList{
· · · TypeQualifier: &cc.TypeQualifier{
· · · · Case: 3,
· · · · Token: ATOMIC "_Atomic",
· · · },
· · },
· },
}
Example (And)
fmt.Println(exampleAST(49, "\U00100000 'a' & 'b'"))
Output:

&cc.Expr{
· Case: ExprAnd,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Expr2: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'b'",
· },
· Token: '&',
}
Example (AndAssign)
fmt.Println(exampleAST(30, "\U00100000 'a' &= 'b'"))
Output:

&cc.Expr{
· Case: ExprAndAssign,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Expr2: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'b'",
· },
· Token: ANDASSIGN,
}
Example (Assign)
fmt.Println(exampleAST(57, "\U00100000 'a' = 'b'"))
Output:

&cc.Expr{
· Case: ExprAssign,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Expr2: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'b'",
· },
· Token: '=',
}
Example (Call)
fmt.Println(exampleAST(50, "\U00100000 'a' ( )"))
Output:

&cc.Expr{
· Case: ExprCall,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Token: '(',
· Token2: ')',
}
Example (Cast)
fmt.Println(exampleAST(21, "\U00100000 ( _Atomic ) 'a'"))
Output:

&cc.Expr{
· Case: ExprCast,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Token: '(',
· Token2: ')',
· TypeName: &cc.TypeName{
· · SpecifierQualifierList: &cc.SpecifierQualifierList{
· · · TypeQualifier: &cc.TypeQualifier{
· · · · Case: 3,
· · · · Token: ATOMIC "_Atomic",
· · · },
· · },
· },
}
Example (Char)
fmt.Println(exampleAST(26, "\U00100000 'a'"))
Output:

&cc.Expr{
· Case: ExprChar,
· Token: CHARCONST "'a'",
}
Example (CompLit)
fmt.Println(exampleAST(20, "\U00100000 ( _Atomic ) { }"))
Output:

&cc.Expr{
· Case: ExprCompLit,
· Token: '(',
· Token2: ')',
· Token3: '{',
· Token4: '}',
· TypeName: &cc.TypeName{
· · SpecifierQualifierList: &cc.SpecifierQualifierList{
· · · TypeQualifier: &cc.TypeQualifier{
· · · · Case: 3,
· · · · Token: ATOMIC "_Atomic",
· · · },
· · },
· },
}
Example (Cond)
fmt.Println(exampleAST(59, "\U00100000 'a' ? 'b' : 'c'"))
Output:

&cc.Expr{
· Case: ExprCond,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Expr2: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'c'",
· },
· ExprList: &cc.ExprList{
· · Expr: &cc.Expr{
· · · Case: ExprChar,
· · · Token: CHARCONST "'b'",
· · },
· },
· Token: '?',
· Token2: ':',
}
Example (Cpl)
fmt.Println(exampleAST(25, "\U00100000 ~ 'a'"))
Output:

&cc.Expr{
· Case: ExprCpl,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Token: '~',
}
Example (Deref)
fmt.Println(exampleAST(22, "\U00100000 * 'a'"))
Output:

&cc.Expr{
· Case: ExprDeref,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Token: '*',
}
Example (Div)
fmt.Println(exampleAST(55, "\U00100000 'a' / 'b'"))
Output:

&cc.Expr{
· Case: ExprDiv,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Expr2: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'b'",
· },
· Token: '/',
}
Example (DivAssign)
fmt.Println(exampleAST(37, "\U00100000 'a' /= 'b'"))
Output:

&cc.Expr{
· Case: ExprDivAssign,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Expr2: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'b'",
· },
· Token: DIVASSIGN,
}
Example (Eq)
fmt.Println(exampleAST(41, "\U00100000 'a' == 'b'"))
Output:

&cc.Expr{
· Case: ExprEq,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Expr2: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'b'",
· },
· Token: EQ,
}
Example (Float)
fmt.Println(exampleAST(63, "\U00100000 1.97"))
Output:

&cc.Expr{
· Case: ExprFloat,
· Token: FLOATCONST "1.97",
}
Example (Ge)
fmt.Println(exampleAST(42, "\U00100000 'a' >= 'b'"))
Output:

&cc.Expr{
· Case: ExprGe,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Expr2: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'b'",
· },
· Token: GEQ,
}
Example (Gt)
fmt.Println(exampleAST(58, "\U00100000 'a' > 'b'"))
Output:

&cc.Expr{
· Case: ExprGt,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Expr2: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'b'",
· },
· Token: '>',
}
Example (Ident)
fmt.Println(exampleAST(64, "\U00100001 a { b %"))
Output:

&cc.Expr{
· Scope: &cc.Scope{
· · Parent: &cc.Scope{
· · },
· },
· Case: ExprIdent,
· Token: IDENTIFIER "b",
}
Example (Index)
fmt.Println(exampleAST(60, "\U00100000 'a' [ 'b' ]"))
Output:

&cc.Expr{
· Case: ExprIndex,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· ExprList: &cc.ExprList{
· · Expr: &cc.Expr{
· · · Case: ExprChar,
· · · Token: CHARCONST "'b'",
· · },
· },
· Token: '[',
· Token2: ']',
}
Example (Int)
fmt.Println(exampleAST(65, "\U00100000 97"))
Output:

&cc.Expr{
· Case: ExprInt,
· Token: INTCONST "97",
}
Example (LAnd)
fmt.Println(exampleAST(29, "\U00100000 'a' && 'b'"))
Output:

&cc.Expr{
· Case: ExprLAnd,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Expr2: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'b'",
· },
· Token: ANDAND,
}
Example (LChar)
fmt.Println(exampleAST(66, "\U00100000 L'a'"))
Output:

&cc.Expr{
· Case: ExprLChar,
· Token: LONGCHARCONST "L'a'",
}
Example (LOr)
fmt.Println(exampleAST(47, "\U00100000 'a' || 'b'"))
Output:

&cc.Expr{
· Case: ExprLOr,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Expr2: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'b'",
· },
· Token: OROR,
}
Example (LString)
fmt.Println(exampleAST(67, "\U00100000 L\"a\""))
Output:

&cc.Expr{
· Case: ExprLString,
· Token: LONGSTRINGLITERAL "L\"a\"",
}
Example (Le)
fmt.Println(exampleAST(40, "\U00100000 'a' <= 'b'"))
Output:

&cc.Expr{
· Case: ExprLe,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Expr2: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'b'",
· },
· Token: LEQ,
}
Example (Lsh)
fmt.Println(exampleAST(38, "\U00100000 'a' << 'b'"))
Output:

&cc.Expr{
· Case: ExprLsh,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Expr2: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'b'",
· },
· Token: LSH,
}
Example (LshAssign)
fmt.Println(exampleAST(39, "\U00100000 'a' <<= 'b'"))
Output:

&cc.Expr{
· Case: ExprLshAssign,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Expr2: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'b'",
· },
· Token: LSHASSIGN,
}
Example (Lt)
fmt.Println(exampleAST(56, "\U00100000 'a' < 'b'"))
Output:

&cc.Expr{
· Case: ExprLt,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Expr2: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'b'",
· },
· Token: '<',
}
Example (Mod)
fmt.Println(exampleAST(48, "\U00100000 'a' % 'b'"))
Output:

&cc.Expr{
· Case: ExprMod,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Expr2: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'b'",
· },
· Token: '%',
}
Example (ModAssign)
fmt.Println(exampleAST(28, "\U00100000 'a' %= 'b'"))
Output:

&cc.Expr{
· Case: ExprModAssign,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Expr2: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'b'",
· },
· Token: MODASSIGN,
}
Example (Mul)
fmt.Println(exampleAST(51, "\U00100000 'a' * 'b'"))
Output:

&cc.Expr{
· Case: ExprMul,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Expr2: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'b'",
· },
· Token: '*',
}
Example (MulAssign)
fmt.Println(exampleAST(31, "\U00100000 'a' *= 'b'"))
Output:

&cc.Expr{
· Case: ExprMulAssign,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Expr2: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'b'",
· },
· Token: MULASSIGN,
}
Example (Ne)
fmt.Println(exampleAST(27, "\U00100000 'a' != 'b'"))
Output:

&cc.Expr{
· Case: ExprNe,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Expr2: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'b'",
· },
· Token: NEQ,
}
Example (Not)
fmt.Println(exampleAST(16, "\U00100000 ! 'a'"))
Output:

&cc.Expr{
· Case: ExprNot,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Token: '!',
}
Example (Or)
fmt.Println(exampleAST(62, "\U00100000 'a' | 'b'"))
Output:

&cc.Expr{
· Case: ExprOr,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Expr2: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'b'",
· },
· Token: '|',
}
Example (OrAssign)
fmt.Println(exampleAST(46, "\U00100000 'a' |= 'b'"))
Output:

&cc.Expr{
· Case: ExprOrAssign,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Expr2: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'b'",
· },
· Token: ORASSIGN,
}
Example (PExprList)
fmt.Println(exampleAST(19, "\U00100000 ( 'a' )"))
Output:

&cc.Expr{
· Case: ExprPExprList,
· ExprList: &cc.ExprList{
· · Expr: &cc.Expr{
· · · Case: ExprChar,
· · · Token: CHARCONST "'a'",
· · },
· },
· Token: '(',
· Token2: ')',
}
Example (PSelect)
fmt.Println(exampleAST(36, "\U00100000 'a' -> b"))
Output:

&cc.Expr{
· Case: ExprPSelect,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Token: ARROW,
· Token2: IDENTIFIER "b",
}
Example (PostDec)
fmt.Println(exampleAST(34, "\U00100000 'a' --"))
Output:

&cc.Expr{
· Case: ExprPostDec,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Token: DEC,
}
Example (PostInc)
fmt.Println(exampleAST(32, "\U00100000 'a' ++"))
Output:

&cc.Expr{
· Case: ExprPostInc,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Token: INC,
}
Example (PreDec)
fmt.Println(exampleAST(11, "\U00100000 -- 'a'"))
Output:

&cc.Expr{
· Case: ExprPreDec,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Token: DEC,
}
Example (PreInc)
fmt.Println(exampleAST(10, "\U00100000 ++ 'a'"))
Output:

&cc.Expr{
· Case: ExprPreInc,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Token: INC,
}
Example (Rsh)
fmt.Println(exampleAST(43, "\U00100000 'a' >> 'b'"))
Output:

&cc.Expr{
· Case: ExprRsh,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Expr2: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'b'",
· },
· Token: RSH,
}
Example (RshAssign)
fmt.Println(exampleAST(44, "\U00100000 'a' >>= 'b'"))
Output:

&cc.Expr{
· Case: ExprRshAssign,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Expr2: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'b'",
· },
· Token: RSHASSIGN,
}
Example (Select)
fmt.Println(exampleAST(54, "\U00100000 'a' . b"))
Output:

&cc.Expr{
· Case: ExprSelect,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Token: '.',
· Token2: IDENTIFIER "b",
}
Example (SizeofExpr)
fmt.Println(exampleAST(15, "\U00100000 sizeof 'a'"))
Output:

&cc.Expr{
· Case: ExprSizeofExpr,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Token: SIZEOF "sizeof",
}
Example (SizeofType)
fmt.Println(exampleAST(14, "\U00100000 sizeof ( _Atomic )"))
Output:

&cc.Expr{
· Case: ExprSizeofType,
· Token: SIZEOF "sizeof",
· Token2: '(',
· Token3: ')',
· TypeName: &cc.TypeName{
· · SpecifierQualifierList: &cc.SpecifierQualifierList{
· · · TypeQualifier: &cc.TypeQualifier{
· · · · Case: 3,
· · · · Token: ATOMIC "_Atomic",
· · · },
· · },
· },
}
Example (Statement)
fmt.Println(exampleAST(18, "\U00100000 ( { } )"))
Output:

&cc.Expr{
· Case: ExprStatement,
· CompoundStmt: &cc.CompoundStmt{
· · Token: '{',
· · Token2: '}',
· },
· Token: '(',
· Token2: ')',
}
Example (String)
fmt.Println(exampleAST(68, "\U00100000 \"a\""))
Output:

&cc.Expr{
· Case: ExprString,
· Token: STRINGLITERAL "\"a\"",
}
Example (Sub)
fmt.Println(exampleAST(53, "\U00100000 'a' - 'b'"))
Output:

&cc.Expr{
· Case: ExprSub,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Expr2: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'b'",
· },
· Token: '-',
}
Example (SubAssign)
fmt.Println(exampleAST(35, "\U00100000 'a' -= 'b'"))
Output:

&cc.Expr{
· Case: ExprSubAssign,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Expr2: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'b'",
· },
· Token: SUBASSIGN,
}
Example (UnaryMinus)
fmt.Println(exampleAST(24, "\U00100000 - 'a'"))
Output:

&cc.Expr{
· Case: ExprUnaryMinus,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Token: '-',
}
Example (UnaryPlus)
fmt.Println(exampleAST(23, "\U00100000 + 'a'"))
Output:

&cc.Expr{
· Case: ExprUnaryPlus,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Token: '+',
}
Example (Xor)
fmt.Println(exampleAST(61, "\U00100000 'a' ^ 'b'"))
Output:

&cc.Expr{
· Case: ExprXor,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Expr2: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'b'",
· },
· Token: '^',
}
Example (XorAssign)
fmt.Println(exampleAST(45, "\U00100000 'a' ^= 'b'"))
Output:

&cc.Expr{
· Case: ExprXorAssign,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Expr2: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'b'",
· },
· Token: XORASSIGN,
}

func (*Expr) DumpOperands

func (n *Expr) DumpOperands(s string)

DumpOperands dumps the operands of n to stdout.

func (*Expr) Equals

func (n *Expr) Equals(m *Expr) bool

Equals reports whether s equals m.

func (*Expr) IsNonZero

func (n *Expr) IsNonZero() bool

IsNonZero reports whether n is provably non zero.

func (*Expr) IsZero

func (n *Expr) IsZero() bool

IsZero reports whether n is provably zero.

func (*Expr) Pos

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

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

func (*Expr) String

func (n *Expr) String() string

String implements fmt.Stringer.

type ExprCase

type ExprCase int

ExprCase represents case numbers of production Expr

const (
	ExprPreInc ExprCase = iota
	ExprPreDec
	ExprAlignofType
	ExprAlignofExpr
	ExprSizeofType
	ExprSizeofExpr
	ExprNot
	ExprAddrof
	ExprStatement
	ExprPExprList
	ExprCompLit
	ExprCast
	ExprDeref
	ExprUnaryPlus
	ExprUnaryMinus
	ExprCpl
	ExprChar
	ExprNe
	ExprModAssign
	ExprLAnd
	ExprAndAssign
	ExprMulAssign
	ExprPostInc
	ExprAddAssign
	ExprPostDec
	ExprSubAssign
	ExprPSelect
	ExprDivAssign
	ExprLsh
	ExprLshAssign
	ExprLe
	ExprEq
	ExprGe
	ExprRsh
	ExprRshAssign
	ExprXorAssign
	ExprOrAssign
	ExprLOr
	ExprMod
	ExprAnd
	ExprCall
	ExprMul
	ExprAdd
	ExprSub
	ExprSelect
	ExprDiv
	ExprLt
	ExprAssign
	ExprGt
	ExprCond
	ExprIndex
	ExprXor
	ExprOr
	ExprFloat
	ExprIdent
	ExprInt
	ExprLChar
	ExprLString
	ExprString
)

Values of type ExprCase

func (ExprCase) String

func (n ExprCase) String() string

String implements fmt.Stringer

type ExprList

type ExprList struct {
	Operand  Operand
	Case     int
	Expr     *Expr
	ExprList *ExprList
	Token    xc.Token
}

ExprList represents data reduced by productions:

ExprList:
        Expr               // Case 0
|       ExprList ',' Expr  // Case 1
Example (Case0)
fmt.Println(exampleAST(71, "\U00100000 ( 'a' )"))
Output:

&cc.ExprList{
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
}
Example (Case1)
fmt.Println(exampleAST(72, "\U00100000 ( 'a' , 'b' )"))
Output:

&cc.ExprList{
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· ExprList: &cc.ExprList{
· · Case: 1,
· · Expr: &cc.Expr{
· · · Case: ExprChar,
· · · Token: CHARCONST "'b'",
· · },
· · Token: ',',
· },
}

func (*ExprList) DumpOperands

func (n *ExprList) DumpOperands(s string)

DumpOperands dumps the operands of n to stdout.

func (*ExprList) IsNonZero

func (n *ExprList) IsNonZero() bool

IsNonZero reports whether n is provably non zero.

func (*ExprList) IsZero

func (n *ExprList) IsZero() bool

IsZero reports whether n is provably zero.

func (*ExprList) Pos

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

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

func (*ExprList) String

func (n *ExprList) String() string

String implements fmt.Stringer.

type ExprListOpt

type ExprListOpt struct {
	ExprList *ExprList
}

ExprListOpt represents data reduced by productions:

ExprListOpt:
        /* empty */  // Case 0
|       ExprList     // Case 1
Example (Case0)
fmt.Println(exampleAST(73, "\U00100001 a { ;") == (*ExprListOpt)(nil))
Output:

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

&cc.ExprListOpt{
· ExprList: &cc.ExprList{
· · Expr: &cc.Expr{
· · · Case: ExprChar,
· · · Token: CHARCONST "'b'",
· · },
· },
}

func (*ExprListOpt) Pos

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

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

func (*ExprListOpt) String

func (n *ExprListOpt) String() string

String implements fmt.Stringer.

type ExprOpt

type ExprOpt struct {
	Expr *Expr
}

ExprOpt represents data reduced by productions:

ExprOpt:
        /* empty */  // Case 0
|       Expr         // Case 1
Example (Case0)
fmt.Println(exampleAST(69, "\U00100000 ( _Atomic [ ]") == (*ExprOpt)(nil))
Output:

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

&cc.ExprOpt{
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'b'",
· },
}

func (*ExprOpt) Pos

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

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

func (*ExprOpt) String

func (n *ExprOpt) String() string

String implements fmt.Stringer.

type ExprStmt

type ExprStmt struct {
	UseGotos    bool
	ExprListOpt *ExprListOpt
	Token       xc.Token
	// contains filtered or unexported fields
}

ExprStmt represents data reduced by production:

ExprStmt:
        ExprListOpt statementEnd ';'  // Case 0
Example (Case0)
fmt.Println(exampleAST(231, "\U00100001 a { ; !"))
Output:

&cc.ExprStmt{
· Token: ';',
}

func (*ExprStmt) Pos

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

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

func (*ExprStmt) String

func (n *ExprStmt) String() string

String implements fmt.Stringer.

type ExternalDeclaration

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

ExternalDeclaration represents data reduced by productions:

ExternalDeclaration:
        Declaration         // Case ExternalDeclarationDecl
|       FunctionDefinition  // Case ExternalDeclarationFunc
Example (Decl)
fmt.Println(exampleAST(245, "\U00100001 _Atomic ;"))
Output:

&cc.ExternalDeclaration{
· Declaration: &cc.Declaration{
· · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · Case: 2,
· · · TypeQualifier: &cc.TypeQualifier{
· · · · Case: 3,
· · · · Token: ATOMIC "_Atomic",
· · · },
· · },
· · Token: ';',
· },
}
Example (Func)
fmt.Println(exampleAST(246, "\U00100001 a { }"))
Output:

&cc.ExternalDeclaration{
· Case: 1,
· FunctionDefinition: &cc.FunctionDefinition{
· · Case: 1,
· · Declarator: &cc.Declarator{
· · · FunctionDefinition: &cc.FunctionDefinition{ /* recursive/repetitive pointee not shown */ },
· · · Linkage: LinkageNone,
· · · Scope: &cc.Scope{
· · · },
· · · StorageDuration: StorageDurationAutomatic,
· · · DirectDeclarator: &cc.DirectDeclarator{
· · · · Case: DirectDeclaratorIdent,
· · · · Token: IDENTIFIER "a",
· · · },
· · },
· · FunctionBody: &cc.FunctionBody{
· · · CompoundStmt: &cc.CompoundStmt{
· · · · BlockItemListOpt: &cc.BlockItemListOpt{
· · · · · BlockItemList: &cc.BlockItemList{
· · · · · · BlockItem: &cc.BlockItem{
· · · · · · · Declaration: &cc.Declaration{
· · · · · · · · Scope: &cc.Scope{
· · · · · · · · · Parent: &cc.Scope{ /* recursive/repetitive pointee not shown */ },
· · · · · · · · },
· · · · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · · · · · Case: 1,
· · · · · · · · · DeclarationSpecifiersOpt: &cc.DeclarationSpecifiersOpt{
· · · · · · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · · · · · · · Case: 2,
· · · · · · · · · · · DeclarationSpecifiersOpt: &cc.DeclarationSpecifiersOpt{
· · · · · · · · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · · · · · · · · · Case: 3,
· · · · · · · · · · · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · · · · · · · · · · Case: 3,
· · · · · · · · · · · · · · Token: CHAR "char",
· · · · · · · · · · · · · },
· · · · · · · · · · · · },
· · · · · · · · · · · },
· · · · · · · · · · · TypeQualifier: &cc.TypeQualifier{
· · · · · · · · · · · · Token: CONST "const",
· · · · · · · · · · · },
· · · · · · · · · · },
· · · · · · · · · },
· · · · · · · · · StorageClassSpecifier: &cc.StorageClassSpecifier{
· · · · · · · · · · Case: 3,
· · · · · · · · · · Token: STATIC "static",
· · · · · · · · · },
· · · · · · · · },
· · · · · · · · InitDeclaratorListOpt: &cc.InitDeclaratorListOpt{
· · · · · · · · · InitDeclaratorList: &cc.InitDeclaratorList{
· · · · · · · · · · InitDeclarator: &cc.InitDeclarator{
· · · · · · · · · · · Case: 1,
· · · · · · · · · · · Declarator: &cc.Declarator{
· · · · · · · · · · · · Linkage: LinkageNone,
· · · · · · · · · · · · Scope: &cc.Scope{ /* recursive/repetitive pointee not shown */ },
· · · · · · · · · · · · StorageDuration: StorageDurationAutomatic,
· · · · · · · · · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · · · · · · · · Case: DirectDeclaratorArray,
· · · · · · · · · · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · · · · · · · · · Case: DirectDeclaratorIdent,
· · · · · · · · · · · · · · Token: IDENTIFIER "__func__",
· · · · · · · · · · · · · },
· · · · · · · · · · · · · Token: '[',
· · · · · · · · · · · · · Token2: ']',
· · · · · · · · · · · · },
· · · · · · · · · · · },
· · · · · · · · · · · Initializer: &cc.Initializer{
· · · · · · · · · · · · Case: 1,
· · · · · · · · · · · · Expr: &cc.Expr{
· · · · · · · · · · · · · Case: ExprString,
· · · · · · · · · · · · · Token: STRINGLITERAL "\"a\"",
· · · · · · · · · · · · },
· · · · · · · · · · · },
· · · · · · · · · · · Token: '=',
· · · · · · · · · · },
· · · · · · · · · },
· · · · · · · · },
· · · · · · · · Token: ';',
· · · · · · · },
· · · · · · },
· · · · · },
· · · · },
· · · · Token: '{',
· · · · Token2: '}',
· · · },
· · },
· },
}

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 ExternalDeclarationCase

type ExternalDeclarationCase int

ExternalDeclarationCase represents case numbers of production ExternalDeclaration

const (
	ExternalDeclarationDecl ExternalDeclarationCase = iota
	ExternalDeclarationFunc
)

Values of type ExternalDeclarationCase

func (ExternalDeclarationCase) String

func (n ExternalDeclarationCase) String() string

String implements fmt.Stringer

type ExternalDeclarationList

type ExternalDeclarationList struct {
	Case                    int
	ExternalDeclaration     *ExternalDeclaration
	ExternalDeclarationList *ExternalDeclarationList
}

ExternalDeclarationList represents data reduced by productions:

ExternalDeclarationList:
        ExternalDeclaration                          // Case 0
|       ExternalDeclarationList ExternalDeclaration  // Case 1
Example (Case0)
fmt.Println(exampleAST(243, "\U00100001 _Atomic ;"))
Output:

&cc.ExternalDeclarationList{
· ExternalDeclaration: &cc.ExternalDeclaration{
· · Declaration: &cc.Declaration{
· · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · Case: 2,
· · · · TypeQualifier: &cc.TypeQualifier{
· · · · · Case: 3,
· · · · · Token: ATOMIC "_Atomic",
· · · · },
· · · },
· · · Token: ';',
· · },
· },
}
Example (Case1)
fmt.Println(exampleAST(244, "\U00100001 _Atomic ; _Atomic ;"))
Output:

&cc.ExternalDeclarationList{
· ExternalDeclaration: &cc.ExternalDeclaration{
· · Declaration: &cc.Declaration{
· · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · Case: 2,
· · · · TypeQualifier: &cc.TypeQualifier{
· · · · · Case: 3,
· · · · · Token: ATOMIC "_Atomic",
· · · · },
· · · },
· · · Token: ';',
· · },
· },
· ExternalDeclarationList: &cc.ExternalDeclarationList{
· · Case: 1,
· · ExternalDeclaration: &cc.ExternalDeclaration{
· · · Declaration: &cc.Declaration{
· · · · Scope: &cc.Scope{ /* recursive/repetitive pointee not shown */ },
· · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · Case: 2,
· · · · · TypeQualifier: &cc.TypeQualifier{
· · · · · · Case: 3,
· · · · · · Token: ATOMIC "_Atomic",
· · · · · },
· · · · },
· · · · Token: ';',
· · · },
· · },
· },
}

func (*ExternalDeclarationList) Pos

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

func (*ExternalDeclarationList) String

func (n *ExternalDeclarationList) String() string

String implements fmt.Stringer.

type Field

type Field struct {
	Bits       int
	Declarator *Declarator
	Name       int
	PackedType Type // Bits != 0: underlaying struct field type
	Type       Type

	Anonymous       bool
	IsFlexibleArray bool
}

Field represents a struct/union field.

func (Field) String

func (f Field) String() string

type FieldProperties

type FieldProperties struct {
	Bitoff     int // Zero based bit number of a bitfield
	Bits       int // Width of a bit field or zero otherwise.
	Declarator *Declarator
	Offset     int64 // Byte offset relative to start of the struct/union.
	PackedType Type  // Bits != 0: Storage type holding the bit field.
	Padding    int   // Adjustment to enforce proper alignment.
	Size       int64 // Field size for copying.
	Type       Type

	Anonymous       bool
	IsFlexibleArray bool
}

FieldProperties describe a struct/union field.

func (*FieldProperties) Mask

func (f *FieldProperties) Mask() uint64

Mask returns the bit mask of bit field described by f.

type FileSource

type FileSource struct {
	*bufio.Reader
	// contains filtered or unexported fields
}

FileSource is a Source reading from a named file.

func MustFileSource

func MustFileSource(nm string) *FileSource

MustFileSource is like NewFileSource but panics on error.

func MustFileSource2

func MustFileSource2(nm string, cacheable bool) *FileSource

MustFileSource2 is like NewFileSource but panics on error.

func NewFileSource

func NewFileSource(name string) (*FileSource, error)

NewFileSource returns a newly created *FileSource reading from name.

func NewFileSource2

func NewFileSource2(name string, cacheable bool) (*FileSource, error)

NewFileSource2 returns a newly created *FileSource reading from name.

func (*FileSource) Cache

func (s *FileSource) Cache(a []uint32)

Cache implements Source.

func (*FileSource) Cached

func (s *FileSource) Cached() (r []uint32)

Cached implements Source.

func (*FileSource) Close

func (s *FileSource) Close() error

Close implements io.ReadCloser.

func (*FileSource) Name

func (s *FileSource) Name() string

Name implements Source.

func (*FileSource) ReadCloser

func (s *FileSource) ReadCloser() (io.ReadCloser, error)

ReadCloser implements Source.

func (*FileSource) Size

func (s *FileSource) Size() (int64, error)

Size implements Source.

func (*FileSource) String

func (s *FileSource) String() string

type FunctionBody

type FunctionBody struct {
	CompoundStmt *CompoundStmt
}

FunctionBody represents data reduced by production:

FunctionBody:
        CompoundStmt  // Case 0
Example (Case0)
fmt.Println(exampleAST(252, "\U00100001 a { }"))
Output:

&cc.FunctionBody{
· CompoundStmt: &cc.CompoundStmt{
· · BlockItemListOpt: &cc.BlockItemListOpt{
· · · BlockItemList: &cc.BlockItemList{
· · · · BlockItem: &cc.BlockItem{
· · · · · Declaration: &cc.Declaration{
· · · · · · Scope: &cc.Scope{
· · · · · · · Parent: &cc.Scope{
· · · · · · · },
· · · · · · },
· · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · · · Case: 1,
· · · · · · · DeclarationSpecifiersOpt: &cc.DeclarationSpecifiersOpt{
· · · · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · · · · · Case: 2,
· · · · · · · · · DeclarationSpecifiersOpt: &cc.DeclarationSpecifiersOpt{
· · · · · · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · · · · · · · Case: 3,
· · · · · · · · · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · · · · · · · · Case: 3,
· · · · · · · · · · · · Token: CHAR "char",
· · · · · · · · · · · },
· · · · · · · · · · },
· · · · · · · · · },
· · · · · · · · · TypeQualifier: &cc.TypeQualifier{
· · · · · · · · · · Token: CONST "const",
· · · · · · · · · },
· · · · · · · · },
· · · · · · · },
· · · · · · · StorageClassSpecifier: &cc.StorageClassSpecifier{
· · · · · · · · Case: 3,
· · · · · · · · Token: STATIC "static",
· · · · · · · },
· · · · · · },
· · · · · · InitDeclaratorListOpt: &cc.InitDeclaratorListOpt{
· · · · · · · InitDeclaratorList: &cc.InitDeclaratorList{
· · · · · · · · InitDeclarator: &cc.InitDeclarator{
· · · · · · · · · Case: 1,
· · · · · · · · · Declarator: &cc.Declarator{
· · · · · · · · · · Linkage: LinkageNone,
· · · · · · · · · · Scope: &cc.Scope{ /* recursive/repetitive pointee not shown */ },
· · · · · · · · · · StorageDuration: StorageDurationAutomatic,
· · · · · · · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · · · · · · Case: DirectDeclaratorArray,
· · · · · · · · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · · · · · · · Case: DirectDeclaratorIdent,
· · · · · · · · · · · · Token: IDENTIFIER "__func__",
· · · · · · · · · · · },
· · · · · · · · · · · Token: '[',
· · · · · · · · · · · Token2: ']',
· · · · · · · · · · },
· · · · · · · · · },
· · · · · · · · · Initializer: &cc.Initializer{
· · · · · · · · · · Case: 1,
· · · · · · · · · · Expr: &cc.Expr{
· · · · · · · · · · · Case: ExprString,
· · · · · · · · · · · Token: STRINGLITERAL "\"a\"",
· · · · · · · · · · },
· · · · · · · · · },
· · · · · · · · · Token: '=',
· · · · · · · · },
· · · · · · · },
· · · · · · },
· · · · · · Token: ';',
· · · · · },
· · · · },
· · · },
· · },
· · Token: '{',
· · Token2: '}',
· },
}

func (*FunctionBody) Pos

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

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

func (*FunctionBody) String

func (n *FunctionBody) String() string

String implements fmt.Stringer.

type FunctionDefinition

type FunctionDefinition struct {
	Case                  FunctionDefinitionCase
	DeclarationListOpt    *DeclarationListOpt
	DeclarationSpecifiers *DeclarationSpecifiers
	Declarator            *Declarator
	FunctionBody          *FunctionBody
}

FunctionDefinition represents data reduced by productions:

FunctionDefinition:
        DeclarationSpecifiers Declarator DeclarationListOpt FunctionBody  // Case FunctionDefinitionSpec
|       Declarator DeclarationListOpt FunctionBody                        // Case FunctionDefinitionInt
Example (Int)
fmt.Println(exampleAST(250, "\U00100001 a { }"))
Output:

&cc.FunctionDefinition{
· Case: 1,
· Declarator: &cc.Declarator{
· · FunctionDefinition: &cc.FunctionDefinition{ /* recursive/repetitive pointee not shown */ },
· · Linkage: LinkageNone,
· · Scope: &cc.Scope{
· · },
· · StorageDuration: StorageDurationAutomatic,
· · DirectDeclarator: &cc.DirectDeclarator{
· · · Case: DirectDeclaratorIdent,
· · · Token: IDENTIFIER "a",
· · },
· },
· FunctionBody: &cc.FunctionBody{
· · CompoundStmt: &cc.CompoundStmt{
· · · BlockItemListOpt: &cc.BlockItemListOpt{
· · · · BlockItemList: &cc.BlockItemList{
· · · · · BlockItem: &cc.BlockItem{
· · · · · · Declaration: &cc.Declaration{
· · · · · · · Scope: &cc.Scope{
· · · · · · · · Parent: &cc.Scope{ /* recursive/repetitive pointee not shown */ },
· · · · · · · },
· · · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · · · · Case: 1,
· · · · · · · · DeclarationSpecifiersOpt: &cc.DeclarationSpecifiersOpt{
· · · · · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · · · · · · Case: 2,
· · · · · · · · · · DeclarationSpecifiersOpt: &cc.DeclarationSpecifiersOpt{
· · · · · · · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · · · · · · · · Case: 3,
· · · · · · · · · · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · · · · · · · · · Case: 3,
· · · · · · · · · · · · · Token: CHAR "char",
· · · · · · · · · · · · },
· · · · · · · · · · · },
· · · · · · · · · · },
· · · · · · · · · · TypeQualifier: &cc.TypeQualifier{
· · · · · · · · · · · Token: CONST "const",
· · · · · · · · · · },
· · · · · · · · · },
· · · · · · · · },
· · · · · · · · StorageClassSpecifier: &cc.StorageClassSpecifier{
· · · · · · · · · Case: 3,
· · · · · · · · · Token: STATIC "static",
· · · · · · · · },
· · · · · · · },
· · · · · · · InitDeclaratorListOpt: &cc.InitDeclaratorListOpt{
· · · · · · · · InitDeclaratorList: &cc.InitDeclaratorList{
· · · · · · · · · InitDeclarator: &cc.InitDeclarator{
· · · · · · · · · · Case: 1,
· · · · · · · · · · Declarator: &cc.Declarator{
· · · · · · · · · · · Linkage: LinkageNone,
· · · · · · · · · · · Scope: &cc.Scope{ /* recursive/repetitive pointee not shown */ },
· · · · · · · · · · · StorageDuration: StorageDurationAutomatic,
· · · · · · · · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · · · · · · · Case: DirectDeclaratorArray,
· · · · · · · · · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · · · · · · · · Case: DirectDeclaratorIdent,
· · · · · · · · · · · · · Token: IDENTIFIER "__func__",
· · · · · · · · · · · · },
· · · · · · · · · · · · Token: '[',
· · · · · · · · · · · · Token2: ']',
· · · · · · · · · · · },
· · · · · · · · · · },
· · · · · · · · · · Initializer: &cc.Initializer{
· · · · · · · · · · · Case: 1,
· · · · · · · · · · · Expr: &cc.Expr{
· · · · · · · · · · · · Case: ExprString,
· · · · · · · · · · · · Token: STRINGLITERAL "\"a\"",
· · · · · · · · · · · },
· · · · · · · · · · },
· · · · · · · · · · Token: '=',
· · · · · · · · · },
· · · · · · · · },
· · · · · · · },
· · · · · · · Token: ';',
· · · · · · },
· · · · · },
· · · · },
· · · },
· · · Token: '{',
· · · Token2: '}',
· · },
· },
}
Example (Spec)
fmt.Println(exampleAST(248, "\U00100001 _Atomic a { }"))
Output:

&cc.FunctionDefinition{
· DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · Case: 2,
· · TypeQualifier: &cc.TypeQualifier{
· · · Case: 3,
· · · Token: ATOMIC "_Atomic",
· · },
· },
· Declarator: &cc.Declarator{
· · FunctionDefinition: &cc.FunctionDefinition{ /* recursive/repetitive pointee not shown */ },
· · Linkage: LinkageNone,
· · Scope: &cc.Scope{
· · },
· · StorageDuration: StorageDurationAutomatic,
· · DirectDeclarator: &cc.DirectDeclarator{
· · · Case: DirectDeclaratorIdent,
· · · Token: IDENTIFIER "a",
· · },
· },
· FunctionBody: &cc.FunctionBody{
· · CompoundStmt: &cc.CompoundStmt{
· · · BlockItemListOpt: &cc.BlockItemListOpt{
· · · · BlockItemList: &cc.BlockItemList{
· · · · · BlockItem: &cc.BlockItem{
· · · · · · Declaration: &cc.Declaration{
· · · · · · · Scope: &cc.Scope{
· · · · · · · · Parent: &cc.Scope{ /* recursive/repetitive pointee not shown */ },
· · · · · · · },
· · · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · · · · Case: 1,
· · · · · · · · DeclarationSpecifiersOpt: &cc.DeclarationSpecifiersOpt{
· · · · · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · · · · · · Case: 2,
· · · · · · · · · · DeclarationSpecifiersOpt: &cc.DeclarationSpecifiersOpt{
· · · · · · · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · · · · · · · · Case: 3,
· · · · · · · · · · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · · · · · · · · · Case: 3,
· · · · · · · · · · · · · Token: CHAR "char",
· · · · · · · · · · · · },
· · · · · · · · · · · },
· · · · · · · · · · },
· · · · · · · · · · TypeQualifier: &cc.TypeQualifier{
· · · · · · · · · · · Token: CONST "const",
· · · · · · · · · · },
· · · · · · · · · },
· · · · · · · · },
· · · · · · · · StorageClassSpecifier: &cc.StorageClassSpecifier{
· · · · · · · · · Case: 3,
· · · · · · · · · Token: STATIC "static",
· · · · · · · · },
· · · · · · · },
· · · · · · · InitDeclaratorListOpt: &cc.InitDeclaratorListOpt{
· · · · · · · · InitDeclaratorList: &cc.InitDeclaratorList{
· · · · · · · · · InitDeclarator: &cc.InitDeclarator{
· · · · · · · · · · Case: 1,
· · · · · · · · · · Declarator: &cc.Declarator{
· · · · · · · · · · · Linkage: LinkageNone,
· · · · · · · · · · · Scope: &cc.Scope{ /* recursive/repetitive pointee not shown */ },
· · · · · · · · · · · StorageDuration: StorageDurationAutomatic,
· · · · · · · · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · · · · · · · Case: DirectDeclaratorArray,
· · · · · · · · · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · · · · · · · · Case: DirectDeclaratorIdent,
· · · · · · · · · · · · · Token: IDENTIFIER "__func__",
· · · · · · · · · · · · },
· · · · · · · · · · · · Token: '[',
· · · · · · · · · · · · Token2: ']',
· · · · · · · · · · · },
· · · · · · · · · · },
· · · · · · · · · · Initializer: &cc.Initializer{
· · · · · · · · · · · Case: 1,
· · · · · · · · · · · Expr: &cc.Expr{
· · · · · · · · · · · · Case: ExprString,
· · · · · · · · · · · · Token: STRINGLITERAL "\"a\"",
· · · · · · · · · · · },
· · · · · · · · · · },
· · · · · · · · · · Token: '=',
· · · · · · · · · },
· · · · · · · · },
· · · · · · · },
· · · · · · · Token: ';',
· · · · · · },
· · · · · },
· · · · },
· · · },
· · · Token: '{',
· · · Token2: '}',
· · },
· },
}

func (*FunctionDefinition) LocalVariables

func (n *FunctionDefinition) LocalVariables() []*Declarator

LocalVariables returns all local variables declared in a function in the order of appearance. The result does not include function parameters.

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 FunctionDefinitionCase

type FunctionDefinitionCase int

FunctionDefinitionCase represents case numbers of production FunctionDefinition

const (
	FunctionDefinitionSpec FunctionDefinitionCase = iota
	FunctionDefinitionInt
)

Values of type FunctionDefinitionCase

func (FunctionDefinitionCase) String

func (n FunctionDefinitionCase) String() string

String implements fmt.Stringer

type FunctionSpecifier

type FunctionSpecifier struct {
	Case  FunctionSpecifierCase
	Token xc.Token
}

FunctionSpecifier represents data reduced by productions:

FunctionSpecifier:
        "inline"     // Case FunctionSpecifierInline
|       "_Noreturn"  // Case FunctionSpecifierNoreturn
Example (Inline)
fmt.Println(exampleAST(146, "\U00100001 inline ("))
Output:

&cc.FunctionSpecifier{
· Token: INLINE "inline",
}
Example (Noreturn)
fmt.Println(exampleAST(147, "\U00100001 _Noreturn ("))
Output:

&cc.FunctionSpecifier{
· Case: 1,
· Token: NORETURN "_Noreturn",
}

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 FunctionSpecifierCase added in v1.0.1

type FunctionSpecifierCase int

FunctionSpecifierCase represents case numbers of production FunctionSpecifier

const (
	FunctionSpecifierInline FunctionSpecifierCase = iota
	FunctionSpecifierNoreturn
)

Values of type FunctionSpecifierCase

func (FunctionSpecifierCase) String added in v1.0.1

func (n FunctionSpecifierCase) String() string

String implements fmt.Stringer

type FunctionType

type FunctionType struct {
	Params   []Type
	Result   Type
	Variadic bool
	// contains filtered or unexported fields
}

FunctionType represents a function type.

func (*FunctionType) Equal

func (t *FunctionType) Equal(u Type) bool

Equal implements Type.

func (*FunctionType) IsArithmeticType

func (t *FunctionType) IsArithmeticType() bool

IsArithmeticType implements Type.

func (*FunctionType) IsCompatible

func (t *FunctionType) IsCompatible(u Type) bool

IsCompatible implements Type.

func (*FunctionType) IsIntegerType

func (t *FunctionType) IsIntegerType() bool

IsIntegerType implements Type.

func (*FunctionType) IsPointerType

func (t *FunctionType) IsPointerType() bool

IsPointerType implements Type.

func (*FunctionType) IsScalarType

func (t *FunctionType) IsScalarType() bool

IsScalarType implements Type.

func (*FunctionType) IsUnsigned

func (t *FunctionType) IsUnsigned() bool

IsUnsigned implements Type.

func (*FunctionType) IsVoidPointerType

func (t *FunctionType) IsVoidPointerType() bool

IsVoidPointerType implements Type.

func (*FunctionType) Kind

func (t *FunctionType) Kind() TypeKind

Kind implements Type.

func (*FunctionType) Pos added in v1.0.1

func (t *FunctionType) Pos() token.Pos

func (*FunctionType) String

func (t *FunctionType) String() string

type IdentifierList

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

IdentifierList represents data reduced by productions:

IdentifierList:
        IDENTIFIER                     // Case 0
|       IdentifierList ',' IDENTIFIER  // Case 1
Example (Case0)
fmt.Println(exampleAST(178, "\U00100001 a ( b )"))
Output:

&cc.IdentifierList{
· Token: IDENTIFIER "b",
}
Example (Case1)
fmt.Println(exampleAST(179, "\U00100001 a ( b , c )"))
Output:

&cc.IdentifierList{
· IdentifierList: &cc.IdentifierList{
· · Case: 1,
· · Token: ',',
· · Token2: IDENTIFIER "c",
· },
· Token: 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
}

IdentifierListOpt represents data reduced by productions:

IdentifierListOpt:
        /* empty */     // Case 0
|       IdentifierList  // Case 1
Example (Case0)
fmt.Println(exampleAST(180, "\U00100001 a ( )") == (*IdentifierListOpt)(nil))
Output:

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

&cc.IdentifierListOpt{
· IdentifierList: &cc.IdentifierList{
· · Token: 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 */  // Case 0
|       IDENTIFIER   // Case 1
Example (Case0)
fmt.Println(exampleAST(182, "\U00100001 struct {") == (*IdentifierOpt)(nil))
Output:

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

&cc.IdentifierOpt{
· Token: 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 InitDeclarator

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

InitDeclarator represents data reduced by productions:

InitDeclarator:
        Declarator                  // Case InitDeclaratorBase
|       Declarator '=' Initializer  // Case InitDeclaratorInit
Example (Base)
fmt.Println(exampleAST(89, "\U00100001 a _Atomic b ,"))
Output:

&cc.InitDeclarator{
· Declarator: &cc.Declarator{
· · Linkage: LinkageNone,
· · Scope: &cc.Scope{
· · },
· · StorageDuration: StorageDurationAutomatic,
· · DirectDeclarator: &cc.DirectDeclarator{
· · · Case: DirectDeclaratorIdent,
· · · Token: IDENTIFIER "b",
· · },
· },
}
Example (Init)
fmt.Println(exampleAST(90, "\U00100001 _Atomic a = 'b' ,"))
Output:

&cc.InitDeclarator{
· Case: 1,
· Declarator: &cc.Declarator{
· · Linkage: LinkageNone,
· · Scope: &cc.Scope{
· · },
· · StorageDuration: StorageDurationAutomatic,
· · DirectDeclarator: &cc.DirectDeclarator{
· · · Case: DirectDeclaratorIdent,
· · · Token: IDENTIFIER "a",
· · },
· },
· Initializer: &cc.Initializer{
· · Case: 1,
· · Expr: &cc.Expr{
· · · Case: ExprChar,
· · · Token: CHARCONST "'b'",
· · },
· },
· Token: '=',
}

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 InitDeclaratorCase

type InitDeclaratorCase int

InitDeclaratorCase represents case numbers of production InitDeclarator

const (
	InitDeclaratorBase InitDeclaratorCase = iota
	InitDeclaratorInit
)

Values of type InitDeclaratorCase

func (InitDeclaratorCase) String

func (n InitDeclaratorCase) 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                         // Case 0
|       InitDeclaratorList ',' InitDeclarator  // Case 1
Example (Case0)
fmt.Println(exampleAST(85, "\U00100001 _Atomic a ,"))
Output:

&cc.InitDeclaratorList{
· InitDeclarator: &cc.InitDeclarator{
· · Declarator: &cc.Declarator{
· · · Linkage: LinkageNone,
· · · Scope: &cc.Scope{
· · · },
· · · StorageDuration: StorageDurationAutomatic,
· · · DirectDeclarator: &cc.DirectDeclarator{
· · · · Case: DirectDeclaratorIdent,
· · · · Token: IDENTIFIER "a",
· · · },
· · },
· },
}
Example (Case1)
fmt.Println(exampleAST(86, "\U00100001 _Atomic a , b ,"))
Output:

&cc.InitDeclaratorList{
· InitDeclarator: &cc.InitDeclarator{
· · Declarator: &cc.Declarator{
· · · Linkage: LinkageNone,
· · · Scope: &cc.Scope{
· · · },
· · · StorageDuration: StorageDurationAutomatic,
· · · DirectDeclarator: &cc.DirectDeclarator{
· · · · Case: DirectDeclaratorIdent,
· · · · Token: IDENTIFIER "a",
· · · },
· · },
· },
· InitDeclaratorList: &cc.InitDeclaratorList{
· · Case: 1,
· · InitDeclarator: &cc.InitDeclarator{
· · · Declarator: &cc.Declarator{
· · · · Linkage: LinkageNone,
· · · · Scope: &cc.Scope{ /* recursive/repetitive pointee not shown */ },
· · · · StorageDuration: StorageDurationAutomatic,
· · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · Case: DirectDeclaratorIdent,
· · · · · Token: IDENTIFIER "b",
· · · · },
· · · },
· · },
· · Token: ',',
· },
}

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 */         // Case 0
|       InitDeclaratorList  // Case 1
Example (Case0)
fmt.Println(exampleAST(87, "\U00100001 _Atomic ;") == (*InitDeclaratorListOpt)(nil))
Output:

true
Example (Case1)
fmt.Println(exampleAST(88, "\U00100001 _Atomic a ;"))
Output:

&cc.InitDeclaratorListOpt{
· InitDeclaratorList: &cc.InitDeclaratorList{
· · InitDeclarator: &cc.InitDeclarator{
· · · Declarator: &cc.Declarator{
· · · · Linkage: LinkageNone,
· · · · Scope: &cc.Scope{
· · · · },
· · · · StorageDuration: StorageDurationAutomatic,
· · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · Case: DirectDeclaratorIdent,
· · · · · Token: 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            InitializerCase
	CommaOpt        *CommaOpt
	Expr            *Expr
	InitializerList *InitializerList
	Token           xc.Token
	Token2          xc.Token
}

Initializer represents data reduced by productions:

Initializer:
        '{' InitializerList CommaOpt '}'  // Case InitializerCompLit
|       Expr                              // Case InitializerExpr
Example (CompLit)
fmt.Println(exampleAST(199, "\U00100001 _Atomic a = { } ,"))
Output:

&cc.Initializer{
· Token: '{',
· Token2: '}',
}
Example (Expr)
fmt.Println(exampleAST(200, "\U00100001 _Atomic a = 'b' ,"))
Output:

&cc.Initializer{
· Case: 1,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'b'",
· },
}

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 InitializerCase

type InitializerCase int

InitializerCase represents case numbers of production Initializer

const (
	InitializerCompLit InitializerCase = iota
	InitializerExpr
)

Values of type InitializerCase

func (InitializerCase) String

func (n InitializerCase) String() string

String implements fmt.Stringer

type InitializerList

type InitializerList struct {
	Operand         Operand //TODO-
	Len             int
	Case            int
	Designation     *Designation
	Initializer     *Initializer
	InitializerList *InitializerList
	Token           xc.Token
}

InitializerList represents data reduced by productions:

InitializerList:
        /* empty */                                  // Case 0
|       Initializer                                  // Case 1
|       Designation Initializer                      // Case 2
|       InitializerList ',' Initializer              // Case 3
|       InitializerList ',' Designation Initializer  // Case 4
Example (Case0)
fmt.Println(exampleAST(201, "\U00100000 ( _Atomic ) { ,") == (*InitializerList)(nil))
Output:

true
Example (Case1)
fmt.Println(exampleAST(202, "\U00100001 _Atomic a = { 'b' ,"))
Output:

&cc.InitializerList{
· Case: 1,
· Initializer: &cc.Initializer{
· · Case: 1,
· · Expr: &cc.Expr{
· · · Case: ExprChar,
· · · Token: CHARCONST "'b'",
· · },
· },
}
Example (Case2)
fmt.Println(exampleAST(203, "\U00100001 _Atomic a = { . b = 'c' ,"))
Output:

&cc.InitializerList{
· Case: 2,
· Designation: &cc.Designation{
· · DesignatorList: &cc.DesignatorList{
· · · Designator: &cc.Designator{
· · · · Token: '.',
· · · · Token2: IDENTIFIER "b",
· · · },
· · },
· · Token: '=',
· },
· Initializer: &cc.Initializer{
· · Case: 1,
· · Expr: &cc.Expr{
· · · Case: ExprChar,
· · · Token: CHARCONST "'c'",
· · },
· },
}
Example (Case3)
fmt.Println(exampleAST(204, "\U00100000 ( _Atomic ) { , 'a' ,"))
Output:

&cc.InitializerList{
· Case: 3,
· Initializer: &cc.Initializer{
· · Case: 1,
· · Expr: &cc.Expr{
· · · Case: ExprChar,
· · · Token: CHARCONST "'a'",
· · },
· },
· Token: ',',
}
Example (Case4)
fmt.Println(exampleAST(205, "\U00100000 ( _Atomic ) { , . a = 'b' ,"))
Output:

&cc.InitializerList{
· Case: 4,
· Designation: &cc.Designation{
· · DesignatorList: &cc.DesignatorList{
· · · Designator: &cc.Designator{
· · · · Token: '.',
· · · · Token2: IDENTIFIER "a",
· · · },
· · },
· · Token: '=',
· },
· Initializer: &cc.Initializer{
· · Case: 1,
· · Expr: &cc.Expr{
· · · Case: ExprChar,
· · · Token: CHARCONST "'b'",
· · },
· },
· Token: ',',
}

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 IterationStmt

type IterationStmt struct {
	UseGotos     bool
	Case         IterationStmtCase
	Declaration  *Declaration
	ExprList     *ExprList
	ExprListOpt  *ExprListOpt
	ExprListOpt2 *ExprListOpt
	ExprListOpt3 *ExprListOpt
	Stmt         *Stmt
	Token        xc.Token
	Token2       xc.Token
	Token3       xc.Token
	Token4       xc.Token
	Token5       xc.Token
	// contains filtered or unexported fields
}

IterationStmt represents data reduced by productions:

IterationStmt:
        "do" Stmt "while" '(' ExprList ')' statementEnd ';'             // Case IterationStmtDo
|       "for" '(' Declaration ExprListOpt ';' ExprListOpt ')' Stmt      // Case IterationStmtForDecl
|       "for" '(' ExprListOpt ';' ExprListOpt ';' ExprListOpt ')' Stmt  // Case IterationStmtFor
|       "while" '(' ExprList ')' Stmt                                   // Case IterationStmtWhile
Example (Do)
fmt.Println(exampleAST(235, "\U00100001 a { do ; while ( 'b' ) ; !"))
Output:

&cc.IterationStmt{
· ExprList: &cc.ExprList{
· · Expr: &cc.Expr{
· · · Case: ExprChar,
· · · Token: CHARCONST "'b'",
· · },
· },
· Stmt: &cc.Stmt{
· · Case: 1,
· · ExprStmt: &cc.ExprStmt{
· · · Token: ';',
· · },
· },
· Token: DO "do",
· Token2: WHILE "while",
· Token3: '(',
· Token4: ')',
· Token5: ';',
}
Example (For)
fmt.Println(exampleAST(237, "\U00100001 a { for ( ; ; ) ; !"))
Output:

&cc.IterationStmt{
· Case: 2,
· Stmt: &cc.Stmt{
· · Case: 1,
· · ExprStmt: &cc.ExprStmt{
· · · Token: ';',
· · },
· },
· Token: FOR "for",
· Token2: '(',
· Token3: ';',
· Token4: ';',
· Token5: ')',
}
Example (ForDecl)
fmt.Println(exampleAST(236, "\U00100001 a { for ( _Atomic ; ; ) ; !"))
Output:

&cc.IterationStmt{
· Case: 1,
· Declaration: &cc.Declaration{
· · Scope: &cc.Scope{
· · · Parent: &cc.Scope{
· · · · Parent: &cc.Scope{
· · · · },
· · · },
· · },
· · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · Case: 2,
· · · TypeQualifier: &cc.TypeQualifier{
· · · · Case: 3,
· · · · Token: ATOMIC "_Atomic",
· · · },
· · },
· · Token: ';',
· },
· Stmt: &cc.Stmt{
· · Case: 1,
· · ExprStmt: &cc.ExprStmt{
· · · Token: ';',
· · },
· },
· Token: FOR "for",
· Token2: '(',
· Token3: ';',
· Token4: ')',
}
Example (While)
fmt.Println(exampleAST(238, "\U00100001 a { while ( 'b' ) ; !"))
Output:

&cc.IterationStmt{
· Case: 3,
· ExprList: &cc.ExprList{
· · Expr: &cc.Expr{
· · · Case: ExprChar,
· · · Token: CHARCONST "'b'",
· · },
· },
· Stmt: &cc.Stmt{
· · Case: 1,
· · ExprStmt: &cc.ExprStmt{
· · · Token: ';',
· · },
· },
· Token: WHILE "while",
· Token2: '(',
· Token3: ')',
}

func (*IterationStmt) Pos

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

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

func (*IterationStmt) String

func (n *IterationStmt) String() string

String implements fmt.Stringer.

type IterationStmtCase

type IterationStmtCase int

IterationStmtCase represents case numbers of production IterationStmt

const (
	IterationStmtDo IterationStmtCase = iota
	IterationStmtForDecl
	IterationStmtFor
	IterationStmtWhile
)

Values of type IterationStmtCase

func (IterationStmtCase) String

func (n IterationStmtCase) String() string

String implements fmt.Stringer

type JumpStmt

type JumpStmt struct {
	ReturnOperand Operand

	UseGotos    bool
	Case        JumpStmtCase
	ExprListOpt *ExprListOpt
	Token       xc.Token
	Token2      xc.Token
	Token3      xc.Token
	// contains filtered or unexported fields
}

JumpStmt represents data reduced by productions:

JumpStmt:
        "break" statementEnd ';'               // Case JumpStmtBreak
|       "continue" statementEnd ';'            // Case JumpStmtContinue
|       "goto" IDENTIFIER statementEnd ';'     // Case JumpStmtGoto
|       "return" ExprListOpt statementEnd ';'  // Case JumpStmtReturn
Example (Break)
fmt.Println(exampleAST(239, "\U00100001 a { break ; !"))
Output:

&cc.JumpStmt{
· Token: BREAK "break",
· Token2: ';',
}
Example (Continue)
fmt.Println(exampleAST(240, "\U00100001 a { continue ; !"))
Output:

&cc.JumpStmt{
· Case: 1,
· Token: CONTINUE "continue",
· Token2: ';',
}
Example (Goto)
fmt.Println(exampleAST(241, "\U00100001 a { goto b ; !"))
Output:

&cc.JumpStmt{
· Case: 2,
· Token: GOTO "goto",
· Token2: IDENTIFIER "b",
· Token3: ';',
}
Example (Return)
fmt.Println(exampleAST(242, "\U00100001 a { return ; !"))
Output:

&cc.JumpStmt{
· Case: 3,
· Token: RETURN "return",
· Token2: ';',
}

func (*JumpStmt) Pos

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

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

func (*JumpStmt) String

func (n *JumpStmt) String() string

String implements fmt.Stringer.

type JumpStmtCase

type JumpStmtCase int

JumpStmtCase represents case numbers of production JumpStmt

const (
	JumpStmtBreak JumpStmtCase = iota
	JumpStmtContinue
	JumpStmtGoto
	JumpStmtReturn
)

Values of type JumpStmtCase

func (JumpStmtCase) String

func (n JumpStmtCase) String() string

String implements fmt.Stringer

type LabeledStmt

type LabeledStmt struct {
	UseGotos  bool
	Case      LabeledStmtCase
	ConstExpr *ConstExpr
	Stmt      *Stmt
	Token     xc.Token
	Token2    xc.Token
}

LabeledStmt represents data reduced by productions:

LabeledStmt:
        "case" ConstExpr ':' Stmt  // Case LabeledStmtSwitchCase
|       "default" ':' Stmt         // Case LabeledStmtDefault
|       IDENTIFIER ':' Stmt        // Case LabeledStmtLabel
|       TYPEDEF_NAME ':' Stmt      // Case LabeledStmtLabel2
Example (Default)
fmt.Println(exampleAST(218, "\U00100001 a { default : ; !"))
Output:

&cc.LabeledStmt{
· Case: 1,
· Stmt: &cc.Stmt{
· · Case: 1,
· · ExprStmt: &cc.ExprStmt{
· · · Token: ';',
· · },
· },
· Token: DEFAULT "default",
· Token2: ':',
}
Example (Label)
fmt.Println(exampleAST(219, "\U00100001 a { b : ; !"))
Output:

&cc.LabeledStmt{
· Case: 2,
· Stmt: &cc.Stmt{
· · Case: 1,
· · ExprStmt: &cc.ExprStmt{
· · · Token: ';',
· · },
· },
· Token: IDENTIFIER "b",
· Token2: ':',
}
Example (Label2)
fmt.Println(exampleAST(220, "\U00100001 a { typedef name : ; !"))
Output:

TODO: example220.c:1:19: unexpected ':', expected one of [',', ';', '=']
Example (SwitchCase)
fmt.Println(exampleAST(217, "\U00100001 a { case 'b' : ; !"))
Output:

&cc.LabeledStmt{
· ConstExpr: &cc.ConstExpr{
· · Expr: &cc.Expr{
· · · Case: ExprChar,
· · · Token: CHARCONST "'b'",
· · },
· },
· Stmt: &cc.Stmt{
· · Case: 1,
· · ExprStmt: &cc.ExprStmt{
· · · Token: ';',
· · },
· },
· Token: CASE "case",
· Token2: ':',
}

func (*LabeledStmt) Pos

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

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

func (*LabeledStmt) String

func (n *LabeledStmt) String() string

String implements fmt.Stringer.

type LabeledStmtCase

type LabeledStmtCase int

LabeledStmtCase represents case numbers of production LabeledStmt

const (
	LabeledStmtSwitchCase LabeledStmtCase = iota
	LabeledStmtDefault
	LabeledStmtLabel
	LabeledStmtLabel2
)

Values of type LabeledStmtCase

func (LabeledStmtCase) String

func (n LabeledStmtCase) String() string

String implements fmt.Stringer

type Linkage

type Linkage int

Linkage describes linkage of identifiers, [0]6.2.2.

const (
	LinkageNone     Linkage = iota
	LinkageInternal Linkage = Linkage(ir.InternalLinkage)
	LinkageExternal Linkage = Linkage(ir.ExternalLinkage)
)

Values of Linkage

func (Linkage) String

func (i Linkage) String() string

type Macro

type Macro struct {
	Args            []int      // Numeric IDs of argument identifiers.
	DefTok          xc.Token   // Macro name definition token.
	ReplacementToks []xc.Token // The tokens that replace the macro. R/O

	IsFnLike   bool // Whether the macro is function like.
	IsVariadic bool // Whether the macro is variadic.
	// contains filtered or unexported fields
}

Macro represents a preprocessor Macro.

func (*Macro) Eval

func (m *Macro) Eval(model Model, macros map[int]*Macro) (op Operand, err error)

Eval attempts to evaluate m, which must be a simple macro, like `#define foo numeric-literal`.

type Model

type Model map[TypeKind]ModelItem

Model describes properties of scalar Types.

func NewModel

func NewModel() (m Model, err error)

NewModel returns the model appropriate for the current OS and architecture or according to the environment variables GOOS and GOARCH, if set.

func (Model) Alignof

func (m Model) Alignof(t Type) int

Alignof computes the memory alignment requirements of t. One is returned for a struct/union type with no fields.

func (Model) Equal

func (m Model) Equal(n Model) bool

Equal returns whether m equals n.

func (Model) Layout

func (m Model) Layout(t Type) (r []FieldProperties)

Layout computes the memory layout of t.

func (Model) Sizeof

func (m Model) Sizeof(t Type) int64

Sizeof returns the size in bytes of a variable of type t.

func (Model) StructAlignof

func (m Model) StructAlignof(t Type) int

StructAlignof computes the memory alignment requirements of t when its instance is a struct field. One is returned for a struct/union type with no fields.

type ModelItem

type ModelItem struct {
	Size        int
	Align       int
	StructAlign int
}

ModelItem describers properties of a particular Type.

type NamedType

type NamedType struct {
	Name int
	Type Type // The type Name refers to.
	// contains filtered or unexported fields
}

NamedType represents a type described by a typedef name.

func (*NamedType) Equal

func (t *NamedType) Equal(u Type) bool

Equal implements Type.

func (*NamedType) IsArithmeticType

func (t *NamedType) IsArithmeticType() bool

IsArithmeticType implements Type.

func (*NamedType) IsCompatible

func (t *NamedType) IsCompatible(u Type) (r bool)

IsCompatible implements Type.

func (*NamedType) IsIntegerType

func (t *NamedType) IsIntegerType() bool

IsIntegerType implements Type.

func (*NamedType) IsPointerType

func (t *NamedType) IsPointerType() bool

IsPointerType implements Type.

func (*NamedType) IsScalarType

func (t *NamedType) IsScalarType() bool

IsScalarType implements Type.

func (*NamedType) IsUnsigned

func (t *NamedType) IsUnsigned() bool

IsUnsigned implements Type.

func (*NamedType) IsVoidPointerType

func (t *NamedType) IsVoidPointerType() bool

IsVoidPointerType implements Type.

func (*NamedType) Kind

func (t *NamedType) Kind() TypeKind

Kind implements Type.

func (*NamedType) Pos added in v1.0.1

func (t *NamedType) Pos() token.Pos

func (*NamedType) String

func (t *NamedType) String() string

type Node

type Node interface {
	Pos() token.Pos
}

Node represents an AST node.

type Operand

type Operand struct {
	Type Type
	ir.Value
	FieldProperties *FieldProperties

	IsEnumConst bool // Blocks int -> unsigned int promotions. See [0]6.4.4.3/2
}

Operand represents the type and optionally the value of an expression.

func (*Operand) Bits

func (o *Operand) Bits() int

Bits return the width of a bit field operand or zero othewise

func (Operand) ConvertTo

func (o Operand) ConvertTo(m Model, t Type) (r Operand)

ConvertTo converts o to type t.

func (Operand) IsNonZero

func (o Operand) IsNonZero() bool

IsNonZero returns true when the value of o is known to be non-zero.

func (Operand) IsZero

func (o Operand) IsZero() bool

IsZero returns true when the value of o is known to be zero.

func (Operand) String

func (o Operand) String() string

type ParameterDeclaration

type ParameterDeclaration struct {
	AbstractDeclaratorOpt *AbstractDeclaratorOpt
	Case                  ParameterDeclarationCase
	DeclarationSpecifiers *DeclarationSpecifiers
	Declarator            *Declarator
}

ParameterDeclaration represents data reduced by productions:

ParameterDeclaration:
        DeclarationSpecifiers AbstractDeclaratorOpt  // Case ParameterDeclarationAbstract
|       DeclarationSpecifiers Declarator             // Case ParameterDeclarationDeclarator
Example (Abstract)
fmt.Println(exampleAST(176, "\U00100001 a ( _Atomic )"))
Output:

&cc.ParameterDeclaration{
· DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · Case: 2,
· · TypeQualifier: &cc.TypeQualifier{
· · · Case: 3,
· · · Token: ATOMIC "_Atomic",
· · },
· },
}
Example (Declarator)
fmt.Println(exampleAST(177, "\U00100001 a ( _Atomic b )"))
Output:

&cc.ParameterDeclaration{
· Case: 1,
· DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · Case: 2,
· · TypeQualifier: &cc.TypeQualifier{
· · · Case: 3,
· · · Token: ATOMIC "_Atomic",
· · },
· },
· Declarator: &cc.Declarator{
· · Linkage: LinkageNone,
· · Scope: &cc.Scope{
· · },
· · StorageDuration: StorageDurationAutomatic,
· · DirectDeclarator: &cc.DirectDeclarator{
· · · Case: DirectDeclaratorIdent,
· · · Token: IDENTIFIER "b",
· · },
· },
}

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 ParameterDeclarationCase

type ParameterDeclarationCase int

ParameterDeclarationCase represents case numbers of production ParameterDeclaration

const (
	ParameterDeclarationAbstract ParameterDeclarationCase = iota
	ParameterDeclarationDeclarator
)

Values of type ParameterDeclarationCase

func (ParameterDeclarationCase) String

func (n ParameterDeclarationCase) 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                    // Case 0
|       ParameterList ',' ParameterDeclaration  // Case 1
Example (Case0)
fmt.Println(exampleAST(174, "\U00100001 a ( _Atomic )"))
Output:

&cc.ParameterList{
· ParameterDeclaration: &cc.ParameterDeclaration{
· · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · Case: 2,
· · · TypeQualifier: &cc.TypeQualifier{
· · · · Case: 3,
· · · · Token: ATOMIC "_Atomic",
· · · },
· · },
· },
}
Example (Case1)
fmt.Println(exampleAST(175, "\U00100001 a ( _Atomic , _Atomic )"))
Output:

&cc.ParameterList{
· ParameterDeclaration: &cc.ParameterDeclaration{
· · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · Case: 2,
· · · TypeQualifier: &cc.TypeQualifier{
· · · · Case: 3,
· · · · Token: ATOMIC "_Atomic",
· · · },
· · },
· },
· ParameterList: &cc.ParameterList{
· · Case: 1,
· · ParameterDeclaration: &cc.ParameterDeclaration{
· · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · Case: 2,
· · · · TypeQualifier: &cc.TypeQualifier{
· · · · · Case: 3,
· · · · · Token: ATOMIC "_Atomic",
· · · · },
· · · },
· · },
· · Token: ',',
· },
}

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          ParameterTypeListCase
	ParameterList *ParameterList
	Token         xc.Token
	Token2        xc.Token
}

ParameterTypeList represents data reduced by productions:

ParameterTypeList:
        ParameterList            // Case ParameterTypeListBase
|       ParameterList ',' "..."  // Case ParameterTypeListDots
Example (Base)
fmt.Println(exampleAST(170, "\U00100001 a ( _Atomic )"))
Output:

&cc.ParameterTypeList{
· ParameterList: &cc.ParameterList{
· · ParameterDeclaration: &cc.ParameterDeclaration{
· · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · Case: 2,
· · · · TypeQualifier: &cc.TypeQualifier{
· · · · · Case: 3,
· · · · · Token: ATOMIC "_Atomic",
· · · · },
· · · },
· · },
· },
}
Example (Dots)
fmt.Println(exampleAST(171, "\U00100001 a ( _Atomic , ... )"))
Output:

&cc.ParameterTypeList{
· Case: 1,
· ParameterList: &cc.ParameterList{
· · ParameterDeclaration: &cc.ParameterDeclaration{
· · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · Case: 2,
· · · · TypeQualifier: &cc.TypeQualifier{
· · · · · Case: 3,
· · · · · Token: ATOMIC "_Atomic",
· · · · },
· · · },
· · },
· },
· Token: ',',
· Token2: 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 ParameterTypeListCase

type ParameterTypeListCase int

ParameterTypeListCase represents case numbers of production ParameterTypeList

const (
	ParameterTypeListBase ParameterTypeListCase = iota
	ParameterTypeListDots
)

Values of type ParameterTypeListCase

func (ParameterTypeListCase) String

func (n ParameterTypeListCase) String() string

String implements fmt.Stringer

type ParameterTypeListOpt

type ParameterTypeListOpt struct {
	ParameterTypeList *ParameterTypeList
}

ParameterTypeListOpt represents data reduced by productions:

ParameterTypeListOpt:
        /* empty */        // Case 0
|       ParameterTypeList  // Case 1
Example (Case0)
fmt.Println(exampleAST(172, "\U00100000 ( _Atomic ( )") == (*ParameterTypeListOpt)(nil))
Output:

true
Example (Case1)
fmt.Println(exampleAST(173, "\U00100000 ( _Atomic ( _Atomic )"))
Output:

&cc.ParameterTypeListOpt{
· ParameterTypeList: &cc.ParameterTypeList{
· · ParameterList: &cc.ParameterList{
· · · ParameterDeclaration: &cc.ParameterDeclaration{
· · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · Case: 2,
· · · · · TypeQualifier: &cc.TypeQualifier{
· · · · · · Case: 3,
· · · · · · Token: ATOMIC "_Atomic",
· · · · · },
· · · · },
· · · },
· · },
· },
}

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 Parameters added in v1.0.1

type Parameters struct {
	Case              ParametersCase
	IdentifierListOpt *IdentifierListOpt
	ParameterTypeList *ParameterTypeList
}

Parameters represents data reduced by productions:

Parameters:
        IdentifierListOpt  // Case ParametersIdentList
|       ParameterTypeList  // Case ParametersParamTypes
Example (IdentList)
fmt.Println(exampleAST(149, "\U00100001 a ( )"))
Output:

Example (ParamTypes)
fmt.Println(exampleAST(150, "\U00100001 a ( _Atomic )"))
Output:

&cc.Parameters{
· Case: 1,
· ParameterTypeList: &cc.ParameterTypeList{
· · ParameterList: &cc.ParameterList{
· · · ParameterDeclaration: &cc.ParameterDeclaration{
· · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · Case: 2,
· · · · · TypeQualifier: &cc.TypeQualifier{
· · · · · · Case: 3,
· · · · · · Token: ATOMIC "_Atomic",
· · · · · },
· · · · },
· · · },
· · },
· },
}

func (*Parameters) Pos added in v1.0.1

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

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

func (*Parameters) String added in v1.0.1

func (n *Parameters) String() string

String implements fmt.Stringer.

type ParametersCase added in v1.0.1

type ParametersCase int

ParametersCase represents case numbers of production Parameters

const (
	ParametersIdentList ParametersCase = iota
	ParametersParamTypes
)

Values of type ParametersCase

func (ParametersCase) String added in v1.0.1

func (n ParametersCase) String() string

String implements fmt.Stringer

type Pointer

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

Pointer represents data reduced by productions:

Pointer:
        '*' TypeQualifierListOpt          // Case PointerBase
|       '*' TypeQualifierListOpt Pointer  // Case PointerPtr
Example (Base)
fmt.Println(exampleAST(162, "\U00100001 * ("))
Output:

&cc.Pointer{
· Token: '*',
}
Example (Ptr)
fmt.Println(exampleAST(163, "\U00100001 * * ("))
Output:

&cc.Pointer{
· Case: 1,
· Pointer: &cc.Pointer{
· · Token: '*',
· },
· Token: '*',
}

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 PointerCase

type PointerCase int

PointerCase represents case numbers of production Pointer

const (
	PointerBase PointerCase = iota
	PointerPtr
)

Values of type PointerCase

func (PointerCase) String

func (n PointerCase) String() string

String implements fmt.Stringer

type PointerOpt

type PointerOpt struct {
	Pointer *Pointer
}

PointerOpt represents data reduced by productions:

PointerOpt:
        /* empty */  // Case 0
|       Pointer      // Case 1
Example (Case0)
fmt.Println(exampleAST(164, "\U00100001 (") == (*PointerOpt)(nil))
Output:

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

&cc.PointerOpt{
· Pointer: &cc.Pointer{
· · Token: '*',
· },
}

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 PointerType

type PointerType struct {
	Item Type
	// contains filtered or unexported fields
}

PointerType represents a pointer type.

func (*PointerType) Equal

func (t *PointerType) Equal(u Type) bool

Equal implements Type.

func (*PointerType) IsArithmeticType

func (t *PointerType) IsArithmeticType() bool

IsArithmeticType implements Type.

func (*PointerType) IsCompatible

func (t *PointerType) IsCompatible(u Type) bool

IsCompatible implements Type.

func (*PointerType) IsIntegerType

func (t *PointerType) IsIntegerType() bool

IsIntegerType implements Type.

func (*PointerType) IsPointerType

func (t *PointerType) IsPointerType() bool

IsPointerType implements Type.

func (*PointerType) IsScalarType

func (t *PointerType) IsScalarType() bool

IsScalarType implements Type.

func (*PointerType) IsUnsigned

func (t *PointerType) IsUnsigned() bool

IsUnsigned implements Type.

func (*PointerType) IsVoidPointerType

func (t *PointerType) IsVoidPointerType() bool

IsVoidPointerType implements Type.

func (*PointerType) Kind

func (t *PointerType) Kind() TypeKind

Kind implements Type.

func (*PointerType) Pos added in v1.0.1

func (t *PointerType) Pos() token.Pos

func (*PointerType) String

func (t *PointerType) String() string

type Scope

type Scope struct {
	EnumTags   map[int]*EnumSpecifier // name ID: *EnumSpecifier
	Idents     map[int]Node           // name ID: Node in {*Declarator, EnumerationConstant}
	Labels     map[int]*LabeledStmt   // name ID: label
	Parent     *Scope
	StructTags map[int]*StructOrUnionSpecifier // name ID: *StructOrUnionSpecifier
	// contains filtered or unexported fields
}

Scope binds names to declarations.

func (*Scope) LookupIdent

func (s *Scope) LookupIdent(nm int) Node

LookupIdent will return the Node associated with name ID nm.

func (*Scope) LookupLabel

func (s *Scope) LookupLabel(nm int) Node

LookupLabel will return the Node associated with label ID nm.

func (*Scope) String

func (s *Scope) String() string

type SelectionStmt

type SelectionStmt struct {
	Cases    []*LabeledStmt
	SwitchOp Operand // Promoted switch operand
	UseGotos bool
	Case     SelectionStmtCase
	ExprList *ExprList
	Stmt     *Stmt
	Stmt2    *Stmt
	Token    xc.Token
	Token2   xc.Token
	Token3   xc.Token
	Token4   xc.Token
}

SelectionStmt represents data reduced by productions:

SelectionStmt:
        "if" '(' ExprList ')' Stmt "else" Stmt  // Case SelectionStmtIfElse
|       "if" '(' ExprList ')' Stmt              // Case SelectionStmtIf
|       "switch" '(' ExprList ')' Stmt          // Case SelectionStmtSwitch
Example (If)
fmt.Println(exampleAST(233, "\U00100001 a { if ( 'b' ) ; !"))
Output:

&cc.SelectionStmt{
· Case: 1,
· ExprList: &cc.ExprList{
· · Expr: &cc.Expr{
· · · Case: ExprChar,
· · · Token: CHARCONST "'b'",
· · },
· },
· Stmt: &cc.Stmt{
· · Case: 1,
· · ExprStmt: &cc.ExprStmt{
· · · Token: ';',
· · },
· },
· Token: IF "if",
· Token2: '(',
· Token3: ')',
}
Example (IfElse)
fmt.Println(exampleAST(232, "\U00100001 a { if ( 'b' ) ; else ; !"))
Output:

&cc.SelectionStmt{
· ExprList: &cc.ExprList{
· · Expr: &cc.Expr{
· · · Case: ExprChar,
· · · Token: CHARCONST "'b'",
· · },
· },
· Stmt: &cc.Stmt{
· · Case: 1,
· · ExprStmt: &cc.ExprStmt{
· · · Token: ';',
· · },
· },
· Stmt2: &cc.Stmt{
· · Case: 1,
· · ExprStmt: &cc.ExprStmt{
· · · Token: ';',
· · },
· },
· Token: IF "if",
· Token2: '(',
· Token3: ')',
· Token4: ELSE "else",
}
Example (Switch)
fmt.Println(exampleAST(234, "\U00100001 a { switch ( 'b' ) ; !"))
Output:

&cc.SelectionStmt{
· Case: 2,
· ExprList: &cc.ExprList{
· · Expr: &cc.Expr{
· · · Case: ExprChar,
· · · Token: CHARCONST "'b'",
· · },
· },
· Stmt: &cc.Stmt{
· · Case: 1,
· · ExprStmt: &cc.ExprStmt{
· · · Token: ';',
· · },
· },
· Token: SWITCH "switch",
· Token2: '(',
· Token3: ')',
}

func (*SelectionStmt) Pos

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

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

func (*SelectionStmt) String

func (n *SelectionStmt) String() string

String implements fmt.Stringer.

type SelectionStmtCase

type SelectionStmtCase int

SelectionStmtCase represents case numbers of production SelectionStmt

const (
	SelectionStmtIfElse SelectionStmtCase = iota
	SelectionStmtIf
	SelectionStmtSwitch
)

Values of type SelectionStmtCase

func (SelectionStmtCase) String

func (n SelectionStmtCase) String() string

String implements fmt.Stringer

type Source

type Source interface {
	Cache([]uint32)                     // Optionally cache the encoded source. Can be a no-operation.
	Cached() []uint32                   // Return nil or the optionally encoded source cached by earlier call to Cache.
	Name() string                       // Result will be used in reporting source code positions.
	ReadCloser() (io.ReadCloser, error) // Where to read the source from
	Size() (int64, error)               // Report the size of the source in bytes.
	String() string
}

Source represents parser's input.

func Builtin

func Builtin() (Source, error)

Builtin returns the Source for built-in and predefined stuff or an error, if any.

func Crt0

func Crt0() (Source, error)

Crt0 returns the Source for program initialization code.

func MustBuiltin

func MustBuiltin() Source

MustBuiltin is like Builtin but panics on error.

func MustCrt0

func MustCrt0() Source

MustCrt0 is like Crt0 but panics on error.

type SpecifierQualifierList

type SpecifierQualifierList struct {
	Case                      SpecifierQualifierListCase
	SpecifierQualifierListOpt *SpecifierQualifierListOpt
	TypeQualifier             *TypeQualifier
	TypeSpecifier             *TypeSpecifier
}

SpecifierQualifierList represents data reduced by productions:

SpecifierQualifierList:
        TypeQualifier SpecifierQualifierListOpt  // Case SpecifierQualifierListQualifier
|       TypeSpecifier SpecifierQualifierListOpt  // Case SpecifierQualifierListSpecifier
Example (Qualifier)
fmt.Println(exampleAST(126, "\U00100000 ( _Atomic ("))
Output:

&cc.SpecifierQualifierList{
· TypeQualifier: &cc.TypeQualifier{
· · Case: 3,
· · Token: ATOMIC "_Atomic",
· },
}
Example (Specifier)
fmt.Println(exampleAST(127, "\U00100000 ( _Bool ("))
Output:

&cc.SpecifierQualifierList{
· Case: 1,
· TypeSpecifier: &cc.TypeSpecifier{
· · Token: BOOL "_Bool",
· },
}

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.

type SpecifierQualifierListCase

type SpecifierQualifierListCase int

SpecifierQualifierListCase represents case numbers of production SpecifierQualifierList

const (
	SpecifierQualifierListQualifier SpecifierQualifierListCase = iota
	SpecifierQualifierListSpecifier
)

Values of type SpecifierQualifierListCase

func (SpecifierQualifierListCase) String

String implements fmt.Stringer

type SpecifierQualifierListOpt

type SpecifierQualifierListOpt struct {
	SpecifierQualifierList *SpecifierQualifierList
}

SpecifierQualifierListOpt represents data reduced by productions:

SpecifierQualifierListOpt:
        /* empty */             // Case 0
|       SpecifierQualifierList  // Case 1
Example (Case0)
fmt.Println(exampleAST(128, "\U00100000 ( _Atomic (") == (*SpecifierQualifierListOpt)(nil))
Output:

true
Example (Case1)
fmt.Println(exampleAST(129, "\U00100000 ( _Atomic _Atomic ("))
Output:

&cc.SpecifierQualifierListOpt{
· SpecifierQualifierList: &cc.SpecifierQualifierList{
· · TypeQualifier: &cc.TypeQualifier{
· · · Case: 3,
· · · Token: ATOMIC "_Atomic",
· · },
· },
}

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 Stmt

type Stmt struct {
	UseGotos      bool
	Case          StmtCase
	CompoundStmt  *CompoundStmt
	ExprStmt      *ExprStmt
	IterationStmt *IterationStmt
	JumpStmt      *JumpStmt
	LabeledStmt   *LabeledStmt
	SelectionStmt *SelectionStmt
}

Stmt represents data reduced by productions:

Stmt:
        CompoundStmt   // Case StmtBlock
|       ExprStmt       // Case StmtExpr
|       IterationStmt  // Case StmtIter
|       JumpStmt       // Case StmtJump
|       LabeledStmt    // Case StmtLabeled
|       SelectionStmt  // Case StmtSelect
Example (Block)
fmt.Println(exampleAST(211, "\U00100001 a { { } !"))
Output:

&cc.Stmt{
· CompoundStmt: &cc.CompoundStmt{
· · Token: '{',
· · Token2: '}',
· },
}
Example (Expr)
fmt.Println(exampleAST(212, "\U00100001 a { ; !"))
Output:

&cc.Stmt{
· Case: 1,
· ExprStmt: &cc.ExprStmt{
· · Token: ';',
· },
}
Example (Iter)
fmt.Println(exampleAST(213, "\U00100001 a { while ( 'b' ) ; !"))
Output:

&cc.Stmt{
· Case: 2,
· IterationStmt: &cc.IterationStmt{
· · Case: 3,
· · ExprList: &cc.ExprList{
· · · Expr: &cc.Expr{
· · · · Case: ExprChar,
· · · · Token: CHARCONST "'b'",
· · · },
· · },
· · Stmt: &cc.Stmt{
· · · Case: 1,
· · · ExprStmt: &cc.ExprStmt{
· · · · Token: ';',
· · · },
· · },
· · Token: WHILE "while",
· · Token2: '(',
· · Token3: ')',
· },
}
Example (Jump)
fmt.Println(exampleAST(214, "\U00100001 a { break ; !"))
Output:

&cc.Stmt{
· Case: 3,
· JumpStmt: &cc.JumpStmt{
· · Token: BREAK "break",
· · Token2: ';',
· },
}
Example (Labeled)
fmt.Println(exampleAST(215, "\U00100001 a { default : ; !"))
Output:

&cc.Stmt{
· Case: 4,
· LabeledStmt: &cc.LabeledStmt{
· · Case: 1,
· · Stmt: &cc.Stmt{
· · · Case: 1,
· · · ExprStmt: &cc.ExprStmt{
· · · · Token: ';',
· · · },
· · },
· · Token: DEFAULT "default",
· · Token2: ':',
· },
}
Example (Select)
fmt.Println(exampleAST(216, "\U00100001 a { if ( 'b' ) ; !"))
Output:

&cc.Stmt{
· Case: 5,
· SelectionStmt: &cc.SelectionStmt{
· · Case: 1,
· · ExprList: &cc.ExprList{
· · · Expr: &cc.Expr{
· · · · Case: ExprChar,
· · · · Token: CHARCONST "'b'",
· · · },
· · },
· · Stmt: &cc.Stmt{
· · · Case: 1,
· · · ExprStmt: &cc.ExprStmt{
· · · · Token: ';',
· · · },
· · },
· · Token: IF "if",
· · Token2: '(',
· · Token3: ')',
· },
}

func (*Stmt) Pos

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

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

func (*Stmt) String

func (n *Stmt) String() string

String implements fmt.Stringer.

type StmtCase

type StmtCase int

StmtCase represents case numbers of production Stmt

const (
	StmtBlock StmtCase = iota
	StmtExpr
	StmtIter
	StmtJump
	StmtLabeled
	StmtSelect
)

Values of type StmtCase

func (StmtCase) String

func (n StmtCase) String() string

String implements fmt.Stringer

type StorageClassSpecifier

type StorageClassSpecifier struct {
	Case  StorageClassSpecifierCase
	Token xc.Token
}

StorageClassSpecifier represents data reduced by productions:

StorageClassSpecifier:
        "auto"      // Case StorageClassSpecifierAuto
|       "extern"    // Case StorageClassSpecifierExtern
|       "register"  // Case StorageClassSpecifierRegister
|       "static"    // Case StorageClassSpecifierStatic
|       "typedef"   // Case StorageClassSpecifierTypedef
Example (Auto)
fmt.Println(exampleAST(91, "\U00100001 auto ("))
Output:

&cc.StorageClassSpecifier{
· Token: AUTO "auto",
}
Example (Extern)
fmt.Println(exampleAST(92, "\U00100001 extern ("))
Output:

&cc.StorageClassSpecifier{
· Case: 1,
· Token: EXTERN "extern",
}
Example (Register)
fmt.Println(exampleAST(93, "\U00100001 register ("))
Output:

&cc.StorageClassSpecifier{
· Case: 2,
· Token: REGISTER "register",
}
Example (Static)
fmt.Println(exampleAST(94, "\U00100001 static ("))
Output:

&cc.StorageClassSpecifier{
· Case: 3,
· Token: STATIC "static",
}
Example (Typedef)
fmt.Println(exampleAST(95, "\U00100001 typedef ("))
Output:

&cc.StorageClassSpecifier{
· Case: 4,
· Token: TYPEDEF "typedef",
}

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 StorageClassSpecifierCase

type StorageClassSpecifierCase int

StorageClassSpecifierCase represents case numbers of production StorageClassSpecifier

const (
	StorageClassSpecifierAuto StorageClassSpecifierCase = iota
	StorageClassSpecifierExtern
	StorageClassSpecifierRegister
	StorageClassSpecifierStatic
	StorageClassSpecifierTypedef
)

Values of type StorageClassSpecifierCase

func (StorageClassSpecifierCase) String

func (n StorageClassSpecifierCase) String() string

String implements fmt.Stringer

type StorageDuration

type StorageDuration int

StorageDuration describes lifetime of an object, [0]6.2.4.

const (
	StorageDurationAutomatic StorageDuration = iota
	StorageDurationStatic
)

Values of StorageDuration

func (StorageDuration) String

func (i StorageDuration) String() string

type StringSource

type StringSource struct {
	*strings.Reader
	// contains filtered or unexported fields
}

StringSource is a Source reading from a string.

func NewStringSource

func NewStringSource(name, src string) *StringSource

NewStringSource returns a newly created *StringSource reading from src and having the presumed name.

func (*StringSource) Cache

func (s *StringSource) Cache(a []uint32)

Cache implements Source.

func (*StringSource) Cached

func (s *StringSource) Cached() (r []uint32)

Cached implements Source.

func (*StringSource) Close

func (s *StringSource) Close() error

Close implements io.ReadCloser.

func (*StringSource) Name

func (s *StringSource) Name() string

Name implements Source.

func (*StringSource) ReadCloser

func (s *StringSource) ReadCloser() (io.ReadCloser, error)

ReadCloser implements Source.

func (*StringSource) Size

func (s *StringSource) Size() (int64, error)

Size implements Source.

func (*StringSource) String

func (s *StringSource) String() string

type StructDeclaration

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

StructDeclaration represents data reduced by productions:

StructDeclaration:
        SpecifierQualifierList StructDeclaratorList ';'  // Case StructDeclarationBase
|       SpecifierQualifierList ';'                       // Case StructDeclarationAnon
Example (Anon)
fmt.Println(exampleAST(125, "\U00100001 struct { _Atomic ; }"))
Output:

&cc.StructDeclaration{
· Case: 1,
· SpecifierQualifierList: &cc.SpecifierQualifierList{
· · TypeQualifier: &cc.TypeQualifier{
· · · Case: 3,
· · · Token: ATOMIC "_Atomic",
· · },
· },
· Token: ';',
}
Example (Base)
fmt.Println(exampleAST(124, "\U00100001 struct { _Atomic a ; }"))
Output:

&cc.StructDeclaration{
· SpecifierQualifierList: &cc.SpecifierQualifierList{
· · TypeQualifier: &cc.TypeQualifier{
· · · Case: 3,
· · · Token: ATOMIC "_Atomic",
· · },
· },
· StructDeclaratorList: &cc.StructDeclaratorList{
· · StructDeclarator: &cc.StructDeclarator{
· · · Declarator: &cc.Declarator{
· · · · Linkage: LinkageNone,
· · · · Scope: &cc.Scope{
· · · · },
· · · · StorageDuration: StorageDurationAutomatic,
· · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · Case: DirectDeclaratorIdent,
· · · · · Token: IDENTIFIER "a",
· · · · },
· · · },
· · },
· },
· Token: ';',
}

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 StructDeclarationCase

type StructDeclarationCase int

StructDeclarationCase represents case numbers of production StructDeclaration

const (
	StructDeclarationBase StructDeclarationCase = iota
	StructDeclarationAnon
)

Values of type StructDeclarationCase

func (StructDeclarationCase) String

func (n StructDeclarationCase) 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                        // Case 0
|       StructDeclarationList StructDeclaration  // Case 1
Example (Case0)
fmt.Println(exampleAST(122, "\U00100001 struct { _Atomic ; }"))
Output:

&cc.StructDeclarationList{
· StructDeclaration: &cc.StructDeclaration{
· · Case: 1,
· · SpecifierQualifierList: &cc.SpecifierQualifierList{
· · · TypeQualifier: &cc.TypeQualifier{
· · · · Case: 3,
· · · · Token: ATOMIC "_Atomic",
· · · },
· · },
· · Token: ';',
· },
}
Example (Case1)
fmt.Println(exampleAST(123, "\U00100001 struct { _Atomic ; _Atomic ; }"))
Output:

&cc.StructDeclarationList{
· StructDeclaration: &cc.StructDeclaration{
· · Case: 1,
· · SpecifierQualifierList: &cc.SpecifierQualifierList{
· · · TypeQualifier: &cc.TypeQualifier{
· · · · Case: 3,
· · · · Token: ATOMIC "_Atomic",
· · · },
· · },
· · Token: ';',
· },
· StructDeclarationList: &cc.StructDeclarationList{
· · Case: 1,
· · StructDeclaration: &cc.StructDeclaration{
· · · Case: 1,
· · · SpecifierQualifierList: &cc.SpecifierQualifierList{
· · · · TypeQualifier: &cc.TypeQualifier{
· · · · · Case: 3,
· · · · · Token: ATOMIC "_Atomic",
· · · · },
· · · },
· · · Token: ';',
· · },
· },
}

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 {
	Bits          int
	Case          StructDeclaratorCase
	ConstExpr     *ConstExpr
	Declarator    *Declarator
	DeclaratorOpt *DeclaratorOpt
	Token         xc.Token
}

StructDeclarator represents data reduced by productions:

StructDeclarator:
        Declarator                   // Case StructDeclaratorBase
|       DeclaratorOpt ':' ConstExpr  // Case StructDeclaratorBits
Example (Base)
fmt.Println(exampleAST(132, "\U00100001 struct { _Atomic a ,"))
Output:

&cc.StructDeclarator{
· Declarator: &cc.Declarator{
· · Linkage: LinkageNone,
· · Scope: &cc.Scope{
· · },
· · StorageDuration: StorageDurationAutomatic,
· · DirectDeclarator: &cc.DirectDeclarator{
· · · Case: DirectDeclaratorIdent,
· · · Token: IDENTIFIER "a",
· · },
· },
}
Example (Bits)
fmt.Println(exampleAST(133, "\U00100001 struct { _Atomic : 'a' ,"))
Output:

&cc.StructDeclarator{
· Case: 1,
· ConstExpr: &cc.ConstExpr{
· · Expr: &cc.Expr{
· · · Case: ExprChar,
· · · Token: CHARCONST "'a'",
· · },
· },
· Token: ':',
}

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 StructDeclaratorCase

type StructDeclaratorCase int

StructDeclaratorCase represents case numbers of production StructDeclarator

const (
	StructDeclaratorBase StructDeclaratorCase = iota
	StructDeclaratorBits
)

Values of type StructDeclaratorCase

func (StructDeclaratorCase) String

func (n StructDeclaratorCase) 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                           // Case 0
|       StructDeclaratorList ',' StructDeclarator  // Case 1
Example (Case0)
fmt.Println(exampleAST(130, "\U00100001 struct { _Atomic a ,"))
Output:

&cc.StructDeclaratorList{
· StructDeclarator: &cc.StructDeclarator{
· · Declarator: &cc.Declarator{
· · · Linkage: LinkageNone,
· · · Scope: &cc.Scope{
· · · },
· · · StorageDuration: StorageDurationAutomatic,
· · · DirectDeclarator: &cc.DirectDeclarator{
· · · · Case: DirectDeclaratorIdent,
· · · · Token: IDENTIFIER "a",
· · · },
· · },
· },
}
Example (Case1)
fmt.Println(exampleAST(131, "\U00100001 struct { _Atomic a , b ,"))
Output:

&cc.StructDeclaratorList{
· StructDeclarator: &cc.StructDeclarator{
· · Declarator: &cc.Declarator{
· · · Linkage: LinkageNone,
· · · Scope: &cc.Scope{
· · · },
· · · StorageDuration: StorageDurationAutomatic,
· · · DirectDeclarator: &cc.DirectDeclarator{
· · · · Case: DirectDeclaratorIdent,
· · · · Token: IDENTIFIER "a",
· · · },
· · },
· },
· StructDeclaratorList: &cc.StructDeclaratorList{
· · Case: 1,
· · StructDeclarator: &cc.StructDeclarator{
· · · Declarator: &cc.Declarator{
· · · · Linkage: LinkageNone,
· · · · Scope: &cc.Scope{ /* recursive/repetitive pointee not shown */ },
· · · · StorageDuration: StorageDurationAutomatic,
· · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · Case: DirectDeclaratorIdent,
· · · · · Token: IDENTIFIER "b",
· · · · },
· · · },
· · },
· · Token: ',',
· },
}

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  StructOrUnionCase
	Token xc.Token
}

StructOrUnion represents data reduced by productions:

StructOrUnion:
        "struct"  // Case StructOrUnionStruct
|       "union"   // Case StructOrUnionUnion
Example (Struct)
fmt.Println(exampleAST(120, "\U00100001 struct {"))
Output:

&cc.StructOrUnion{
· Token: STRUCT "struct",
}
Example (Union)
fmt.Println(exampleAST(121, "\U00100001 union {"))
Output:

&cc.StructOrUnion{
· Case: 1,
· Token: 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 StructOrUnionCase

type StructOrUnionCase int

StructOrUnionCase represents case numbers of production StructOrUnion

const (
	StructOrUnionStruct StructOrUnionCase = iota
	StructOrUnionUnion
)

Values of type StructOrUnionCase

func (StructOrUnionCase) String

func (n StructOrUnionCase) String() string

String implements fmt.Stringer

type StructOrUnionSpecifier

type StructOrUnionSpecifier struct {
	Case                  StructOrUnionSpecifierCase
	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 IDENTIFIER                                   // Case StructOrUnionSpecifierTag
|       StructOrUnion IdentifierOpt '{' '}'                        // Case StructOrUnionSpecifierEmpty
|       StructOrUnion IdentifierOpt '{' StructDeclarationList '}'  // Case StructOrUnionSpecifierDefine
Example (Define)
fmt.Println(exampleAST(119, "\U00100001 struct { _Atomic ; } ("))
Output:

&cc.StructOrUnionSpecifier{
· Case: 2,
· StructDeclarationList: &cc.StructDeclarationList{
· · StructDeclaration: &cc.StructDeclaration{
· · · Case: 1,
· · · SpecifierQualifierList: &cc.SpecifierQualifierList{
· · · · TypeQualifier: &cc.TypeQualifier{
· · · · · Case: 3,
· · · · · Token: ATOMIC "_Atomic",
· · · · },
· · · },
· · · Token: ';',
· · },
· },
· StructOrUnion: &cc.StructOrUnion{
· · Token: STRUCT "struct",
· },
· Token: '{',
· Token2: '}',
}
Example (Empty)
fmt.Println(exampleAST(116, "\U00100001 struct { } ("))
Output:

&cc.StructOrUnionSpecifier{
· Case: 1,
· StructOrUnion: &cc.StructOrUnion{
· · Token: STRUCT "struct",
· },
· Token: '{',
· Token2: '}',
}
Example (Tag)
fmt.Println(exampleAST(114, "\U00100001 struct a ("))
Output:

&cc.StructOrUnionSpecifier{
· StructOrUnion: &cc.StructOrUnion{
· · Token: STRUCT "struct",
· },
· Token: IDENTIFIER "a",
}

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 StructOrUnionSpecifierCase

type StructOrUnionSpecifierCase int

StructOrUnionSpecifierCase represents case numbers of production StructOrUnionSpecifier

const (
	StructOrUnionSpecifierTag StructOrUnionSpecifierCase = iota
	StructOrUnionSpecifierEmpty
	StructOrUnionSpecifierDefine
)

Values of type StructOrUnionSpecifierCase

func (StructOrUnionSpecifierCase) String

String implements fmt.Stringer

type StructType

type StructType struct {
	// contains filtered or unexported fields
}

StructType represents a struct type.

func (*StructType) Equal

func (t *StructType) Equal(u Type) bool

Equal implements Type.

func (*StructType) Field

func (t *StructType) Field(nm int) *FieldProperties

Field returns the properties of field nm or nil if the field does not exist.

func (*StructType) IsArithmeticType

func (t *StructType) IsArithmeticType() bool

IsArithmeticType implements Type.

func (*StructType) IsCompatible

func (t *StructType) IsCompatible(u Type) bool

IsCompatible implements Type.

func (*StructType) IsIntegerType

func (t *StructType) IsIntegerType() bool

IsIntegerType implements Type.

func (*StructType) IsPointerType

func (t *StructType) IsPointerType() bool

IsPointerType implements Type.

func (*StructType) IsScalarType

func (t *StructType) IsScalarType() bool

IsScalarType implements Type.

func (*StructType) IsUnsigned

func (t *StructType) IsUnsigned() bool

IsUnsigned implements Type.

func (*StructType) IsVoidPointerType

func (t *StructType) IsVoidPointerType() bool

IsVoidPointerType implements Type.

func (*StructType) Kind

func (t *StructType) Kind() TypeKind

Kind implements Type.

func (*StructType) Pos added in v1.0.1

func (t *StructType) Pos() token.Pos

func (*StructType) String

func (t *StructType) String() string

type TaggedEnumType

type TaggedEnumType struct {
	Tag  int
	Type Type
	// contains filtered or unexported fields
}

TaggedEnumType represents an enum type described by a tag name.

func (*TaggedEnumType) Equal

func (t *TaggedEnumType) Equal(u Type) bool

Equal implements Type.

func (*TaggedEnumType) IsArithmeticType

func (t *TaggedEnumType) IsArithmeticType() bool

IsArithmeticType implements Type.

func (*TaggedEnumType) IsCompatible

func (t *TaggedEnumType) IsCompatible(u Type) bool

IsCompatible implements Type.

func (*TaggedEnumType) IsIntegerType

func (t *TaggedEnumType) IsIntegerType() bool

IsIntegerType implements Type.

func (*TaggedEnumType) IsPointerType

func (t *TaggedEnumType) IsPointerType() bool

IsPointerType implements Type.

func (*TaggedEnumType) IsScalarType

func (t *TaggedEnumType) IsScalarType() bool

IsScalarType implements Type.

func (*TaggedEnumType) IsUnsigned

func (t *TaggedEnumType) IsUnsigned() bool

IsUnsigned implements Type.

func (*TaggedEnumType) IsVoidPointerType

func (t *TaggedEnumType) IsVoidPointerType() bool

IsVoidPointerType implements Type.

func (*TaggedEnumType) Kind

func (t *TaggedEnumType) Kind() TypeKind

Kind implements Type.

func (*TaggedEnumType) Pos added in v1.0.1

func (t *TaggedEnumType) Pos() token.Pos

func (*TaggedEnumType) String

func (t *TaggedEnumType) String() string

type TaggedStructType

type TaggedStructType struct {
	Tag  int
	Type Type
	// contains filtered or unexported fields
}

TaggedStructType represents a struct type described by a tag name.

func (*TaggedStructType) Equal

func (t *TaggedStructType) Equal(u Type) bool

Equal implements Type.

func (*TaggedStructType) IsArithmeticType

func (t *TaggedStructType) IsArithmeticType() bool

IsArithmeticType implements Type.

func (*TaggedStructType) IsCompatible

func (t *TaggedStructType) IsCompatible(u Type) bool

IsCompatible implements Type.

func (*TaggedStructType) IsIntegerType

func (t *TaggedStructType) IsIntegerType() bool

IsIntegerType implements Type.

func (*TaggedStructType) IsPointerType

func (t *TaggedStructType) IsPointerType() bool

IsPointerType implements Type.

func (*TaggedStructType) IsScalarType

func (t *TaggedStructType) IsScalarType() bool

IsScalarType implements Type.

func (*TaggedStructType) IsUnsigned

func (t *TaggedStructType) IsUnsigned() bool

IsUnsigned implements Type.

func (*TaggedStructType) IsVoidPointerType

func (t *TaggedStructType) IsVoidPointerType() bool

IsVoidPointerType implements Type.

func (*TaggedStructType) Kind

func (t *TaggedStructType) Kind() TypeKind

Kind implements Type.

func (*TaggedStructType) Pos added in v1.0.1

func (t *TaggedStructType) Pos() token.Pos

func (*TaggedStructType) String

func (t *TaggedStructType) String() string

type TaggedUnionType

type TaggedUnionType struct {
	Tag  int
	Type Type
	// contains filtered or unexported fields
}

TaggedUnionType represents a struct type described by a tag name.

func (*TaggedUnionType) Equal

func (t *TaggedUnionType) Equal(u Type) bool

Equal implements Type.

func (*TaggedUnionType) IsArithmeticType

func (t *TaggedUnionType) IsArithmeticType() bool

IsArithmeticType implements Type.

func (*TaggedUnionType) IsCompatible

func (t *TaggedUnionType) IsCompatible(u Type) bool

IsCompatible implements Type.

func (*TaggedUnionType) IsIntegerType

func (t *TaggedUnionType) IsIntegerType() bool

IsIntegerType implements Type.

func (*TaggedUnionType) IsPointerType

func (t *TaggedUnionType) IsPointerType() bool

IsPointerType implements Type.

func (*TaggedUnionType) IsScalarType

func (t *TaggedUnionType) IsScalarType() bool

IsScalarType implements Type.

func (*TaggedUnionType) IsUnsigned

func (t *TaggedUnionType) IsUnsigned() bool

IsUnsigned implements Type.

func (*TaggedUnionType) IsVoidPointerType

func (t *TaggedUnionType) IsVoidPointerType() bool

IsVoidPointerType implements Type.

func (*TaggedUnionType) Kind

func (t *TaggedUnionType) Kind() TypeKind

Kind implements Type.

func (*TaggedUnionType) Pos added in v1.0.1

func (t *TaggedUnionType) Pos() token.Pos

func (*TaggedUnionType) String

func (t *TaggedUnionType) String() string

type TranslationUnit

type TranslationUnit struct {
	ExternalDeclarationList *ExternalDeclarationList
	FileScope               *Scope
	FileSet                 *token.FileSet
	IncludePaths            []string
	Macros                  map[int]*Macro
	Model                   Model
	SysIncludePaths         []string
}

TranslationUnit represents a translation unit, see [0]6.9.

func Translate

func Translate(tweaks *Tweaks, includePaths, sysIncludePaths []string, sources ...Source) (tu *TranslationUnit, err error)

Translate preprocesses, parses and type checks a translation unit using includePaths and sysIncludePaths for looking for "foo.h" and <foo.h> files. A special path "@" is interpretted as 'the same directory as where the file with the #include is'. The input consists of sources which must include any predefined/builtin stuff.

func (*TranslationUnit) Pos

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

Pos implements Node.

type Tweaks

type Tweaks struct {
	TrackExpand   func(string)
	TrackIncludes func(string)

	DefinesOnly                 bool // like in CC -E -dM foo.c
	EnableAnonymousStructFields bool // struct{int;}
	EnableBinaryLiterals        bool // 0b101010 == 42
	EnableEmptyStructs          bool // struct{}
	EnableImplicitBuiltins      bool // Undefined printf becomes __builtin_printf.
	EnableImplicitDeclarations  bool // eg. using exit(1) w/o #include <stdlib.h>
	EnableOmitFuncDeclSpec      bool // foo() { ... } == int foo() { ... }
	EnablePointerCompatibility  bool // All pointers are assignment compatible.
	EnableReturnExprInVoidFunc  bool // void f() { return 1; }
	EnableTrigraphs             bool
	EnableUnionCasts            bool // (union foo)0
	IgnoreUnknownPragmas        bool // #pragma
	InjectFinalNL               bool // Specs want the source to always end in a newline.
	PreprocessOnly              bool // like in CC -E foo.c
	// contains filtered or unexported fields
}

Tweaks amend the behavior of the parser.

type Type

type Type interface {
	Node
	Equal(Type) bool
	IsArithmeticType() bool
	IsCompatible(Type) bool // [0]6.2.7
	IsIntegerType() bool
	IsPointerType() bool
	IsScalarType() bool
	IsUnsigned() bool
	IsVoidPointerType() bool
	Kind() TypeKind
	String() string
	// contains filtered or unexported methods
}

Type represents a C type.

func AdjustedParameterType

func AdjustedParameterType(t Type) Type

AdjustedParameterType returns the type of an expression when used as an argument of a function, see [0]6.9.1-10.

func UnderlyingType

func UnderlyingType(t Type) Type

UnderlyingType returns the concrete type of t, if posible.

type TypeKind

type TypeKind int

TypeKind represents a particular type kind.

const (
	Bool TypeKind
	Char
	Int
	Long
	LongLong
	SChar
	Short
	UChar
	UInt
	ULong
	ULongLong
	UShort

	Float
	Double
	LongDouble

	FloatComplex
	DoubleComplex
	LongDoubleComplex

	FloatImaginary
	DoubleImaginary
	LongDoubleImaginary

	Array
	Enum
	EnumTag
	Function
	Ptr
	Struct
	StructTag
	TypedefName
	Union
	UnionTag
	Void
)

TypeKind values.

func Unsigned

func Unsigned(t Type) TypeKind

func (TypeKind) Equal

func (t TypeKind) Equal(u Type) bool

Equal implements Type.

func (TypeKind) IsArithmeticType

func (t TypeKind) IsArithmeticType() bool

IsArithmeticType implements Type.

func (TypeKind) IsCompatible

func (t TypeKind) IsCompatible(u Type) bool

IsCompatible implements Type.

func (TypeKind) IsIntegerType

func (t TypeKind) IsIntegerType() bool

IsIntegerType implements Type.

func (TypeKind) IsPointerType

func (t TypeKind) IsPointerType() bool

IsPointerType implements Type.

func (TypeKind) IsScalarType

func (t TypeKind) IsScalarType() bool

IsScalarType implements Type.

func (TypeKind) IsUnsigned

func (t TypeKind) IsUnsigned() bool

IsUnsigned implements Type.

func (TypeKind) IsVoidPointerType

func (t TypeKind) IsVoidPointerType() bool

IsVoidPointerType implements Type.

func (TypeKind) Kind

func (t TypeKind) Kind() TypeKind

Kind implements Type.

func (TypeKind) Pos added in v1.0.1

func (t TypeKind) Pos() token.Pos

func (TypeKind) String

func (t TypeKind) String() string

type TypeName

type TypeName struct {
	Type                   Type
	AbstractDeclaratorOpt  *AbstractDeclaratorOpt
	SpecifierQualifierList *SpecifierQualifierList
}

TypeName represents data reduced by production:

TypeName:
        SpecifierQualifierList AbstractDeclaratorOpt  // Case 0
Example (Case0)
fmt.Println(exampleAST(184, "\U00100000 ( _Atomic )"))
Output:

&cc.TypeName{
· SpecifierQualifierList: &cc.SpecifierQualifierList{
· · TypeQualifier: &cc.TypeQualifier{
· · · Case: 3,
· · · Token: ATOMIC "_Atomic",
· · },
· },
}

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  TypeQualifierCase
	Token xc.Token
}

TypeQualifier represents data reduced by productions:

TypeQualifier:
        "const"     // Case TypeQualifierConst
|       "restrict"  // Case TypeQualifierRestrict
|       "volatile"  // Case TypeQualifierVolatile
|       "_Atomic"   // Case TypeQualifierAtomic
Example (Atomic)
fmt.Println(exampleAST(145, "\U00100001 _Atomic ("))
Output:

&cc.TypeQualifier{
· Case: 3,
· Token: ATOMIC "_Atomic",
}
Example (Const)
fmt.Println(exampleAST(142, "\U00100001 const !"))
Output:

&cc.TypeQualifier{
· Token: CONST "const",
}
Example (Restrict)
fmt.Println(exampleAST(143, "\U00100001 restrict !"))
Output:

&cc.TypeQualifier{
· Case: 1,
· Token: RESTRICT "restrict",
}
Example (Volatile)
fmt.Println(exampleAST(144, "\U00100001 volatile !"))
Output:

&cc.TypeQualifier{
· Case: 2,
· Token: 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 TypeQualifierCase

type TypeQualifierCase int

TypeQualifierCase represents case numbers of production TypeQualifier

const (
	TypeQualifierConst TypeQualifierCase = iota
	TypeQualifierRestrict
	TypeQualifierVolatile
	TypeQualifierAtomic
)

Values of type TypeQualifierCase

func (TypeQualifierCase) String

func (n TypeQualifierCase) String() string

String implements fmt.Stringer

type TypeQualifierList

type TypeQualifierList struct {
	Case              int
	TypeQualifier     *TypeQualifier
	TypeQualifierList *TypeQualifierList
}

TypeQualifierList represents data reduced by productions:

TypeQualifierList:
        TypeQualifier                    // Case 0
|       TypeQualifierList TypeQualifier  // Case 1
Example (Case0)
fmt.Println(exampleAST(166, "\U00100001 * _Atomic !"))
Output:

&cc.TypeQualifierList{
· TypeQualifier: &cc.TypeQualifier{
· · Case: 3,
· · Token: ATOMIC "_Atomic",
· },
}
Example (Case1)
fmt.Println(exampleAST(167, "\U00100001 * _Atomic _Atomic !"))
Output:

&cc.TypeQualifierList{
· TypeQualifier: &cc.TypeQualifier{
· · Case: 3,
· · Token: ATOMIC "_Atomic",
· },
· TypeQualifierList: &cc.TypeQualifierList{
· · Case: 1,
· · TypeQualifier: &cc.TypeQualifier{
· · · Case: 3,
· · · Token: ATOMIC "_Atomic",
· · },
· },
}

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 */        // Case 0
|       TypeQualifierList  // Case 1
Example (Case0)
fmt.Println(exampleAST(168, "\U00100001 * (") == (*TypeQualifierListOpt)(nil))
Output:

true
Example (Case1)
fmt.Println(exampleAST(169, "\U00100001 * _Atomic !"))
Output:

&cc.TypeQualifierListOpt{
· TypeQualifierList: &cc.TypeQualifierList{
· · TypeQualifier: &cc.TypeQualifier{
· · · Case: 3,
· · · Token: ATOMIC "_Atomic",
· · },
· },
}

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 {
	Case                   TypeSpecifierCase
	EnumSpecifier          *EnumSpecifier
	Expr                   *Expr
	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:
        "_Bool"                               // Case TypeSpecifierBool
|       "_Complex"                            // Case TypeSpecifierComplex
|       "_Imaginary"                          // Case TypeSpecifierImaginary
|       "char"                                // Case TypeSpecifierChar
|       "double"                              // Case TypeSpecifierDouble
|       "float"                               // Case TypeSpecifierFloat
|       "int"                                 // Case TypeSpecifierInt
|       "long"                                // Case TypeSpecifierLong
|       "short"                               // Case TypeSpecifierShort
|       "signed"                              // Case TypeSpecifierSigned
|       "unsigned"                            // Case TypeSpecifierUnsigned
|       "void"                                // Case TypeSpecifierVoid
|       EnumSpecifier                         // Case TypeSpecifierEnum
|       StructOrUnionSpecifier                // Case TypeSpecifierStruct
|       TYPEDEF_NAME                          // Case TypeSpecifierName
|       "typeof" '(' Expr ')'                 // Case TypeSpecifierTypeofExpr
|       "typeof" '(' TypeName ')'             // Case TypeSpecifierTypeof
|       "_Atomic" ATOMIC_LPAREN TypeName ')'  // Case TypeSpecifierAtomic
Example (Atomic)
fmt.Println(exampleAST(113, "\U00100001 _Atomic ( _Atomic ) ("))
Output:

TODO: example113.c:1:12: unexpected _Atomic, expected declarator or one of ['(', '*', identifier]
Example (Bool)
fmt.Println(exampleAST(96, "\U00100001 _Bool ("))
Output:

&cc.TypeSpecifier{
· Token: BOOL "_Bool",
}
Example (Char)
fmt.Println(exampleAST(99, "\U00100001 char ("))
Output:

&cc.TypeSpecifier{
· Case: 3,
· Token: CHAR "char",
}
Example (Complex)
fmt.Println(exampleAST(97, "\U00100001 _Complex ("))
Output:

&cc.TypeSpecifier{
· Case: 1,
· Token: COMPLEX "_Complex",
}
Example (Double)
fmt.Println(exampleAST(100, "\U00100001 double ("))
Output:

&cc.TypeSpecifier{
· Case: 4,
· Token: DOUBLE "double",
}
Example (Enum)
fmt.Println(exampleAST(108, "\U00100001 enum a ("))
Output:

&cc.TypeSpecifier{
· Case: 12,
· EnumSpecifier: &cc.EnumSpecifier{
· · Token: ENUM "enum",
· · Token2: IDENTIFIER "a",
· },
}
Example (Float)
fmt.Println(exampleAST(101, "\U00100001 float ("))
Output:

&cc.TypeSpecifier{
· Case: 5,
· Token: FLOAT "float",
}
Example (Imaginary)
fmt.Println(exampleAST(98, "\U00100001 _Imaginary ("))
Output:

&cc.TypeSpecifier{
· Case: 2,
· Token: IMAGINARY "_Imaginary",
}
Example (Int)
fmt.Println(exampleAST(102, "\U00100001 int ("))
Output:

&cc.TypeSpecifier{
· Case: 6,
· Token: INT "int",
}
Example (Long)
fmt.Println(exampleAST(103, "\U00100001 long ("))
Output:

&cc.TypeSpecifier{
· Case: 7,
· Token: LONG "long",
}
Example (Name)
fmt.Println(exampleAST(110, "\U00100001 typedef int foo; foo bar;"))
Output:

&cc.TypeSpecifier{
· Case: 14,
· Token: TYPEDEF_NAME "foo",
}
Example (Short)
fmt.Println(exampleAST(104, "\U00100001 short ("))
Output:

&cc.TypeSpecifier{
· Case: 8,
· Token: SHORT "short",
}
Example (Signed)
fmt.Println(exampleAST(105, "\U00100001 signed ("))
Output:

&cc.TypeSpecifier{
· Case: 9,
· Token: SIGNED "signed",
}
Example (Struct)
fmt.Println(exampleAST(109, "\U00100001 struct a ("))
Output:

&cc.TypeSpecifier{
· Case: 13,
· StructOrUnionSpecifier: &cc.StructOrUnionSpecifier{
· · StructOrUnion: &cc.StructOrUnion{
· · · Token: STRUCT "struct",
· · },
· · Token: IDENTIFIER "a",
· },
}
Example (Typeof)
fmt.Println(exampleAST(112, "\U00100001 typeof ( _Atomic ) ("))
Output:

&cc.TypeSpecifier{
· Case: 16,
· Token: TYPEOF "typeof",
· Token2: '(',
· Token3: ')',
· TypeName: &cc.TypeName{
· · SpecifierQualifierList: &cc.SpecifierQualifierList{
· · · TypeQualifier: &cc.TypeQualifier{
· · · · Case: 3,
· · · · Token: ATOMIC "_Atomic",
· · · },
· · },
· },
}
Example (TypeofExpr)
fmt.Println(exampleAST(111, "\U00100001 typeof ( 'a' ) ("))
Output:

&cc.TypeSpecifier{
· Case: 15,
· Expr: &cc.Expr{
· · Case: ExprChar,
· · Token: CHARCONST "'a'",
· },
· Token: TYPEOF "typeof",
· Token2: '(',
· Token3: ')',
}
Example (Unsigned)
fmt.Println(exampleAST(106, "\U00100001 unsigned ("))
Output:

&cc.TypeSpecifier{
· Case: 10,
· Token: UNSIGNED "unsigned",
}
Example (Void)
fmt.Println(exampleAST(107, "\U00100001 void ("))
Output:

&cc.TypeSpecifier{
· Case: 11,
· Token: VOID "void",
}

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.

type TypeSpecifierCase

type TypeSpecifierCase int

TypeSpecifierCase represents case numbers of production TypeSpecifier

const (
	TypeSpecifierBool TypeSpecifierCase = iota
	TypeSpecifierComplex
	TypeSpecifierImaginary
	TypeSpecifierChar
	TypeSpecifierDouble
	TypeSpecifierFloat
	TypeSpecifierInt
	TypeSpecifierLong
	TypeSpecifierShort
	TypeSpecifierSigned
	TypeSpecifierUnsigned
	TypeSpecifierVoid
	TypeSpecifierEnum
	TypeSpecifierStruct
	TypeSpecifierName
	TypeSpecifierTypeofExpr
	TypeSpecifierTypeof
	TypeSpecifierAtomic
)

Values of type TypeSpecifierCase

func (TypeSpecifierCase) String

func (n TypeSpecifierCase) String() string

String implements fmt.Stringer

type UnionType

type UnionType struct {
	// contains filtered or unexported fields
}

UnionType represents a union type.

func (*UnionType) Equal

func (t *UnionType) Equal(u Type) bool

Equal implements Type.

func (*UnionType) Field

func (t *UnionType) Field(nm int) *FieldProperties

Field returns the properties of field nm or nil if the field does not exist.

func (*UnionType) IsArithmeticType

func (t *UnionType) IsArithmeticType() bool

IsArithmeticType implements Type.

func (*UnionType) IsCompatible

func (t *UnionType) IsCompatible(u Type) bool

IsCompatible implements Type.

func (*UnionType) IsIntegerType

func (t *UnionType) IsIntegerType() bool

IsIntegerType implements Type.

func (*UnionType) IsPointerType

func (t *UnionType) IsPointerType() bool

IsPointerType implements Type.

func (*UnionType) IsScalarType

func (t *UnionType) IsScalarType() bool

IsScalarType implements Type.

func (*UnionType) IsUnsigned

func (t *UnionType) IsUnsigned() bool

IsUnsigned implements Type.

func (*UnionType) IsVoidPointerType

func (t *UnionType) IsVoidPointerType() bool

IsVoidPointerType implements Type.

func (*UnionType) Kind

func (t *UnionType) Kind() TypeKind

Kind implements Type.

func (*UnionType) Pos added in v1.0.1

func (t *UnionType) Pos() token.Pos

func (*UnionType) String

func (t *UnionType) String() string

type VolatileOpt

type VolatileOpt struct {
	Token xc.Token
}

VolatileOpt represents data reduced by productions:

VolatileOpt:
        /* empty */  // Case 0
|       "volatile"   // Case 1

func (*VolatileOpt) Pos

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

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

func (*VolatileOpt) String

func (n *VolatileOpt) String() string

String implements fmt.Stringer.

Jump to

Keyboard shortcuts

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