cc

package module
v4.21.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: BSD-3-Clause Imports: 27 Imported by: 19

Documentation

Overview

Package cc is a C99 compiler front end.

Online documentation

See https://godoc.org/modernc.org/cc/v4.

Index

Examples

Constants

View Source
const (
	ADDASSIGN         tokCh // '+='
	ALIGNAS                 // '_Alignas'
	ALIGNOF                 // '_Alignof'
	ANDAND                  // '&&'
	ANDASSIGN               // '&='
	ARROW                   // '->'
	ASM                     // '__asm__'
	ATOMIC                  // '_Atomic'
	ATTRIBUTE               // '__attribute__'
	AUTO                    // 'auto'
	AUTOTYPE                // '__auto_type'
	BOOL                    // '_Bool'
	BREAK                   // 'break'
	CASE                    // 'case'
	CHAR                    // 'char'
	CHARCONST               // character constant
	COMPLEX                 // '_Complex'
	CONST                   // 'const'
	CONTINUE                // 'continue'
	DDD                     // '...'
	DEC                     // '--'
	DECIMAL128              // '_Decimal128'
	DECIMAL32               // '_Decimal32'
	DECIMAL64               // '_Decimal64'
	DECLSPEC                // '__declspec'
	DEFAULT                 // 'default'
	DIVASSIGN               // '/='
	DO                      // 'do'
	DOUBLE                  // 'double'
	ELSE                    // 'else'
	ENUM                    // 'enum'
	EQ                      // '=='
	EXTERN                  // 'extern'
	FLOAT                   // 'float'
	FLOAT128                // '_Float128'
	FLOAT128X               // '_Float128x'
	FLOAT16                 // '_Float16'
	FLOAT32                 // '_Float32'
	FLOAT32X                // '_Float32x'
	FLOAT64                 // '_Float64'
	FLOAT64X                // '_Float64x'
	FLOATCONST              // floating point constant
	FOR                     // 'for'
	GENERIC                 // '_Generic'
	GEQ                     // '>='
	GOTO                    // 'goto'
	HEADER_NAME             // <header-name>
	IDENTIFIER              // identifier
	IF                      // 'if'
	IMAG                    // '__imag__'
	IMAGINARY               // '_Imaginary'
	INC                     // '++'
	INLINE                  // 'inline'
	INT                     // 'int'
	INT128                  // '__int128'
	INTCONST                // integer constant
	LABEL                   // '__label__'
	LEQ                     // '<='
	LONG                    // 'long'
	LONGCHARCONST           // long character constant
	LONGSTRINGLITERAL       // long string literal
	LSH                     // '<<'
	LSHASSIGN               // '<<='
	MODASSIGN               // '%='
	MULASSIGN               // '*='
	NEQ                     // '!='
	NONNULL                 // '_Nonnull'
	NORETURN                // '_Noreturn'
	ORASSIGN                // '|='
	OROR                    // '||'
	PPNUMBER                // preprocessing number
	PPPASTE                 // '##'
	REAL                    // '__real__'
	REGISTER                // 'register'
	RESTRICT                // 'restrict'
	RETURN                  // 'return'
	RSH                     // '>>'
	RSHASSIGN               // '>>='
	SHORT                   // 'short'
	SIGNED                  // 'signed'
	SIZEOF                  // 'sizeof'
	STATIC                  // 'static'
	STATICASSERT            // _Static_assert
	STRINGLITERAL           // string literal
	STRUCT                  // 'struct'
	SUBASSIGN               // '-='
	SWITCH                  // 'switch'
	THREADLOCAL             // '_Thread_local'
	TYPEDEF                 // 'typedef'
	TYPENAME                // type name
	TYPEOF                  // 'typeof'
	UINT128                 // '__uint128_t'
	UNION                   // 'union'
	UNSIGNED                // 'unsigned'
	VOID                    // 'void'
	VOLATILE                // 'volatile'
	WHILE                   // 'while'
	XORASSIGN               // '^='
)

Values of Token.Rune representing non-character categories.

View Source
const (
	// Builtin definitions used by package tests. Possibly usable also by consumers
	// of this package.
	Builtin = `` /* 9024-byte string literal not displayed */

)
View Source
const Dmesgs = false

Variables

View Source
var (
	DmesgsFile string
)

Functions

func Dmesg

func Dmesg(s string, args ...interface{})

Dmesg does nothing. To enable use -tags=cc.dmesg. Cannot be enabled on Windows.

func IsArithmeticType

func IsArithmeticType(t Type) bool

IsArithmeticType reports whether t is an arithmetic type.

func IsComplexType

func IsComplexType(t Type) bool

IsComplexType reports whether t is a complex type.

func IsFloatingPointType

func IsFloatingPointType(t Type) bool

IsFloatingPointType reports whether t is a floating point type.

func IsIntegerType

func IsIntegerType(t Type) bool

IsIntegerType reports whether t is an integer type.

func IsRealType

func IsRealType(t Type) bool

IsRealType reports whether t is a real type.

func IsScalarType

func IsScalarType(t Type) bool

IsScalarType reports whether t is a scalar type.

func IsSignedInteger

func IsSignedInteger(t Type) bool

IsSignedInteger reports whether t is a signed integer type.

func LongDouble64Flag

func LongDouble64Flag(os, arch string) string

LongDouble64Flag returns the C compiler flag that switches long double to 64 bits, if any.

func NodeSource

func NodeSource(s ...Node) string

NodeSource returns the source form of s. Non-empty separators between tokens are replaced by a single ' '.

func Preprocess

func Preprocess(cfg *Config, sources []Source, w io.Writer) (err error)

Preprocess preprocesses a translation unit, consisting of inputs in sources, and writes the result to w.

func PrettyString

func PrettyString(v interface{}) string

PrettyString returns a formatted representation of Tokens and AST nodes.

Types

type ABI

type ABI struct {
	ByteOrder binary.ByteOrder

	Types map[Kind]AbiType

	SignedChar bool
	// contains filtered or unexported fields
}

ABI describes selected parts of the Application Binary Interface.

func NewABI

func NewABI(os, arch string) (*ABI, error)

NewABI creates an ABI based on the os+arch pair.

type AST

type AST struct {
	ABI    *ABI
	EOF    Token
	Macros map[string]*Macro
	Scope  *Scope // File scope.
	// All struct types created during type checking.
	Structs         map[*StructType]struct{}
	TranslationUnit *TranslationUnit
	// All union types created during type checking.
	Unions map[*UnionType]struct{}

	// These field are valid only after Translate
	Char       Type
	Double     Type
	Float      Type
	Int        Type
	Long       Type
	LongDouble Type
	LongLong   Type
	PVoid      Type
	SChar      Type
	Short      Type
	SizeT      Type
	UChar      Type
	UInt       Type
	ULong      Type
	ULongLong  Type
	UShort     Type
	Void       Type
	// contains filtered or unexported fields
}

func Parse

func Parse(cfg *Config, sources []Source) (*AST, error)

Parse preprocesses and parses a translation unit, consisting of inputs in sources.

Config.Predefined and cc.Builtin are not used by default, the caller is responsible for manually inserting them in sources.

func Translate

func Translate(cfg *Config, sources []Source) (*AST, error)

Translate preprocesses, parses and type checks a translation unit, consisting of inputs in sources.

type AbiType added in v4.0.1

type AbiType struct {
	Size       int64
	Align      int
	FieldAlign int
}

type AbstractDeclarator

type AbstractDeclarator struct {
	Case                     AbstractDeclaratorCase `PrettyPrint:"stringer,zero"`
	DirectAbstractDeclarator *DirectAbstractDeclarator
	Pointer                  *Pointer
	// contains filtered or unexported fields
}

AbstractDeclarator represents data reduced by productions:

AbstractDeclarator:
        Pointer                           // Case AbstractDeclaratorPtr
|       Pointer DirectAbstractDeclarator  // Case AbstractDeclaratorDecl
Example (Decl)
fmt.Println(exampleAST(196, "void f(int());"))
Output:

&cc.AbstractDeclarator{
· Case: AbstractDeclaratorDecl,
· DirectAbstractDeclarator: &cc.DirectAbstractDeclarator{
· · Case: DirectAbstractDeclaratorFunc,
· · Token: example.c:1:11: '(' "(",
· · Token2: example.c:1:12: ')' ")",
· },
}
Example (Ptr)
fmt.Println(exampleAST(195, "void f(int*);"))
Output:

&cc.AbstractDeclarator{
· Case: AbstractDeclaratorPtr,
· Pointer: &cc.Pointer{
· · Case: PointerTypeQual,
· · Token: example.c:1:11: '*' "*",
· },
}

func (*AbstractDeclarator) Position

func (n *AbstractDeclarator) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*AbstractDeclarator) String

func (n *AbstractDeclarator) String() string

String implements fmt.Stringer.

func (AbstractDeclarator) Type

func (t AbstractDeclarator) Type() Type

Type returns the type of a node or an *InvalidType type value, if the type is unknown/undetermined.

type AbstractDeclaratorCase

type AbstractDeclaratorCase int

AbstractDeclaratorCase represents case numbers of production AbstractDeclarator

const (
	AbstractDeclaratorPtr AbstractDeclaratorCase = iota
	AbstractDeclaratorDecl
)

Values of type AbstractDeclaratorCase

func (AbstractDeclaratorCase) String

func (n AbstractDeclaratorCase) String() string

String implements fmt.Stringer

type AdditiveExpression

type AdditiveExpression struct {
	AdditiveExpression       ExpressionNode
	Case                     AdditiveExpressionCase `PrettyPrint:"stringer,zero"`
	MultiplicativeExpression ExpressionNode
	Token                    Token
	// contains filtered or unexported fields
}

AdditiveExpression represents data reduced by productions:

AdditiveExpression:
        MultiplicativeExpression                         // Case AdditiveExpressionMul
|       AdditiveExpression '+' MultiplicativeExpression  // Case AdditiveExpressionAdd
|       AdditiveExpression '-' MultiplicativeExpression  // Case AdditiveExpressionSub
Example (Add)
fmt.Println(exampleAST(49, "int i = x+y;"))
Output:

&cc.AdditiveExpression{
· AdditiveExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:9: identifier "x",
· },
· Case: AdditiveExpressionAdd,
· MultiplicativeExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:11: identifier "y",
· },
· Token: example.c:1:10: '+' "+",
}
Example (Sub)
fmt.Println(exampleAST(50, "int i = x-y;"))
Output:

&cc.AdditiveExpression{
· AdditiveExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:9: identifier "x",
· },
· Case: AdditiveExpressionSub,
· MultiplicativeExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:11: identifier "y",
· },
· Token: example.c:1:10: '-' "-",
}

func (*AdditiveExpression) Position

func (n *AdditiveExpression) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*AdditiveExpression) Pure added in v4.6.0

func (p *AdditiveExpression) Pure() bool

Pure implements ExpressionNode.

func (*AdditiveExpression) String

func (n *AdditiveExpression) String() string

String implements fmt.Stringer.

func (AdditiveExpression) Type

func (t AdditiveExpression) Type() Type

Type returns the type of a node or an *InvalidType type value, if the type is unknown/undetermined.

func (AdditiveExpression) Value

func (v AdditiveExpression) Value() Value

Value returns the value of a node or UnknownValue if it is undetermined. The dynamic type of a Value is one of

*ComplexLongDoubleValue
*LongDoubleValue
*UnknownValue
*ZeroValue
Complex128Value
Complex64Value
Float64Value
Int64Value
StringValue
UInt64Value
UTF16StringValue
UTF32StringValue
VoidValue

type AdditiveExpressionCase

type AdditiveExpressionCase int

AdditiveExpressionCase represents case numbers of production AdditiveExpression

const (
	AdditiveExpressionMul AdditiveExpressionCase = iota
	AdditiveExpressionAdd
	AdditiveExpressionSub
)

Values of type AdditiveExpressionCase

func (AdditiveExpressionCase) String

func (n AdditiveExpressionCase) String() string

String implements fmt.Stringer

type AlignmentSpecifier

type AlignmentSpecifier struct {
	Case               AlignmentSpecifierCase `PrettyPrint:"stringer,zero"`
	ConstantExpression ExpressionNode
	Token              Token
	Token2             Token
	Token3             Token
	TypeName           *TypeName
}

AlignmentSpecifier represents data reduced by productions:

AlignmentSpecifier:
        "_Alignas" '(' TypeName ')'            // Case AlignmentSpecifierType
|       "_Alignas" '(' ConstantExpression ')'  // Case AlignmentSpecifierExpr
Example (Expr)
fmt.Println(exampleAST(172, "_Alignas(0ll) char c;"))
Output:

&cc.AlignmentSpecifier{
· Case: AlignmentSpecifierExpr,
· ConstantExpression: &cc.ConstantExpression{
· · ConditionalExpression: &cc.PrimaryExpression{
· · · Case: PrimaryExpressionInt,
· · · Token: example.c:1:10: integer constant "0ll",
· · },
· },
· Token: example.c:1:1: '_Alignas' "_Alignas",
· Token2: example.c:1:9: '(' "(",
· Token3: example.c:1:13: ')' ")",
}
Example (Type)
fmt.Println(exampleAST(171, "_Alignas(double) char c;"))
Output:

&cc.AlignmentSpecifier{
· Case: AlignmentSpecifierType,
· Token: example.c:1:1: '_Alignas' "_Alignas",
· Token2: example.c:1:9: '(' "(",
· Token3: example.c:1:16: ')' ")",
· TypeName: &cc.TypeName{
· · SpecifierQualifierList: &cc.SpecifierQualifierList{
· · · Case: SpecifierQualifierListTypeSpec,
· · · TypeSpecifier: &cc.TypeSpecifier{
· · · · Case: TypeSpecifierDouble,
· · · · Token: example.c:1:10: 'double' "double",
· · · },
· · },
· },
}

func (*AlignmentSpecifier) Position

func (n *AlignmentSpecifier) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*AlignmentSpecifier) String

func (n *AlignmentSpecifier) String() string

String implements fmt.Stringer.

type AlignmentSpecifierCase

type AlignmentSpecifierCase int

AlignmentSpecifierCase represents case numbers of production AlignmentSpecifier

const (
	AlignmentSpecifierType AlignmentSpecifierCase = iota
	AlignmentSpecifierExpr
)

Values of type AlignmentSpecifierCase

func (AlignmentSpecifierCase) String

func (n AlignmentSpecifierCase) String() string

String implements fmt.Stringer

type AndExpression

type AndExpression struct {
	AndExpression      ExpressionNode
	Case               AndExpressionCase `PrettyPrint:"stringer,zero"`
	EqualityExpression ExpressionNode
	Token              Token
	// contains filtered or unexported fields
}

AndExpression represents data reduced by productions:

AndExpression:
        EqualityExpression                    // Case AndExpressionEq
|       AndExpression '&' EqualityExpression  // Case AndExpressionAnd
Example (And)
fmt.Println(exampleAST(63, "int i = x & y;"))
Output:

&cc.AndExpression{
· AndExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:9: identifier "x",
· },
· Case: AndExpressionAnd,
· EqualityExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:13: identifier "y",
· },
· Token: example.c:1:11: '&' "&",
}

func (*AndExpression) Position

func (n *AndExpression) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*AndExpression) Pure added in v4.6.0

func (p *AndExpression) Pure() bool

Pure implements ExpressionNode.

func (*AndExpression) String

func (n *AndExpression) String() string

String implements fmt.Stringer.

func (AndExpression) Type

func (t AndExpression) Type() Type

Type returns the type of a node or an *InvalidType type value, if the type is unknown/undetermined.

func (AndExpression) Value

func (v AndExpression) Value() Value

Value returns the value of a node or UnknownValue if it is undetermined. The dynamic type of a Value is one of

*ComplexLongDoubleValue
*LongDoubleValue
*UnknownValue
*ZeroValue
Complex128Value
Complex64Value
Float64Value
Int64Value
StringValue
UInt64Value
UTF16StringValue
UTF32StringValue
VoidValue

type AndExpressionCase

type AndExpressionCase int

AndExpressionCase represents case numbers of production AndExpression

const (
	AndExpressionEq AndExpressionCase = iota
	AndExpressionAnd
)

Values of type AndExpressionCase

func (AndExpressionCase) String

func (n AndExpressionCase) String() string

String implements fmt.Stringer

type ArgumentExpressionList

type ArgumentExpressionList struct {
	ArgumentExpressionList *ArgumentExpressionList
	AssignmentExpression   ExpressionNode
	Token                  Token
}

ArgumentExpressionList represents data reduced by productions:

ArgumentExpressionList:
        AssignmentExpression
|       ArgumentExpressionList ',' AssignmentExpression
Example (Case0)
fmt.Println(exampleAST(24, "int i = f(x);"))
Output:

&cc.ArgumentExpressionList{
· AssignmentExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:11: identifier "x",
· },
}
Example (Case1)
fmt.Println(exampleAST(25, "int i = f(x, y);"))
Output:

&cc.ArgumentExpressionList{
· ArgumentExpressionList: &cc.ArgumentExpressionList{
· · AssignmentExpression: &cc.PrimaryExpression{
· · · Case: PrimaryExpressionIdent,
· · · Token: example.c:1:14: identifier "y",
· · },
· · Token: example.c:1:12: ',' ",",
· },
· AssignmentExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:11: identifier "x",
· },
}

func (*ArgumentExpressionList) Position

func (n *ArgumentExpressionList) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*ArgumentExpressionList) String

func (n *ArgumentExpressionList) String() string

String implements fmt.Stringer.

type ArrayType

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

func (*ArrayType) Align

func (n *ArrayType) Align() int

Align implements Type.

func (ArrayType) Attributes

func (n ArrayType) Attributes() *Attributes

Attributes implemets Type.

func (ArrayType) BitField added in v4.1.1

func (ArrayType) BitField() *Field

BitField implements Type.

func (*ArrayType) Decay

func (n *ArrayType) Decay() Type

Decay implements Type.

func (*ArrayType) Elem

func (n *ArrayType) Elem() Type

Elem reports the element type of n.

func (*ArrayType) FieldAlign

func (n *ArrayType) FieldAlign() int

FieldAlign implements Type.

func (*ArrayType) IsCompatible

func (n *ArrayType) IsCompatible(t Type) (r bool)

func (*ArrayType) IsIncomplete

func (n *ArrayType) IsIncomplete() bool

IsIncomplete implements Type.

func (*ArrayType) IsVLA

func (n *ArrayType) IsVLA() bool

func (*ArrayType) Kind

func (n *ArrayType) Kind() Kind

Kind implements Type.

func (*ArrayType) Len

func (n *ArrayType) Len() int64

Len reports the number of elements in n or a negative value if n is incomplete.

func (*ArrayType) Pointer

func (n *ArrayType) Pointer() Type

Pointer implements Type.

func (*ArrayType) Size

func (n *ArrayType) Size() int64

Size implements Type.

func (*ArrayType) SizeExpression added in v4.10.0

func (n *ArrayType) SizeExpression() ExpressionNode

SizeExpression returns the expression determining the number of elements in 'n', if available.

func (*ArrayType) String

func (n *ArrayType) String() string

String implements Type.

func (ArrayType) Typedef

func (n ArrayType) Typedef() *Declarator

Typedef implements Type

func (*ArrayType) Undecay

func (n *ArrayType) Undecay() Type

Undecay implements Type.

func (ArrayType) VectorSize

func (ArrayType) VectorSize() int64

VectorSize implements Type.

type Asm

type Asm struct {
	AsmArgList       *AsmArgList
	AsmQualifierList *AsmQualifierList
	Token            Token
	Token2           Token
	Token3           Token
	Token4           Token
}

Asm represents data reduced by production:

Asm:
        "__asm__" AsmQualifierList '(' STRINGLITERAL AsmArgList ')'
Example (Case0)
fmt.Println(exampleAST(260, "__asm__(\"nop\");"))
Output:

&cc.Asm{
· Token: example.c:1:1: '__asm__' "__asm__",
· Token2: example.c:1:8: '(' "(",
· Token3: example.c:1:9: string literal "\"nop\"",
· Token4: example.c:1:14: ')' ")",
}

func (*Asm) Position

func (n *Asm) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*Asm) String

func (n *Asm) String() string

String implements fmt.Stringer.

type AsmArgList

type AsmArgList struct {
	AsmArgList        *AsmArgList
	AsmExpressionList *AsmExpressionList
	Token             Token
}

AsmArgList represents data reduced by productions:

AsmArgList:
        ':' AsmExpressionList
|       AsmArgList ':' AsmExpressionList
Example (Case0)
fmt.Println(exampleAST(258, "__asm__(\"nop\": a);"))
Output:

&cc.AsmArgList{
· AsmExpressionList: &cc.AsmExpressionList{
· · AssignmentExpression: &cc.PrimaryExpression{
· · · Case: PrimaryExpressionIdent,
· · · Token: example.c:1:16: identifier "a",
· · },
· },
· Token: example.c:1:14: ':' ":",
}
Example (Case1)
fmt.Println(exampleAST(259, "__asm__(\"nop\": a : b);"))
Output:

&cc.AsmArgList{
· AsmArgList: &cc.AsmArgList{
· · AsmExpressionList: &cc.AsmExpressionList{
· · · AssignmentExpression: &cc.PrimaryExpression{
· · · · Case: PrimaryExpressionIdent,
· · · · Token: example.c:1:20: identifier "b",
· · · },
· · },
· · Token: example.c:1:18: ':' ":",
· },
· AsmExpressionList: &cc.AsmExpressionList{
· · AssignmentExpression: &cc.PrimaryExpression{
· · · Case: PrimaryExpressionIdent,
· · · Token: example.c:1:16: identifier "a",
· · },
· },
· Token: example.c:1:14: ':' ":",
}

func (*AsmArgList) Position

func (n *AsmArgList) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*AsmArgList) String

func (n *AsmArgList) String() string

String implements fmt.Stringer.

type AsmExpressionList

type AsmExpressionList struct {
	AsmExpressionList    *AsmExpressionList
	AsmIndex             *AsmIndex
	AssignmentExpression ExpressionNode
	Token                Token
}

AsmExpressionList represents data reduced by productions:

AsmExpressionList:
        AsmIndex AssignmentExpression
|       AsmExpressionList ',' AsmIndex AssignmentExpression
Example (Case0)
fmt.Println(exampleAST(256, "__asm__(\"nop\": a);"))
Output:

&cc.AsmExpressionList{
· AssignmentExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:16: identifier "a",
· },
}
Example (Case1)
fmt.Println(exampleAST(257, "__asm__(\"nop\": a, b);"))
Output:

&cc.AsmExpressionList{
· AsmExpressionList: &cc.AsmExpressionList{
· · AssignmentExpression: &cc.PrimaryExpression{
· · · Case: PrimaryExpressionIdent,
· · · Token: example.c:1:19: identifier "b",
· · },
· · Token: example.c:1:17: ',' ",",
· },
· AssignmentExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:16: identifier "a",
· },
}

func (*AsmExpressionList) Position

func (n *AsmExpressionList) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*AsmExpressionList) String

func (n *AsmExpressionList) String() string

String implements fmt.Stringer.

type AsmIndex

type AsmIndex struct {
	ExpressionList ExpressionNode
	Token          Token
	Token2         Token
}

AsmIndex represents data reduced by production:

AsmIndex:
        '[' ExpressionList ']'
Example (Case0)
fmt.Println(exampleAST(255, "__asm__(\"nop\": [a] b);"))
Output:

&cc.AsmIndex{
· ExpressionList: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:17: identifier "a",
· },
· Token: example.c:1:16: '[' "[",
· Token2: example.c:1:18: ']' "]",
}

func (*AsmIndex) Position

func (n *AsmIndex) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*AsmIndex) String

func (n *AsmIndex) String() string

String implements fmt.Stringer.

type AsmQualifier

type AsmQualifier struct {
	Case  AsmQualifierCase `PrettyPrint:"stringer,zero"`
	Token Token
}

AsmQualifier represents data reduced by productions:

AsmQualifier:
        "volatile"  // Case AsmQualifierVolatile
|       "inline"    // Case AsmQualifierInline
|       "goto"      // Case AsmQualifierGoto
Example (Goto)
fmt.Println(exampleAST(264, "__asm__ goto (\"nop\");"))
Output:

&cc.AsmQualifier{
· Case: AsmQualifierGoto,
· Token: example.c:1:9: 'goto' "goto",
}
Example (Inline)
fmt.Println(exampleAST(263, "__asm__ inline (\"nop\");"))
Output:

&cc.AsmQualifier{
· Case: AsmQualifierInline,
· Token: example.c:1:9: 'inline' "inline",
}
Example (Volatile)
fmt.Println(exampleAST(262, "__asm__ volatile (\"nop\");"))
Output:

&cc.AsmQualifier{
· Case: AsmQualifierVolatile,
· Token: example.c:1:9: 'volatile' "volatile",
}

func (*AsmQualifier) Position

func (n *AsmQualifier) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*AsmQualifier) String

func (n *AsmQualifier) String() string

String implements fmt.Stringer.

type AsmQualifierCase

type AsmQualifierCase int

AsmQualifierCase represents case numbers of production AsmQualifier

const (
	AsmQualifierVolatile AsmQualifierCase = iota
	AsmQualifierInline
	AsmQualifierGoto
)

Values of type AsmQualifierCase

func (AsmQualifierCase) String

func (n AsmQualifierCase) String() string

String implements fmt.Stringer

type AsmQualifierList

type AsmQualifierList struct {
	AsmQualifier     *AsmQualifier
	AsmQualifierList *AsmQualifierList
}

AsmQualifierList represents data reduced by productions:

AsmQualifierList:
        AsmQualifier
|       AsmQualifierList AsmQualifier
Example (Case0)
fmt.Println(exampleAST(265, "__asm__ inline (\"nop\");"))
Output:

&cc.AsmQualifierList{
· AsmQualifier: &cc.AsmQualifier{
· · Case: AsmQualifierInline,
· · Token: example.c:1:9: 'inline' "inline",
· },
}
Example (Case1)
fmt.Println(exampleAST(266, "__asm__ inline volatile (\"nop\");"))
Output:

&cc.AsmQualifierList{
· AsmQualifier: &cc.AsmQualifier{
· · Case: AsmQualifierInline,
· · Token: example.c:1:9: 'inline' "inline",
· },
· AsmQualifierList: &cc.AsmQualifierList{
· · AsmQualifier: &cc.AsmQualifier{
· · · Case: AsmQualifierVolatile,
· · · Token: example.c:1:16: 'volatile' "volatile",
· · },
· },
}

func (*AsmQualifierList) Position

func (n *AsmQualifierList) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*AsmQualifierList) String

func (n *AsmQualifierList) String() string

String implements fmt.Stringer.

type AsmStatement

type AsmStatement struct {
	Asm   *Asm
	Token Token
}

AsmStatement represents data reduced by production:

AsmStatement:
        Asm ';'
Example (Case0)
fmt.Println(exampleAST(261, "void f() { __asm__(\"nop\"); }"))
Output:

&cc.AsmStatement{
· Asm: &cc.Asm{
· · Token: example.c:1:12: '__asm__' "__asm__",
· · Token2: example.c:1:19: '(' "(",
· · Token3: example.c:1:20: string literal "\"nop\"",
· · Token4: example.c:1:25: ')' ")",
· },
· Token: example.c:1:26: ';' ";",
}

func (*AsmStatement) Position

func (n *AsmStatement) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*AsmStatement) String

func (n *AsmStatement) String() string

String implements fmt.Stringer.

type AssignmentExpression

type AssignmentExpression struct {
	AssignmentExpression  ExpressionNode
	Case                  AssignmentExpressionCase `PrettyPrint:"stringer,zero"`
	ConditionalExpression ExpressionNode
	Token                 Token
	UnaryExpression       ExpressionNode
	// contains filtered or unexported fields
}

AssignmentExpression represents data reduced by productions:

AssignmentExpression:
        ConditionalExpression                       // Case AssignmentExpressionCond
|       UnaryExpression '=' AssignmentExpression    // Case AssignmentExpressionAssign
|       UnaryExpression "*=" AssignmentExpression   // Case AssignmentExpressionMul
|       UnaryExpression "/=" AssignmentExpression   // Case AssignmentExpressionDiv
|       UnaryExpression "%=" AssignmentExpression   // Case AssignmentExpressionMod
|       UnaryExpression "+=" AssignmentExpression   // Case AssignmentExpressionAdd
|       UnaryExpression "-=" AssignmentExpression   // Case AssignmentExpressionSub
|       UnaryExpression "<<=" AssignmentExpression  // Case AssignmentExpressionLsh
|       UnaryExpression ">>=" AssignmentExpression  // Case AssignmentExpressionRsh
|       UnaryExpression "&=" AssignmentExpression   // Case AssignmentExpressionAnd
|       UnaryExpression "^=" AssignmentExpression   // Case AssignmentExpressionXor
|       UnaryExpression "|=" AssignmentExpression   // Case AssignmentExpressionOr
Example (Add)
fmt.Println(exampleAST(79, "int f() { x += y; }"))
Output:

&cc.AssignmentExpression{
· AssignmentExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:16: identifier "y",
· },
· Case: AssignmentExpressionAdd,
· Token: example.c:1:13: '+=' "+=",
· UnaryExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:11: identifier "x",
· },
}
Example (And)
fmt.Println(exampleAST(83, "int f() { x &= y; }"))
Output:

&cc.AssignmentExpression{
· AssignmentExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:16: identifier "y",
· },
· Case: AssignmentExpressionAnd,
· Token: example.c:1:13: '&=' "&=",
· UnaryExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:11: identifier "x",
· },
}
Example (Assign)
fmt.Println(exampleAST(75, "int f() { x = y; }"))
Output:

&cc.AssignmentExpression{
· AssignmentExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:15: identifier "y",
· },
· Case: AssignmentExpressionAssign,
· Token: example.c:1:13: '=' "=",
· UnaryExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:11: identifier "x",
· },
}
Example (Div)
fmt.Println(exampleAST(77, "int f() { x /= y; }"))
Output:

&cc.AssignmentExpression{
· AssignmentExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:16: identifier "y",
· },
· Case: AssignmentExpressionDiv,
· Token: example.c:1:13: '/=' "/=",
· UnaryExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:11: identifier "x",
· },
}
Example (Lsh)
fmt.Println(exampleAST(81, "int f() { x <<= y; }"))
Output:

&cc.AssignmentExpression{
· AssignmentExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:17: identifier "y",
· },
· Case: AssignmentExpressionLsh,
· Token: example.c:1:13: '<<=' "<<=",
· UnaryExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:11: identifier "x",
· },
}
Example (Mod)
fmt.Println(exampleAST(78, "int f() { x %= y; }"))
Output:

&cc.AssignmentExpression{
· AssignmentExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:16: identifier "y",
· },
· Case: AssignmentExpressionMod,
· Token: example.c:1:13: '%=' "%=",
· UnaryExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:11: identifier "x",
· },
}
Example (Mul)
fmt.Println(exampleAST(76, "int f() { x *= y; }"))
Output:

&cc.AssignmentExpression{
· AssignmentExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:16: identifier "y",
· },
· Case: AssignmentExpressionMul,
· Token: example.c:1:13: '*=' "*=",
· UnaryExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:11: identifier "x",
· },
}
Example (Or)
fmt.Println(exampleAST(85, "int f() { x |= y; }"))
Output:

&cc.AssignmentExpression{
· AssignmentExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:16: identifier "y",
· },
· Case: AssignmentExpressionOr,
· Token: example.c:1:13: '|=' "|=",
· UnaryExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:11: identifier "x",
· },
}
Example (Rsh)
fmt.Println(exampleAST(82, "int f() { x >>= y; }"))
Output:

&cc.AssignmentExpression{
· AssignmentExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:17: identifier "y",
· },
· Case: AssignmentExpressionRsh,
· Token: example.c:1:13: '>>=' ">>=",
· UnaryExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:11: identifier "x",
· },
}
Example (Sub)
fmt.Println(exampleAST(80, "int f() { x -= y; }"))
Output:

&cc.AssignmentExpression{
· AssignmentExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:16: identifier "y",
· },
· Case: AssignmentExpressionSub,
· Token: example.c:1:13: '-=' "-=",
· UnaryExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:11: identifier "x",
· },
}
Example (Xor)
fmt.Println(exampleAST(84, "int f() { x ^= y; }"))
Output:

&cc.AssignmentExpression{
· AssignmentExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:16: identifier "y",
· },
· Case: AssignmentExpressionXor,
· Token: example.c:1:13: '^=' "^=",
· UnaryExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:11: identifier "x",
· },
}

func (*AssignmentExpression) Position

func (n *AssignmentExpression) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*AssignmentExpression) Pure added in v4.6.0

func (p *AssignmentExpression) Pure() bool

Pure implements ExpressionNode.

func (*AssignmentExpression) String

func (n *AssignmentExpression) String() string

String implements fmt.Stringer.

func (AssignmentExpression) Type

func (t AssignmentExpression) Type() Type

Type returns the type of a node or an *InvalidType type value, if the type is unknown/undetermined.

func (AssignmentExpression) Value

func (v AssignmentExpression) Value() Value

Value returns the value of a node or UnknownValue if it is undetermined. The dynamic type of a Value is one of

*ComplexLongDoubleValue
*LongDoubleValue
*UnknownValue
*ZeroValue
Complex128Value
Complex64Value
Float64Value
Int64Value
StringValue
UInt64Value
UTF16StringValue
UTF32StringValue
VoidValue

type AssignmentExpressionCase

type AssignmentExpressionCase int

AssignmentExpressionCase represents case numbers of production AssignmentExpression

const (
	AssignmentExpressionCond AssignmentExpressionCase = iota
	AssignmentExpressionAssign
	AssignmentExpressionMul
	AssignmentExpressionDiv
	AssignmentExpressionMod
	AssignmentExpressionAdd
	AssignmentExpressionSub
	AssignmentExpressionLsh
	AssignmentExpressionRsh
	AssignmentExpressionAnd
	AssignmentExpressionXor
	AssignmentExpressionOr
)

Values of type AssignmentExpressionCase

func (AssignmentExpressionCase) String

func (n AssignmentExpressionCase) String() string

String implements fmt.Stringer

type AtomicTypeSpecifier

type AtomicTypeSpecifier struct {
	Token    Token
	Token2   Token
	Token3   Token
	TypeName *TypeName
}

AtomicTypeSpecifier represents data reduced by production:

AtomicTypeSpecifier:
        "_Atomic" '(' TypeName ')'
Example (Case0)
fmt.Println(exampleAST(161, "_Atomic(int) i;"))
Output:

&cc.AtomicTypeSpecifier{
· Token: example.c:1:1: '_Atomic' "_Atomic",
· Token2: example.c:1:8: '(' "(",
· Token3: example.c:1:12: ')' ")",
· TypeName: &cc.TypeName{
· · SpecifierQualifierList: &cc.SpecifierQualifierList{
· · · Case: SpecifierQualifierListTypeSpec,
· · · TypeSpecifier: &cc.TypeSpecifier{
· · · · Case: TypeSpecifierInt,
· · · · Token: example.c:1:9: 'int' "int",
· · · },
· · },
· },
}

func (*AtomicTypeSpecifier) Position

func (n *AtomicTypeSpecifier) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*AtomicTypeSpecifier) String

func (n *AtomicTypeSpecifier) String() string

String implements fmt.Stringer.

type AttributeSpecifier

type AttributeSpecifier struct {
	AttributeValueList *AttributeValueList
	Token              Token
	Token2             Token
	Token3             Token
	Token4             Token
	Token5             Token
}

AttributeSpecifier represents data reduced by production:

AttributeSpecifier:
        "__attribute__" '(' '(' AttributeValueList ')' ')'
Example (Case0)
fmt.Println(exampleAST(271, "int i __attribute__((a));"))
Output:

&cc.AttributeSpecifier{
· AttributeValueList: &cc.AttributeValueList{
· · AttributeValue: &cc.AttributeValue{
· · · Case: AttributeValueIdent,
· · · Token: example.c:1:22: identifier "a",
· · },
· },
· Token: example.c:1:7: '__attribute__' "__attribute__",
· Token2: example.c:1:20: '(' "(",
· Token3: example.c:1:21: '(' "(",
· Token4: example.c:1:23: ')' ")",
· Token5: example.c:1:24: ')' ")",
}

func (*AttributeSpecifier) Position

func (n *AttributeSpecifier) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*AttributeSpecifier) String

func (n *AttributeSpecifier) String() string

String implements fmt.Stringer.

type AttributeSpecifierList

type AttributeSpecifierList struct {
	AttributeSpecifier     *AttributeSpecifier
	AttributeSpecifierList *AttributeSpecifierList
}

AttributeSpecifierList represents data reduced by productions:

AttributeSpecifierList:
        AttributeSpecifier
|       AttributeSpecifierList AttributeSpecifier
Example (Case0)
fmt.Println(exampleAST(272, "int i __attribute__((a));"))
Output:

&cc.AttributeSpecifierList{
· AttributeSpecifier: &cc.AttributeSpecifier{
· · AttributeValueList: &cc.AttributeValueList{
· · · AttributeValue: &cc.AttributeValue{
· · · · Case: AttributeValueIdent,
· · · · Token: example.c:1:22: identifier "a",
· · · },
· · },
· · Token: example.c:1:7: '__attribute__' "__attribute__",
· · Token2: example.c:1:20: '(' "(",
· · Token3: example.c:1:21: '(' "(",
· · Token4: example.c:1:23: ')' ")",
· · Token5: example.c:1:24: ')' ")",
· },
}
Example (Case1)
fmt.Println(exampleAST(273, "int i __attribute__((a)) __attribute__((b));"))
Output:

&cc.AttributeSpecifierList{
· AttributeSpecifier: &cc.AttributeSpecifier{
· · AttributeValueList: &cc.AttributeValueList{
· · · AttributeValue: &cc.AttributeValue{
· · · · Case: AttributeValueIdent,
· · · · Token: example.c:1:22: identifier "a",
· · · },
· · },
· · Token: example.c:1:7: '__attribute__' "__attribute__",
· · Token2: example.c:1:20: '(' "(",
· · Token3: example.c:1:21: '(' "(",
· · Token4: example.c:1:23: ')' ")",
· · Token5: example.c:1:24: ')' ")",
· },
· AttributeSpecifierList: &cc.AttributeSpecifierList{
· · AttributeSpecifier: &cc.AttributeSpecifier{
· · · AttributeValueList: &cc.AttributeValueList{
· · · · AttributeValue: &cc.AttributeValue{
· · · · · Case: AttributeValueIdent,
· · · · · Token: example.c:1:41: identifier "b",
· · · · },
· · · },
· · · Token: example.c:1:26: '__attribute__' "__attribute__",
· · · Token2: example.c:1:39: '(' "(",
· · · Token3: example.c:1:40: '(' "(",
· · · Token4: example.c:1:42: ')' ")",
· · · Token5: example.c:1:43: ')' ")",
· · },
· },
}

func (*AttributeSpecifierList) Position

func (n *AttributeSpecifierList) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*AttributeSpecifierList) String

func (n *AttributeSpecifierList) String() string

String implements fmt.Stringer.

type AttributeValue

type AttributeValue struct {
	ArgumentExpressionList *ArgumentExpressionList
	Case                   AttributeValueCase `PrettyPrint:"stringer,zero"`
	Token                  Token
	Token2                 Token
	Token3                 Token
}

AttributeValue represents data reduced by productions:

AttributeValue:
        IDENTIFIER                                 // Case AttributeValueIdent
|       IDENTIFIER '(' ArgumentExpressionList ')'  // Case AttributeValueExpr
Example (Expr)
fmt.Println(exampleAST(268, "int i __attribute__((a(b)));"))
Output:

&cc.AttributeValue{
· ArgumentExpressionList: &cc.ArgumentExpressionList{
· · AssignmentExpression: &cc.PrimaryExpression{
· · · Case: PrimaryExpressionIdent,
· · · Token: example.c:1:24: identifier "b",
· · },
· },
· Case: AttributeValueExpr,
· Token: example.c:1:22: identifier "a",
· Token2: example.c:1:23: '(' "(",
· Token3: example.c:1:25: ')' ")",
}
Example (Ident)
fmt.Println(exampleAST(267, "int i __attribute__((a));"))
Output:

&cc.AttributeValue{
· Case: AttributeValueIdent,
· Token: example.c:1:22: identifier "a",
}

func (*AttributeValue) Position

func (n *AttributeValue) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*AttributeValue) String

func (n *AttributeValue) String() string

String implements fmt.Stringer.

type AttributeValueCase

type AttributeValueCase int

AttributeValueCase represents case numbers of production AttributeValue

const (
	AttributeValueIdent AttributeValueCase = iota
	AttributeValueExpr
)

Values of type AttributeValueCase

func (AttributeValueCase) String

func (n AttributeValueCase) String() string

String implements fmt.Stringer

type AttributeValueList

type AttributeValueList struct {
	AttributeValue     *AttributeValue
	AttributeValueList *AttributeValueList
	Token              Token
}

AttributeValueList represents data reduced by productions:

AttributeValueList:
        AttributeValue
|       AttributeValueList ',' AttributeValue
Example (Case0)
fmt.Println(exampleAST(269, "int i __attribute__((a));"))
Output:

&cc.AttributeValueList{
· AttributeValue: &cc.AttributeValue{
· · Case: AttributeValueIdent,
· · Token: example.c:1:22: identifier "a",
· },
}
Example (Case1)
fmt.Println(exampleAST(270, "int i __attribute__((a, b));"))
Output:

&cc.AttributeValueList{
· AttributeValue: &cc.AttributeValue{
· · Case: AttributeValueIdent,
· · Token: example.c:1:22: identifier "a",
· },
· AttributeValueList: &cc.AttributeValueList{
· · AttributeValue: &cc.AttributeValue{
· · · Case: AttributeValueIdent,
· · · Token: example.c:1:25: identifier "b",
· · },
· · Token: example.c:1:23: ',' ",",
· },
}

func (*AttributeValueList) Position

func (n *AttributeValueList) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*AttributeValueList) String

func (n *AttributeValueList) String() string

String implements fmt.Stringer.

type Attributes

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

Attributes represent selected values from __attribute__ constructs, qualifiers etc.

See also https://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html

func (*Attributes) Alias

func (n *Attributes) Alias() string

Alias returns S from __attribute__((alias("S"))) or "" if not present.

func (*Attributes) AliasDecl added in v4.8.0

func (n *Attributes) AliasDecl() *Declarator

AliasDecl returns the declarator, if any, named in __attribute__((alias("S"))) or nil if not present.

func (*Attributes) Aligned

func (n *Attributes) Aligned() int64

Aligned returns N from __attribute__((aligned(N)) or -1 if not present/valid.

func (*Attributes) AlwaysInline added in v4.15.0

func (n *Attributes) AlwaysInline() bool

AlwaysInline reports whether __attribute__((__always_inline__)) is present.

func (*Attributes) AttrValue added in v4.12.1

func (n *Attributes) AttrValue(name string) []Value

AttrValue reports the value associated with a custom attribute, if present. For example, with __attribute__((my_attribute1, my_attribute2(42))), it reports nil for my_attribute1 but a Value containing 42 for my_attribute2

func (*Attributes) GNUInline added in v4.15.0

func (n *Attributes) GNUInline() bool

GNUInline reports whether __attribute__((__gnu_inline__)) is present.

func (*Attributes) IsAttrSet added in v4.12.1

func (n *Attributes) IsAttrSet(name string) bool

IsAttrSet reports whether an attribute has been set, with or without value. For example, with __attribute__((my_attribute1, my_attribute2(42))), it reports true for both my_attribute1 and my_attribute2

func (*Attributes) IsConst added in v4.18.0

func (n *Attributes) IsConst() bool

IsConst reports if a type is qualified by the 'const' keyword.

func (*Attributes) IsVolatile added in v4.12.0

func (n *Attributes) IsVolatile() bool

IsVolatile reports if a type is qualified by the 'volatile' keyword.

func (*Attributes) VectorSize

func (n *Attributes) VectorSize() int64

VectorSize returns N from __attribute__((vector_size(N)) or -1 if not present/valid.

The vector_size attribute is only applicable to integral and floating scalars, otherwise it's ignored.

func (*Attributes) Visibility added in v4.11.0

func (n *Attributes) Visibility() string

Visibility returns S from __attribute__((visibility("S"))) or "" if not present.

func (*Attributes) VisibilityDecl added in v4.11.0

func (n *Attributes) VisibilityDecl() *Declarator

VisibilityDecl returns the declarator, if any, named in __attribute__((visibility("S"))) or nil if not present.

func (*Attributes) Weak added in v4.5.2

func (n *Attributes) Weak() bool

Weak reports whether 'weak', as in __attribute__((weak, alias("S"))), is present.

type BlockItem

type BlockItem struct {
	Case                  BlockItemCase `PrettyPrint:"stringer,zero"`
	CompoundStatement     *CompoundStatement
	Declaration           *Declaration
	DeclarationSpecifiers *DeclarationSpecifiers
	Declarator            *Declarator
	LabelDeclaration      *LabelDeclaration
	Statement             *Statement
}

BlockItem represents data reduced by productions:

BlockItem:
        Declaration                                         // Case BlockItemDecl
|       LabelDeclaration                                    // Case BlockItemLabel
|       Statement                                           // Case BlockItemStmt
|       DeclarationSpecifiers Declarator CompoundStatement  // Case BlockItemFuncDef
Example (Decl)
fmt.Println(exampleAST(229, "int f() { int i; }"))
Output:

&cc.BlockItem{
· Case: BlockItemDecl,
· Declaration: &cc.Declaration{
· · Case: DeclarationDecl,
· · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · Case: DeclarationSpecifiersStorage,
· · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · Case: DeclarationSpecifiersTypeQual,
· · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · Case: DeclarationSpecifiersTypeSpec,
· · · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · · Case: TypeSpecifierChar,
· · · · · · Token: example.c:1:9: 'char' "char",
· · · · · },
· · · · },
· · · · TypeQualifier: &cc.TypeQualifier{
· · · · · Case: TypeQualifierConst,
· · · · · Token: example.c:1:9: 'const' "const",
· · · · },
· · · },
· · · StorageClassSpecifier: &cc.StorageClassSpecifier{
· · · · Case: StorageClassSpecifierStatic,
· · · · Token: example.c:1:9: 'static' "static",
· · · },
· · },
· · InitDeclaratorList: &cc.InitDeclaratorList{
· · · InitDeclarator: &cc.InitDeclarator{
· · · · Case: InitDeclaratorInit,
· · · · Declarator: &cc.Declarator{
· · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · Case: DirectDeclaratorArr,
· · · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · · Case: DirectDeclaratorIdent,
· · · · · · · Token: example.c:1:9: identifier "__func__",
· · · · · · },
· · · · · · Token: example.c:1:9: '[' "[",
· · · · · · Token2: example.c:1:9: ']' "]",
· · · · · },
· · · · },
· · · · Initializer: &cc.Initializer{
· · · · · AssignmentExpression: &cc.PrimaryExpression{
· · · · · · Case: PrimaryExpressionString,
· · · · · · Token: example.c:1:9: string literal "\"f\"",
· · · · · },
· · · · · Case: InitializerExpr,
· · · · },
· · · · Token: example.c:1:9: '=' "=",
· · · },
· · },
· · Token: example.c:1:9: ';' ";",
· },
}
Example (FuncDef)
fmt.Println(exampleAST(232, "int f() { int g() {} }"))
Output:

&cc.BlockItem{
· Case: BlockItemDecl,
· Declaration: &cc.Declaration{
· · Case: DeclarationDecl,
· · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · Case: DeclarationSpecifiersStorage,
· · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · Case: DeclarationSpecifiersTypeQual,
· · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · Case: DeclarationSpecifiersTypeSpec,
· · · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · · Case: TypeSpecifierChar,
· · · · · · Token: example.c:1:9: 'char' "char",
· · · · · },
· · · · },
· · · · TypeQualifier: &cc.TypeQualifier{
· · · · · Case: TypeQualifierConst,
· · · · · Token: example.c:1:9: 'const' "const",
· · · · },
· · · },
· · · StorageClassSpecifier: &cc.StorageClassSpecifier{
· · · · Case: StorageClassSpecifierStatic,
· · · · Token: example.c:1:9: 'static' "static",
· · · },
· · },
· · InitDeclaratorList: &cc.InitDeclaratorList{
· · · InitDeclarator: &cc.InitDeclarator{
· · · · Case: InitDeclaratorInit,
· · · · Declarator: &cc.Declarator{
· · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · Case: DirectDeclaratorArr,
· · · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · · Case: DirectDeclaratorIdent,
· · · · · · · Token: example.c:1:9: identifier "__func__",
· · · · · · },
· · · · · · Token: example.c:1:9: '[' "[",
· · · · · · Token2: example.c:1:9: ']' "]",
· · · · · },
· · · · },
· · · · Initializer: &cc.Initializer{
· · · · · AssignmentExpression: &cc.PrimaryExpression{
· · · · · · Case: PrimaryExpressionString,
· · · · · · Token: example.c:1:9: string literal "\"f\"",
· · · · · },
· · · · · Case: InitializerExpr,
· · · · },
· · · · Token: example.c:1:9: '=' "=",
· · · },
· · },
· · Token: example.c:1:9: ';' ";",
· },
}
Example (Label)
fmt.Println(exampleAST(230, "int f() { __label__ L; int i; }"))
Output:

&cc.BlockItem{
· Case: BlockItemDecl,
· Declaration: &cc.Declaration{
· · Case: DeclarationDecl,
· · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · Case: DeclarationSpecifiersStorage,
· · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · Case: DeclarationSpecifiersTypeQual,
· · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · Case: DeclarationSpecifiersTypeSpec,
· · · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · · Case: TypeSpecifierChar,
· · · · · · Token: example.c:1:9: 'char' "char",
· · · · · },
· · · · },
· · · · TypeQualifier: &cc.TypeQualifier{
· · · · · Case: TypeQualifierConst,
· · · · · Token: example.c:1:9: 'const' "const",
· · · · },
· · · },
· · · StorageClassSpecifier: &cc.StorageClassSpecifier{
· · · · Case: StorageClassSpecifierStatic,
· · · · Token: example.c:1:9: 'static' "static",
· · · },
· · },
· · InitDeclaratorList: &cc.InitDeclaratorList{
· · · InitDeclarator: &cc.InitDeclarator{
· · · · Case: InitDeclaratorInit,
· · · · Declarator: &cc.Declarator{
· · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · Case: DirectDeclaratorArr,
· · · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · · Case: DirectDeclaratorIdent,
· · · · · · · Token: example.c:1:9: identifier "__func__",
· · · · · · },
· · · · · · Token: example.c:1:9: '[' "[",
· · · · · · Token2: example.c:1:9: ']' "]",
· · · · · },
· · · · },
· · · · Initializer: &cc.Initializer{
· · · · · AssignmentExpression: &cc.PrimaryExpression{
· · · · · · Case: PrimaryExpressionString,
· · · · · · Token: example.c:1:9: string literal "\"f\"",
· · · · · },
· · · · · Case: InitializerExpr,
· · · · },
· · · · Token: example.c:1:9: '=' "=",
· · · },
· · },
· · Token: example.c:1:9: ';' ";",
· },
}
Example (Stmt)
fmt.Println(exampleAST(231, "int f() { g(); }"))
Output:

&cc.BlockItem{
· Case: BlockItemDecl,
· Declaration: &cc.Declaration{
· · Case: DeclarationDecl,
· · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · Case: DeclarationSpecifiersStorage,
· · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · Case: DeclarationSpecifiersTypeQual,
· · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · Case: DeclarationSpecifiersTypeSpec,
· · · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · · Case: TypeSpecifierChar,
· · · · · · Token: example.c:1:9: 'char' "char",
· · · · · },
· · · · },
· · · · TypeQualifier: &cc.TypeQualifier{
· · · · · Case: TypeQualifierConst,
· · · · · Token: example.c:1:9: 'const' "const",
· · · · },
· · · },
· · · StorageClassSpecifier: &cc.StorageClassSpecifier{
· · · · Case: StorageClassSpecifierStatic,
· · · · Token: example.c:1:9: 'static' "static",
· · · },
· · },
· · InitDeclaratorList: &cc.InitDeclaratorList{
· · · InitDeclarator: &cc.InitDeclarator{
· · · · Case: InitDeclaratorInit,
· · · · Declarator: &cc.Declarator{
· · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · Case: DirectDeclaratorArr,
· · · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · · Case: DirectDeclaratorIdent,
· · · · · · · Token: example.c:1:9: identifier "__func__",
· · · · · · },
· · · · · · Token: example.c:1:9: '[' "[",
· · · · · · Token2: example.c:1:9: ']' "]",
· · · · · },
· · · · },
· · · · Initializer: &cc.Initializer{
· · · · · AssignmentExpression: &cc.PrimaryExpression{
· · · · · · Case: PrimaryExpressionString,
· · · · · · Token: example.c:1:9: string literal "\"f\"",
· · · · · },
· · · · · Case: InitializerExpr,
· · · · },
· · · · Token: example.c:1:9: '=' "=",
· · · },
· · },
· · Token: example.c:1:9: ';' ";",
· },
}

func (*BlockItem) Position

func (n *BlockItem) Position() (r token.Position)

Position reports the position of the first component of n, if available.

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
	BlockItemLabel
	BlockItemStmt
	BlockItemFuncDef
)

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
}

BlockItemList represents data reduced by productions:

BlockItemList:
        BlockItem
|       BlockItemList BlockItem
Example (Case0)
fmt.Println(exampleAST(227, "int f() { int i; }"))
Output:

&cc.BlockItemList{
· BlockItem: &cc.BlockItem{
· · Case: BlockItemDecl,
· · Declaration: &cc.Declaration{
· · · Case: DeclarationDecl,
· · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · Case: DeclarationSpecifiersStorage,
· · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · Case: DeclarationSpecifiersTypeQual,
· · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · · Case: DeclarationSpecifiersTypeSpec,
· · · · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · · · Case: TypeSpecifierChar,
· · · · · · · Token: example.c:1:9: 'char' "char",
· · · · · · },
· · · · · },
· · · · · TypeQualifier: &cc.TypeQualifier{
· · · · · · Case: TypeQualifierConst,
· · · · · · Token: example.c:1:9: 'const' "const",
· · · · · },
· · · · },
· · · · StorageClassSpecifier: &cc.StorageClassSpecifier{
· · · · · Case: StorageClassSpecifierStatic,
· · · · · Token: example.c:1:9: 'static' "static",
· · · · },
· · · },
· · · InitDeclaratorList: &cc.InitDeclaratorList{
· · · · InitDeclarator: &cc.InitDeclarator{
· · · · · Case: InitDeclaratorInit,
· · · · · Declarator: &cc.Declarator{
· · · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · · Case: DirectDeclaratorArr,
· · · · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · · · Case: DirectDeclaratorIdent,
· · · · · · · · Token: example.c:1:9: identifier "__func__",
· · · · · · · },
· · · · · · · Token: example.c:1:9: '[' "[",
· · · · · · · Token2: example.c:1:9: ']' "]",
· · · · · · },
· · · · · },
· · · · · Initializer: &cc.Initializer{
· · · · · · AssignmentExpression: &cc.PrimaryExpression{
· · · · · · · Case: PrimaryExpressionString,
· · · · · · · Token: example.c:1:9: string literal "\"f\"",
· · · · · · },
· · · · · · Case: InitializerExpr,
· · · · · },
· · · · · Token: example.c:1:9: '=' "=",
· · · · },
· · · },
· · · Token: example.c:1:9: ';' ";",
· · },
· },
· BlockItemList: &cc.BlockItemList{
· · BlockItem: &cc.BlockItem{
· · · Case: BlockItemDecl,
· · · Declaration: &cc.Declaration{
· · · · Case: DeclarationDecl,
· · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · Case: DeclarationSpecifiersTypeSpec,
· · · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · · Case: TypeSpecifierInt,
· · · · · · Token: example.c:1:11: 'int' "int",
· · · · · },
· · · · },
· · · · InitDeclaratorList: &cc.InitDeclaratorList{
· · · · · InitDeclarator: &cc.InitDeclarator{
· · · · · · Case: InitDeclaratorDecl,
· · · · · · Declarator: &cc.Declarator{
· · · · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · · · Case: DirectDeclaratorIdent,
· · · · · · · · Token: example.c:1:15: identifier "i",
· · · · · · · },
· · · · · · },
· · · · · },
· · · · },
· · · · Token: example.c:1:16: ';' ";",
· · · },
· · },
· },
}
Example (Case1)
fmt.Println(exampleAST(228, "int f() { int i; double j; }"))
Output:

&cc.BlockItemList{
· BlockItem: &cc.BlockItem{
· · Case: BlockItemDecl,
· · Declaration: &cc.Declaration{
· · · Case: DeclarationDecl,
· · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · Case: DeclarationSpecifiersStorage,
· · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · Case: DeclarationSpecifiersTypeQual,
· · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · · Case: DeclarationSpecifiersTypeSpec,
· · · · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · · · Case: TypeSpecifierChar,
· · · · · · · Token: example.c:1:9: 'char' "char",
· · · · · · },
· · · · · },
· · · · · TypeQualifier: &cc.TypeQualifier{
· · · · · · Case: TypeQualifierConst,
· · · · · · Token: example.c:1:9: 'const' "const",
· · · · · },
· · · · },
· · · · StorageClassSpecifier: &cc.StorageClassSpecifier{
· · · · · Case: StorageClassSpecifierStatic,
· · · · · Token: example.c:1:9: 'static' "static",
· · · · },
· · · },
· · · InitDeclaratorList: &cc.InitDeclaratorList{
· · · · InitDeclarator: &cc.InitDeclarator{
· · · · · Case: InitDeclaratorInit,
· · · · · Declarator: &cc.Declarator{
· · · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · · Case: DirectDeclaratorArr,
· · · · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · · · Case: DirectDeclaratorIdent,
· · · · · · · · Token: example.c:1:9: identifier "__func__",
· · · · · · · },
· · · · · · · Token: example.c:1:9: '[' "[",
· · · · · · · Token2: example.c:1:9: ']' "]",
· · · · · · },
· · · · · },
· · · · · Initializer: &cc.Initializer{
· · · · · · AssignmentExpression: &cc.PrimaryExpression{
· · · · · · · Case: PrimaryExpressionString,
· · · · · · · Token: example.c:1:9: string literal "\"f\"",
· · · · · · },
· · · · · · Case: InitializerExpr,
· · · · · },
· · · · · Token: example.c:1:9: '=' "=",
· · · · },
· · · },
· · · Token: example.c:1:9: ';' ";",
· · },
· },
· BlockItemList: &cc.BlockItemList{
· · BlockItem: &cc.BlockItem{
· · · Case: BlockItemDecl,
· · · Declaration: &cc.Declaration{
· · · · Case: DeclarationDecl,
· · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · Case: DeclarationSpecifiersTypeSpec,
· · · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · · Case: TypeSpecifierInt,
· · · · · · Token: example.c:1:11: 'int' "int",
· · · · · },
· · · · },
· · · · InitDeclaratorList: &cc.InitDeclaratorList{
· · · · · InitDeclarator: &cc.InitDeclarator{
· · · · · · Case: InitDeclaratorDecl,
· · · · · · Declarator: &cc.Declarator{
· · · · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · · · Case: DirectDeclaratorIdent,
· · · · · · · · Token: example.c:1:15: identifier "i",
· · · · · · · },
· · · · · · },
· · · · · },
· · · · },
· · · · Token: example.c:1:16: ';' ";",
· · · },
· · },
· · BlockItemList: &cc.BlockItemList{
· · · BlockItem: &cc.BlockItem{
· · · · Case: BlockItemDecl,
· · · · Declaration: &cc.Declaration{
· · · · · Case: DeclarationDecl,
· · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · · Case: DeclarationSpecifiersTypeSpec,
· · · · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · · · Case: TypeSpecifierDouble,
· · · · · · · Token: example.c:1:18: 'double' "double",
· · · · · · },
· · · · · },
· · · · · InitDeclaratorList: &cc.InitDeclaratorList{
· · · · · · InitDeclarator: &cc.InitDeclarator{
· · · · · · · Case: InitDeclaratorDecl,
· · · · · · · Declarator: &cc.Declarator{
· · · · · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · · · · Case: DirectDeclaratorIdent,
· · · · · · · · · Token: example.c:1:25: identifier "j",
· · · · · · · · },
· · · · · · · },
· · · · · · },
· · · · · },
· · · · · Token: example.c:1:26: ';' ";",
· · · · },
· · · },
· · },
· },
}

func (*BlockItemList) Position

func (n *BlockItemList) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*BlockItemList) String

func (n *BlockItemList) String() string

String implements fmt.Stringer.

type CastExpression

type CastExpression struct {
	Case            CastExpressionCase `PrettyPrint:"stringer,zero"`
	CastExpression  ExpressionNode
	Token           Token
	Token2          Token
	TypeName        *TypeName
	UnaryExpression ExpressionNode
	// contains filtered or unexported fields
}

CastExpression represents data reduced by productions:

CastExpression:
        UnaryExpression                  // Case CastExpressionUnary
|       '(' TypeName ')' CastExpression  // Case CastExpressionCast
Example (Cast)
fmt.Println(exampleAST(43, "int i = (__attribute__((a)) int)3.14;"))
Output:

&cc.CastExpression{
· Case: CastExpressionCast,
· CastExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionFloat,
· · Token: example.c:1:33: floating point constant "3.14",
· },
· Token: example.c:1:9: '(' "(",
· Token2: example.c:1:32: ')' ")",
· TypeName: &cc.TypeName{
· · SpecifierQualifierList: &cc.SpecifierQualifierList{
· · · Case: SpecifierQualifierListTypeQual,
· · · SpecifierQualifierList: &cc.SpecifierQualifierList{
· · · · Case: SpecifierQualifierListTypeSpec,
· · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · Case: TypeSpecifierInt,
· · · · · Token: example.c:1:29: 'int' "int",
· · · · },
· · · },
· · · TypeQualifier: &cc.TypeQualifier{
· · · · AttributeSpecifierList: &cc.AttributeSpecifierList{
· · · · · AttributeSpecifier: &cc.AttributeSpecifier{
· · · · · · AttributeValueList: &cc.AttributeValueList{
· · · · · · · AttributeValue: &cc.AttributeValue{
· · · · · · · · Case: AttributeValueIdent,
· · · · · · · · Token: example.c:1:25: identifier "a",
· · · · · · · },
· · · · · · },
· · · · · · Token: example.c:1:10: '__attribute__' "__attribute__",
· · · · · · Token2: example.c:1:23: '(' "(",
· · · · · · Token3: example.c:1:24: '(' "(",
· · · · · · Token4: example.c:1:26: ')' ")",
· · · · · · Token5: example.c:1:27: ')' ")",
· · · · · },
· · · · },
· · · · Case: TypeQualifierAttr,
· · · },
· · },
· },
}

func (*CastExpression) Position

func (n *CastExpression) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*CastExpression) Pure added in v4.6.0

func (p *CastExpression) Pure() bool

Pure implements ExpressionNode.

func (*CastExpression) String

func (n *CastExpression) String() string

String implements fmt.Stringer.

func (CastExpression) Type

func (t CastExpression) Type() Type

Type returns the type of a node or an *InvalidType type value, if the type is unknown/undetermined.

func (CastExpression) Value

func (v CastExpression) Value() Value

Value returns the value of a node or UnknownValue if it is undetermined. The dynamic type of a Value is one of

*ComplexLongDoubleValue
*LongDoubleValue
*UnknownValue
*ZeroValue
Complex128Value
Complex64Value
Float64Value
Int64Value
StringValue
UInt64Value
UTF16StringValue
UTF32StringValue
VoidValue

type CastExpressionCase

type CastExpressionCase int

CastExpressionCase represents case numbers of production CastExpression

const (
	CastExpressionUnary CastExpressionCase = iota
	CastExpressionCast
)

Values of type CastExpressionCase

func (CastExpressionCase) String

func (n CastExpressionCase) String() string

String implements fmt.Stringer

type Complex128Value

type Complex128Value complex128

func (Complex128Value) Convert

func (n Complex128Value) Convert(to Type) Value

type Complex64Value

type Complex64Value complex64

func (Complex64Value) Convert

func (n Complex64Value) Convert(to Type) Value

type ComplexLongDoubleValue

type ComplexLongDoubleValue struct {
	Re *LongDoubleValue
	Im *LongDoubleValue
}

func (*ComplexLongDoubleValue) Convert

func (n *ComplexLongDoubleValue) Convert(to Type) Value

type CompoundStatement

type CompoundStatement struct {
	BlockItemList *BlockItemList
	Token         Token
	Token2        Token
	// contains filtered or unexported fields
}

CompoundStatement represents data reduced by production:

CompoundStatement:
        '{' BlockItemList '}'
Example (Case0)
fmt.Println(exampleAST(225, "int f() { __label__ L; int i; }"))
Output:

&cc.CompoundStatement{
· BlockItemList: &cc.BlockItemList{
· · BlockItem: &cc.BlockItem{
· · · Case: BlockItemDecl,
· · · Declaration: &cc.Declaration{
· · · · Case: DeclarationDecl,
· · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · Case: DeclarationSpecifiersStorage,
· · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · · Case: DeclarationSpecifiersTypeQual,
· · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · · · Case: DeclarationSpecifiersTypeSpec,
· · · · · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · · · · Case: TypeSpecifierChar,
· · · · · · · · Token: example.c:1:9: 'char' "char",
· · · · · · · },
· · · · · · },
· · · · · · TypeQualifier: &cc.TypeQualifier{
· · · · · · · Case: TypeQualifierConst,
· · · · · · · Token: example.c:1:9: 'const' "const",
· · · · · · },
· · · · · },
· · · · · StorageClassSpecifier: &cc.StorageClassSpecifier{
· · · · · · Case: StorageClassSpecifierStatic,
· · · · · · Token: example.c:1:9: 'static' "static",
· · · · · },
· · · · },
· · · · InitDeclaratorList: &cc.InitDeclaratorList{
· · · · · InitDeclarator: &cc.InitDeclarator{
· · · · · · Case: InitDeclaratorInit,
· · · · · · Declarator: &cc.Declarator{
· · · · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · · · Case: DirectDeclaratorArr,
· · · · · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · · · · Case: DirectDeclaratorIdent,
· · · · · · · · · Token: example.c:1:9: identifier "__func__",
· · · · · · · · },
· · · · · · · · Token: example.c:1:9: '[' "[",
· · · · · · · · Token2: example.c:1:9: ']' "]",
· · · · · · · },
· · · · · · },
· · · · · · Initializer: &cc.Initializer{
· · · · · · · AssignmentExpression: &cc.PrimaryExpression{
· · · · · · · · Case: PrimaryExpressionString,
· · · · · · · · Token: example.c:1:9: string literal "\"f\"",
· · · · · · · },
· · · · · · · Case: InitializerExpr,
· · · · · · },
· · · · · · Token: example.c:1:9: '=' "=",
· · · · · },
· · · · },
· · · · Token: example.c:1:9: ';' ";",
· · · },
· · },
· · BlockItemList: &cc.BlockItemList{
· · · BlockItem: &cc.BlockItem{
· · · · Case: BlockItemLabel,
· · · · LabelDeclaration: &cc.LabelDeclaration{
· · · · · IdentifierList: &cc.IdentifierList{
· · · · · · Token2: example.c:1:21: identifier "L",
· · · · · },
· · · · · Token: example.c:1:11: '__label__' "__label__",
· · · · · Token2: example.c:1:22: ';' ";",
· · · · },
· · · },
· · · BlockItemList: &cc.BlockItemList{
· · · · BlockItem: &cc.BlockItem{
· · · · · Case: BlockItemDecl,
· · · · · Declaration: &cc.Declaration{
· · · · · · Case: DeclarationDecl,
· · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · · · Case: DeclarationSpecifiersTypeSpec,
· · · · · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · · · · Case: TypeSpecifierInt,
· · · · · · · · Token: example.c:1:24: 'int' "int",
· · · · · · · },
· · · · · · },
· · · · · · InitDeclaratorList: &cc.InitDeclaratorList{
· · · · · · · InitDeclarator: &cc.InitDeclarator{
· · · · · · · · Case: InitDeclaratorDecl,
· · · · · · · · Declarator: &cc.Declarator{
· · · · · · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · · · · · Case: DirectDeclaratorIdent,
· · · · · · · · · · Token: example.c:1:28: identifier "i",
· · · · · · · · · },
· · · · · · · · },
· · · · · · · },
· · · · · · },
· · · · · · Token: example.c:1:29: ';' ";",
· · · · · },
· · · · },
· · · },
· · },
· },
· Token: example.c:1:9: '{' "{",
· Token2: example.c:1:31: '}' "}",
}

func (*CompoundStatement) Gotos

func (n *CompoundStatement) Gotos() []*JumpStatement

Gotos returns a slice of all goto statements in n if n is a function block.

func (CompoundStatement) LexicalScope

func (n CompoundStatement) LexicalScope() *Scope

LexicalScope provides the scope a node appears in.

func (*CompoundStatement) Position

func (n *CompoundStatement) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*CompoundStatement) String

func (n *CompoundStatement) String() string

String implements fmt.Stringer.

type ConditionalExpression

type ConditionalExpression struct {
	Case                  ConditionalExpressionCase `PrettyPrint:"stringer,zero"`
	ConditionalExpression ExpressionNode
	ExpressionList        ExpressionNode
	LogicalOrExpression   ExpressionNode
	Token                 Token
	Token2                Token
	// contains filtered or unexported fields
}

ConditionalExpression represents data reduced by productions:

ConditionalExpression:
        LogicalOrExpression                                               // Case ConditionalExpressionLOr
|       LogicalOrExpression '?' ExpressionList ':' ConditionalExpression  // Case ConditionalExpressionCond
Example (Cond)
fmt.Println(exampleAST(73, "int i = x ? y : z;"))
Output:

&cc.ConditionalExpression{
· Case: ConditionalExpressionCond,
· ConditionalExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:17: identifier "z",
· },
· ExpressionList: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:13: identifier "y",
· },
· LogicalOrExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:9: identifier "x",
· },
· Token: example.c:1:11: '?' "?",
· Token2: example.c:1:15: ':' ":",
}

func (*ConditionalExpression) Position

func (n *ConditionalExpression) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*ConditionalExpression) Pure added in v4.6.0

func (p *ConditionalExpression) Pure() bool

Pure implements ExpressionNode.

func (*ConditionalExpression) String

func (n *ConditionalExpression) String() string

String implements fmt.Stringer.

func (ConditionalExpression) Type

func (t ConditionalExpression) Type() Type

Type returns the type of a node or an *InvalidType type value, if the type is unknown/undetermined.

func (ConditionalExpression) Value

func (v ConditionalExpression) Value() Value

Value returns the value of a node or UnknownValue if it is undetermined. The dynamic type of a Value is one of

*ComplexLongDoubleValue
*LongDoubleValue
*UnknownValue
*ZeroValue
Complex128Value
Complex64Value
Float64Value
Int64Value
StringValue
UInt64Value
UTF16StringValue
UTF32StringValue
VoidValue

type ConditionalExpressionCase

type ConditionalExpressionCase int

ConditionalExpressionCase represents case numbers of production ConditionalExpression

const (
	ConditionalExpressionLOr ConditionalExpressionCase = iota
	ConditionalExpressionCond
)

Values of type ConditionalExpressionCase

func (ConditionalExpressionCase) String

func (n ConditionalExpressionCase) String() string

String implements fmt.Stringer

type Config

type Config struct {
	ABI                 *ABI
	CC                  string // The configured C compiler, filled by NewConfig.
	FS                  fs.FS
	HostIncludePaths    []string
	HostSysIncludePaths []string
	IncludePaths        []string
	PragmaHandler       func([]Token) error
	Predefined          string // The predefined macros from CC, filled by NewConfig.
	SysIncludePaths     []string

	// Default cc.Kinds for types the type checker cannot work without. Used only
	// when the type is not defined already but needed. Must be an integer type or
	// zero (= cc.InvalidKind). The last fallback is C int.
	DefaultSizeT    Kind
	DefaultPtrdiffT Kind
	DefaultWcharT   Kind

	// EvalAllMacros enables attempt to assign a value to all object-like, constant macros.
	EvalAllMacros bool
	// Header disables type checking of function bodies.
	Header bool
	// GCC compatibility: enums with no negative values will have unsigned type.
	UnsignedEnums bool
	// contains filtered or unexported fields
}

Config configures the preprocessor, parser and type checker.

Search paths listed in IncludePaths and SysIncludePaths are used to resolve #include "foo.h" and #include <foo.h> preprocessing directives respectively. A special search path "@" or "" is interpreted as 'the same directory as where the file with the #include "foo" directive is'.

If FS is nil, os.Open is used to open named files.

func NewConfig

func NewConfig(goos, goarch string, opts ...string) (r *Config, err error)

NewConfig returns the system C compiler configuration, or an error, if any. The function will look for the compiler first in the environment variable CC, then it'll try other options. Usually that means looking for the "cc" and "gcc" binary, in that order.

Additional arguments (flags) in opts are passed to the system C compiler unchanged. For example, the _REENTRANT preprocessor macro is defined when the -pthread flag is present. The set of recognized keywords is adjusted to emulate gcc, see:

https://gcc.gnu.org/onlinedocs/gcc/Alternate-Keywords.html#Alternate-Keywords

Execution of NewConfig is expensive, caching the results is recommended wherever possible.

If goos or goarch are empty, the current OS and architecture are used.

func (*Config) AdjustLongDouble added in v4.5.0

func (c *Config) AdjustLongDouble() error

AdjustLongDouble will force C long double to have the same size as Go float64 and C complex long double as Go complex128.

type ConstantExpression

type ConstantExpression struct {
	ConditionalExpression ExpressionNode
	// contains filtered or unexported fields
}

ConstantExpression represents data reduced by production:

ConstantExpression:
        ConditionalExpression
Example (Case0)
fmt.Println(exampleAST(88, "struct { int i:3; };"))
Output:

&cc.ConstantExpression{
· ConditionalExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionInt,
· · Token: example.c:1:16: integer constant "3",
· },
}

func (*ConstantExpression) Position

func (n *ConstantExpression) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*ConstantExpression) Pure added in v4.6.0

func (p *ConstantExpression) Pure() bool

Pure implements ExpressionNode.

func (*ConstantExpression) String

func (n *ConstantExpression) String() string

String implements fmt.Stringer.

func (ConstantExpression) Type

func (t ConstantExpression) Type() Type

Type returns the type of a node or an *InvalidType type value, if the type is unknown/undetermined.

func (ConstantExpression) Value

func (v ConstantExpression) Value() Value

Value returns the value of a node or UnknownValue if it is undetermined. The dynamic type of a Value is one of

*ComplexLongDoubleValue
*LongDoubleValue
*UnknownValue
*ZeroValue
Complex128Value
Complex64Value
Float64Value
Int64Value
StringValue
UInt64Value
UTF16StringValue
UTF32StringValue
VoidValue

type Declaration

type Declaration struct {
	AttributeSpecifierList  *AttributeSpecifierList
	Case                    DeclarationCase `PrettyPrint:"stringer,zero"`
	DeclarationSpecifiers   *DeclarationSpecifiers
	Declarator              *Declarator
	InitDeclaratorList      *InitDeclaratorList
	Initializer             *Initializer
	StaticAssertDeclaration *StaticAssertDeclaration
	Token                   Token
	Token2                  Token
	Token3                  Token
}

Declaration represents data reduced by productions:

Declaration:
        DeclarationSpecifiers InitDeclaratorList AttributeSpecifierList ';'  // Case DeclarationDecl
|       StaticAssertDeclaration                                              // Case DeclarationAssert
|       "__auto_type" Declarator '=' Initializer ';'                         // Case DeclarationAuto
Example (Assert)
fmt.Println(exampleAST(90, "_Static_assert(x > y, \"abc\")"))
Output:

&cc.Declaration{
· Case: DeclarationAssert,
· StaticAssertDeclaration: &cc.StaticAssertDeclaration{
· · ConstantExpression: &cc.ConstantExpression{
· · · ConditionalExpression: &cc.RelationalExpression{
· · · · Case: RelationalExpressionGt,
· · · · RelationalExpression: &cc.PrimaryExpression{
· · · · · Case: PrimaryExpressionIdent,
· · · · · Token: example.c:1:16: identifier "x",
· · · · },
· · · · ShiftExpression: &cc.PrimaryExpression{
· · · · · Case: PrimaryExpressionIdent,
· · · · · Token: example.c:1:20: identifier "y",
· · · · },
· · · · Token: example.c:1:18: '>' ">",
· · · },
· · },
· · Token: example.c:1:1: _Static_assert "_Static_assert",
· · Token2: example.c:1:15: '(' "(",
· · Token3: example.c:1:21: ',' ",",
· · Token4: example.c:1:23: string literal "\"abc\"",
· · Token5: example.c:1:28: ')' ")",
· },
}
Example (Auto)
fmt.Println(exampleAST(91, "__auto_type x = y;"))
Output:

&cc.Declaration{
· Case: DeclarationAuto,
· Declarator: &cc.Declarator{
· · DirectDeclarator: &cc.DirectDeclarator{
· · · Case: DirectDeclaratorIdent,
· · · Token: example.c:1:13: identifier "x",
· · },
· },
· Initializer: &cc.Initializer{
· · AssignmentExpression: &cc.PrimaryExpression{
· · · Case: PrimaryExpressionIdent,
· · · Token: example.c:1:17: identifier "y",
· · },
· · Case: InitializerExpr,
· },
· Token: example.c:1:1: '__auto_type' "__auto_type",
· Token2: example.c:1:15: '=' "=",
· Token3: example.c:1:18: ';' ";",
}
Example (Decl)
fmt.Println(exampleAST(89, "int i, j __attribute__((a));"))
Output:

&cc.Declaration{
· Case: DeclarationDecl,
· DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · Case: DeclarationSpecifiersTypeSpec,
· · TypeSpecifier: &cc.TypeSpecifier{
· · · Case: TypeSpecifierInt,
· · · Token: example.c:1:1: 'int' "int",
· · },
· },
· InitDeclaratorList: &cc.InitDeclaratorList{
· · InitDeclarator: &cc.InitDeclarator{
· · · Case: InitDeclaratorDecl,
· · · Declarator: &cc.Declarator{
· · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · Case: DirectDeclaratorIdent,
· · · · · Token: example.c:1:5: identifier "i",
· · · · },
· · · },
· · },
· · InitDeclaratorList: &cc.InitDeclaratorList{
· · · InitDeclarator: &cc.InitDeclarator{
· · · · AttributeSpecifierList: &cc.AttributeSpecifierList{
· · · · · AttributeSpecifier: &cc.AttributeSpecifier{
· · · · · · AttributeValueList: &cc.AttributeValueList{
· · · · · · · AttributeValue: &cc.AttributeValue{
· · · · · · · · Case: AttributeValueIdent,
· · · · · · · · Token: example.c:1:25: identifier "a",
· · · · · · · },
· · · · · · },
· · · · · · Token: example.c:1:10: '__attribute__' "__attribute__",
· · · · · · Token2: example.c:1:23: '(' "(",
· · · · · · Token3: example.c:1:24: '(' "(",
· · · · · · Token4: example.c:1:26: ')' ")",
· · · · · · Token5: example.c:1:27: ')' ")",
· · · · · },
· · · · },
· · · · Case: InitDeclaratorDecl,
· · · · Declarator: &cc.Declarator{
· · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · Case: DirectDeclaratorIdent,
· · · · · · Token: example.c:1:8: identifier "j",
· · · · · },
· · · · },
· · · },
· · · Token: example.c:1:6: ',' ",",
· · },
· },
· Token: example.c:1:28: ';' ";",
}

func (*Declaration) Position

func (n *Declaration) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*Declaration) String

func (n *Declaration) String() string

String implements fmt.Stringer.

type DeclarationCase

type DeclarationCase int

DeclarationCase represents case numbers of production Declaration

const (
	DeclarationDecl DeclarationCase = iota
	DeclarationAssert
	DeclarationAuto
)

Values of type DeclarationCase

func (DeclarationCase) String

func (n DeclarationCase) String() string

String implements fmt.Stringer

type DeclarationList

type DeclarationList struct {
	Declaration     *Declaration
	DeclarationList *DeclarationList
}

DeclarationList represents data reduced by productions:

DeclarationList:
        Declaration
|       DeclarationList Declaration
Example (Case0)
fmt.Println(exampleAST(253, "int f(i) int i; {}"))
Output:

&cc.DeclarationList{
· Declaration: &cc.Declaration{
· · Case: DeclarationDecl,
· · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · Case: DeclarationSpecifiersTypeSpec,
· · · TypeSpecifier: &cc.TypeSpecifier{
· · · · Case: TypeSpecifierInt,
· · · · Token: example.c:1:10: 'int' "int",
· · · },
· · },
· · InitDeclaratorList: &cc.InitDeclaratorList{
· · · InitDeclarator: &cc.InitDeclarator{
· · · · Case: InitDeclaratorDecl,
· · · · Declarator: &cc.Declarator{
· · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · Case: DirectDeclaratorIdent,
· · · · · · Token: example.c:1:14: identifier "i",
· · · · · },
· · · · },
· · · },
· · },
· · Token: example.c:1:15: ';' ";",
· },
}
Example (Case1)
fmt.Println(exampleAST(254, "int f(i, j) int i; int j; {}"))
Output:

&cc.DeclarationList{
· Declaration: &cc.Declaration{
· · Case: DeclarationDecl,
· · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · Case: DeclarationSpecifiersTypeSpec,
· · · TypeSpecifier: &cc.TypeSpecifier{
· · · · Case: TypeSpecifierInt,
· · · · Token: example.c:1:13: 'int' "int",
· · · },
· · },
· · InitDeclaratorList: &cc.InitDeclaratorList{
· · · InitDeclarator: &cc.InitDeclarator{
· · · · Case: InitDeclaratorDecl,
· · · · Declarator: &cc.Declarator{
· · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · Case: DirectDeclaratorIdent,
· · · · · · Token: example.c:1:17: identifier "i",
· · · · · },
· · · · },
· · · },
· · },
· · Token: example.c:1:18: ';' ";",
· },
· DeclarationList: &cc.DeclarationList{
· · Declaration: &cc.Declaration{
· · · Case: DeclarationDecl,
· · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · Case: DeclarationSpecifiersTypeSpec,
· · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · Case: TypeSpecifierInt,
· · · · · Token: example.c:1:20: 'int' "int",
· · · · },
· · · },
· · · InitDeclaratorList: &cc.InitDeclaratorList{
· · · · InitDeclarator: &cc.InitDeclarator{
· · · · · Case: InitDeclaratorDecl,
· · · · · Declarator: &cc.Declarator{
· · · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · · Case: DirectDeclaratorIdent,
· · · · · · · Token: example.c:1:24: identifier "j",
· · · · · · },
· · · · · },
· · · · },
· · · },
· · · Token: example.c:1:25: ';' ";",
· · },
· },
}

func (*DeclarationList) Position

func (n *DeclarationList) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*DeclarationList) String

func (n *DeclarationList) String() string

String implements fmt.Stringer.

type DeclarationSpecifiers

type DeclarationSpecifiers struct {
	AttributeSpecifierList *AttributeSpecifierList

	AlignmentSpecifier    *AlignmentSpecifier
	Case                  DeclarationSpecifiersCase `PrettyPrint:"stringer,zero"`
	DeclarationSpecifiers *DeclarationSpecifiers
	FunctionSpecifier     *FunctionSpecifier
	StorageClassSpecifier *StorageClassSpecifier
	Token                 Token
	TypeQualifier         *TypeQualifier
	TypeSpecifier         *TypeSpecifier
	// contains filtered or unexported fields
}

DeclarationSpecifiers represents data reduced by productions:

DeclarationSpecifiers:
        StorageClassSpecifier DeclarationSpecifiers  // Case DeclarationSpecifiersStorage
|       TypeSpecifier DeclarationSpecifiers          // Case DeclarationSpecifiersTypeSpec
|       TypeQualifier DeclarationSpecifiers          // Case DeclarationSpecifiersTypeQual
|       FunctionSpecifier DeclarationSpecifiers      // Case DeclarationSpecifiersFunc
|       AlignmentSpecifier DeclarationSpecifiers     // Case DeclarationSpecifiersAlignSpec
|       "__attribute__"                              // Case DeclarationSpecifiersAttr
Example (AlignSpec)
fmt.Println(exampleAST(97, "_Alignas(double) int i;"))
Output:

&cc.DeclarationSpecifiers{
· AlignmentSpecifier: &cc.AlignmentSpecifier{
· · Case: AlignmentSpecifierType,
· · Token: example.c:1:1: '_Alignas' "_Alignas",
· · Token2: example.c:1:9: '(' "(",
· · Token3: example.c:1:16: ')' ")",
· · TypeName: &cc.TypeName{
· · · SpecifierQualifierList: &cc.SpecifierQualifierList{
· · · · Case: SpecifierQualifierListTypeSpec,
· · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · Case: TypeSpecifierDouble,
· · · · · Token: example.c:1:10: 'double' "double",
· · · · },
· · · },
· · },
· },
· Case: DeclarationSpecifiersAlignSpec,
· DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · Case: DeclarationSpecifiersTypeSpec,
· · TypeSpecifier: &cc.TypeSpecifier{
· · · Case: TypeSpecifierInt,
· · · Token: example.c:1:18: 'int' "int",
· · },
· },
}
Example (Attr)
fmt.Println(exampleAST(98, "__attribute__((a)) int i;"))
Output:

&cc.DeclarationSpecifiers{
· AttributeSpecifierList: &cc.AttributeSpecifierList{
· · AttributeSpecifier: &cc.AttributeSpecifier{
· · · AttributeValueList: &cc.AttributeValueList{
· · · · AttributeValue: &cc.AttributeValue{
· · · · · Case: AttributeValueIdent,
· · · · · Token: example.c:1:16: identifier "a",
· · · · },
· · · },
· · · Token: example.c:1:1: '__attribute__' "__attribute__",
· · · Token2: example.c:1:14: '(' "(",
· · · Token3: example.c:1:15: '(' "(",
· · · Token4: example.c:1:17: ')' ")",
· · · Token5: example.c:1:18: ')' ")",
· · },
· },
· Case: DeclarationSpecifiersAttr,
· DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · Case: DeclarationSpecifiersTypeSpec,
· · TypeSpecifier: &cc.TypeSpecifier{
· · · Case: TypeSpecifierInt,
· · · Token: example.c:1:20: 'int' "int",
· · },
· },
}
Example (Func)
fmt.Println(exampleAST(96, "inline int f() {}"))
Output:

&cc.DeclarationSpecifiers{
· Case: DeclarationSpecifiersFunc,
· DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · Case: DeclarationSpecifiersTypeSpec,
· · TypeSpecifier: &cc.TypeSpecifier{
· · · Case: TypeSpecifierInt,
· · · Token: example.c:1:8: 'int' "int",
· · },
· },
· FunctionSpecifier: &cc.FunctionSpecifier{
· · Case: FunctionSpecifierInline,
· · Token: example.c:1:1: 'inline' "inline",
· },
}
Example (Storage)
fmt.Println(exampleAST(93, "__attribute__((a)) static int i;"))
Output:

&cc.DeclarationSpecifiers{
· AttributeSpecifierList: &cc.AttributeSpecifierList{
· · AttributeSpecifier: &cc.AttributeSpecifier{
· · · AttributeValueList: &cc.AttributeValueList{
· · · · AttributeValue: &cc.AttributeValue{
· · · · · Case: AttributeValueIdent,
· · · · · Token: example.c:1:16: identifier "a",
· · · · },
· · · },
· · · Token: example.c:1:1: '__attribute__' "__attribute__",
· · · Token2: example.c:1:14: '(' "(",
· · · Token3: example.c:1:15: '(' "(",
· · · Token4: example.c:1:17: ')' ")",
· · · Token5: example.c:1:18: ')' ")",
· · },
· },
· Case: DeclarationSpecifiersAttr,
· DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · Case: DeclarationSpecifiersStorage,
· · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · Case: DeclarationSpecifiersTypeSpec,
· · · TypeSpecifier: &cc.TypeSpecifier{
· · · · Case: TypeSpecifierInt,
· · · · Token: example.c:1:27: 'int' "int",
· · · },
· · },
· · StorageClassSpecifier: &cc.StorageClassSpecifier{
· · · Case: StorageClassSpecifierStatic,
· · · Token: example.c:1:20: 'static' "static",
· · },
· },
}
Example (TypeQual)
fmt.Println(exampleAST(95, "volatile int i;"))
Output:

&cc.DeclarationSpecifiers{
· Case: DeclarationSpecifiersTypeQual,
· DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · Case: DeclarationSpecifiersTypeSpec,
· · TypeSpecifier: &cc.TypeSpecifier{
· · · Case: TypeSpecifierInt,
· · · Token: example.c:1:10: 'int' "int",
· · },
· },
· TypeQualifier: &cc.TypeQualifier{
· · Case: TypeQualifierVolatile,
· · Token: example.c:1:1: 'volatile' "volatile",
· },
}
Example (TypeSpec)
fmt.Println(exampleAST(94, "int i;"))
Output:

&cc.DeclarationSpecifiers{
· Case: DeclarationSpecifiersTypeSpec,
· TypeSpecifier: &cc.TypeSpecifier{
· · Case: TypeSpecifierInt,
· · Token: example.c:1:1: 'int' "int",
· },
}

func (*DeclarationSpecifiers) Position

func (n *DeclarationSpecifiers) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*DeclarationSpecifiers) String

func (n *DeclarationSpecifiers) String() string

String implements fmt.Stringer.

func (DeclarationSpecifiers) Type

func (t DeclarationSpecifiers) Type() Type

Type returns the type of a node or an *InvalidType type value, if the type is unknown/undetermined.

type DeclarationSpecifiersCase

type DeclarationSpecifiersCase int

DeclarationSpecifiersCase represents case numbers of production DeclarationSpecifiers

const (
	DeclarationSpecifiersStorage DeclarationSpecifiersCase = iota
	DeclarationSpecifiersTypeSpec
	DeclarationSpecifiersTypeQual
	DeclarationSpecifiersFunc
	DeclarationSpecifiersAlignSpec
	DeclarationSpecifiersAttr
)

Values of type DeclarationSpecifiersCase

func (DeclarationSpecifiersCase) String

func (n DeclarationSpecifiersCase) String() string

String implements fmt.Stringer

type Declarator

type Declarator struct {
	DirectDeclarator *DirectDeclarator
	Pointer          *Pointer
	// contains filtered or unexported fields
}

Declarator represents data reduced by production:

Declarator:
        Pointer DirectDeclarator
Example (Case0)
fmt.Println(exampleAST(170, "int *p;"))
Output:

&cc.Declarator{
· DirectDeclarator: &cc.DirectDeclarator{
· · Case: DirectDeclaratorIdent,
· · Token: example.c:1:6: identifier "p",
· },
· Pointer: &cc.Pointer{
· · Case: PointerTypeQual,
· · Token: example.c:1:5: '*' "*",
· },
}

func (*Declarator) AddressTaken

func (n *Declarator) AddressTaken() bool

AddressTaken reports whether address of n is taken. The result is valid after Translate.

func (*Declarator) Alignas

func (n *Declarator) Alignas() int

Alignas reports whether the _Alignas specifier was present in the declaration specifiers of n, if non-zero.

func (*Declarator) HasInitializer

func (n *Declarator) HasInitializer() bool

HasInitializer reports whether n has an initializer.

func (*Declarator) IsAtomic

func (n *Declarator) IsAtomic() bool

IsAtomic reports whether the type specifier '_Atomic' was present in the declaration of n.

func (*Declarator) IsConst

func (n *Declarator) IsConst() bool

IsConst reports whether the type qualifier 'const' was present in the declaration of n.

func (*Declarator) IsExtern

func (n *Declarator) IsExtern() bool

IsExtern reports whether the storage class specifier 'extern' was present in the declaration of n.

func (*Declarator) IsFuncDef

func (n *Declarator) IsFuncDef() bool

IsFuncDef reports whether n declares the name of a function definition.

func (*Declarator) IsInline

func (n *Declarator) IsInline() bool

IsInline reports whether the function specifier 'inline' was present in the declaration of n.

func (*Declarator) IsParam

func (n *Declarator) IsParam() bool

IsParam reports whether n is a function paramater.

func (*Declarator) IsRegister

func (n *Declarator) IsRegister() bool

IsRegister reports whether the storage class specifier 'register' was present in the declaration of n.

func (*Declarator) IsStatic

func (n *Declarator) IsStatic() bool

IsStatic reports whether the storage class specifier 'static' was present in the declaration of n.

func (*Declarator) IsSynthetic

func (n *Declarator) IsSynthetic() bool

IsSynthetic reports whether n is synthesized.

func (*Declarator) IsThreadLocal

func (n *Declarator) IsThreadLocal() bool

IsThreadLocal reports whether the storage class specifier '_Thread_local' was present in the declaration of n.

func (*Declarator) IsTypename

func (n *Declarator) IsTypename() bool

IsTypename reports whether n is a typedef.

func (*Declarator) IsVolatile

func (n *Declarator) IsVolatile() bool

IsVolatile reports whether the type qualifier 'volatile' was present in the declaration of n.

func (Declarator) LexicalScope

func (n Declarator) LexicalScope() *Scope

LexicalScope provides the scope a node appears in.

func (*Declarator) Linkage

func (n *Declarator) Linkage() Linkage

Linkage reports n's linkage.

func (*Declarator) Name

func (n *Declarator) Name() string

Name returns the name of n.

func (*Declarator) NameTok

func (n *Declarator) NameTok() (r Token)

NameTok returns the name token of n.

func (*Declarator) Position

func (n *Declarator) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*Declarator) ReadCount

func (n *Declarator) ReadCount() int

ReadCount reports the number of times n is read. The result is valid after Translate.

func (Declarator) ResolvedIn

func (n Declarator) ResolvedIn() *Scope

ResolvedIn returns the scope an identifier was resolved in, if any.

func (*Declarator) SizeofCount

func (n *Declarator) SizeofCount() int

SizeofCount reports the number of times n appears in sizeof(expr). The result is valid after Translate.

func (*Declarator) StorageDuration

func (n *Declarator) StorageDuration() StorageDuration

func (*Declarator) String

func (n *Declarator) String() string

String implements fmt.Stringer.

func (Declarator) Type

func (t Declarator) Type() Type

Type returns the type of a node or an *InvalidType type value, if the type is unknown/undetermined.

func (Declarator) Visible

func (v Declarator) Visible() int

Visible reports the token sequence number where the visibility of a name starts.

func (*Declarator) WriteCount

func (n *Declarator) WriteCount() int

WriteCount reports the number of times n is written. The result is valid after Translate.

type Designation

type Designation struct {
	DesignatorList *DesignatorList
	Token          Token
}

Designation represents data reduced by production:

Designation:
        DesignatorList '='
Example (Case0)
fmt.Println(exampleAST(207, "int a[] = { [42] = 314 };"))
Output:

&cc.Designation{
· DesignatorList: &cc.DesignatorList{
· · Designator: &cc.Designator{
· · · Case: DesignatorIndex,
· · · ConstantExpression: &cc.ConstantExpression{
· · · · ConditionalExpression: &cc.PrimaryExpression{
· · · · · Case: PrimaryExpressionInt,
· · · · · Token: example.c:1:14: integer constant "42",
· · · · },
· · · },
· · · Token: example.c:1:13: '[' "[",
· · · Token2: example.c:1:16: ']' "]",
· · },
· },
· Token: example.c:1:18: '=' "=",
}

func (*Designation) Position

func (n *Designation) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*Designation) String

func (n *Designation) String() string

String implements fmt.Stringer.

type Designator

type Designator struct {
	Case                DesignatorCase `PrettyPrint:"stringer,zero"`
	ConstantExpression  ExpressionNode
	ConstantExpression2 ExpressionNode
	Token               Token
	Token2              Token
	Token3              Token
	// contains filtered or unexported fields
}

Designator represents data reduced by productions:

Designator:
        '[' ConstantExpression ']'                           // Case DesignatorIndex
|       '[' ConstantExpression "..." ConstantExpression ']'  // Case DesignatorIndex2
|       '.' IDENTIFIER                                       // Case DesignatorField
|       IDENTIFIER ':'                                       // Case DesignatorField2
Example (Field)
fmt.Println(exampleAST(212, "struct t s = { .fld = 314 };"))
Output:

&cc.Designator{
· Case: DesignatorField,
· Token: example.c:1:16: '.' ".",
· Token2: example.c:1:17: identifier "fld",
}
Example (Field2)
fmt.Println(exampleAST(213, "struct t s = { fld: 314 };"))
Output:

&cc.Designator{
· Case: DesignatorField2,
· Token: example.c:1:16: identifier "fld",
· Token2: example.c:1:19: ':' ":",
}
Example (Index)
fmt.Println(exampleAST(210, "int a[] = { [42] = 314 };"))
Output:

&cc.Designator{
· Case: DesignatorIndex,
· ConstantExpression: &cc.ConstantExpression{
· · ConditionalExpression: &cc.PrimaryExpression{
· · · Case: PrimaryExpressionInt,
· · · Token: example.c:1:14: integer constant "42",
· · },
· },
· Token: example.c:1:13: '[' "[",
· Token2: example.c:1:16: ']' "]",
}
Example (Index2)
fmt.Println(exampleAST(211, "int a[] = { [42 ... 278] = 314 };"))
Output:

&cc.Designator{
· Case: DesignatorIndex2,
· ConstantExpression: &cc.ConstantExpression{
· · ConditionalExpression: &cc.PrimaryExpression{
· · · Case: PrimaryExpressionInt,
· · · Token: example.c:1:14: integer constant "42",
· · },
· },
· ConstantExpression2: &cc.ConstantExpression{
· · ConditionalExpression: &cc.PrimaryExpression{
· · · Case: PrimaryExpressionInt,
· · · Token: example.c:1:21: integer constant "278",
· · },
· },
· Token: example.c:1:13: '[' "[",
· Token2: example.c:1:17: '...' "...",
· Token3: example.c:1:24: ']' "]",
}

func (*Designator) Position

func (n *Designator) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*Designator) String

func (n *Designator) String() string

String implements fmt.Stringer.

func (Designator) Type added in v4.1.1

func (t Designator) Type() Type

Type returns the type of a node or an *InvalidType type value, if the type is unknown/undetermined.

type DesignatorCase

type DesignatorCase int

DesignatorCase represents case numbers of production Designator

const (
	DesignatorIndex DesignatorCase = iota
	DesignatorIndex2
	DesignatorField
	DesignatorField2
)

Values of type DesignatorCase

func (DesignatorCase) String

func (n DesignatorCase) String() string

String implements fmt.Stringer

type DesignatorList

type DesignatorList struct {
	Designator     *Designator
	DesignatorList *DesignatorList
}

DesignatorList represents data reduced by productions:

DesignatorList:
        Designator
|       DesignatorList Designator
Example (Case0)
fmt.Println(exampleAST(208, "int a[] = { [42] = 314 };"))
Output:

&cc.DesignatorList{
· Designator: &cc.Designator{
· · Case: DesignatorIndex,
· · ConstantExpression: &cc.ConstantExpression{
· · · ConditionalExpression: &cc.PrimaryExpression{
· · · · Case: PrimaryExpressionInt,
· · · · Token: example.c:1:14: integer constant "42",
· · · },
· · },
· · Token: example.c:1:13: '[' "[",
· · Token2: example.c:1:16: ']' "]",
· },
}
Example (Case1)
fmt.Println(exampleAST(209, "int a[100][] = { [42][12] = 314 };"))
Output:

&cc.DesignatorList{
· Designator: &cc.Designator{
· · Case: DesignatorIndex,
· · ConstantExpression: &cc.ConstantExpression{
· · · ConditionalExpression: &cc.PrimaryExpression{
· · · · Case: PrimaryExpressionInt,
· · · · Token: example.c:1:19: integer constant "42",
· · · },
· · },
· · Token: example.c:1:18: '[' "[",
· · Token2: example.c:1:21: ']' "]",
· },
· DesignatorList: &cc.DesignatorList{
· · Designator: &cc.Designator{
· · · Case: DesignatorIndex,
· · · ConstantExpression: &cc.ConstantExpression{
· · · · ConditionalExpression: &cc.PrimaryExpression{
· · · · · Case: PrimaryExpressionInt,
· · · · · Token: example.c:1:23: integer constant "12",
· · · · },
· · · },
· · · Token: example.c:1:22: '[' "[",
· · · Token2: example.c:1:25: ']' "]",
· · },
· },
}

func (*DesignatorList) Position

func (n *DesignatorList) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*DesignatorList) String

func (n *DesignatorList) String() string

String implements fmt.Stringer.

type DirectAbstractDeclarator

type DirectAbstractDeclarator struct {
	AbstractDeclarator       *AbstractDeclarator
	AssignmentExpression     ExpressionNode
	Case                     DirectAbstractDeclaratorCase `PrettyPrint:"stringer,zero"`
	DirectAbstractDeclarator *DirectAbstractDeclarator
	ParameterTypeList        *ParameterTypeList
	Token                    Token
	Token2                   Token
	Token3                   Token
	TypeQualifiers           *TypeQualifiers
	// contains filtered or unexported fields
}

DirectAbstractDeclarator represents data reduced by productions:

DirectAbstractDeclarator:
        '(' AbstractDeclarator ')'                                                     // Case DirectAbstractDeclaratorDecl
|       DirectAbstractDeclarator '[' TypeQualifiers AssignmentExpression ']'           // Case DirectAbstractDeclaratorArr
|       DirectAbstractDeclarator '[' "static" TypeQualifiers AssignmentExpression ']'  // Case DirectAbstractDeclaratorStaticArr
|       DirectAbstractDeclarator '[' TypeQualifiers "static" AssignmentExpression ']'  // Case DirectAbstractDeclaratorArrStatic
|       DirectAbstractDeclarator '[' '*' ']'                                           // Case DirectAbstractDeclaratorArrStar
|       DirectAbstractDeclarator '(' ParameterTypeList ')'                             // Case DirectAbstractDeclaratorFunc
Example (Arr)
fmt.Println(exampleAST(198, "void f(int[const 42]);"))
Output:

&cc.DirectAbstractDeclarator{
· AssignmentExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionInt,
· · Token: example.c:1:18: integer constant "42",
· },
· Case: DirectAbstractDeclaratorArr,
· Token: example.c:1:11: '[' "[",
· Token2: example.c:1:20: ']' "]",
· TypeQualifiers: &cc.TypeQualifiers{
· · Case: TypeQualifiersTypeQual,
· · TypeQualifier: &cc.TypeQualifier{
· · · Case: TypeQualifierConst,
· · · Token: example.c:1:12: 'const' "const",
· · },
· },
}
Example (ArrStar)
fmt.Println(exampleAST(201, "void f(int[*]);"))
Output:

&cc.DirectAbstractDeclarator{
· Case: DirectAbstractDeclaratorArrStar,
· Token: example.c:1:11: '[' "[",
· Token2: example.c:1:12: '*' "*",
· Token3: example.c:1:13: ']' "]",
}
Example (ArrStatic)
fmt.Println(exampleAST(200, "void f(int[const static 42]);"))
Output:

&cc.DirectAbstractDeclarator{
· AssignmentExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionInt,
· · Token: example.c:1:25: integer constant "42",
· },
· Case: DirectAbstractDeclaratorArr,
· Token: example.c:1:11: '[' "[",
· Token2: example.c:1:18: 'static' "static",
· Token3: example.c:1:27: ']' "]",
· TypeQualifiers: &cc.TypeQualifiers{
· · Case: TypeQualifiersTypeQual,
· · TypeQualifier: &cc.TypeQualifier{
· · · Case: TypeQualifierConst,
· · · Token: example.c:1:12: 'const' "const",
· · },
· },
}
Example (Decl)
fmt.Println(exampleAST(197, "void f(int(*));"))
Output:

&cc.DirectAbstractDeclarator{
· AbstractDeclarator: &cc.AbstractDeclarator{
· · Case: AbstractDeclaratorPtr,
· · Pointer: &cc.Pointer{
· · · Case: PointerTypeQual,
· · · Token: example.c:1:12: '*' "*",
· · },
· },
· Case: DirectAbstractDeclaratorDecl,
· Token: example.c:1:11: '(' "(",
· Token2: example.c:1:13: ')' ")",
}
Example (Func)
fmt.Println(exampleAST(202, "void f(int(char));"))
Output:

&cc.DirectAbstractDeclarator{
· Case: DirectAbstractDeclaratorFunc,
· ParameterTypeList: &cc.ParameterTypeList{
· · Case: ParameterTypeListList,
· · ParameterList: &cc.ParameterList{
· · · ParameterDeclaration: &cc.ParameterDeclaration{
· · · · Case: ParameterDeclarationAbstract,
· · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · Case: DeclarationSpecifiersTypeSpec,
· · · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · · Case: TypeSpecifierChar,
· · · · · · Token: example.c:1:12: 'char' "char",
· · · · · },
· · · · },
· · · },
· · },
· },
· Token: example.c:1:11: '(' "(",
· Token2: example.c:1:16: ')' ")",
}
Example (StaticArr)
fmt.Println(exampleAST(199, "void f(int[static const 42]);"))
Output:

&cc.DirectAbstractDeclarator{
· AssignmentExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionInt,
· · Token: example.c:1:25: integer constant "42",
· },
· Case: DirectAbstractDeclaratorStaticArr,
· Token: example.c:1:11: '[' "[",
· Token2: example.c:1:12: 'static' "static",
· Token3: example.c:1:27: ']' "]",
· TypeQualifiers: &cc.TypeQualifiers{
· · Case: TypeQualifiersTypeQual,
· · TypeQualifier: &cc.TypeQualifier{
· · · Case: TypeQualifierConst,
· · · Token: example.c:1:19: 'const' "const",
· · },
· },
}

func (*DirectAbstractDeclarator) Position

func (n *DirectAbstractDeclarator) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*DirectAbstractDeclarator) String

func (n *DirectAbstractDeclarator) String() string

String implements fmt.Stringer.

type DirectAbstractDeclaratorCase

type DirectAbstractDeclaratorCase int

DirectAbstractDeclaratorCase represents case numbers of production DirectAbstractDeclarator

const (
	DirectAbstractDeclaratorDecl DirectAbstractDeclaratorCase = iota
	DirectAbstractDeclaratorArr
	DirectAbstractDeclaratorStaticArr
	DirectAbstractDeclaratorArrStatic
	DirectAbstractDeclaratorArrStar
	DirectAbstractDeclaratorFunc
)

Values of type DirectAbstractDeclaratorCase

func (DirectAbstractDeclaratorCase) String

String implements fmt.Stringer

type DirectDeclarator

type DirectDeclarator struct {
	AssignmentExpression ExpressionNode
	Case                 DirectDeclaratorCase `PrettyPrint:"stringer,zero"`
	Declarator           *Declarator
	DirectDeclarator     *DirectDeclarator
	IdentifierList       *IdentifierList
	ParameterTypeList    *ParameterTypeList
	Token                Token
	Token2               Token
	Token3               Token
	TypeQualifiers       *TypeQualifiers
	// contains filtered or unexported fields
}

DirectDeclarator represents data reduced by productions:

DirectDeclarator:
        IDENTIFIER                                                             // Case DirectDeclaratorIdent
|       '(' Declarator ')'                                                     // Case DirectDeclaratorDecl
|       DirectDeclarator '[' TypeQualifiers AssignmentExpression ']'           // Case DirectDeclaratorArr
|       DirectDeclarator '[' "static" TypeQualifiers AssignmentExpression ']'  // Case DirectDeclaratorStaticArr
|       DirectDeclarator '[' TypeQualifiers "static" AssignmentExpression ']'  // Case DirectDeclaratorArrStatic
|       DirectDeclarator '[' TypeQualifiers '*' ']'                            // Case DirectDeclaratorStar
|       DirectDeclarator '(' ParameterTypeList ')'                             // Case DirectDeclaratorFuncParam
|       DirectDeclarator '(' IdentifierList ')'                                // Case DirectDeclaratorFuncIdent
Example (Arr)
fmt.Println(exampleAST(175, "int i[const 42];"))
Output:

&cc.DirectDeclarator{
· AssignmentExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionInt,
· · Token: example.c:1:13: integer constant "42",
· },
· Case: DirectDeclaratorArr,
· DirectDeclarator: &cc.DirectDeclarator{
· · Case: DirectDeclaratorIdent,
· · Token: example.c:1:5: identifier "i",
· },
· Token: example.c:1:6: '[' "[",
· Token3: example.c:1:15: ']' "]",
· TypeQualifiers: &cc.TypeQualifiers{
· · Case: TypeQualifiersTypeQual,
· · TypeQualifier: &cc.TypeQualifier{
· · · Case: TypeQualifierConst,
· · · Token: example.c:1:7: 'const' "const",
· · },
· },
}
Example (ArrStatic)
fmt.Println(exampleAST(177, "int i[const static 42];"))
Output:

&cc.DirectDeclarator{
· AssignmentExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionInt,
· · Token: example.c:1:20: integer constant "42",
· },
· Case: DirectDeclaratorArrStatic,
· DirectDeclarator: &cc.DirectDeclarator{
· · Case: DirectDeclaratorIdent,
· · Token: example.c:1:5: identifier "i",
· },
· Token: example.c:1:6: '[' "[",
· Token2: example.c:1:13: 'static' "static",
· Token3: example.c:1:22: ']' "]",
· TypeQualifiers: &cc.TypeQualifiers{
· · Case: TypeQualifiersTypeQual,
· · TypeQualifier: &cc.TypeQualifier{
· · · Case: TypeQualifierConst,
· · · Token: example.c:1:7: 'const' "const",
· · },
· },
}
Example (Decl)
fmt.Println(exampleAST(174, "int (f);"))
Output:

&cc.DirectDeclarator{
· Case: DirectDeclaratorDecl,
· Declarator: &cc.Declarator{
· · DirectDeclarator: &cc.DirectDeclarator{
· · · Case: DirectDeclaratorIdent,
· · · Token: example.c:1:6: identifier "f",
· · },
· },
· Token: example.c:1:5: '(' "(",
· Token2: example.c:1:7: ')' ")",
}
Example (FuncIdent)
fmt.Println(exampleAST(180, "int f(a);"))
Output:

&cc.DirectDeclarator{
· Case: DirectDeclaratorFuncIdent,
· DirectDeclarator: &cc.DirectDeclarator{
· · Case: DirectDeclaratorIdent,
· · Token: example.c:1:5: identifier "f",
· },
· IdentifierList: &cc.IdentifierList{
· · Token2: example.c:1:7: identifier "a",
· },
· Token: example.c:1:6: '(' "(",
· Token2: example.c:1:8: ')' ")",
}
Example (FuncParam)
fmt.Println(exampleAST(179, "int f(int i);"))
Output:

&cc.DirectDeclarator{
· Case: DirectDeclaratorFuncParam,
· DirectDeclarator: &cc.DirectDeclarator{
· · Case: DirectDeclaratorIdent,
· · Token: example.c:1:5: identifier "f",
· },
· ParameterTypeList: &cc.ParameterTypeList{
· · Case: ParameterTypeListList,
· · ParameterList: &cc.ParameterList{
· · · ParameterDeclaration: &cc.ParameterDeclaration{
· · · · Case: ParameterDeclarationDecl,
· · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · Case: DeclarationSpecifiersTypeSpec,
· · · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · · Case: TypeSpecifierInt,
· · · · · · Token: example.c:1:7: 'int' "int",
· · · · · },
· · · · },
· · · · Declarator: &cc.Declarator{
· · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · Case: DirectDeclaratorIdent,
· · · · · · Token: example.c:1:11: identifier "i",
· · · · · },
· · · · },
· · · },
· · },
· },
· Token: example.c:1:6: '(' "(",
· Token2: example.c:1:12: ')' ")",
}
Example (Ident)
fmt.Println(exampleAST(173, "int i;"))
Output:

&cc.DirectDeclarator{
· Case: DirectDeclaratorIdent,
· Token: example.c:1:5: identifier "i",
}
Example (Star)
fmt.Println(exampleAST(178, "int i[const *];"))
Output:

&cc.DirectDeclarator{
· Case: DirectDeclaratorStar,
· DirectDeclarator: &cc.DirectDeclarator{
· · Case: DirectDeclaratorIdent,
· · Token: example.c:1:5: identifier "i",
· },
· Token: example.c:1:6: '[' "[",
· Token2: example.c:1:13: '*' "*",
· Token3: example.c:1:14: ']' "]",
· TypeQualifiers: &cc.TypeQualifiers{
· · Case: TypeQualifiersTypeQual,
· · TypeQualifier: &cc.TypeQualifier{
· · · Case: TypeQualifierConst,
· · · Token: example.c:1:7: 'const' "const",
· · },
· },
}
Example (StaticArr)
fmt.Println(exampleAST(176, "int i[static const 42];"))
Output:

&cc.DirectDeclarator{
· AssignmentExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionInt,
· · Token: example.c:1:20: integer constant "42",
· },
· Case: DirectDeclaratorStaticArr,
· DirectDeclarator: &cc.DirectDeclarator{
· · Case: DirectDeclaratorIdent,
· · Token: example.c:1:5: identifier "i",
· },
· Token: example.c:1:6: '[' "[",
· Token2: example.c:1:7: 'static' "static",
· Token3: example.c:1:22: ']' "]",
· TypeQualifiers: &cc.TypeQualifiers{
· · Case: TypeQualifiersTypeQual,
· · TypeQualifier: &cc.TypeQualifier{
· · · Case: TypeQualifierConst,
· · · Token: example.c:1:14: 'const' "const",
· · },
· },
}

func (*DirectDeclarator) Position

func (n *DirectDeclarator) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*DirectDeclarator) String

func (n *DirectDeclarator) String() string

String implements fmt.Stringer.

type DirectDeclaratorCase

type DirectDeclaratorCase int

DirectDeclaratorCase represents case numbers of production DirectDeclarator

const (
	DirectDeclaratorIdent DirectDeclaratorCase = iota
	DirectDeclaratorDecl
	DirectDeclaratorArr
	DirectDeclaratorStaticArr
	DirectDeclaratorArrStatic
	DirectDeclaratorStar
	DirectDeclaratorFuncParam
	DirectDeclaratorFuncIdent
)

Values of type DirectDeclaratorCase

func (DirectDeclaratorCase) String

func (n DirectDeclaratorCase) String() string

String implements fmt.Stringer

type EnumSpecifier

type EnumSpecifier struct {
	Case           EnumSpecifierCase `PrettyPrint:"stringer,zero"`
	EnumeratorList *EnumeratorList
	Token          Token
	Token2         Token
	Token3         Token
	Token4         Token
	Token5         Token
	// contains filtered or unexported fields
}

EnumSpecifier represents data reduced by productions:

EnumSpecifier:
        "enum" IDENTIFIER '{' EnumeratorList ',' '}'  // Case EnumSpecifierDef
|       "enum" IDENTIFIER                             // Case EnumSpecifierTag
Example (Def)
fmt.Println(exampleAST(155, "enum e {a};"))
Output:

&cc.EnumSpecifier{
· Case: EnumSpecifierDef,
· EnumeratorList: &cc.EnumeratorList{
· · Enumerator: &cc.Enumerator{
· · · Case: EnumeratorIdent,
· · · Token: example.c:1:9: identifier "a",
· · },
· },
· Token: example.c:1:1: 'enum' "enum",
· Token2: example.c:1:6: identifier "e",
· Token3: example.c:1:8: '{' "{",
· Token5: example.c:1:10: '}' "}",
}
Example (Tag)
fmt.Println(exampleAST(156, "enum e i;"))
Output:

&cc.EnumSpecifier{
· Case: EnumSpecifierTag,
· Token: example.c:1:1: 'enum' "enum",
· Token2: example.c:1:6: identifier "e",
}

func (EnumSpecifier) LexicalScope

func (n EnumSpecifier) LexicalScope() *Scope

LexicalScope provides the scope a node appears in.

func (*EnumSpecifier) Position

func (n *EnumSpecifier) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*EnumSpecifier) String

func (n *EnumSpecifier) String() string

String implements fmt.Stringer.

func (EnumSpecifier) Type

func (t EnumSpecifier) Type() Type

Type returns the type of a node or an *InvalidType type value, if the type is unknown/undetermined.

func (EnumSpecifier) Visible

func (v EnumSpecifier) Visible() int

Visible reports the token sequence number where the visibility of a name starts.

type EnumSpecifierCase

type EnumSpecifierCase int

EnumSpecifierCase represents case numbers of production EnumSpecifier

const (
	EnumSpecifierDef EnumSpecifierCase = iota
	EnumSpecifierTag
)

Values of type EnumSpecifierCase

func (EnumSpecifierCase) String

func (n EnumSpecifierCase) String() string

String implements fmt.Stringer

type EnumType

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

func (*EnumType) Align

func (n *EnumType) Align() int

Align implements Type.

func (*EnumType) Attributes

func (n *EnumType) Attributes() *Attributes

Attributes implemets Type.

func (EnumType) BitField added in v4.1.1

func (EnumType) BitField() *Field

BitField implements Type.

func (*EnumType) Decay

func (n *EnumType) Decay() Type

Decay implements Type.

func (*EnumType) Enumerators

func (n *EnumType) Enumerators() []*Enumerator

Enumerators returns enumerators defined by n.

func (*EnumType) FieldAlign

func (n *EnumType) FieldAlign() int

FieldAlign implements Type.

func (*EnumType) IsCompatible

func (n *EnumType) IsCompatible(t Type) (r bool)

func (*EnumType) IsIncomplete

func (n *EnumType) IsIncomplete() bool

IsIncomplete implements Type.

func (*EnumType) Kind

func (n *EnumType) Kind() Kind

Kind implements Type.

func (*EnumType) LexicalScope

func (n *EnumType) LexicalScope() *Scope

LexicalScope provides the scope the definition of n appears in.

func (*EnumType) Max added in v4.1.1

func (n *EnumType) Max() uint64

Max returns n's highest enumeration constant.

func (*EnumType) Min added in v4.1.1

func (n *EnumType) Min() int64

Min returns n's lowest enumeration constant.

func (*EnumType) Pointer

func (n *EnumType) Pointer() Type

Pointer implements Type.

func (*EnumType) Size

func (n *EnumType) Size() int64

Size implements Type.

func (*EnumType) String

func (n *EnumType) String() string

String implements Type.

func (*EnumType) Tag

func (n *EnumType) Tag() Token

Tag returns n's tag, if any.

func (EnumType) Typedef

func (n EnumType) Typedef() *Declarator

Typedef implements Type

func (*EnumType) Undecay

func (n *EnumType) Undecay() Type

Undecay implements Type.

func (*EnumType) UnderlyingType

func (n *EnumType) UnderlyingType() Type

Type returns n's underlying integer type.

func (EnumType) VectorSize

func (EnumType) VectorSize() int64

VectorSize implements Type.

type Enumerator

type Enumerator struct {
	Case               EnumeratorCase `PrettyPrint:"stringer,zero"`
	ConstantExpression ExpressionNode
	Token              Token
	Token2             Token
	// contains filtered or unexported fields
}

Enumerator represents data reduced by productions:

Enumerator:
        IDENTIFIER                         // Case EnumeratorIdent
|       IDENTIFIER '=' ConstantExpression  // Case EnumeratorExpr
Example (Expr)
fmt.Println(exampleAST(160, "enum e {a = 42};"))
Output:

&cc.Enumerator{
· Case: EnumeratorExpr,
· ConstantExpression: &cc.ConstantExpression{
· · ConditionalExpression: &cc.PrimaryExpression{
· · · Case: PrimaryExpressionInt,
· · · Token: example.c:1:13: integer constant "42",
· · },
· },
· Token: example.c:1:9: identifier "a",
· Token2: example.c:1:11: '=' "=",
}
Example (Ident)
fmt.Println(exampleAST(159, "enum e {a};"))
Output:

&cc.Enumerator{
· Case: EnumeratorIdent,
· Token: example.c:1:9: identifier "a",
}

func (*Enumerator) Position

func (n *Enumerator) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (Enumerator) ResolvedIn

func (n Enumerator) ResolvedIn() *Scope

ResolvedIn returns the scope an identifier was resolved in, if any.

func (*Enumerator) String

func (n *Enumerator) String() string

String implements fmt.Stringer.

func (Enumerator) Type

func (t Enumerator) Type() Type

Type returns the type of a node or an *InvalidType type value, if the type is unknown/undetermined.

func (Enumerator) Value

func (v Enumerator) Value() Value

Value returns the value of a node or UnknownValue if it is undetermined. The dynamic type of a Value is one of

*ComplexLongDoubleValue
*LongDoubleValue
*UnknownValue
*ZeroValue
Complex128Value
Complex64Value
Float64Value
Int64Value
StringValue
UInt64Value
UTF16StringValue
UTF32StringValue
VoidValue

func (Enumerator) Visible

func (v Enumerator) Visible() int

Visible reports the token sequence number where the visibility of a name starts.

type EnumeratorCase

type EnumeratorCase int

EnumeratorCase represents case numbers of production Enumerator

const (
	EnumeratorIdent EnumeratorCase = iota
	EnumeratorExpr
)

Values of type EnumeratorCase

func (EnumeratorCase) String

func (n EnumeratorCase) String() string

String implements fmt.Stringer

type EnumeratorList

type EnumeratorList struct {
	Enumerator     *Enumerator
	EnumeratorList *EnumeratorList
	Token          Token
}

EnumeratorList represents data reduced by productions:

EnumeratorList:
        Enumerator
|       EnumeratorList ',' Enumerator
Example (Case0)
fmt.Println(exampleAST(157, "enum e {a};"))
Output:

&cc.EnumeratorList{
· Enumerator: &cc.Enumerator{
· · Case: EnumeratorIdent,
· · Token: example.c:1:9: identifier "a",
· },
}
Example (Case1)
fmt.Println(exampleAST(158, "enum e {a, b};"))
Output:

&cc.EnumeratorList{
· Enumerator: &cc.Enumerator{
· · Case: EnumeratorIdent,
· · Token: example.c:1:9: identifier "a",
· },
· EnumeratorList: &cc.EnumeratorList{
· · Enumerator: &cc.Enumerator{
· · · Case: EnumeratorIdent,
· · · Token: example.c:1:12: identifier "b",
· · },
· · Token: example.c:1:10: ',' ",",
· },
}

func (*EnumeratorList) Position

func (n *EnumeratorList) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*EnumeratorList) String

func (n *EnumeratorList) String() string

String implements fmt.Stringer.

type EqualityExpression

type EqualityExpression struct {
	Case                 EqualityExpressionCase `PrettyPrint:"stringer,zero"`
	EqualityExpression   ExpressionNode
	RelationalExpression ExpressionNode
	Token                Token
	// contains filtered or unexported fields
}

EqualityExpression represents data reduced by productions:

EqualityExpression:
        RelationalExpression                          // Case EqualityExpressionRel
|       EqualityExpression "==" RelationalExpression  // Case EqualityExpressionEq
|       EqualityExpression "!=" RelationalExpression  // Case EqualityExpressionNeq
Example (Eq)
fmt.Println(exampleAST(60, "int i = x == y;"))
Output:

&cc.EqualityExpression{
· Case: EqualityExpressionEq,
· EqualityExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:9: identifier "x",
· },
· RelationalExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:14: identifier "y",
· },
· Token: example.c:1:11: '==' "==",
}
Example (Neq)
fmt.Println(exampleAST(61, "int i = x != y;"))
Output:

&cc.EqualityExpression{
· Case: EqualityExpressionNeq,
· EqualityExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:9: identifier "x",
· },
· RelationalExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:14: identifier "y",
· },
· Token: example.c:1:11: '!=' "!=",
}

func (*EqualityExpression) Position

func (n *EqualityExpression) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*EqualityExpression) Pure added in v4.6.0

func (p *EqualityExpression) Pure() bool

Pure implements ExpressionNode.

func (*EqualityExpression) String

func (n *EqualityExpression) String() string

String implements fmt.Stringer.

func (EqualityExpression) Type

func (t EqualityExpression) Type() Type

Type returns the type of a node or an *InvalidType type value, if the type is unknown/undetermined.

func (EqualityExpression) Value

func (v EqualityExpression) Value() Value

Value returns the value of a node or UnknownValue if it is undetermined. The dynamic type of a Value is one of

*ComplexLongDoubleValue
*LongDoubleValue
*UnknownValue
*ZeroValue
Complex128Value
Complex64Value
Float64Value
Int64Value
StringValue
UInt64Value
UTF16StringValue
UTF32StringValue
VoidValue

type EqualityExpressionCase

type EqualityExpressionCase int

EqualityExpressionCase represents case numbers of production EqualityExpression

const (
	EqualityExpressionRel EqualityExpressionCase = iota
	EqualityExpressionEq
	EqualityExpressionNeq
)

Values of type EqualityExpressionCase

func (EqualityExpressionCase) String

func (n EqualityExpressionCase) String() string

String implements fmt.Stringer

type ExclusiveOrExpression

type ExclusiveOrExpression struct {
	AndExpression         ExpressionNode
	Case                  ExclusiveOrExpressionCase `PrettyPrint:"stringer,zero"`
	ExclusiveOrExpression ExpressionNode
	Token                 Token
	// contains filtered or unexported fields
}

ExclusiveOrExpression represents data reduced by productions:

ExclusiveOrExpression:
        AndExpression                            // Case ExclusiveOrExpressionAnd
|       ExclusiveOrExpression '^' AndExpression  // Case ExclusiveOrExpressionXor
Example (Xor)
fmt.Println(exampleAST(65, "int i = x^y;"))
Output:

&cc.ExclusiveOrExpression{
· AndExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:11: identifier "y",
· },
· Case: ExclusiveOrExpressionXor,
· ExclusiveOrExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:9: identifier "x",
· },
· Token: example.c:1:10: '^' "^",
}

func (*ExclusiveOrExpression) Position

func (n *ExclusiveOrExpression) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*ExclusiveOrExpression) Pure added in v4.6.0

func (p *ExclusiveOrExpression) Pure() bool

Pure implements ExpressionNode.

func (*ExclusiveOrExpression) String

func (n *ExclusiveOrExpression) String() string

String implements fmt.Stringer.

func (ExclusiveOrExpression) Type

func (t ExclusiveOrExpression) Type() Type

Type returns the type of a node or an *InvalidType type value, if the type is unknown/undetermined.

func (ExclusiveOrExpression) Value

func (v ExclusiveOrExpression) Value() Value

Value returns the value of a node or UnknownValue if it is undetermined. The dynamic type of a Value is one of

*ComplexLongDoubleValue
*LongDoubleValue
*UnknownValue
*ZeroValue
Complex128Value
Complex64Value
Float64Value
Int64Value
StringValue
UInt64Value
UTF16StringValue
UTF32StringValue
VoidValue

type ExclusiveOrExpressionCase

type ExclusiveOrExpressionCase int

ExclusiveOrExpressionCase represents case numbers of production ExclusiveOrExpression

const (
	ExclusiveOrExpressionAnd ExclusiveOrExpressionCase = iota
	ExclusiveOrExpressionXor
)

Values of type ExclusiveOrExpressionCase

func (ExclusiveOrExpressionCase) String

func (n ExclusiveOrExpressionCase) String() string

String implements fmt.Stringer

type ExpressionList

type ExpressionList struct {
	AssignmentExpression ExpressionNode
	ExpressionList       *ExpressionList
	Token                Token
	// contains filtered or unexported fields
}

ExpressionList represents data reduced by productions:

ExpressionList:
        AssignmentExpression
|       ExpressionList ',' AssignmentExpression
Example (Assign)
fmt.Println(exampleAST(86, "int f() { i = x; };"))
Output:

<nil>
Example (Comma)
fmt.Println(exampleAST(87, "int f() { x, y; };"))
Output:

&cc.ExpressionList{
· AssignmentExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:11: identifier "x",
· },
· ExpressionList: &cc.ExpressionList{
· · AssignmentExpression: &cc.PrimaryExpression{
· · · Case: PrimaryExpressionIdent,
· · · Token: example.c:1:14: identifier "y",
· · },
· · Token: example.c:1:12: ',' ",",
· },
}

func (*ExpressionList) Position

func (n *ExpressionList) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*ExpressionList) Pure added in v4.6.0

func (p *ExpressionList) Pure() bool

Pure implements ExpressionNode.

func (*ExpressionList) String

func (n *ExpressionList) String() string

String implements fmt.Stringer.

func (ExpressionList) Type

func (t ExpressionList) Type() Type

Type returns the type of a node or an *InvalidType type value, if the type is unknown/undetermined.

func (ExpressionList) Value

func (v ExpressionList) Value() Value

Value returns the value of a node or UnknownValue if it is undetermined. The dynamic type of a Value is one of

*ComplexLongDoubleValue
*LongDoubleValue
*UnknownValue
*ZeroValue
Complex128Value
Complex64Value
Float64Value
Int64Value
StringValue
UInt64Value
UTF16StringValue
UTF32StringValue
VoidValue

type ExpressionListCase

type ExpressionListCase int

ExpressionListCase represents case numbers of production ExpressionList

const (
	ExpressionListAssign ExpressionListCase = iota
	ExpressionListComma
)

Values of type ExpressionListCase

func (ExpressionListCase) String

func (n ExpressionListCase) String() string

String implements fmt.Stringer

type ExpressionNode

type ExpressionNode interface {
	Node
	Type() Type
	Value() Value
	// Pure returns true if an expression has no side effects.
	Pure() bool
	// contains filtered or unexported methods
}

type ExpressionStatement

type ExpressionStatement struct {
	AttributeSpecifierList *AttributeSpecifierList

	ExpressionList ExpressionNode
	Token          Token
	// contains filtered or unexported fields
}

ExpressionStatement represents data reduced by production:

ExpressionStatement:
        ExpressionList ';'
Example (Case0)
fmt.Println(exampleAST(233, "int f() { g(); }"))
Output:

&cc.ExpressionStatement{
· ExpressionList: &cc.PostfixExpression{
· · Case: PostfixExpressionCall,
· · PostfixExpression: &cc.PrimaryExpression{
· · · Case: PrimaryExpressionIdent,
· · · Token: example.c:1:11: identifier "g",
· · },
· · Token: example.c:1:12: '(' "(",
· · Token2: example.c:1:13: ')' ")",
· },
· Token: example.c:1:14: ';' ";",
}

func (*ExpressionStatement) Position

func (n *ExpressionStatement) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*ExpressionStatement) String

func (n *ExpressionStatement) String() string

String implements fmt.Stringer.

type ExternalDeclaration

type ExternalDeclaration struct {
	AsmStatement       *AsmStatement
	Case               ExternalDeclarationCase `PrettyPrint:"stringer,zero"`
	Declaration        *Declaration
	FunctionDefinition *FunctionDefinition
	Token              Token
}

ExternalDeclaration represents data reduced by productions:

ExternalDeclaration:
        FunctionDefinition  // Case ExternalDeclarationFuncDef
|       Declaration         // Case ExternalDeclarationDecl
|       AsmStatement        // Case ExternalDeclarationAsmStmt
|       ';'                 // Case ExternalDeclarationEmpty
Example (AsmStmt)
fmt.Println(exampleAST(250, "__asm__(\"nop\");"))
Output:

&cc.ExternalDeclaration{
· AsmStatement: &cc.AsmStatement{
· · Asm: &cc.Asm{
· · · Token: example.c:1:1: '__asm__' "__asm__",
· · · Token2: example.c:1:8: '(' "(",
· · · Token3: example.c:1:9: string literal "\"nop\"",
· · · Token4: example.c:1:14: ')' ")",
· · },
· · Token: example.c:1:15: ';' ";",
· },
· Case: ExternalDeclarationAsmStmt,
}
Example (Decl)
fmt.Println(exampleAST(249, "register int i __asm__(\"r0\");"))
Output:

&cc.ExternalDeclaration{
· Case: ExternalDeclarationDecl,
· Declaration: &cc.Declaration{
· · Case: DeclarationDecl,
· · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · Case: DeclarationSpecifiersStorage,
· · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · Case: DeclarationSpecifiersTypeSpec,
· · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · Case: TypeSpecifierInt,
· · · · · Token: example.c:1:10: 'int' "int",
· · · · },
· · · },
· · · StorageClassSpecifier: &cc.StorageClassSpecifier{
· · · · Case: StorageClassSpecifierRegister,
· · · · Token: example.c:1:1: 'register' "register",
· · · },
· · },
· · InitDeclaratorList: &cc.InitDeclaratorList{
· · · InitDeclarator: &cc.InitDeclarator{
· · · · Asm: &cc.Asm{
· · · · · Token: example.c:1:16: '__asm__' "__asm__",
· · · · · Token2: example.c:1:23: '(' "(",
· · · · · Token3: example.c:1:24: string literal "\"r0\"",
· · · · · Token4: example.c:1:28: ')' ")",
· · · · },
· · · · Case: InitDeclaratorDecl,
· · · · Declarator: &cc.Declarator{
· · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · Case: DirectDeclaratorIdent,
· · · · · · Token: example.c:1:14: identifier "i",
· · · · · },
· · · · },
· · · },
· · },
· · Token: example.c:1:29: ';' ";",
· },
}
Example (Empty)
fmt.Println(exampleAST(251, ";"))
Output:

&cc.ExternalDeclaration{
· Case: ExternalDeclarationDecl,
· Declaration: &cc.Declaration{
· · Case: DeclarationDecl,
· · Token: example.c:1:1: ';' ";",
· },
}
Example (FuncDef)
fmt.Println(exampleAST(248, "int f() {}"))
Output:

&cc.ExternalDeclaration{
· Case: ExternalDeclarationFuncDef,
· FunctionDefinition: &cc.FunctionDefinition{
· · CompoundStatement: &cc.CompoundStatement{
· · · BlockItemList: &cc.BlockItemList{
· · · · BlockItem: &cc.BlockItem{
· · · · · Case: BlockItemDecl,
· · · · · Declaration: &cc.Declaration{
· · · · · · Case: DeclarationDecl,
· · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · · · Case: DeclarationSpecifiersStorage,
· · · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · · · · Case: DeclarationSpecifiersTypeQual,
· · · · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · · · · · Case: DeclarationSpecifiersTypeSpec,
· · · · · · · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · · · · · · Case: TypeSpecifierChar,
· · · · · · · · · · Token: example.c:1:9: 'char' "char",
· · · · · · · · · },
· · · · · · · · },
· · · · · · · · TypeQualifier: &cc.TypeQualifier{
· · · · · · · · · Case: TypeQualifierConst,
· · · · · · · · · Token: example.c:1:9: 'const' "const",
· · · · · · · · },
· · · · · · · },
· · · · · · · StorageClassSpecifier: &cc.StorageClassSpecifier{
· · · · · · · · Case: StorageClassSpecifierStatic,
· · · · · · · · Token: example.c:1:9: 'static' "static",
· · · · · · · },
· · · · · · },
· · · · · · InitDeclaratorList: &cc.InitDeclaratorList{
· · · · · · · InitDeclarator: &cc.InitDeclarator{
· · · · · · · · Case: InitDeclaratorInit,
· · · · · · · · Declarator: &cc.Declarator{
· · · · · · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · · · · · Case: DirectDeclaratorArr,
· · · · · · · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · · · · · · Case: DirectDeclaratorIdent,
· · · · · · · · · · · Token: example.c:1:9: identifier "__func__",
· · · · · · · · · · },
· · · · · · · · · · Token: example.c:1:9: '[' "[",
· · · · · · · · · · Token2: example.c:1:9: ']' "]",
· · · · · · · · · },
· · · · · · · · },
· · · · · · · · Initializer: &cc.Initializer{
· · · · · · · · · AssignmentExpression: &cc.PrimaryExpression{
· · · · · · · · · · Case: PrimaryExpressionString,
· · · · · · · · · · Token: example.c:1:9: string literal "\"f\"",
· · · · · · · · · },
· · · · · · · · · Case: InitializerExpr,
· · · · · · · · },
· · · · · · · · Token: example.c:1:9: '=' "=",
· · · · · · · },
· · · · · · },
· · · · · · Token: example.c:1:9: ';' ";",
· · · · · },
· · · · },
· · · },
· · · Token: example.c:1:9: '{' "{",
· · · Token2: example.c:1:10: '}' "}",
· · },
· · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · Case: DeclarationSpecifiersTypeSpec,
· · · TypeSpecifier: &cc.TypeSpecifier{
· · · · Case: TypeSpecifierInt,
· · · · Token: example.c:1:1: 'int' "int",
· · · },
· · },
· · Declarator: &cc.Declarator{
· · · DirectDeclarator: &cc.DirectDeclarator{
· · · · Case: DirectDeclaratorFuncParam,
· · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · Case: DirectDeclaratorIdent,
· · · · · Token: example.c:1:5: identifier "f",
· · · · },
· · · · Token: example.c:1:6: '(' "(",
· · · · Token2: example.c:1:7: ')' ")",
· · · },
· · },
· },
}

func (*ExternalDeclaration) Position

func (n *ExternalDeclaration) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*ExternalDeclaration) String

func (n *ExternalDeclaration) String() string

String implements fmt.Stringer.

type ExternalDeclarationCase

type ExternalDeclarationCase int

ExternalDeclarationCase represents case numbers of production ExternalDeclaration

const (
	ExternalDeclarationFuncDef ExternalDeclarationCase = iota
	ExternalDeclarationDecl
	ExternalDeclarationAsmStmt
	ExternalDeclarationEmpty
)

Values of type ExternalDeclarationCase

func (ExternalDeclarationCase) String

func (n ExternalDeclarationCase) String() string

String implements fmt.Stringer

type Field

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

func LeastCommonAncestorField added in v4.4.0

func LeastCommonAncestorField(s []*Initializer) (r *Field)

LeastCommonAncestorField returns the LCA field containing all field initializers in s, if any.

func (*Field) AccessBytes

func (n *Field) AccessBytes() int64

AccessBytes reports the size in bytes used to access n. AccessBytes can be smaller than size of n's type when n is a bit field.

func (*Field) Declarator

func (n *Field) Declarator() *Declarator

Declarator reports n's declarator, if any.

func (*Field) GroupSize

func (n *Field) GroupSize() int

GroupSize is the maximum .AccessByte() of a group.

A bitfield group is the set of bit fields that share the same .Offset(). Consider:

struct {
	int a:7, b:2;
}

field	.Offset()	group	.AccessBytes()	.GroupSize()
  a	    0		  0	      1		     2
  b	    0		  0	      2		     2

func (*Field) InOverlapGroup

func (n *Field) InOverlapGroup() bool

InOverlapGroup reports whether n, a bit field, is emdedded in a preceding larger bit field group.

A bitfield group is the set of bit fields that share the same .Offset(). Consider:

struct {
	int a:7, b:2, c:1;
}

field	.Offset()	group	.AccessBytes()
  a	    0		  0	      1
  b	    0		  0	      2
  c	    1		  1	      1

Because field b has offset 0 and access bytes 2, group 0 overlaps with group 1. Field c will report InOverlapGroup() == true.

func (*Field) Index

func (n *Field) Index() int

Index returns the zero based field declaration index.

func (*Field) IsBitfield

func (n *Field) IsBitfield() bool

IsBitfield reports whether n is a bit field.

func (*Field) IsFlexibleArrayMember

func (n *Field) IsFlexibleArrayMember() bool

IsFlexibleArrayMember reports whether n is a flexible array member.

https://en.wikipedia.org/wiki/Flexible_array_member

func (*Field) Mask

func (n *Field) Mask() uint64

Mask reports the mask used to access n. It is non zero only for bit fields.

func (*Field) Name

func (n *Field) Name() string

Name reports the name of f, if any.

func (*Field) Offset

func (n *Field) Offset() int64

Offset reports the offset of n in bytes.

func (*Field) OffsetBits

func (n *Field) OffsetBits() int

OffsetBits report n's additional bit offset to Offset. Non zero only for bit fields but can be zero even for a bit field, for example, the first bit field after a non bit field will have OffsetBits zero.

func (*Field) OuterGroupOffset added in v4.0.3

func (n *Field) OuterGroupOffset() int64

OuterGroupOffset reports the non-overlapping group offset of n in bytes. If n is not a bit field the value is the same as Offset(). If n is a bit field the value differs from Offset for bit fields reporting InOverlapGroup() == true.

func (*Field) Parent

func (n *Field) Parent() *Field

Parent reports the parent of n, if any. A field has a parent when it's resolved in certain contexts, for example:

struct {
	int a;
	struct {
		int b;
		int c;
		int d;
	} e;
	int f;
} g;

A postfix expression node for 'g.a' will have the field 'a' attached, with no parent. A postfix expression node for 'g.c' will have the field 'c' attached, with parent field 'e'.

func (*Field) ParentField added in v4.4.0

func (n *Field) ParentField() *Field

ParentField reports the parent field of n, if any. ParentField differs from Parent in that it works more generally, not only in certain contexts.

func (*Field) ParentType added in v4.3.0

func (n *Field) ParentType() Type

ParentType returns the type containing 'n'.

func (*Field) Type

func (n *Field) Type() Type

Type reports the type of f.

func (*Field) ValueBits

func (n *Field) ValueBits() int64

ValueBits reports n's size in bits.

type Float64Value

type Float64Value float64

func (Float64Value) Convert

func (n Float64Value) Convert(to Type) Value

type FunctionDefinition

type FunctionDefinition struct {
	CompoundStatement     *CompoundStatement
	DeclarationList       *DeclarationList
	DeclarationSpecifiers *DeclarationSpecifiers
	Declarator            *Declarator
	// contains filtered or unexported fields
}

FunctionDefinition represents data reduced by production:

FunctionDefinition:
        DeclarationSpecifiers Declarator DeclarationList CompoundStatement
Example (Case0)
fmt.Println(exampleAST(252, "int f() {}"))
Output:

&cc.FunctionDefinition{
· CompoundStatement: &cc.CompoundStatement{
· · BlockItemList: &cc.BlockItemList{
· · · BlockItem: &cc.BlockItem{
· · · · Case: BlockItemDecl,
· · · · Declaration: &cc.Declaration{
· · · · · Case: DeclarationDecl,
· · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · · Case: DeclarationSpecifiersStorage,
· · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · · · Case: DeclarationSpecifiersTypeQual,
· · · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · · · · Case: DeclarationSpecifiersTypeSpec,
· · · · · · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · · · · · Case: TypeSpecifierChar,
· · · · · · · · · Token: example.c:1:9: 'char' "char",
· · · · · · · · },
· · · · · · · },
· · · · · · · TypeQualifier: &cc.TypeQualifier{
· · · · · · · · Case: TypeQualifierConst,
· · · · · · · · Token: example.c:1:9: 'const' "const",
· · · · · · · },
· · · · · · },
· · · · · · StorageClassSpecifier: &cc.StorageClassSpecifier{
· · · · · · · Case: StorageClassSpecifierStatic,
· · · · · · · Token: example.c:1:9: 'static' "static",
· · · · · · },
· · · · · },
· · · · · InitDeclaratorList: &cc.InitDeclaratorList{
· · · · · · InitDeclarator: &cc.InitDeclarator{
· · · · · · · Case: InitDeclaratorInit,
· · · · · · · Declarator: &cc.Declarator{
· · · · · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · · · · Case: DirectDeclaratorArr,
· · · · · · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · · · · · Case: DirectDeclaratorIdent,
· · · · · · · · · · Token: example.c:1:9: identifier "__func__",
· · · · · · · · · },
· · · · · · · · · Token: example.c:1:9: '[' "[",
· · · · · · · · · Token2: example.c:1:9: ']' "]",
· · · · · · · · },
· · · · · · · },
· · · · · · · Initializer: &cc.Initializer{
· · · · · · · · AssignmentExpression: &cc.PrimaryExpression{
· · · · · · · · · Case: PrimaryExpressionString,
· · · · · · · · · Token: example.c:1:9: string literal "\"f\"",
· · · · · · · · },
· · · · · · · · Case: InitializerExpr,
· · · · · · · },
· · · · · · · Token: example.c:1:9: '=' "=",
· · · · · · },
· · · · · },
· · · · · Token: example.c:1:9: ';' ";",
· · · · },
· · · },
· · },
· · Token: example.c:1:9: '{' "{",
· · Token2: example.c:1:10: '}' "}",
· },
· DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · Case: DeclarationSpecifiersTypeSpec,
· · TypeSpecifier: &cc.TypeSpecifier{
· · · Case: TypeSpecifierInt,
· · · Token: example.c:1:1: 'int' "int",
· · },
· },
· Declarator: &cc.Declarator{
· · DirectDeclarator: &cc.DirectDeclarator{
· · · Case: DirectDeclaratorFuncParam,
· · · DirectDeclarator: &cc.DirectDeclarator{
· · · · Case: DirectDeclaratorIdent,
· · · · Token: example.c:1:5: identifier "f",
· · · },
· · · Token: example.c:1:6: '(' "(",
· · · Token2: example.c:1:7: ')' ")",
· · },
· },
}

func (*FunctionDefinition) Position

func (n *FunctionDefinition) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*FunctionDefinition) String

func (n *FunctionDefinition) String() string

String implements fmt.Stringer.

func (*FunctionDefinition) UsesVectors added in v4.1.1

func (n *FunctionDefinition) UsesVectors() bool

UsesVectors reports whether n uses any vector type.

type FunctionSpecifier

type FunctionSpecifier struct {
	Case  FunctionSpecifierCase `PrettyPrint:"stringer,zero"`
	Token Token
}

FunctionSpecifier represents data reduced by productions:

FunctionSpecifier:
        "inline"     // Case FunctionSpecifierInline
|       "_Noreturn"  // Case FunctionSpecifierNoreturn
Example (Inline)
fmt.Println(exampleAST(168, "inline int f() {}"))
Output:

&cc.FunctionSpecifier{
· Case: FunctionSpecifierInline,
· Token: example.c:1:1: 'inline' "inline",
}
Example (Noreturn)
fmt.Println(exampleAST(169, "_Noreturn int f() {}"))
Output:

&cc.FunctionSpecifier{
· Case: FunctionSpecifierNoreturn,
· Token: example.c:1:1: '_Noreturn' "_Noreturn",
}

func (*FunctionSpecifier) Position

func (n *FunctionSpecifier) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*FunctionSpecifier) String

func (n *FunctionSpecifier) String() string

String implements fmt.Stringer.

type FunctionSpecifierCase

type FunctionSpecifierCase int

FunctionSpecifierCase represents case numbers of production FunctionSpecifier

const (
	FunctionSpecifierInline FunctionSpecifierCase = iota
	FunctionSpecifierNoreturn
)

Values of type FunctionSpecifierCase

func (FunctionSpecifierCase) String

func (n FunctionSpecifierCase) String() string

String implements fmt.Stringer

type FunctionType

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

func (*FunctionType) Align

func (n *FunctionType) Align() int

Align implements Type.

func (FunctionType) Attributes

func (n FunctionType) Attributes() *Attributes

Attributes implemets Type.

func (FunctionType) BitField added in v4.1.1

func (FunctionType) BitField() *Field

BitField implements Type.

func (*FunctionType) Decay

func (n *FunctionType) Decay() Type

Decay implements Type.

func (*FunctionType) FieldAlign

func (n *FunctionType) FieldAlign() int

FieldAlign implements Type.

func (*FunctionType) IsCompatible

func (n *FunctionType) IsCompatible(t Type) (r bool)

func (*FunctionType) IsIncomplete

func (n *FunctionType) IsIncomplete() bool

IsIncomplete implements Type.

func (*FunctionType) IsVariadic

func (n *FunctionType) IsVariadic() bool

IsVariadic reports whether n is variadic.

func (*FunctionType) Kind

func (n *FunctionType) Kind() Kind

Kind implements Type.

func (*FunctionType) MaxArgs

func (n *FunctionType) MaxArgs() int

MaxArgs returns the maximum number of arguments n expects. Variadic functions return a negative value.

func (*FunctionType) MinArgs

func (n *FunctionType) MinArgs() int

MinArgs returns the minimum number of arguments n expects.

func (*FunctionType) Parameters

func (n *FunctionType) Parameters() []*Parameter

Parameters returns function type parameters.

func (*FunctionType) Pointer

func (n *FunctionType) Pointer() Type

Pointer implements Type.

func (*FunctionType) Result

func (n *FunctionType) Result() Type

Result reports the result type of n.

func (*FunctionType) Size

func (n *FunctionType) Size() int64

Size implements Type.

func (*FunctionType) String

func (n *FunctionType) String() string

String implements Type.

func (FunctionType) Typedef

func (n FunctionType) Typedef() *Declarator

Typedef implements Type

func (*FunctionType) Undecay

func (n *FunctionType) Undecay() Type

Undecay implements Type.

func (*FunctionType) UsesVectors added in v4.1.1

func (n *FunctionType) UsesVectors() bool

UsesVectors reports whether n uses any vector tyoe.

func (FunctionType) VectorSize

func (FunctionType) VectorSize() int64

VectorSize implements Type.

type GenericAssociation

type GenericAssociation struct {
	AssignmentExpression ExpressionNode
	Case                 GenericAssociationCase `PrettyPrint:"stringer,zero"`
	Token                Token
	Token2               Token
	TypeName             *TypeName
}

GenericAssociation represents data reduced by productions:

GenericAssociation:
        TypeName ':' AssignmentExpression   // Case GenericAssociationType
|       "default" ':' AssignmentExpression  // Case GenericAssociationDefault
Example (Default)
fmt.Println(exampleAST(15, "int i = _Generic(x, default: y)(42);"))
Output:

&cc.GenericAssociation{
· AssignmentExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:30: identifier "y",
· },
· Case: GenericAssociationDefault,
· Token: example.c:1:21: 'default' "default",
· Token2: example.c:1:28: ':' ":",
}
Example (Type)
fmt.Println(exampleAST(14, "int i = _Generic(x, int: y)(42);"))
Output:

&cc.GenericAssociation{
· AssignmentExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:26: identifier "y",
· },
· Case: GenericAssociationType,
· Token: example.c:1:24: ':' ":",
· TypeName: &cc.TypeName{
· · SpecifierQualifierList: &cc.SpecifierQualifierList{
· · · Case: SpecifierQualifierListTypeSpec,
· · · TypeSpecifier: &cc.TypeSpecifier{
· · · · Case: TypeSpecifierInt,
· · · · Token: example.c:1:21: 'int' "int",
· · · },
· · },
· },
}

func (*GenericAssociation) Position

func (n *GenericAssociation) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*GenericAssociation) String

func (n *GenericAssociation) String() string

String implements fmt.Stringer.

type GenericAssociationCase

type GenericAssociationCase int

GenericAssociationCase represents case numbers of production GenericAssociation

const (
	GenericAssociationType GenericAssociationCase = iota
	GenericAssociationDefault
)

Values of type GenericAssociationCase

func (GenericAssociationCase) String

func (n GenericAssociationCase) String() string

String implements fmt.Stringer

type GenericAssociationList

type GenericAssociationList struct {
	GenericAssociation     *GenericAssociation
	GenericAssociationList *GenericAssociationList
	Token                  Token
}

GenericAssociationList represents data reduced by productions:

GenericAssociationList:
        GenericAssociation
|       GenericAssociationList ',' GenericAssociation
Example (Case0)
fmt.Println(exampleAST(12, "int i = _Generic(x, int: y)(42);"))
Output:

&cc.GenericAssociationList{
· GenericAssociation: &cc.GenericAssociation{
· · AssignmentExpression: &cc.PrimaryExpression{
· · · Case: PrimaryExpressionIdent,
· · · Token: example.c:1:26: identifier "y",
· · },
· · Case: GenericAssociationType,
· · Token: example.c:1:24: ':' ":",
· · TypeName: &cc.TypeName{
· · · SpecifierQualifierList: &cc.SpecifierQualifierList{
· · · · Case: SpecifierQualifierListTypeSpec,
· · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · Case: TypeSpecifierInt,
· · · · · Token: example.c:1:21: 'int' "int",
· · · · },
· · · },
· · },
· },
}
Example (Case1)
fmt.Println(exampleAST(13, "int i = _Generic(x, int: y, float: z)(42);"))
Output:

&cc.GenericAssociationList{
· GenericAssociation: &cc.GenericAssociation{
· · AssignmentExpression: &cc.PrimaryExpression{
· · · Case: PrimaryExpressionIdent,
· · · Token: example.c:1:26: identifier "y",
· · },
· · Case: GenericAssociationType,
· · Token: example.c:1:24: ':' ":",
· · TypeName: &cc.TypeName{
· · · SpecifierQualifierList: &cc.SpecifierQualifierList{
· · · · Case: SpecifierQualifierListTypeSpec,
· · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · Case: TypeSpecifierInt,
· · · · · Token: example.c:1:21: 'int' "int",
· · · · },
· · · },
· · },
· },
· GenericAssociationList: &cc.GenericAssociationList{
· · GenericAssociation: &cc.GenericAssociation{
· · · AssignmentExpression: &cc.PrimaryExpression{
· · · · Case: PrimaryExpressionIdent,
· · · · Token: example.c:1:36: identifier "z",
· · · },
· · · Case: GenericAssociationType,
· · · Token: example.c:1:34: ':' ":",
· · · TypeName: &cc.TypeName{
· · · · SpecifierQualifierList: &cc.SpecifierQualifierList{
· · · · · Case: SpecifierQualifierListTypeSpec,
· · · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · · Case: TypeSpecifierFloat,
· · · · · · Token: example.c:1:29: 'float' "float",
· · · · · },
· · · · },
· · · },
· · },
· · Token: example.c:1:27: ',' ",",
· },
}

func (*GenericAssociationList) Position

func (n *GenericAssociationList) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*GenericAssociationList) String

func (n *GenericAssociationList) String() string

String implements fmt.Stringer.

type GenericSelection

type GenericSelection struct {
	AssignmentExpression   ExpressionNode
	GenericAssociationList *GenericAssociationList
	Token                  Token
	Token2                 Token
	Token3                 Token
	Token4                 Token
	// contains filtered or unexported fields
}

GenericSelection represents data reduced by production:

GenericSelection:
        "_Generic" '(' AssignmentExpression ',' GenericAssociationList ')'
Example (Case0)
fmt.Println(exampleAST(11, "int i = _Generic(x, int: y)(42);"))
Output:

&cc.GenericSelection{
· AssignmentExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:18: identifier "x",
· },
· GenericAssociationList: &cc.GenericAssociationList{
· · GenericAssociation: &cc.GenericAssociation{
· · · AssignmentExpression: &cc.PrimaryExpression{
· · · · Case: PrimaryExpressionIdent,
· · · · Token: example.c:1:26: identifier "y",
· · · },
· · · Case: GenericAssociationType,
· · · Token: example.c:1:24: ':' ":",
· · · TypeName: &cc.TypeName{
· · · · SpecifierQualifierList: &cc.SpecifierQualifierList{
· · · · · Case: SpecifierQualifierListTypeSpec,
· · · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · · Case: TypeSpecifierInt,
· · · · · · Token: example.c:1:21: 'int' "int",
· · · · · },
· · · · },
· · · },
· · },
· },
· Token: example.c:1:9: '_Generic' "_Generic",
· Token2: example.c:1:17: '(' "(",
· Token3: example.c:1:19: ',' ",",
· Token4: example.c:1:27: ')' ")",
}

func (*GenericSelection) Associated

func (n *GenericSelection) Associated() *GenericAssociation

Associated returns the selected association of n, if any.

func (*GenericSelection) Position

func (n *GenericSelection) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*GenericSelection) String

func (n *GenericSelection) String() string

String implements fmt.Stringer.

func (GenericSelection) Type

func (t GenericSelection) Type() Type

Type returns the type of a node or an *InvalidType type value, if the type is unknown/undetermined.

type IdentifierList

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

IdentifierList represents data reduced by productions:

IdentifierList:
        IDENTIFIER
|       IdentifierList ',' IDENTIFIER
Example (Case0)
fmt.Println(exampleAST(192, "int f(i) int i; {}"))
Output:

&cc.IdentifierList{
· Token2: example.c:1:7: identifier "i",
}
Example (Case1)
fmt.Println(exampleAST(193, "int f(i, j) int i, j; {}"))
Output:

&cc.IdentifierList{
· IdentifierList: &cc.IdentifierList{
· · Token: example.c:1:8: ',' ",",
· · Token2: example.c:1:10: identifier "j",
· },
· Token2: example.c:1:7: identifier "i",
}

func (*IdentifierList) Position

func (n *IdentifierList) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*IdentifierList) String

func (n *IdentifierList) String() string

String implements fmt.Stringer.

type InclusiveOrExpression

type InclusiveOrExpression struct {
	Case                  InclusiveOrExpressionCase `PrettyPrint:"stringer,zero"`
	ExclusiveOrExpression ExpressionNode
	InclusiveOrExpression ExpressionNode
	Token                 Token
	// contains filtered or unexported fields
}

InclusiveOrExpression represents data reduced by productions:

InclusiveOrExpression:
        ExclusiveOrExpression                            // Case InclusiveOrExpressionXor
|       InclusiveOrExpression '|' ExclusiveOrExpression  // Case InclusiveOrExpressionOr
Example (Or)
fmt.Println(exampleAST(67, "int i = x|y;"))
Output:

&cc.InclusiveOrExpression{
· Case: InclusiveOrExpressionOr,
· ExclusiveOrExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:11: identifier "y",
· },
· InclusiveOrExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:9: identifier "x",
· },
· Token: example.c:1:10: '|' "|",
}

func (*InclusiveOrExpression) Position

func (n *InclusiveOrExpression) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*InclusiveOrExpression) Pure added in v4.6.0

func (p *InclusiveOrExpression) Pure() bool

Pure implements ExpressionNode.

func (*InclusiveOrExpression) String

func (n *InclusiveOrExpression) String() string

String implements fmt.Stringer.

func (InclusiveOrExpression) Type

func (t InclusiveOrExpression) Type() Type

Type returns the type of a node or an *InvalidType type value, if the type is unknown/undetermined.

func (InclusiveOrExpression) Value

func (v InclusiveOrExpression) Value() Value

Value returns the value of a node or UnknownValue if it is undetermined. The dynamic type of a Value is one of

*ComplexLongDoubleValue
*LongDoubleValue
*UnknownValue
*ZeroValue
Complex128Value
Complex64Value
Float64Value
Int64Value
StringValue
UInt64Value
UTF16StringValue
UTF32StringValue
VoidValue

type InclusiveOrExpressionCase

type InclusiveOrExpressionCase int

InclusiveOrExpressionCase represents case numbers of production InclusiveOrExpression

const (
	InclusiveOrExpressionXor InclusiveOrExpressionCase = iota
	InclusiveOrExpressionOr
)

Values of type InclusiveOrExpressionCase

func (InclusiveOrExpressionCase) String

func (n InclusiveOrExpressionCase) String() string

String implements fmt.Stringer

type InitDeclarator

type InitDeclarator struct {
	AttributeSpecifierList *AttributeSpecifierList
	Asm                    *Asm
	Case                   InitDeclaratorCase `PrettyPrint:"stringer,zero"`
	Declarator             *Declarator
	Initializer            *Initializer
	Token                  Token
}

InitDeclarator represents data reduced by productions:

InitDeclarator:
        Declarator Asm                  // Case InitDeclaratorDecl
|       Declarator Asm '=' Initializer  // Case InitDeclaratorInit
Example (Decl)
fmt.Println(exampleAST(101, "register int i __asm__(\"r0\");"))
Output:

&cc.InitDeclarator{
· Asm: &cc.Asm{
· · Token: example.c:1:16: '__asm__' "__asm__",
· · Token2: example.c:1:23: '(' "(",
· · Token3: example.c:1:24: string literal "\"r0\"",
· · Token4: example.c:1:28: ')' ")",
· },
· Case: InitDeclaratorDecl,
· Declarator: &cc.Declarator{
· · DirectDeclarator: &cc.DirectDeclarator{
· · · Case: DirectDeclaratorIdent,
· · · Token: example.c:1:14: identifier "i",
· · },
· },
}
Example (Init)
fmt.Println(exampleAST(102, "register int i __asm__(\"r0\") = x;"))
Output:

&cc.InitDeclarator{
· Asm: &cc.Asm{
· · Token: example.c:1:16: '__asm__' "__asm__",
· · Token2: example.c:1:23: '(' "(",
· · Token3: example.c:1:24: string literal "\"r0\"",
· · Token4: example.c:1:28: ')' ")",
· },
· Case: InitDeclaratorInit,
· Declarator: &cc.Declarator{
· · DirectDeclarator: &cc.DirectDeclarator{
· · · Case: DirectDeclaratorIdent,
· · · Token: example.c:1:14: identifier "i",
· · },
· },
· Initializer: &cc.Initializer{
· · AssignmentExpression: &cc.PrimaryExpression{
· · · Case: PrimaryExpressionIdent,
· · · Token: example.c:1:32: identifier "x",
· · },
· · Case: InitializerExpr,
· },
· Token: example.c:1:30: '=' "=",
}

func (*InitDeclarator) Position

func (n *InitDeclarator) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*InitDeclarator) String

func (n *InitDeclarator) String() string

String implements fmt.Stringer.

type InitDeclaratorCase

type InitDeclaratorCase int

InitDeclaratorCase represents case numbers of production InitDeclarator

const (
	InitDeclaratorDecl InitDeclaratorCase = iota
	InitDeclaratorInit
)

Values of type InitDeclaratorCase

func (InitDeclaratorCase) String

func (n InitDeclaratorCase) String() string

String implements fmt.Stringer

type InitDeclaratorList

type InitDeclaratorList struct {
	AttributeSpecifierList *AttributeSpecifierList
	InitDeclarator         *InitDeclarator
	InitDeclaratorList     *InitDeclaratorList
	Token                  Token
}

InitDeclaratorList represents data reduced by productions:

InitDeclaratorList:
        InitDeclarator
|       InitDeclaratorList ',' InitDeclarator
Example (Case0)
fmt.Println(exampleAST(99, "int i;"))
Output:

&cc.InitDeclaratorList{
· InitDeclarator: &cc.InitDeclarator{
· · Case: InitDeclaratorDecl,
· · Declarator: &cc.Declarator{
· · · DirectDeclarator: &cc.DirectDeclarator{
· · · · Case: DirectDeclaratorIdent,
· · · · Token: example.c:1:5: identifier "i",
· · · },
· · },
· },
}
Example (Case1)
fmt.Println(exampleAST(100, "int i, __attribute__((a)) j;"))
Output:

&cc.InitDeclaratorList{
· InitDeclarator: &cc.InitDeclarator{
· · Case: InitDeclaratorDecl,
· · Declarator: &cc.Declarator{
· · · DirectDeclarator: &cc.DirectDeclarator{
· · · · Case: DirectDeclaratorIdent,
· · · · Token: example.c:1:5: identifier "i",
· · · },
· · },
· },
· InitDeclaratorList: &cc.InitDeclaratorList{
· · AttributeSpecifierList: &cc.AttributeSpecifierList{
· · · AttributeSpecifier: &cc.AttributeSpecifier{
· · · · AttributeValueList: &cc.AttributeValueList{
· · · · · AttributeValue: &cc.AttributeValue{
· · · · · · Case: AttributeValueIdent,
· · · · · · Token: example.c:1:23: identifier "a",
· · · · · },
· · · · },
· · · · Token: example.c:1:8: '__attribute__' "__attribute__",
· · · · Token2: example.c:1:21: '(' "(",
· · · · Token3: example.c:1:22: '(' "(",
· · · · Token4: example.c:1:24: ')' ")",
· · · · Token5: example.c:1:25: ')' ")",
· · · },
· · },
· · InitDeclarator: &cc.InitDeclarator{
· · · Case: InitDeclaratorDecl,
· · · Declarator: &cc.Declarator{
· · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · Case: DirectDeclaratorIdent,
· · · · · Token: example.c:1:27: identifier "j",
· · · · },
· · · },
· · },
· · Token: example.c:1:6: ',' ",",
· },
}

func (*InitDeclaratorList) Position

func (n *InitDeclaratorList) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*InitDeclaratorList) String

func (n *InitDeclaratorList) String() string

String implements fmt.Stringer.

type Initializer

type Initializer struct {
	AssignmentExpression ExpressionNode
	Case                 InitializerCase `PrettyPrint:"stringer,zero"`
	InitializerList      *InitializerList
	Token                Token
	Token2               Token
	Token3               Token
	// contains filtered or unexported fields
}

Initializer represents data reduced by productions:

Initializer:
        AssignmentExpression         // Case InitializerExpr
|       '{' InitializerList ',' '}'  // Case InitializerInitList
Example (Expr)
fmt.Println(exampleAST(203, "int i = x;"))
Output:

&cc.Initializer{
· AssignmentExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:9: identifier "x",
· },
· Case: InitializerExpr,
}
Example (InitList)
fmt.Println(exampleAST(204, "int i[] = { x };"))
Output:

&cc.Initializer{
· Case: InitializerInitList,
· InitializerList: &cc.InitializerList{
· · Initializer: &cc.Initializer{
· · · AssignmentExpression: &cc.PrimaryExpression{
· · · · Case: PrimaryExpressionIdent,
· · · · Token: example.c:1:13: identifier "x",
· · · },
· · · Case: InitializerExpr,
· · },
· },
· Token: example.c:1:11: '{' "{",
· Token3: example.c:1:15: '}' "}",
}

func (*Initializer) Field added in v4.0.3

func (n *Initializer) Field() *Field

Field returns the field associated with n, if any.

func (*Initializer) Len

func (n *Initializer) Len() int64

Len returns the number of array elements initialized. It's normally one, but can be more using the [lo ... hi] designator.

func (*Initializer) Offset

func (n *Initializer) Offset() int64

Offset returns the offset of n within it's containing type.

func (*Initializer) Order added in v4.1.1

func (n *Initializer) Order() int64

Order returns a number that can be used to order initializers in their order of appearance in the preprocessed source.

func (*Initializer) Parent

func (n *Initializer) Parent() *Initializer

Parent returns Initalizer m that has n on its InitializerList, if any.

func (*Initializer) Position

func (n *Initializer) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*Initializer) String

func (n *Initializer) String() string

String implements fmt.Stringer.

func (Initializer) Type

func (t Initializer) Type() Type

Type returns the type of a node or an *InvalidType type value, if the type is unknown/undetermined.

func (Initializer) Value

func (v Initializer) Value() Value

Value returns the value of a node or UnknownValue if it is undetermined. The dynamic type of a Value is one of

*ComplexLongDoubleValue
*LongDoubleValue
*UnknownValue
*ZeroValue
Complex128Value
Complex64Value
Float64Value
Int64Value
StringValue
UInt64Value
UTF16StringValue
UTF32StringValue
VoidValue

type InitializerCase

type InitializerCase int

InitializerCase represents case numbers of production Initializer

const (
	InitializerExpr InitializerCase = iota
	InitializerInitList
)

Values of type InitializerCase

func (InitializerCase) String

func (n InitializerCase) String() string

String implements fmt.Stringer

type InitializerList

type InitializerList struct {
	Designation     *Designation
	Initializer     *Initializer
	InitializerList *InitializerList
	Token           Token
	// contains filtered or unexported fields
}

InitializerList represents data reduced by productions:

InitializerList:
        Designation Initializer
|       InitializerList ',' Designation Initializer
Example (Case0)
fmt.Println(exampleAST(205, "int i[] = { [10] = x };"))
Output:

&cc.InitializerList{
· Designation: &cc.Designation{
· · DesignatorList: &cc.DesignatorList{
· · · Designator: &cc.Designator{
· · · · Case: DesignatorIndex,
· · · · ConstantExpression: &cc.ConstantExpression{
· · · · · ConditionalExpression: &cc.PrimaryExpression{
· · · · · · Case: PrimaryExpressionInt,
· · · · · · Token: example.c:1:14: integer constant "10",
· · · · · },
· · · · },
· · · · Token: example.c:1:13: '[' "[",
· · · · Token2: example.c:1:16: ']' "]",
· · · },
· · },
· · Token: example.c:1:18: '=' "=",
· },
· Initializer: &cc.Initializer{
· · AssignmentExpression: &cc.PrimaryExpression{
· · · Case: PrimaryExpressionIdent,
· · · Token: example.c:1:20: identifier "x",
· · },
· · Case: InitializerExpr,
· },
}
Example (Case1)
fmt.Println(exampleAST(206, "int i[] = { [10] = x, [20] = y };"))
Output:

&cc.InitializerList{
· Designation: &cc.Designation{
· · DesignatorList: &cc.DesignatorList{
· · · Designator: &cc.Designator{
· · · · Case: DesignatorIndex,
· · · · ConstantExpression: &cc.ConstantExpression{
· · · · · ConditionalExpression: &cc.PrimaryExpression{
· · · · · · Case: PrimaryExpressionInt,
· · · · · · Token: example.c:1:14: integer constant "10",
· · · · · },
· · · · },
· · · · Token: example.c:1:13: '[' "[",
· · · · Token2: example.c:1:16: ']' "]",
· · · },
· · },
· · Token: example.c:1:18: '=' "=",
· },
· Initializer: &cc.Initializer{
· · AssignmentExpression: &cc.PrimaryExpression{
· · · Case: PrimaryExpressionIdent,
· · · Token: example.c:1:20: identifier "x",
· · },
· · Case: InitializerExpr,
· },
· InitializerList: &cc.InitializerList{
· · Designation: &cc.Designation{
· · · DesignatorList: &cc.DesignatorList{
· · · · Designator: &cc.Designator{
· · · · · Case: DesignatorIndex,
· · · · · ConstantExpression: &cc.ConstantExpression{
· · · · · · ConditionalExpression: &cc.PrimaryExpression{
· · · · · · · Case: PrimaryExpressionInt,
· · · · · · · Token: example.c:1:24: integer constant "20",
· · · · · · },
· · · · · },
· · · · · Token: example.c:1:23: '[' "[",
· · · · · Token2: example.c:1:26: ']' "]",
· · · · },
· · · },
· · · Token: example.c:1:28: '=' "=",
· · },
· · Initializer: &cc.Initializer{
· · · AssignmentExpression: &cc.PrimaryExpression{
· · · · Case: PrimaryExpressionIdent,
· · · · Token: example.c:1:30: identifier "y",
· · · },
· · · Case: InitializerExpr,
· · },
· · Token: example.c:1:21: ',' ",",
· },
}

func (*InitializerList) Position

func (n *InitializerList) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*InitializerList) String

func (n *InitializerList) String() string

String implements fmt.Stringer.

func (InitializerList) Type

func (t InitializerList) Type() Type

Type returns the type of a node or an *InvalidType type value, if the type is unknown/undetermined.

func (*InitializerList) UnionField added in v4.1.1

func (n *InitializerList) UnionField() *Field

UnionField reports the union field initilized by n.

type Int64Value

type Int64Value int64

func (Int64Value) Convert

func (n Int64Value) Convert(to Type) Value

type InvalidType

type InvalidType struct{}

func (*InvalidType) Align

func (n *InvalidType) Align() int

Align implements Type.

func (*InvalidType) Attributes

func (n *InvalidType) Attributes() *Attributes

Attributes implements Type.

func (*InvalidType) BitField added in v4.1.1

func (n *InvalidType) BitField() *Field

BitField implements Type.

func (*InvalidType) Decay

func (n *InvalidType) Decay() Type

Decay implements Type.

func (*InvalidType) FieldAlign

func (n *InvalidType) FieldAlign() int

FieldAlign implements Type.

func (*InvalidType) IsCompatible

func (n *InvalidType) IsCompatible(Type) bool

func (*InvalidType) IsIncomplete

func (n *InvalidType) IsIncomplete() bool

IsIncomplete implements Type.

func (*InvalidType) Kind

func (n *InvalidType) Kind() Kind

Kind implements Type.

func (*InvalidType) Pointer

func (n *InvalidType) Pointer() Type

Pointer implements Type.

func (*InvalidType) Size

func (n *InvalidType) Size() int64

Size implements Type.

func (*InvalidType) String

func (n *InvalidType) String() string

String implements Type.

func (*InvalidType) Typedef

func (n *InvalidType) Typedef() *Declarator

Name implements Type.

func (*InvalidType) Undecay

func (n *InvalidType) Undecay() Type

Undecay implements Type.

func (*InvalidType) VectorSize

func (n *InvalidType) VectorSize() int64

VectorSize implements Type.

type IterationStatement

type IterationStatement struct {
	Case            IterationStatementCase `PrettyPrint:"stringer,zero"`
	Declaration     *Declaration
	ExpressionList  ExpressionNode
	ExpressionList2 ExpressionNode
	ExpressionList3 ExpressionNode
	Statement       *Statement
	Token           Token
	Token2          Token
	Token3          Token
	Token4          Token
	Token5          Token
	// contains filtered or unexported fields
}

IterationStatement represents data reduced by productions:

IterationStatement:
        "while" '(' ExpressionList ')' Statement                                      // Case IterationStatementWhile
|       "do" Statement "while" '(' ExpressionList ')' ';'                             // Case IterationStatementDo
|       "for" '(' ExpressionList ';' ExpressionList ';' ExpressionList ')' Statement  // Case IterationStatementFor
|       "for" '(' Declaration ExpressionList ';' ExpressionList ')' Statement         // Case IterationStatementForDecl
Example (Do)
fmt.Println(exampleAST(238, "int f() { do x(); while(y); }"))
Output:

&cc.IterationStatement{
· Case: IterationStatementDo,
· ExpressionList: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:25: identifier "y",
· },
· Statement: &cc.Statement{
· · Case: StatementExpr,
· · ExpressionStatement: &cc.ExpressionStatement{
· · · ExpressionList: &cc.PostfixExpression{
· · · · Case: PostfixExpressionCall,
· · · · PostfixExpression: &cc.PrimaryExpression{
· · · · · Case: PrimaryExpressionIdent,
· · · · · Token: example.c:1:14: identifier "x",
· · · · },
· · · · Token: example.c:1:15: '(' "(",
· · · · Token2: example.c:1:16: ')' ")",
· · · },
· · · Token: example.c:1:17: ';' ";",
· · },
· },
· Token: example.c:1:11: 'do' "do",
· Token2: example.c:1:19: 'while' "while",
· Token3: example.c:1:24: '(' "(",
· Token4: example.c:1:26: ')' ")",
· Token5: example.c:1:27: ';' ";",
}
Example (For)
fmt.Println(exampleAST(239, "int f() { for( i = 0; i < 10; i++) x(); }"))
Output:

&cc.IterationStatement{
· Case: IterationStatementFor,
· ExpressionList: &cc.AssignmentExpression{
· · AssignmentExpression: &cc.PrimaryExpression{
· · · Case: PrimaryExpressionInt,
· · · Token: example.c:1:20: integer constant "0",
· · },
· · Case: AssignmentExpressionAssign,
· · Token: example.c:1:18: '=' "=",
· · UnaryExpression: &cc.PrimaryExpression{
· · · Case: PrimaryExpressionIdent,
· · · Token: example.c:1:16: identifier "i",
· · },
· },
· ExpressionList2: &cc.RelationalExpression{
· · Case: RelationalExpressionLt,
· · RelationalExpression: &cc.PrimaryExpression{
· · · Case: PrimaryExpressionIdent,
· · · Token: example.c:1:23: identifier "i",
· · },
· · ShiftExpression: &cc.PrimaryExpression{
· · · Case: PrimaryExpressionInt,
· · · Token: example.c:1:27: integer constant "10",
· · },
· · Token: example.c:1:25: '<' "<",
· },
· ExpressionList3: &cc.PostfixExpression{
· · Case: PostfixExpressionInc,
· · PostfixExpression: &cc.PrimaryExpression{
· · · Case: PrimaryExpressionIdent,
· · · Token: example.c:1:31: identifier "i",
· · },
· · Token: example.c:1:32: '++' "++",
· },
· Statement: &cc.Statement{
· · Case: StatementExpr,
· · ExpressionStatement: &cc.ExpressionStatement{
· · · ExpressionList: &cc.PostfixExpression{
· · · · Case: PostfixExpressionCall,
· · · · PostfixExpression: &cc.PrimaryExpression{
· · · · · Case: PrimaryExpressionIdent,
· · · · · Token: example.c:1:36: identifier "x",
· · · · },
· · · · Token: example.c:1:37: '(' "(",
· · · · Token2: example.c:1:38: ')' ")",
· · · },
· · · Token: example.c:1:39: ';' ";",
· · },
· },
· Token: example.c:1:11: 'for' "for",
· Token2: example.c:1:14: '(' "(",
· Token3: example.c:1:21: ';' ";",
· Token4: example.c:1:29: ';' ";",
· Token5: example.c:1:34: ')' ")",
}
Example (ForDecl)
fmt.Println(exampleAST(240, "int f() { for( int i = 0; i < 10; i++) x(); }"))
Output:

&cc.IterationStatement{
· Case: IterationStatementForDecl,
· Declaration: &cc.Declaration{
· · Case: DeclarationDecl,
· · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · Case: DeclarationSpecifiersTypeSpec,
· · · TypeSpecifier: &cc.TypeSpecifier{
· · · · Case: TypeSpecifierInt,
· · · · Token: example.c:1:16: 'int' "int",
· · · },
· · },
· · InitDeclaratorList: &cc.InitDeclaratorList{
· · · InitDeclarator: &cc.InitDeclarator{
· · · · Case: InitDeclaratorInit,
· · · · Declarator: &cc.Declarator{
· · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · Case: DirectDeclaratorIdent,
· · · · · · Token: example.c:1:20: identifier "i",
· · · · · },
· · · · },
· · · · Initializer: &cc.Initializer{
· · · · · AssignmentExpression: &cc.PrimaryExpression{
· · · · · · Case: PrimaryExpressionInt,
· · · · · · Token: example.c:1:24: integer constant "0",
· · · · · },
· · · · · Case: InitializerExpr,
· · · · },
· · · · Token: example.c:1:22: '=' "=",
· · · },
· · },
· · Token: example.c:1:25: ';' ";",
· },
· ExpressionList: &cc.RelationalExpression{
· · Case: RelationalExpressionLt,
· · RelationalExpression: &cc.PrimaryExpression{
· · · Case: PrimaryExpressionIdent,
· · · Token: example.c:1:27: identifier "i",
· · },
· · ShiftExpression: &cc.PrimaryExpression{
· · · Case: PrimaryExpressionInt,
· · · Token: example.c:1:31: integer constant "10",
· · },
· · Token: example.c:1:29: '<' "<",
· },
· ExpressionList2: &cc.PostfixExpression{
· · Case: PostfixExpressionInc,
· · PostfixExpression: &cc.PrimaryExpression{
· · · Case: PrimaryExpressionIdent,
· · · Token: example.c:1:35: identifier "i",
· · },
· · Token: example.c:1:36: '++' "++",
· },
· Statement: &cc.Statement{
· · Case: StatementExpr,
· · ExpressionStatement: &cc.ExpressionStatement{
· · · ExpressionList: &cc.PostfixExpression{
· · · · Case: PostfixExpressionCall,
· · · · PostfixExpression: &cc.PrimaryExpression{
· · · · · Case: PrimaryExpressionIdent,
· · · · · Token: example.c:1:40: identifier "x",
· · · · },
· · · · Token: example.c:1:41: '(' "(",
· · · · Token2: example.c:1:42: ')' ")",
· · · },
· · · Token: example.c:1:43: ';' ";",
· · },
· },
· Token: example.c:1:11: 'for' "for",
· Token2: example.c:1:14: '(' "(",
· Token3: example.c:1:33: ';' ";",
· Token4: example.c:1:38: ')' ")",
}
Example (While)
fmt.Println(exampleAST(237, "int f() { while(x) y(); }"))
Output:

&cc.IterationStatement{
· Case: IterationStatementWhile,
· ExpressionList: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:17: identifier "x",
· },
· Statement: &cc.Statement{
· · Case: StatementExpr,
· · ExpressionStatement: &cc.ExpressionStatement{
· · · ExpressionList: &cc.PostfixExpression{
· · · · Case: PostfixExpressionCall,
· · · · PostfixExpression: &cc.PrimaryExpression{
· · · · · Case: PrimaryExpressionIdent,
· · · · · Token: example.c:1:20: identifier "y",
· · · · },
· · · · Token: example.c:1:21: '(' "(",
· · · · Token2: example.c:1:22: ')' ")",
· · · },
· · · Token: example.c:1:23: ';' ";",
· · },
· },
· Token: example.c:1:11: 'while' "while",
· Token2: example.c:1:16: '(' "(",
· Token3: example.c:1:18: ')' ")",
}

func (IterationStatement) LexicalScope

func (n IterationStatement) LexicalScope() *Scope

LexicalScope provides the scope a node appears in.

func (*IterationStatement) Position

func (n *IterationStatement) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*IterationStatement) String

func (n *IterationStatement) String() string

String implements fmt.Stringer.

type IterationStatementCase

type IterationStatementCase int

IterationStatementCase represents case numbers of production IterationStatement

const (
	IterationStatementWhile IterationStatementCase = iota
	IterationStatementDo
	IterationStatementFor
	IterationStatementForDecl
)

Values of type IterationStatementCase

func (IterationStatementCase) String

func (n IterationStatementCase) String() string

String implements fmt.Stringer

type JumpStatement

type JumpStatement struct {
	Case           JumpStatementCase `PrettyPrint:"stringer,zero"`
	ExpressionList ExpressionNode
	Token          Token
	Token2         Token
	Token3         Token
	// contains filtered or unexported fields
}

JumpStatement represents data reduced by productions:

JumpStatement:
        "goto" IDENTIFIER ';'          // Case JumpStatementGoto
|       "goto" '*' ExpressionList ';'  // Case JumpStatementGotoExpr
|       "continue" ';'                 // Case JumpStatementContinue
|       "break" ';'                    // Case JumpStatementBreak
|       "return" ExpressionList ';'    // Case JumpStatementReturn
Example (Break)
fmt.Println(exampleAST(244, "int f() { for(;;) if (i) break; }"))
Output:

&cc.JumpStatement{
· Case: JumpStatementBreak,
· Token: example.c:1:26: 'break' "break",
· Token2: example.c:1:31: ';' ";",
}
Example (Continue)
fmt.Println(exampleAST(243, "int f() { for(;;) if (i) continue; }"))
Output:

&cc.JumpStatement{
· Case: JumpStatementContinue,
· Token: example.c:1:26: 'continue' "continue",
· Token2: example.c:1:34: ';' ";",
}
Example (Goto)
fmt.Println(exampleAST(241, "int f() { L: goto L; }"))
Output:

&cc.JumpStatement{
· Case: JumpStatementGoto,
· Token: example.c:1:14: 'goto' "goto",
· Token2: example.c:1:19: identifier "L",
· Token3: example.c:1:20: ';' ";",
}
Example (GotoExpr)
fmt.Println(exampleAST(242, "int f() { L: x(); void *p = &&L; goto *p; }"))
Output:

&cc.JumpStatement{
· Case: JumpStatementGotoExpr,
· ExpressionList: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:40: identifier "p",
· },
· Token: example.c:1:34: 'goto' "goto",
· Token2: example.c:1:39: '*' "*",
· Token3: example.c:1:41: ';' ";",
}
Example (Return)
fmt.Println(exampleAST(245, "int f() { if (i) return x; }"))
Output:

&cc.JumpStatement{
· Case: JumpStatementReturn,
· ExpressionList: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:25: identifier "x",
· },
· Token: example.c:1:18: 'return' "return",
· Token2: example.c:1:26: ';' ";",
}

func (*JumpStatement) Label

func (n *JumpStatement) Label() Node

Label returns the labeled statement or a label declaration n, case JumpStatementGoto, refers to.

func (JumpStatement) LexicalScope

func (n JumpStatement) LexicalScope() *Scope

LexicalScope provides the scope a node appears in.

func (*JumpStatement) Position

func (n *JumpStatement) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*JumpStatement) String

func (n *JumpStatement) String() string

String implements fmt.Stringer.

type JumpStatementCase

type JumpStatementCase int

JumpStatementCase represents case numbers of production JumpStatement

const (
	JumpStatementGoto JumpStatementCase = iota
	JumpStatementGotoExpr
	JumpStatementContinue
	JumpStatementBreak
	JumpStatementReturn
)

Values of type JumpStatementCase

func (JumpStatementCase) String

func (n JumpStatementCase) String() string

String implements fmt.Stringer

type Kind

type Kind int
const (
	InvalidKind Kind = iota

	Array             // array
	Bool              // _Bool
	Char              // char
	ComplexChar       // _Complex char
	ComplexDouble     // _Complex double
	ComplexFloat      // _Complex float
	ComplexFloat16    // _Complex _Float16
	ComplexInt        // _Complex int
	ComplexLong       // _Complex long
	ComplexLongDouble // _Complex long double
	ComplexLongLong   // _Complex long long
	ComplexShort      // _Complex short
	ComplexUInt       // _Complex unsigned
	ComplexUShort     // _Complex unsigned short
	Decimal128        // _Decimal128
	Decimal32         // _Decimal32
	Decimal64         // _Decimal64
	Double            // double
	Enum              // enum
	Float             // float
	Float128          // _Float128
	Float128x         // _Float128x
	Float16           // _Float16
	Float32           // _Float32
	Float32x          // _Float32x
	Float64           // _Float64
	Float64x          // _Float64x
	Function          // function
	Int               // int
	Int128            // __int128
	Long              // long
	LongDouble        // long double
	LongLong          // long long
	Ptr               // pointer
	SChar             // signed char
	Short             // short
	Struct            // struct
	UChar             // unsigned char
	UInt              // unsigned
	UInt128           // unsigned __int128
	ULong             // unsigned long
	ULongLong         // unsigned long long
	UShort            // unsigned short
	Union             // union
	Void              // void

)

func (Kind) String

func (i Kind) String() string

type LabelDeclaration

type LabelDeclaration struct {
	IdentifierList *IdentifierList
	Token          Token
	Token2         Token
}

LabelDeclaration represents data reduced by production:

LabelDeclaration:
        "__label__" IdentifierList ';'
Example (Case0)
fmt.Println(exampleAST(226, "int f() { __label__ L, M; L: x(); M: y(); }"))
Output:

&cc.LabelDeclaration{
· IdentifierList: &cc.IdentifierList{
· · IdentifierList: &cc.IdentifierList{
· · · Token: example.c:1:22: ',' ",",
· · · Token2: example.c:1:24: identifier "M",
· · },
· · Token2: example.c:1:21: identifier "L",
· },
· Token: example.c:1:11: '__label__' "__label__",
· Token2: example.c:1:25: ';' ";",
}

func (*LabelDeclaration) Position

func (n *LabelDeclaration) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*LabelDeclaration) String

func (n *LabelDeclaration) String() string

String implements fmt.Stringer.

type LabeledStatement

type LabeledStatement struct {
	Case                LabeledStatementCase `PrettyPrint:"stringer,zero"`
	ConstantExpression  ExpressionNode
	ConstantExpression2 ExpressionNode
	Statement           *Statement
	Token               Token
	Token2              Token
	Token3              Token
	// contains filtered or unexported fields
}

LabeledStatement represents data reduced by productions:

LabeledStatement:
        IDENTIFIER ':' Statement                                          // Case LabeledStatementLabel
|       "case" ConstantExpression ':' Statement                           // Case LabeledStatementCaseLabel
|       "case" ConstantExpression "..." ConstantExpression ':' Statement  // Case LabeledStatementRange
|       "default" ':' Statement                                           // Case LabeledStatementDefault
Example (CaseLabel)
fmt.Println(exampleAST(222, "int f() { switch(i) case 42: x(); }"))
Output:

&cc.LabeledStatement{
· Case: LabeledStatementCaseLabel,
· ConstantExpression: &cc.ConstantExpression{
· · ConditionalExpression: &cc.PrimaryExpression{
· · · Case: PrimaryExpressionInt,
· · · Token: example.c:1:26: integer constant "42",
· · },
· },
· Statement: &cc.Statement{
· · Case: StatementExpr,
· · ExpressionStatement: &cc.ExpressionStatement{
· · · ExpressionList: &cc.PostfixExpression{
· · · · Case: PostfixExpressionCall,
· · · · PostfixExpression: &cc.PrimaryExpression{
· · · · · Case: PrimaryExpressionIdent,
· · · · · Token: example.c:1:30: identifier "x",
· · · · },
· · · · Token: example.c:1:31: '(' "(",
· · · · Token2: example.c:1:32: ')' ")",
· · · },
· · · Token: example.c:1:33: ';' ";",
· · },
· },
· Token: example.c:1:21: 'case' "case",
· Token2: example.c:1:28: ':' ":",
}
Example (Default)
fmt.Println(exampleAST(224, "int f() { switch(i) default: x(); }"))
Output:

&cc.LabeledStatement{
· Case: LabeledStatementDefault,
· Statement: &cc.Statement{
· · Case: StatementExpr,
· · ExpressionStatement: &cc.ExpressionStatement{
· · · ExpressionList: &cc.PostfixExpression{
· · · · Case: PostfixExpressionCall,
· · · · PostfixExpression: &cc.PrimaryExpression{
· · · · · Case: PrimaryExpressionIdent,
· · · · · Token: example.c:1:30: identifier "x",
· · · · },
· · · · Token: example.c:1:31: '(' "(",
· · · · Token2: example.c:1:32: ')' ")",
· · · },
· · · Token: example.c:1:33: ';' ";",
· · },
· },
· Token: example.c:1:21: 'default' "default",
· Token2: example.c:1:28: ':' ":",
}
Example (Label)
fmt.Println(exampleAST(221, "int f() { L: goto L; }"))
Output:

&cc.LabeledStatement{
· Case: LabeledStatementLabel,
· Statement: &cc.Statement{
· · Case: StatementJump,
· · JumpStatement: &cc.JumpStatement{
· · · Case: JumpStatementGoto,
· · · Token: example.c:1:14: 'goto' "goto",
· · · Token2: example.c:1:19: identifier "L",
· · · Token3: example.c:1:20: ';' ";",
· · },
· },
· Token: example.c:1:11: identifier "L",
· Token2: example.c:1:12: ':' ":",
}
Example (Range)
fmt.Println(exampleAST(223, "int f() { switch(i) case 42 ... 56: x(); }"))
Output:

&cc.LabeledStatement{
· Case: LabeledStatementRange,
· ConstantExpression: &cc.ConstantExpression{
· · ConditionalExpression: &cc.PrimaryExpression{
· · · Case: PrimaryExpressionInt,
· · · Token: example.c:1:26: integer constant "42",
· · },
· },
· ConstantExpression2: &cc.ConstantExpression{
· · ConditionalExpression: &cc.PrimaryExpression{
· · · Case: PrimaryExpressionInt,
· · · Token: example.c:1:33: integer constant "56",
· · },
· },
· Statement: &cc.Statement{
· · Case: StatementExpr,
· · ExpressionStatement: &cc.ExpressionStatement{
· · · ExpressionList: &cc.PostfixExpression{
· · · · Case: PostfixExpressionCall,
· · · · PostfixExpression: &cc.PrimaryExpression{
· · · · · Case: PrimaryExpressionIdent,
· · · · · Token: example.c:1:37: identifier "x",
· · · · },
· · · · Token: example.c:1:38: '(' "(",
· · · · Token2: example.c:1:39: ')' ")",
· · · },
· · · Token: example.c:1:40: ';' ";",
· · },
· },
· Token: example.c:1:21: 'case' "case",
· Token2: example.c:1:29: '...' "...",
· Token3: example.c:1:35: ':' ":",
}

func (*LabeledStatement) CaseOrdinal

func (n *LabeledStatement) CaseOrdinal() int

CaseOrdinal returns the zero based ordinal number of a labeled statement within a switch statement. Valid only for Case LabeledStatementCaseLabel and LabeledStatementDefault.

func (LabeledStatement) LexicalScope

func (n LabeledStatement) LexicalScope() *Scope

LexicalScope provides the scope a node appears in.

func (*LabeledStatement) Position

func (n *LabeledStatement) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*LabeledStatement) String

func (n *LabeledStatement) String() string

String implements fmt.Stringer.

func (*LabeledStatement) Switch

func (n *LabeledStatement) Switch() *SelectionStatement

Switch returns the switch associated with n, case LabeledStatementCaseLabel, LabeledStatementDefault, LabeledStatementRange.

type LabeledStatementCase

type LabeledStatementCase int

LabeledStatementCase represents case numbers of production LabeledStatement

const (
	LabeledStatementLabel LabeledStatementCase = iota
	LabeledStatementCaseLabel
	LabeledStatementRange
	LabeledStatementDefault
)

Values of type LabeledStatementCase

func (LabeledStatementCase) String

func (n LabeledStatementCase) String() string

String implements fmt.Stringer

type Linkage

type Linkage int

Linkage describes linkage of identifiers ([0]6.2.2).

const (
	External Linkage = iota
	Internal
	None
)

Values of type Linkage

func (Linkage) String

func (i Linkage) String() string

type LogicalAndExpression

type LogicalAndExpression struct {
	Case                  LogicalAndExpressionCase `PrettyPrint:"stringer,zero"`
	InclusiveOrExpression ExpressionNode
	LogicalAndExpression  ExpressionNode
	Token                 Token
	// contains filtered or unexported fields
}

LogicalAndExpression represents data reduced by productions:

LogicalAndExpression:
        InclusiveOrExpression                            // Case LogicalAndExpressionOr
|       LogicalAndExpression "&&" InclusiveOrExpression  // Case LogicalAndExpressionLAnd
Example (LAnd)
fmt.Println(exampleAST(69, "int i = x && y;"))
Output:

&cc.LogicalAndExpression{
· Case: LogicalAndExpressionLAnd,
· InclusiveOrExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:14: identifier "y",
· },
· LogicalAndExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:9: identifier "x",
· },
· Token: example.c:1:11: '&&' "&&",
}

func (*LogicalAndExpression) Position

func (n *LogicalAndExpression) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*LogicalAndExpression) Pure added in v4.6.0

func (p *LogicalAndExpression) Pure() bool

Pure implements ExpressionNode.

func (*LogicalAndExpression) String

func (n *LogicalAndExpression) String() string

String implements fmt.Stringer.

func (LogicalAndExpression) Type

func (t LogicalAndExpression) Type() Type

Type returns the type of a node or an *InvalidType type value, if the type is unknown/undetermined.

func (LogicalAndExpression) Value

func (v LogicalAndExpression) Value() Value

Value returns the value of a node or UnknownValue if it is undetermined. The dynamic type of a Value is one of

*ComplexLongDoubleValue
*LongDoubleValue
*UnknownValue
*ZeroValue
Complex128Value
Complex64Value
Float64Value
Int64Value
StringValue
UInt64Value
UTF16StringValue
UTF32StringValue
VoidValue

type LogicalAndExpressionCase

type LogicalAndExpressionCase int

LogicalAndExpressionCase represents case numbers of production LogicalAndExpression

const (
	LogicalAndExpressionOr LogicalAndExpressionCase = iota
	LogicalAndExpressionLAnd
)

Values of type LogicalAndExpressionCase

func (LogicalAndExpressionCase) String

func (n LogicalAndExpressionCase) String() string

String implements fmt.Stringer

type LogicalOrExpression

type LogicalOrExpression struct {
	Case                 LogicalOrExpressionCase `PrettyPrint:"stringer,zero"`
	LogicalAndExpression ExpressionNode
	LogicalOrExpression  ExpressionNode
	Token                Token
	// contains filtered or unexported fields
}

LogicalOrExpression represents data reduced by productions:

LogicalOrExpression:
        LogicalAndExpression                           // Case LogicalOrExpressionLAnd
|       LogicalOrExpression "||" LogicalAndExpression  // Case LogicalOrExpressionLOr
Example (LOr)
fmt.Println(exampleAST(71, "int i = x || y;"))
Output:

&cc.LogicalOrExpression{
· Case: LogicalOrExpressionLOr,
· LogicalAndExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:14: identifier "y",
· },
· LogicalOrExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:9: identifier "x",
· },
· Token: example.c:1:11: '||' "||",
}

func (*LogicalOrExpression) Position

func (n *LogicalOrExpression) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*LogicalOrExpression) Pure added in v4.6.0

func (p *LogicalOrExpression) Pure() bool

Pure implements ExpressionNode.

func (*LogicalOrExpression) String

func (n *LogicalOrExpression) String() string

String implements fmt.Stringer.

func (LogicalOrExpression) Type

func (t LogicalOrExpression) Type() Type

Type returns the type of a node or an *InvalidType type value, if the type is unknown/undetermined.

func (LogicalOrExpression) Value

func (v LogicalOrExpression) Value() Value

Value returns the value of a node or UnknownValue if it is undetermined. The dynamic type of a Value is one of

*ComplexLongDoubleValue
*LongDoubleValue
*UnknownValue
*ZeroValue
Complex128Value
Complex64Value
Float64Value
Int64Value
StringValue
UInt64Value
UTF16StringValue
UTF32StringValue
VoidValue

type LogicalOrExpressionCase

type LogicalOrExpressionCase int

LogicalOrExpressionCase represents case numbers of production LogicalOrExpression

const (
	LogicalOrExpressionLAnd LogicalOrExpressionCase = iota
	LogicalOrExpressionLOr
)

Values of type LogicalOrExpressionCase

func (LogicalOrExpressionCase) String

func (n LogicalOrExpressionCase) String() string

String implements fmt.Stringer

type LongDoubleValue

type LongDoubleValue big.Float

func (*LongDoubleValue) Convert

func (n *LongDoubleValue) Convert(to Type) Value

type Macro

type Macro struct {
	Name   Token
	Params []Token

	MinArgs int // m x: 0, m() x: 0, m(...): 0, m(a) a: 1, m(a, ...): 1, m(a, b): 2, m(a, b, ...): 2.
	VarArg  int // m(a): -1, m(...): 0, m(a, ...): 1, m(a...): 0, m(a, b...): 1.

	IsConst  bool // Defined only once or all definitions are the same.
	IsFnLike bool // m: false, m(): true, m(x): true.
	// contains filtered or unexported fields
}

Macro represents a preprocessor #define.

func (*Macro) Position

func (m *Macro) Position() token.Position

Position implements Node.

func (*Macro) ReplacementList

func (m *Macro) ReplacementList() (r []Token)

ReplacementList returns the tokens m is substitued with.

func (Macro) Type

func (t Macro) Type() Type

Type returns the type of a node or an *InvalidType type value, if the type is unknown/undetermined.

func (Macro) Value

func (v Macro) Value() Value

Value returns the value of a node or UnknownValue if it is undetermined. The dynamic type of a Value is one of

*ComplexLongDoubleValue
*LongDoubleValue
*UnknownValue
*ZeroValue
Complex128Value
Complex64Value
Float64Value
Int64Value
StringValue
UInt64Value
UTF16StringValue
UTF32StringValue
VoidValue

type MultiplicativeExpression

type MultiplicativeExpression struct {
	Case                     MultiplicativeExpressionCase `PrettyPrint:"stringer,zero"`
	CastExpression           ExpressionNode
	MultiplicativeExpression ExpressionNode
	Token                    Token
	// contains filtered or unexported fields
}

MultiplicativeExpression represents data reduced by productions:

MultiplicativeExpression:
        CastExpression                               // Case MultiplicativeExpressionCast
|       MultiplicativeExpression '*' CastExpression  // Case MultiplicativeExpressionMul
|       MultiplicativeExpression '/' CastExpression  // Case MultiplicativeExpressionDiv
|       MultiplicativeExpression '%' CastExpression  // Case MultiplicativeExpressionMod
Example (Div)
fmt.Println(exampleAST(46, "int i = x / y;"))
Output:

&cc.MultiplicativeExpression{
· Case: MultiplicativeExpressionDiv,
· CastExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:13: identifier "y",
· },
· MultiplicativeExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:9: identifier "x",
· },
· Token: example.c:1:11: '/' "/",
}
Example (Mod)
fmt.Println(exampleAST(47, "int i = x % y;"))
Output:

&cc.MultiplicativeExpression{
· Case: MultiplicativeExpressionMod,
· CastExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:13: identifier "y",
· },
· MultiplicativeExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:9: identifier "x",
· },
· Token: example.c:1:11: '%' "%",
}
Example (Mul)
fmt.Println(exampleAST(45, "int i = x * y;"))
Output:

&cc.MultiplicativeExpression{
· Case: MultiplicativeExpressionMul,
· CastExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:13: identifier "y",
· },
· MultiplicativeExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:9: identifier "x",
· },
· Token: example.c:1:11: '*' "*",
}

func (*MultiplicativeExpression) Position

func (n *MultiplicativeExpression) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*MultiplicativeExpression) Pure added in v4.6.0

func (p *MultiplicativeExpression) Pure() bool

Pure implements ExpressionNode.

func (*MultiplicativeExpression) String

func (n *MultiplicativeExpression) String() string

String implements fmt.Stringer.

func (MultiplicativeExpression) Type

func (t MultiplicativeExpression) Type() Type

Type returns the type of a node or an *InvalidType type value, if the type is unknown/undetermined.

func (MultiplicativeExpression) Value

func (v MultiplicativeExpression) Value() Value

Value returns the value of a node or UnknownValue if it is undetermined. The dynamic type of a Value is one of

*ComplexLongDoubleValue
*LongDoubleValue
*UnknownValue
*ZeroValue
Complex128Value
Complex64Value
Float64Value
Int64Value
StringValue
UInt64Value
UTF16StringValue
UTF32StringValue
VoidValue

type MultiplicativeExpressionCase

type MultiplicativeExpressionCase int

MultiplicativeExpressionCase represents case numbers of production MultiplicativeExpression

const (
	MultiplicativeExpressionCast MultiplicativeExpressionCase = iota
	MultiplicativeExpressionMul
	MultiplicativeExpressionDiv
	MultiplicativeExpressionMod
)

Values of type MultiplicativeExpressionCase

func (MultiplicativeExpressionCase) String

String implements fmt.Stringer

type Node

type Node interface {
	Position() token.Position
}

Node is implemented by Token and AST nodes.

type Parameter

type Parameter struct {
	Declarator         *Declarator         // Can be synthetic.
	AbstractDeclarator *AbstractDeclarator // Can be nil.
	// contains filtered or unexported fields
}

Parameter represents a function parameter.

func (*Parameter) Name

func (n *Parameter) Name() string

Name returns the name of n. The result can be a zero value, like in `void f(int) { ... }`.

func (*Parameter) Position

func (n *Parameter) Position() (r token.Position)

Position implements Node.

func (Parameter) ResolvedIn

func (n Parameter) ResolvedIn() *Scope

ResolvedIn returns the scope an identifier was resolved in, if any.

func (Parameter) Type

func (t Parameter) Type() Type

Type returns the type of a node or an *InvalidType type value, if the type is unknown/undetermined.

func (Parameter) Visible

func (v Parameter) Visible() int

Visible reports the token sequence number where the visibility of a name starts.

type ParameterDeclaration

type ParameterDeclaration struct {
	AttributeSpecifierList *AttributeSpecifierList

	AbstractDeclarator    *AbstractDeclarator
	Case                  ParameterDeclarationCase `PrettyPrint:"stringer,zero"`
	DeclarationSpecifiers *DeclarationSpecifiers
	Declarator            *Declarator
	// contains filtered or unexported fields
}

ParameterDeclaration represents data reduced by productions:

ParameterDeclaration:
        DeclarationSpecifiers Declarator          // Case ParameterDeclarationDecl
|       DeclarationSpecifiers AbstractDeclarator  // Case ParameterDeclarationAbstract
Example (Abstract)
fmt.Println(exampleAST(191, "int f(int*) {}"))
Output:

&cc.ParameterDeclaration{
· AbstractDeclarator: &cc.AbstractDeclarator{
· · Case: AbstractDeclaratorPtr,
· · Pointer: &cc.Pointer{
· · · Case: PointerTypeQual,
· · · Token: example.c:1:10: '*' "*",
· · },
· },
· Case: ParameterDeclarationAbstract,
· DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · Case: DeclarationSpecifiersTypeSpec,
· · TypeSpecifier: &cc.TypeSpecifier{
· · · Case: TypeSpecifierInt,
· · · Token: example.c:1:7: 'int' "int",
· · },
· },
}
Example (Decl)
fmt.Println(exampleAST(190, "int f(int i __attribute__((a))) {}"))
Output:

&cc.ParameterDeclaration{
· AttributeSpecifierList: &cc.AttributeSpecifierList{
· · AttributeSpecifier: &cc.AttributeSpecifier{
· · · AttributeValueList: &cc.AttributeValueList{
· · · · AttributeValue: &cc.AttributeValue{
· · · · · Case: AttributeValueIdent,
· · · · · Token: example.c:1:28: identifier "a",
· · · · },
· · · },
· · · Token: example.c:1:13: '__attribute__' "__attribute__",
· · · Token2: example.c:1:26: '(' "(",
· · · Token3: example.c:1:27: '(' "(",
· · · Token4: example.c:1:29: ')' ")",
· · · Token5: example.c:1:30: ')' ")",
· · },
· },
· Case: ParameterDeclarationDecl,
· DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · Case: DeclarationSpecifiersTypeSpec,
· · TypeSpecifier: &cc.TypeSpecifier{
· · · Case: TypeSpecifierInt,
· · · Token: example.c:1:7: 'int' "int",
· · },
· },
· Declarator: &cc.Declarator{
· · DirectDeclarator: &cc.DirectDeclarator{
· · · Case: DirectDeclaratorIdent,
· · · Token: example.c:1:11: identifier "i",
· · },
· },
}

func (*ParameterDeclaration) Position

func (n *ParameterDeclaration) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*ParameterDeclaration) String

func (n *ParameterDeclaration) String() string

String implements fmt.Stringer.

func (ParameterDeclaration) Type

func (t ParameterDeclaration) Type() Type

Type returns the type of a node or an *InvalidType type value, if the type is unknown/undetermined.

type ParameterDeclarationCase

type ParameterDeclarationCase int

ParameterDeclarationCase represents case numbers of production ParameterDeclaration

const (
	ParameterDeclarationDecl ParameterDeclarationCase = iota
	ParameterDeclarationAbstract
)

Values of type ParameterDeclarationCase

func (ParameterDeclarationCase) String

func (n ParameterDeclarationCase) String() string

String implements fmt.Stringer

type ParameterList

type ParameterList struct {
	ParameterDeclaration *ParameterDeclaration
	ParameterList        *ParameterList
	Token                Token
}

ParameterList represents data reduced by productions:

ParameterList:
        ParameterDeclaration
|       ParameterList ',' ParameterDeclaration
Example (Case0)
fmt.Println(exampleAST(188, "int f(int i) {}"))
Output:

&cc.ParameterList{
· ParameterDeclaration: &cc.ParameterDeclaration{
· · Case: ParameterDeclarationDecl,
· · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · Case: DeclarationSpecifiersTypeSpec,
· · · TypeSpecifier: &cc.TypeSpecifier{
· · · · Case: TypeSpecifierInt,
· · · · Token: example.c:1:7: 'int' "int",
· · · },
· · },
· · Declarator: &cc.Declarator{
· · · DirectDeclarator: &cc.DirectDeclarator{
· · · · Case: DirectDeclaratorIdent,
· · · · Token: example.c:1:11: identifier "i",
· · · },
· · },
· },
}
Example (Case1)
fmt.Println(exampleAST(189, "int f(int i, int j) {}"))
Output:

&cc.ParameterList{
· ParameterDeclaration: &cc.ParameterDeclaration{
· · Case: ParameterDeclarationDecl,
· · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · Case: DeclarationSpecifiersTypeSpec,
· · · TypeSpecifier: &cc.TypeSpecifier{
· · · · Case: TypeSpecifierInt,
· · · · Token: example.c:1:7: 'int' "int",
· · · },
· · },
· · Declarator: &cc.Declarator{
· · · DirectDeclarator: &cc.DirectDeclarator{
· · · · Case: DirectDeclaratorIdent,
· · · · Token: example.c:1:11: identifier "i",
· · · },
· · },
· },
· ParameterList: &cc.ParameterList{
· · ParameterDeclaration: &cc.ParameterDeclaration{
· · · Case: ParameterDeclarationDecl,
· · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · Case: DeclarationSpecifiersTypeSpec,
· · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · Case: TypeSpecifierInt,
· · · · · Token: example.c:1:14: 'int' "int",
· · · · },
· · · },
· · · Declarator: &cc.Declarator{
· · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · Case: DirectDeclaratorIdent,
· · · · · Token: example.c:1:18: identifier "j",
· · · · },
· · · },
· · },
· · Token: example.c:1:12: ',' ",",
· },
}

func (*ParameterList) Position

func (n *ParameterList) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*ParameterList) String

func (n *ParameterList) String() string

String implements fmt.Stringer.

type ParameterTypeList

type ParameterTypeList struct {
	Case          ParameterTypeListCase `PrettyPrint:"stringer,zero"`
	ParameterList *ParameterList
	Token         Token
	Token2        Token
}

ParameterTypeList represents data reduced by productions:

ParameterTypeList:
        ParameterList            // Case ParameterTypeListList
|       ParameterList ',' "..."  // Case ParameterTypeListVar
Example (List)
fmt.Println(exampleAST(186, "int f(int i) {}"))
Output:

&cc.ParameterTypeList{
· Case: ParameterTypeListList,
· ParameterList: &cc.ParameterList{
· · ParameterDeclaration: &cc.ParameterDeclaration{
· · · Case: ParameterDeclarationDecl,
· · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · Case: DeclarationSpecifiersTypeSpec,
· · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · Case: TypeSpecifierInt,
· · · · · Token: example.c:1:7: 'int' "int",
· · · · },
· · · },
· · · Declarator: &cc.Declarator{
· · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · Case: DirectDeclaratorIdent,
· · · · · Token: example.c:1:11: identifier "i",
· · · · },
· · · },
· · },
· },
}
Example (Var)
fmt.Println(exampleAST(187, "int f(int i, ...) {}"))
Output:

&cc.ParameterTypeList{
· Case: ParameterTypeListVar,
· ParameterList: &cc.ParameterList{
· · ParameterDeclaration: &cc.ParameterDeclaration{
· · · Case: ParameterDeclarationDecl,
· · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · Case: DeclarationSpecifiersTypeSpec,
· · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · Case: TypeSpecifierInt,
· · · · · Token: example.c:1:7: 'int' "int",
· · · · },
· · · },
· · · Declarator: &cc.Declarator{
· · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · Case: DirectDeclaratorIdent,
· · · · · Token: example.c:1:11: identifier "i",
· · · · },
· · · },
· · },
· },
· Token: example.c:1:12: ',' ",",
· Token2: example.c:1:14: '...' "...",
}

func (*ParameterTypeList) Position

func (n *ParameterTypeList) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*ParameterTypeList) String

func (n *ParameterTypeList) String() string

String implements fmt.Stringer.

type ParameterTypeListCase

type ParameterTypeListCase int

ParameterTypeListCase represents case numbers of production ParameterTypeList

const (
	ParameterTypeListList ParameterTypeListCase = iota
	ParameterTypeListVar
)

Values of type ParameterTypeListCase

func (ParameterTypeListCase) String

func (n ParameterTypeListCase) String() string

String implements fmt.Stringer

type Pointer

type Pointer struct {
	Case           PointerCase `PrettyPrint:"stringer,zero"`
	Pointer        *Pointer
	Token          Token
	TypeQualifiers *TypeQualifiers
	// contains filtered or unexported fields
}

Pointer represents data reduced by productions:

Pointer:
        '*' TypeQualifiers          // Case PointerTypeQual
|       '*' TypeQualifiers Pointer  // Case PointerPtr
|       '^' TypeQualifiers          // Case PointerBlock
Example (Block)
fmt.Println(exampleAST(183, "int atexit_b(void (^ _Nonnull)(void));"))
Output:

&cc.Pointer{
· Case: PointerBlock,
· Token: example.c:1:20: '^' "^",
· TypeQualifiers: &cc.TypeQualifiers{
· · Case: TypeQualifiersTypeQual,
· · TypeQualifier: &cc.TypeQualifier{
· · · Case: TypeQualifierNonnull,
· · · Token: example.c:1:22: '_Nonnull' "_Nonnull",
· · },
· },
}
Example (Ptr)
fmt.Println(exampleAST(182, "int **p;"))
Output:

&cc.Pointer{
· Case: PointerPtr,
· Pointer: &cc.Pointer{
· · Case: PointerTypeQual,
· · Token: example.c:1:6: '*' "*",
· },
· Token: example.c:1:5: '*' "*",
}
Example (TypeQual)
fmt.Println(exampleAST(181, "int *p;"))
Output:

&cc.Pointer{
· Case: PointerTypeQual,
· Token: example.c:1:5: '*' "*",
}

func (Pointer) LexicalScope added in v4.19.1

func (n Pointer) LexicalScope() *Scope

LexicalScope provides the scope a node appears in.

func (*Pointer) Position

func (n *Pointer) Position() (r token.Position)

Position reports the position of the first component of n, if available.

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 (
	PointerTypeQual PointerCase = iota
	PointerPtr
	PointerBlock
)

Values of type PointerCase

func (PointerCase) String

func (n PointerCase) String() string

String implements fmt.Stringer

type PointerType

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

func (*PointerType) Align

func (n *PointerType) Align() int

Align implements Type.

func (PointerType) Attributes

func (n PointerType) Attributes() *Attributes

Attributes implemets Type.

func (PointerType) BitField added in v4.1.1

func (PointerType) BitField() *Field

BitField implements Type.

func (*PointerType) Decay

func (n *PointerType) Decay() Type

Decay implements Type.

func (*PointerType) Elem

func (n *PointerType) Elem() Type

Elem returns the type n points to.

func (*PointerType) FieldAlign

func (n *PointerType) FieldAlign() int

FieldAlign implements Type.

func (*PointerType) IsCompatible

func (n *PointerType) IsCompatible(t Type) (r bool)

func (*PointerType) IsIncomplete

func (n *PointerType) IsIncomplete() bool

IsIncomplete implements Type.

func (*PointerType) Kind

func (n *PointerType) Kind() Kind

Kind implements Type.

func (*PointerType) Pointer

func (n *PointerType) Pointer() Type

Pointer implements Type.

func (*PointerType) Size

func (n *PointerType) Size() int64

Size implements Type.

func (*PointerType) String

func (n *PointerType) String() string

String implements Type.

func (PointerType) Typedef

func (n PointerType) Typedef() *Declarator

Typedef implements Type

func (*PointerType) Undecay

func (n *PointerType) Undecay() Type

Undecay implements Type.

func (PointerType) VectorSize

func (PointerType) VectorSize() int64

VectorSize implements Type.

type PostfixExpression

type PostfixExpression struct {
	ArgumentExpressionList *ArgumentExpressionList
	Case                   PostfixExpressionCase `PrettyPrint:"stringer,zero"`
	ExpressionList         ExpressionNode
	InitializerList        *InitializerList
	PostfixExpression      ExpressionNode
	PrimaryExpression      ExpressionNode
	Token                  Token
	Token2                 Token
	Token3                 Token
	Token4                 Token
	Token5                 Token
	TypeName               *TypeName
	// contains filtered or unexported fields
}

PostfixExpression represents data reduced by productions:

PostfixExpression:
        PrimaryExpression                                 // Case PostfixExpressionPrimary
|       PostfixExpression '[' ExpressionList ']'          // Case PostfixExpressionIndex
|       PostfixExpression '(' ArgumentExpressionList ')'  // Case PostfixExpressionCall
|       PostfixExpression '.' IDENTIFIER                  // Case PostfixExpressionSelect
|       PostfixExpression "->" IDENTIFIER                 // Case PostfixExpressionPSelect
|       PostfixExpression "++"                            // Case PostfixExpressionInc
|       PostfixExpression "--"                            // Case PostfixExpressionDec
|       '(' TypeName ')' '{' InitializerList ',' '}'      // Case PostfixExpressionComplit
Example (Call)
fmt.Println(exampleAST(18, "int i = x(y);"))
Output:

&cc.PostfixExpression{
· ArgumentExpressionList: &cc.ArgumentExpressionList{
· · AssignmentExpression: &cc.PrimaryExpression{
· · · Case: PrimaryExpressionIdent,
· · · Token: example.c:1:11: identifier "y",
· · },
· },
· Case: PostfixExpressionCall,
· PostfixExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:9: identifier "x",
· },
· Token: example.c:1:10: '(' "(",
· Token2: example.c:1:12: ')' ")",
}
Example (Complit)
fmt.Println(exampleAST(23, "int i = (int[]){y};"))
Output:

&cc.PostfixExpression{
· Case: PostfixExpressionComplit,
· InitializerList: &cc.InitializerList{
· · Initializer: &cc.Initializer{
· · · AssignmentExpression: &cc.PrimaryExpression{
· · · · Case: PrimaryExpressionIdent,
· · · · Token: example.c:1:17: identifier "y",
· · · },
· · · Case: InitializerExpr,
· · },
· },
· Token: example.c:1:9: '(' "(",
· Token2: example.c:1:15: ')' ")",
· Token3: example.c:1:16: '{' "{",
· Token5: example.c:1:18: '}' "}",
· TypeName: &cc.TypeName{
· · AbstractDeclarator: &cc.AbstractDeclarator{
· · · Case: AbstractDeclaratorDecl,
· · · DirectAbstractDeclarator: &cc.DirectAbstractDeclarator{
· · · · Case: DirectAbstractDeclaratorArr,
· · · · Token: example.c:1:13: '[' "[",
· · · · Token2: example.c:1:14: ']' "]",
· · · },
· · },
· · SpecifierQualifierList: &cc.SpecifierQualifierList{
· · · Case: SpecifierQualifierListTypeSpec,
· · · TypeSpecifier: &cc.TypeSpecifier{
· · · · Case: TypeSpecifierInt,
· · · · Token: example.c:1:10: 'int' "int",
· · · },
· · },
· },
}
Example (Dec)
fmt.Println(exampleAST(22, "int i = x--;"))
Output:

&cc.PostfixExpression{
· Case: PostfixExpressionDec,
· PostfixExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:9: identifier "x",
· },
· Token: example.c:1:10: '--' "--",
}
Example (Inc)
fmt.Println(exampleAST(21, "int i = x++;"))
Output:

&cc.PostfixExpression{
· Case: PostfixExpressionInc,
· PostfixExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:9: identifier "x",
· },
· Token: example.c:1:10: '++' "++",
}
Example (Index)
fmt.Println(exampleAST(17, "int i = x[y];"))
Output:

&cc.PostfixExpression{
· Case: PostfixExpressionIndex,
· ExpressionList: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:11: identifier "y",
· },
· PostfixExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:9: identifier "x",
· },
· Token: example.c:1:10: '[' "[",
· Token2: example.c:1:12: ']' "]",
}
Example (PSelect)
fmt.Println(exampleAST(20, "int i = x->y;"))
Output:

&cc.PostfixExpression{
· Case: PostfixExpressionPSelect,
· PostfixExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:9: identifier "x",
· },
· Token: example.c:1:10: '->' "->",
· Token2: example.c:1:12: identifier "y",
}
Example (Select)
fmt.Println(exampleAST(19, "int i = x.y;"))
Output:

&cc.PostfixExpression{
· Case: PostfixExpressionSelect,
· PostfixExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:9: identifier "x",
· },
· Token: example.c:1:10: '.' ".",
· Token2: example.c:1:11: identifier "y",
}

func (*PostfixExpression) Field

func (n *PostfixExpression) Field() *Field

Field reports the resolved field for cases PostfixExpressionSelect and PostfixExpressionPSelect.

func (*PostfixExpression) Position

func (n *PostfixExpression) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*PostfixExpression) Pure added in v4.6.0

func (p *PostfixExpression) Pure() bool

Pure implements ExpressionNode.

func (*PostfixExpression) String

func (n *PostfixExpression) String() string

String implements fmt.Stringer.

func (PostfixExpression) Type

func (t PostfixExpression) Type() Type

Type returns the type of a node or an *InvalidType type value, if the type is unknown/undetermined.

func (PostfixExpression) Value

func (v PostfixExpression) Value() Value

Value returns the value of a node or UnknownValue if it is undetermined. The dynamic type of a Value is one of

*ComplexLongDoubleValue
*LongDoubleValue
*UnknownValue
*ZeroValue
Complex128Value
Complex64Value
Float64Value
Int64Value
StringValue
UInt64Value
UTF16StringValue
UTF32StringValue
VoidValue

type PostfixExpressionCase

type PostfixExpressionCase int

PostfixExpressionCase represents case numbers of production PostfixExpression

const (
	PostfixExpressionPrimary PostfixExpressionCase = iota
	PostfixExpressionIndex
	PostfixExpressionCall
	PostfixExpressionSelect
	PostfixExpressionPSelect
	PostfixExpressionInc
	PostfixExpressionDec
	PostfixExpressionComplit
)

Values of type PostfixExpressionCase

func (PostfixExpressionCase) String

func (n PostfixExpressionCase) String() string

String implements fmt.Stringer

type PredefinedType

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

func (*PredefinedType) Align

func (n *PredefinedType) Align() int

Align implements Type.

func (PredefinedType) Attributes

func (n PredefinedType) Attributes() *Attributes

Attributes implemets Type.

func (*PredefinedType) BitField added in v4.1.1

func (n *PredefinedType) BitField() *Field

BitField implements Type.

func (*PredefinedType) Decay

func (n *PredefinedType) Decay() Type

Decay implements Type.

func (*PredefinedType) FieldAlign

func (n *PredefinedType) FieldAlign() int

FieldAlign implements Type.

func (*PredefinedType) IsCompatible

func (n *PredefinedType) IsCompatible(t Type) (r bool)

func (*PredefinedType) IsIncomplete

func (n *PredefinedType) IsIncomplete() bool

IsIncomplete implements Type.

func (*PredefinedType) Kind

func (n *PredefinedType) Kind() Kind

Kind implements Type.

func (*PredefinedType) Pointer

func (n *PredefinedType) Pointer() Type

Pointer implements Type.

func (*PredefinedType) Size

func (n *PredefinedType) Size() int64

Size implements Type.

func (*PredefinedType) String

func (n *PredefinedType) String() string

String implements Type.

func (PredefinedType) Typedef

func (n PredefinedType) Typedef() *Declarator

Typedef implements Type

func (*PredefinedType) Undecay

func (n *PredefinedType) Undecay() Type

Undecay implements Type.

func (*PredefinedType) VectorSize

func (n *PredefinedType) VectorSize() int64

VectorSize implements Type.

type PrimaryExpression

type PrimaryExpression struct {
	Case              PrimaryExpressionCase `PrettyPrint:"stringer,zero"`
	CompoundStatement *CompoundStatement
	ExpressionList    ExpressionNode
	GenericSelection  *GenericSelection
	Token             Token
	Token2            Token
	// contains filtered or unexported fields
}

PrimaryExpression represents data reduced by productions:

PrimaryExpression:
        IDENTIFIER                 // Case PrimaryExpressionIdent
|       INTCONST                   // Case PrimaryExpressionInt
|       FLOATCONST                 // Case PrimaryExpressionFloat
|       CHARCONST                  // Case PrimaryExpressionChar
|       LONGCHARCONST              // Case PrimaryExpressionLChar
|       STRINGLITERAL              // Case PrimaryExpressionString
|       LONGSTRINGLITERAL          // Case PrimaryExpressionLString
|       '(' ExpressionList ')'     // Case PrimaryExpressionExpr
|       '(' CompoundStatement ')'  // Case PrimaryExpressionStmt
|       GenericSelection           // Case PrimaryExpressionGeneric
Example (Char)
fmt.Println(exampleAST(4, "int i = 'x';"))
Output:

&cc.PrimaryExpression{
· Case: PrimaryExpressionChar,
· Token: example.c:1:9: character constant "'x'",
}
Example (Expr)
fmt.Println(exampleAST(8, "int i = (x+y);"))
Output:

&cc.PrimaryExpression{
· Case: PrimaryExpressionExpr,
· ExpressionList: &cc.AdditiveExpression{
· · AdditiveExpression: &cc.PrimaryExpression{
· · · Case: PrimaryExpressionIdent,
· · · Token: example.c:1:10: identifier "x",
· · },
· · Case: AdditiveExpressionAdd,
· · MultiplicativeExpression: &cc.PrimaryExpression{
· · · Case: PrimaryExpressionIdent,
· · · Token: example.c:1:12: identifier "y",
· · },
· · Token: example.c:1:11: '+' "+",
· },
· Token: example.c:1:9: '(' "(",
· Token2: example.c:1:13: ')' ")",
}
Example (Float)
fmt.Println(exampleAST(3, "int i = 3.14;"))
Output:

&cc.PrimaryExpression{
· Case: PrimaryExpressionFloat,
· Token: example.c:1:9: floating point constant "3.14",
}
Example (Generic)
fmt.Println(exampleAST(10, "int i = _Generic(x, int: y)(42);"))
Output:

&cc.PrimaryExpression{
· Case: PrimaryExpressionGeneric,
· GenericSelection: &cc.GenericSelection{
· · AssignmentExpression: &cc.PrimaryExpression{
· · · Case: PrimaryExpressionIdent,
· · · Token: example.c:1:18: identifier "x",
· · },
· · GenericAssociationList: &cc.GenericAssociationList{
· · · GenericAssociation: &cc.GenericAssociation{
· · · · AssignmentExpression: &cc.PrimaryExpression{
· · · · · Case: PrimaryExpressionIdent,
· · · · · Token: example.c:1:26: identifier "y",
· · · · },
· · · · Case: GenericAssociationType,
· · · · Token: example.c:1:24: ':' ":",
· · · · TypeName: &cc.TypeName{
· · · · · SpecifierQualifierList: &cc.SpecifierQualifierList{
· · · · · · Case: SpecifierQualifierListTypeSpec,
· · · · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · · · Case: TypeSpecifierInt,
· · · · · · · Token: example.c:1:21: 'int' "int",
· · · · · · },
· · · · · },
· · · · },
· · · },
· · },
· · Token: example.c:1:9: '_Generic' "_Generic",
· · Token2: example.c:1:17: '(' "(",
· · Token3: example.c:1:19: ',' ",",
· · Token4: example.c:1:27: ')' ")",
· },
}
Example (Ident)
fmt.Println(exampleAST(1, "int i = x;"))
Output:

&cc.PrimaryExpression{
· Case: PrimaryExpressionIdent,
· Token: example.c:1:9: identifier "x",
}
Example (Int)
fmt.Println(exampleAST(2, "int i = 42;"))
Output:

&cc.PrimaryExpression{
· Case: PrimaryExpressionInt,
· Token: example.c:1:9: integer constant "42",
}
Example (LChar)
fmt.Println(exampleAST(5, "int i = L'x';"))
Output:

&cc.PrimaryExpression{
· Case: PrimaryExpressionLChar,
· Token: example.c:1:9: long character constant "L'x'",
}
Example (LString)
fmt.Println(exampleAST(7, "char *c = L\"x\" L\"y\";"))
Output:

&cc.PrimaryExpression{
· Case: PrimaryExpressionLString,
· Token: example.c:1:11: long string literal "L\"xy\"",
}
Example (Stmt)
fmt.Println(exampleAST(9, "int i = ({x();});"))
Output:

&cc.PrimaryExpression{
· Case: PrimaryExpressionStmt,
· CompoundStatement: &cc.CompoundStatement{
· · BlockItemList: &cc.BlockItemList{
· · · BlockItem: &cc.BlockItem{
· · · · Case: BlockItemStmt,
· · · · Statement: &cc.Statement{
· · · · · Case: StatementExpr,
· · · · · ExpressionStatement: &cc.ExpressionStatement{
· · · · · · ExpressionList: &cc.PostfixExpression{
· · · · · · · Case: PostfixExpressionCall,
· · · · · · · PostfixExpression: &cc.PrimaryExpression{
· · · · · · · · Case: PrimaryExpressionIdent,
· · · · · · · · Token: example.c:1:11: identifier "x",
· · · · · · · },
· · · · · · · Token: example.c:1:12: '(' "(",
· · · · · · · Token2: example.c:1:13: ')' ")",
· · · · · · },
· · · · · · Token: example.c:1:14: ';' ";",
· · · · · },
· · · · },
· · · },
· · },
· · Token: example.c:1:10: '{' "{",
· · Token2: example.c:1:15: '}' "}",
· },
· Token: example.c:1:9: '(' "(",
· Token2: example.c:1:16: ')' ")",
}
Example (String)
fmt.Println(exampleAST(6, "char *c = \"x\" \"y\";"))
Output:

&cc.PrimaryExpression{
· Case: PrimaryExpressionString,
· Token: example.c:1:11: string literal "\"xy\"",
}

func (PrimaryExpression) LexicalScope

func (n PrimaryExpression) LexicalScope() *Scope

LexicalScope provides the scope a node appears in.

func (*PrimaryExpression) Macro

func (n *PrimaryExpression) Macro() *Macro

Macro returns the single, optionally parenthesized token, of an object-like, constant macro that produced this node, if any.

func (*PrimaryExpression) Position

func (n *PrimaryExpression) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*PrimaryExpression) Pure added in v4.6.0

func (p *PrimaryExpression) Pure() bool

Pure implements ExpressionNode.

func (*PrimaryExpression) ResolvedTo

func (n *PrimaryExpression) ResolvedTo() Node

ResolvedTo returns the node n resolved to when n.Case is PrimaryExpressionIdent.

func (*PrimaryExpression) String

func (n *PrimaryExpression) String() string

String implements fmt.Stringer.

func (PrimaryExpression) Type

func (t PrimaryExpression) Type() Type

Type returns the type of a node or an *InvalidType type value, if the type is unknown/undetermined.

func (PrimaryExpression) Value

func (v PrimaryExpression) Value() Value

Value returns the value of a node or UnknownValue if it is undetermined. The dynamic type of a Value is one of

*ComplexLongDoubleValue
*LongDoubleValue
*UnknownValue
*ZeroValue
Complex128Value
Complex64Value
Float64Value
Int64Value
StringValue
UInt64Value
UTF16StringValue
UTF32StringValue
VoidValue

type PrimaryExpressionCase

type PrimaryExpressionCase int

PrimaryExpressionCase represents case numbers of production PrimaryExpression

const (
	PrimaryExpressionIdent PrimaryExpressionCase = iota
	PrimaryExpressionInt
	PrimaryExpressionFloat
	PrimaryExpressionChar
	PrimaryExpressionLChar
	PrimaryExpressionString
	PrimaryExpressionLString
	PrimaryExpressionExpr
	PrimaryExpressionStmt
	PrimaryExpressionGeneric
)

Values of type PrimaryExpressionCase

func (PrimaryExpressionCase) String

func (n PrimaryExpressionCase) String() string

String implements fmt.Stringer

type RelationalExpression

type RelationalExpression struct {
	Case                 RelationalExpressionCase `PrettyPrint:"stringer,zero"`
	RelationalExpression ExpressionNode
	ShiftExpression      ExpressionNode
	Token                Token
	// contains filtered or unexported fields
}

RelationalExpression represents data reduced by productions:

RelationalExpression:
        ShiftExpression                            // Case RelationalExpressionShift
|       RelationalExpression '<' ShiftExpression   // Case RelationalExpressionLt
|       RelationalExpression '>' ShiftExpression   // Case RelationalExpressionGt
|       RelationalExpression "<=" ShiftExpression  // Case RelationalExpressionLeq
|       RelationalExpression ">=" ShiftExpression  // Case RelationalExpressionGeq
Example (Geq)
fmt.Println(exampleAST(58, "int i = x >= y;"))
Output:

&cc.RelationalExpression{
· Case: RelationalExpressionGeq,
· RelationalExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:9: identifier "x",
· },
· ShiftExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:14: identifier "y",
· },
· Token: example.c:1:11: '>=' ">=",
}
Example (Gt)
fmt.Println(exampleAST(56, "int i = x > y;"))
Output:

&cc.RelationalExpression{
· Case: RelationalExpressionGt,
· RelationalExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:9: identifier "x",
· },
· ShiftExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:13: identifier "y",
· },
· Token: example.c:1:11: '>' ">",
}
Example (Leq)
fmt.Println(exampleAST(57, "int i = x <= y;"))
Output:

&cc.RelationalExpression{
· Case: RelationalExpressionLeq,
· RelationalExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:9: identifier "x",
· },
· ShiftExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:14: identifier "y",
· },
· Token: example.c:1:11: '<=' "<=",
}
Example (Lt)
fmt.Println(exampleAST(55, "int i = x < y;"))
Output:

&cc.RelationalExpression{
· Case: RelationalExpressionLt,
· RelationalExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:9: identifier "x",
· },
· ShiftExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:13: identifier "y",
· },
· Token: example.c:1:11: '<' "<",
}

func (*RelationalExpression) Position

func (n *RelationalExpression) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*RelationalExpression) Pure added in v4.6.0

func (p *RelationalExpression) Pure() bool

Pure implements ExpressionNode.

func (*RelationalExpression) String

func (n *RelationalExpression) String() string

String implements fmt.Stringer.

func (RelationalExpression) Type

func (t RelationalExpression) Type() Type

Type returns the type of a node or an *InvalidType type value, if the type is unknown/undetermined.

func (RelationalExpression) Value

func (v RelationalExpression) Value() Value

Value returns the value of a node or UnknownValue if it is undetermined. The dynamic type of a Value is one of

*ComplexLongDoubleValue
*LongDoubleValue
*UnknownValue
*ZeroValue
Complex128Value
Complex64Value
Float64Value
Int64Value
StringValue
UInt64Value
UTF16StringValue
UTF32StringValue
VoidValue

type RelationalExpressionCase

type RelationalExpressionCase int

RelationalExpressionCase represents case numbers of production RelationalExpression

const (
	RelationalExpressionShift RelationalExpressionCase = iota
	RelationalExpressionLt
	RelationalExpressionGt
	RelationalExpressionLeq
	RelationalExpressionGeq
)

Values of type RelationalExpressionCase

func (RelationalExpressionCase) String

func (n RelationalExpressionCase) String() string

String implements fmt.Stringer

type Scope

type Scope struct {
	Children []*Scope
	Nodes    map[string][]Node
	Parent   *Scope
}

Scope binds names to declaring nodes.

The dynamic type of a Node in the Nodes map is one of

Node type                   Note
-----------------           ----
*Declarator
*EnumSpecifier              binds the tag
*Enumerator
*LabelDeclaration
*LabeledStatement           case LabeledStatementLabel
*Parameter
*StructOrUnionSpecifier     binds the tag

type SelectionStatement

type SelectionStatement struct {
	Case           SelectionStatementCase `PrettyPrint:"stringer,zero"`
	ExpressionList ExpressionNode
	Statement      *Statement
	Statement2     *Statement
	Token          Token
	Token2         Token
	Token3         Token
	Token4         Token
	// contains filtered or unexported fields
}

SelectionStatement represents data reduced by productions:

SelectionStatement:
        "if" '(' ExpressionList ')' Statement                   // Case SelectionStatementIf
|       "if" '(' ExpressionList ')' Statement "else" Statement  // Case SelectionStatementIfElse
|       "switch" '(' ExpressionList ')' Statement               // Case SelectionStatementSwitch
Example (If)
fmt.Println(exampleAST(234, "int f() { if(x) y(); }"))
Output:

&cc.SelectionStatement{
· Case: SelectionStatementIf,
· ExpressionList: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:14: identifier "x",
· },
· Statement: &cc.Statement{
· · Case: StatementExpr,
· · ExpressionStatement: &cc.ExpressionStatement{
· · · ExpressionList: &cc.PostfixExpression{
· · · · Case: PostfixExpressionCall,
· · · · PostfixExpression: &cc.PrimaryExpression{
· · · · · Case: PrimaryExpressionIdent,
· · · · · Token: example.c:1:17: identifier "y",
· · · · },
· · · · Token: example.c:1:18: '(' "(",
· · · · Token2: example.c:1:19: ')' ")",
· · · },
· · · Token: example.c:1:20: ';' ";",
· · },
· },
· Token: example.c:1:11: 'if' "if",
· Token2: example.c:1:13: '(' "(",
· Token3: example.c:1:15: ')' ")",
}
Example (IfElse)
fmt.Println(exampleAST(235, "int f() { if(x) y(); else z(); }"))
Output:

&cc.SelectionStatement{
· Case: SelectionStatementIfElse,
· ExpressionList: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:14: identifier "x",
· },
· Statement: &cc.Statement{
· · Case: StatementExpr,
· · ExpressionStatement: &cc.ExpressionStatement{
· · · ExpressionList: &cc.PostfixExpression{
· · · · Case: PostfixExpressionCall,
· · · · PostfixExpression: &cc.PrimaryExpression{
· · · · · Case: PrimaryExpressionIdent,
· · · · · Token: example.c:1:17: identifier "y",
· · · · },
· · · · Token: example.c:1:18: '(' "(",
· · · · Token2: example.c:1:19: ')' ")",
· · · },
· · · Token: example.c:1:20: ';' ";",
· · },
· },
· Statement2: &cc.Statement{
· · Case: StatementExpr,
· · ExpressionStatement: &cc.ExpressionStatement{
· · · ExpressionList: &cc.PostfixExpression{
· · · · Case: PostfixExpressionCall,
· · · · PostfixExpression: &cc.PrimaryExpression{
· · · · · Case: PrimaryExpressionIdent,
· · · · · Token: example.c:1:27: identifier "z",
· · · · },
· · · · Token: example.c:1:28: '(' "(",
· · · · Token2: example.c:1:29: ')' ")",
· · · },
· · · Token: example.c:1:30: ';' ";",
· · },
· },
· Token: example.c:1:11: 'if' "if",
· Token2: example.c:1:13: '(' "(",
· Token3: example.c:1:15: ')' ")",
· Token4: example.c:1:22: 'else' "else",
}
Example (Switch)
fmt.Println(exampleAST(236, "int f() { switch(i) case 42: x(); }"))
Output:

&cc.SelectionStatement{
· Case: SelectionStatementSwitch,
· ExpressionList: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:18: identifier "i",
· },
· Statement: &cc.Statement{
· · Case: StatementLabeled,
· · LabeledStatement: &cc.LabeledStatement{
· · · Case: LabeledStatementCaseLabel,
· · · ConstantExpression: &cc.ConstantExpression{
· · · · ConditionalExpression: &cc.PrimaryExpression{
· · · · · Case: PrimaryExpressionInt,
· · · · · Token: example.c:1:26: integer constant "42",
· · · · },
· · · },
· · · Statement: &cc.Statement{
· · · · Case: StatementExpr,
· · · · ExpressionStatement: &cc.ExpressionStatement{
· · · · · ExpressionList: &cc.PostfixExpression{
· · · · · · Case: PostfixExpressionCall,
· · · · · · PostfixExpression: &cc.PrimaryExpression{
· · · · · · · Case: PrimaryExpressionIdent,
· · · · · · · Token: example.c:1:30: identifier "x",
· · · · · · },
· · · · · · Token: example.c:1:31: '(' "(",
· · · · · · Token2: example.c:1:32: ')' ")",
· · · · · },
· · · · · Token: example.c:1:33: ';' ";",
· · · · },
· · · },
· · · Token: example.c:1:21: 'case' "case",
· · · Token2: example.c:1:28: ':' ":",
· · },
· },
· Token: example.c:1:11: 'switch' "switch",
· Token2: example.c:1:17: '(' "(",
· Token3: example.c:1:19: ')' ")",
}

func (*SelectionStatement) Cases

func (n *SelectionStatement) Cases() int

Cases returns the combined number of "case" and "default" labels in a switch statement. Valid for Case == SelectionStatementSwitch.

func (*SelectionStatement) LabeledStatements

func (n *SelectionStatement) LabeledStatements() []*LabeledStatement

LabeledStatements returns labeled statements appearing within n, case SelectionStatementSwitch.

func (SelectionStatement) LexicalScope

func (n SelectionStatement) LexicalScope() *Scope

LexicalScope provides the scope a node appears in.

func (*SelectionStatement) Position

func (n *SelectionStatement) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*SelectionStatement) String

func (n *SelectionStatement) String() string

String implements fmt.Stringer.

type SelectionStatementCase

type SelectionStatementCase int

SelectionStatementCase represents case numbers of production SelectionStatement

const (
	SelectionStatementIf SelectionStatementCase = iota
	SelectionStatementIfElse
	SelectionStatementSwitch
)

Values of type SelectionStatementCase

func (SelectionStatementCase) String

func (n SelectionStatementCase) String() string

String implements fmt.Stringer

type ShiftExpression

type ShiftExpression struct {
	AdditiveExpression ExpressionNode
	Case               ShiftExpressionCase `PrettyPrint:"stringer,zero"`
	ShiftExpression    ExpressionNode
	Token              Token
	// contains filtered or unexported fields
}

ShiftExpression represents data reduced by productions:

ShiftExpression:
        AdditiveExpression                       // Case ShiftExpressionAdd
|       ShiftExpression "<<" AdditiveExpression  // Case ShiftExpressionLsh
|       ShiftExpression ">>" AdditiveExpression  // Case ShiftExpressionRsh
Example (Lsh)
fmt.Println(exampleAST(52, "int i = x << y;"))
Output:

&cc.ShiftExpression{
· AdditiveExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:14: identifier "y",
· },
· Case: ShiftExpressionLsh,
· ShiftExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:9: identifier "x",
· },
· Token: example.c:1:11: '<<' "<<",
}
Example (Rsh)
fmt.Println(exampleAST(53, "int i = x >> y;"))
Output:

&cc.ShiftExpression{
· AdditiveExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:14: identifier "y",
· },
· Case: ShiftExpressionRsh,
· ShiftExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:9: identifier "x",
· },
· Token: example.c:1:11: '>>' ">>",
}

func (*ShiftExpression) Position

func (n *ShiftExpression) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*ShiftExpression) Pure added in v4.6.0

func (p *ShiftExpression) Pure() bool

Pure implements ExpressionNode.

func (*ShiftExpression) String

func (n *ShiftExpression) String() string

String implements fmt.Stringer.

func (ShiftExpression) Type

func (t ShiftExpression) Type() Type

Type returns the type of a node or an *InvalidType type value, if the type is unknown/undetermined.

func (ShiftExpression) Value

func (v ShiftExpression) Value() Value

Value returns the value of a node or UnknownValue if it is undetermined. The dynamic type of a Value is one of

*ComplexLongDoubleValue
*LongDoubleValue
*UnknownValue
*ZeroValue
Complex128Value
Complex64Value
Float64Value
Int64Value
StringValue
UInt64Value
UTF16StringValue
UTF32StringValue
VoidValue

type ShiftExpressionCase

type ShiftExpressionCase int

ShiftExpressionCase represents case numbers of production ShiftExpression

const (
	ShiftExpressionAdd ShiftExpressionCase = iota
	ShiftExpressionLsh
	ShiftExpressionRsh
)

Values of type ShiftExpressionCase

func (ShiftExpressionCase) String

func (n ShiftExpressionCase) String() string

String implements fmt.Stringer

type Source

type Source struct {
	Name  string
	Value interface{}
	FS    fs.FS
}

Source is a named part of a translation unit. The name argument is used for reporting Token positions. The value argument can be a string, []byte, fs.File, io.ReadCloser, io.Reader or nil. If the value argument is nil an attempt is made to open a file using the name argument.

When the value argument is an *os.File, io.ReadCloser or fs.File, Value.Close() is called before returning from Preprocess, Parse or Translate.

If FS is not nil it overrides the FS from Config.

type SpecifierQualifierList

type SpecifierQualifierList struct {
	AttributeSpecifierList *AttributeSpecifierList
	AlignmentSpecifier     *AlignmentSpecifier
	Case                   SpecifierQualifierListCase `PrettyPrint:"stringer,zero"`
	SpecifierQualifierList *SpecifierQualifierList
	TypeQualifier          *TypeQualifier
	TypeSpecifier          *TypeSpecifier
}

SpecifierQualifierList represents data reduced by productions:

SpecifierQualifierList:
        TypeSpecifier SpecifierQualifierList       // Case SpecifierQualifierListTypeSpec
|       TypeQualifier SpecifierQualifierList       // Case SpecifierQualifierListTypeQual
|       AlignmentSpecifier SpecifierQualifierList  // Case SpecifierQualifierListAlignSpec
Example (AlignSpec)
fmt.Println(exampleAST(150, "struct {_Alignas(double) int i;};"))
Output:

&cc.SpecifierQualifierList{
· AlignmentSpecifier: &cc.AlignmentSpecifier{
· · Case: AlignmentSpecifierType,
· · Token: example.c:1:9: '_Alignas' "_Alignas",
· · Token2: example.c:1:17: '(' "(",
· · Token3: example.c:1:24: ')' ")",
· · TypeName: &cc.TypeName{
· · · SpecifierQualifierList: &cc.SpecifierQualifierList{
· · · · Case: SpecifierQualifierListTypeSpec,
· · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · Case: TypeSpecifierDouble,
· · · · · Token: example.c:1:18: 'double' "double",
· · · · },
· · · },
· · },
· },
· Case: SpecifierQualifierListAlignSpec,
· SpecifierQualifierList: &cc.SpecifierQualifierList{
· · Case: SpecifierQualifierListTypeSpec,
· · TypeSpecifier: &cc.TypeSpecifier{
· · · Case: TypeSpecifierInt,
· · · Token: example.c:1:26: 'int' "int",
· · },
· },
}
Example (TypeQual)
fmt.Println(exampleAST(149, "struct {const int i;};"))
Output:

&cc.SpecifierQualifierList{
· Case: SpecifierQualifierListTypeQual,
· SpecifierQualifierList: &cc.SpecifierQualifierList{
· · Case: SpecifierQualifierListTypeSpec,
· · TypeSpecifier: &cc.TypeSpecifier{
· · · Case: TypeSpecifierInt,
· · · Token: example.c:1:15: 'int' "int",
· · },
· },
· TypeQualifier: &cc.TypeQualifier{
· · Case: TypeQualifierConst,
· · Token: example.c:1:9: 'const' "const",
· },
}
Example (TypeSpec)
fmt.Println(exampleAST(148, "struct {int i;};"))
Output:

&cc.SpecifierQualifierList{
· Case: SpecifierQualifierListTypeSpec,
· TypeSpecifier: &cc.TypeSpecifier{
· · Case: TypeSpecifierInt,
· · Token: example.c:1:9: 'int' "int",
· },
}

func (*SpecifierQualifierList) Position

func (n *SpecifierQualifierList) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*SpecifierQualifierList) String

func (n *SpecifierQualifierList) String() string

String implements fmt.Stringer.

type SpecifierQualifierListCase

type SpecifierQualifierListCase int

SpecifierQualifierListCase represents case numbers of production SpecifierQualifierList

const (
	SpecifierQualifierListTypeSpec SpecifierQualifierListCase = iota
	SpecifierQualifierListTypeQual
	SpecifierQualifierListAlignSpec
)

Values of type SpecifierQualifierListCase

func (SpecifierQualifierListCase) String

String implements fmt.Stringer

type Statement

type Statement struct {
	AsmStatement        *AsmStatement
	Case                StatementCase `PrettyPrint:"stringer,zero"`
	CompoundStatement   *CompoundStatement
	ExpressionStatement *ExpressionStatement
	IterationStatement  *IterationStatement
	JumpStatement       *JumpStatement
	LabeledStatement    *LabeledStatement
	SelectionStatement  *SelectionStatement
}

Statement represents data reduced by productions:

Statement:
        LabeledStatement     // Case StatementLabeled
|       CompoundStatement    // Case StatementCompound
|       ExpressionStatement  // Case StatementExpr
|       SelectionStatement   // Case StatementSelection
|       IterationStatement   // Case StatementIteration
|       JumpStatement        // Case StatementJump
|       AsmStatement         // Case StatementAsm
Example (Asm)
fmt.Println(exampleAST(220, "int f() { __asm__(\"nop\"); }"))
Output:

&cc.Statement{
· AsmStatement: &cc.AsmStatement{
· · Asm: &cc.Asm{
· · · Token: example.c:1:11: '__asm__' "__asm__",
· · · Token2: example.c:1:18: '(' "(",
· · · Token3: example.c:1:19: string literal "\"nop\"",
· · · Token4: example.c:1:24: ')' ")",
· · },
· · Token: example.c:1:25: ';' ";",
· },
· Case: StatementAsm,
}
Example (Compound)
fmt.Println(exampleAST(215, "int f() { { y(); } }"))
Output:

&cc.Statement{
· Case: StatementCompound,
· CompoundStatement: &cc.CompoundStatement{
· · BlockItemList: &cc.BlockItemList{
· · · BlockItem: &cc.BlockItem{
· · · · Case: BlockItemStmt,
· · · · Statement: &cc.Statement{
· · · · · Case: StatementExpr,
· · · · · ExpressionStatement: &cc.ExpressionStatement{
· · · · · · ExpressionList: &cc.PostfixExpression{
· · · · · · · Case: PostfixExpressionCall,
· · · · · · · PostfixExpression: &cc.PrimaryExpression{
· · · · · · · · Case: PrimaryExpressionIdent,
· · · · · · · · Token: example.c:1:13: identifier "y",
· · · · · · · },
· · · · · · · Token: example.c:1:14: '(' "(",
· · · · · · · Token2: example.c:1:15: ')' ")",
· · · · · · },
· · · · · · Token: example.c:1:16: ';' ";",
· · · · · },
· · · · },
· · · },
· · },
· · Token: example.c:1:11: '{' "{",
· · Token2: example.c:1:18: '}' "}",
· },
}
Example (Expr)
fmt.Println(exampleAST(216, "int f() { __attribute__((a)); }"))
Output:

&cc.Statement{
· Case: StatementExpr,
· ExpressionStatement: &cc.ExpressionStatement{
· · Token: example.c:1:29: ';' ";",
· },
}
Example (Iteration)
fmt.Println(exampleAST(218, "int f() { for(;;) x(); }"))
Output:

&cc.Statement{
· Case: StatementIteration,
· IterationStatement: &cc.IterationStatement{
· · Case: IterationStatementFor,
· · Statement: &cc.Statement{
· · · Case: StatementExpr,
· · · ExpressionStatement: &cc.ExpressionStatement{
· · · · ExpressionList: &cc.PostfixExpression{
· · · · · Case: PostfixExpressionCall,
· · · · · PostfixExpression: &cc.PrimaryExpression{
· · · · · · Case: PrimaryExpressionIdent,
· · · · · · Token: example.c:1:19: identifier "x",
· · · · · },
· · · · · Token: example.c:1:20: '(' "(",
· · · · · Token2: example.c:1:21: ')' ")",
· · · · },
· · · · Token: example.c:1:22: ';' ";",
· · · },
· · },
· · Token: example.c:1:11: 'for' "for",
· · Token2: example.c:1:14: '(' "(",
· · Token3: example.c:1:15: ';' ";",
· · Token4: example.c:1:16: ';' ";",
· · Token5: example.c:1:17: ')' ")",
· },
}
Example (Jump)
fmt.Println(exampleAST(219, "int f() { return x; }"))
Output:

&cc.Statement{
· Case: StatementJump,
· JumpStatement: &cc.JumpStatement{
· · Case: JumpStatementReturn,
· · ExpressionList: &cc.PrimaryExpression{
· · · Case: PrimaryExpressionIdent,
· · · Token: example.c:1:18: identifier "x",
· · },
· · Token: example.c:1:11: 'return' "return",
· · Token2: example.c:1:19: ';' ";",
· },
}
Example (Labeled)
fmt.Println(exampleAST(214, "int f() { L: x(); }"))
Output:

&cc.Statement{
· Case: StatementLabeled,
· LabeledStatement: &cc.LabeledStatement{
· · Case: LabeledStatementLabel,
· · Statement: &cc.Statement{
· · · Case: StatementExpr,
· · · ExpressionStatement: &cc.ExpressionStatement{
· · · · ExpressionList: &cc.PostfixExpression{
· · · · · Case: PostfixExpressionCall,
· · · · · PostfixExpression: &cc.PrimaryExpression{
· · · · · · Case: PrimaryExpressionIdent,
· · · · · · Token: example.c:1:14: identifier "x",
· · · · · },
· · · · · Token: example.c:1:15: '(' "(",
· · · · · Token2: example.c:1:16: ')' ")",
· · · · },
· · · · Token: example.c:1:17: ';' ";",
· · · },
· · },
· · Token: example.c:1:11: identifier "L",
· · Token2: example.c:1:12: ':' ":",
· },
}
Example (Selection)
fmt.Println(exampleAST(217, "int f() { if(x) y(); }"))
Output:

&cc.Statement{
· Case: StatementSelection,
· SelectionStatement: &cc.SelectionStatement{
· · Case: SelectionStatementIf,
· · ExpressionList: &cc.PrimaryExpression{
· · · Case: PrimaryExpressionIdent,
· · · Token: example.c:1:14: identifier "x",
· · },
· · Statement: &cc.Statement{
· · · Case: StatementExpr,
· · · ExpressionStatement: &cc.ExpressionStatement{
· · · · ExpressionList: &cc.PostfixExpression{
· · · · · Case: PostfixExpressionCall,
· · · · · PostfixExpression: &cc.PrimaryExpression{
· · · · · · Case: PrimaryExpressionIdent,
· · · · · · Token: example.c:1:17: identifier "y",
· · · · · },
· · · · · Token: example.c:1:18: '(' "(",
· · · · · Token2: example.c:1:19: ')' ")",
· · · · },
· · · · Token: example.c:1:20: ';' ";",
· · · },
· · },
· · Token: example.c:1:11: 'if' "if",
· · Token2: example.c:1:13: '(' "(",
· · Token3: example.c:1:15: ')' ")",
· },
}

func (*Statement) Position

func (n *Statement) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*Statement) String

func (n *Statement) String() string

String implements fmt.Stringer.

type StatementCase

type StatementCase int

StatementCase represents case numbers of production Statement

const (
	StatementLabeled StatementCase = iota
	StatementCompound
	StatementExpr
	StatementSelection
	StatementIteration
	StatementJump
	StatementAsm
)

Values of type StatementCase

func (StatementCase) String

func (n StatementCase) String() string

String implements fmt.Stringer

type StaticAssertDeclaration

type StaticAssertDeclaration struct {
	ConstantExpression ExpressionNode
	Token              Token
	Token2             Token
	Token3             Token
	Token4             Token
	Token5             Token
}

StaticAssertDeclaration represents data reduced by production:

StaticAssertDeclaration:
        "_Static_assert" '(' ConstantExpression ',' STRINGLITERAL ')'
Example (Case0)
fmt.Println(exampleAST(92, "_Static_assert(x > y, \"abc\")"))
Output:

&cc.StaticAssertDeclaration{
· ConstantExpression: &cc.ConstantExpression{
· · ConditionalExpression: &cc.RelationalExpression{
· · · Case: RelationalExpressionGt,
· · · RelationalExpression: &cc.PrimaryExpression{
· · · · Case: PrimaryExpressionIdent,
· · · · Token: example.c:1:16: identifier "x",
· · · },
· · · ShiftExpression: &cc.PrimaryExpression{
· · · · Case: PrimaryExpressionIdent,
· · · · Token: example.c:1:20: identifier "y",
· · · },
· · · Token: example.c:1:18: '>' ">",
· · },
· },
· Token: example.c:1:1: _Static_assert "_Static_assert",
· Token2: example.c:1:15: '(' "(",
· Token3: example.c:1:21: ',' ",",
· Token4: example.c:1:23: string literal "\"abc\"",
· Token5: example.c:1:28: ')' ")",
}

func (*StaticAssertDeclaration) Position

func (n *StaticAssertDeclaration) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*StaticAssertDeclaration) String

func (n *StaticAssertDeclaration) String() string

String implements fmt.Stringer.

type StorageClassSpecifier

type StorageClassSpecifier struct {
	Declspecs []Token
	Case      StorageClassSpecifierCase `PrettyPrint:"stringer,zero"`
	Token     Token
	Token2    Token
	Token3    Token
}

StorageClassSpecifier represents data reduced by productions:

StorageClassSpecifier:
        "typedef"             // Case StorageClassSpecifierTypedef
|       "extern"              // Case StorageClassSpecifierExtern
|       "static"              // Case StorageClassSpecifierStatic
|       "auto"                // Case StorageClassSpecifierAuto
|       "register"            // Case StorageClassSpecifierRegister
|       "_Thread_local"       // Case StorageClassSpecifierThreadLocal
|       "__declspec" '(' ')'  // Case StorageClassSpecifierDeclspec
Example (Auto)
fmt.Println(exampleAST(106, "auto int i;"))
Output:

&cc.StorageClassSpecifier{
· Case: StorageClassSpecifierAuto,
· Token: example.c:1:1: 'auto' "auto",
}
Example (Declspec)
fmt.Println(exampleAST(109, "__declspec(foo) int i;"))
Output:

&cc.StorageClassSpecifier{
· Declspecs: []cc.Token{ // len 1
· · 0: example.c:1:12: identifier "foo",
· },
· Case: StorageClassSpecifierDeclspec,
· Token: example.c:1:1: '__declspec' "__declspec",
· Token2: example.c:1:11: '(' "(",
· Token3: example.c:1:15: ')' ")",
}
Example (Extern)
fmt.Println(exampleAST(104, "extern int i;"))
Output:

&cc.StorageClassSpecifier{
· Case: StorageClassSpecifierExtern,
· Token: example.c:1:1: 'extern' "extern",
}
Example (Register)
fmt.Println(exampleAST(107, "register int i;"))
Output:

&cc.StorageClassSpecifier{
· Case: StorageClassSpecifierRegister,
· Token: example.c:1:1: 'register' "register",
}
Example (Static)
fmt.Println(exampleAST(105, "static int i;"))
Output:

&cc.StorageClassSpecifier{
· Case: StorageClassSpecifierStatic,
· Token: example.c:1:1: 'static' "static",
}
Example (ThreadLocal)
fmt.Println(exampleAST(108, "_Thread_local int i;"))
Output:

&cc.StorageClassSpecifier{
· Case: StorageClassSpecifierThreadLocal,
· Token: example.c:1:1: '_Thread_local' "_Thread_local",
}
Example (Typedef)
fmt.Println(exampleAST(103, "typedef int int_t;"))
Output:

&cc.StorageClassSpecifier{
· Case: StorageClassSpecifierTypedef,
· Token: example.c:1:1: 'typedef' "typedef",
}

func (*StorageClassSpecifier) Position

func (n *StorageClassSpecifier) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*StorageClassSpecifier) String

func (n *StorageClassSpecifier) String() string

String implements fmt.Stringer.

type StorageClassSpecifierCase

type StorageClassSpecifierCase int

StorageClassSpecifierCase represents case numbers of production StorageClassSpecifier

const (
	StorageClassSpecifierTypedef StorageClassSpecifierCase = iota
	StorageClassSpecifierExtern
	StorageClassSpecifierStatic
	StorageClassSpecifierAuto
	StorageClassSpecifierRegister
	StorageClassSpecifierThreadLocal
	StorageClassSpecifierDeclspec
)

Values of type StorageClassSpecifierCase

func (StorageClassSpecifierCase) String

func (n StorageClassSpecifierCase) String() string

String implements fmt.Stringer

type StorageDuration

type StorageDuration int

StorageDuration describes storage duration of objects ([0]6.2.4).

const (
	Static StorageDuration = iota
	Automatic
	Allocated
)

Values of type StorageDuration

func (StorageDuration) String

func (i StorageDuration) String() string

type StringValue

type StringValue string

func (StringValue) Convert

func (n StringValue) Convert(to Type) Value

type StructDeclaration

type StructDeclaration struct {
	AttributeSpecifierList  *AttributeSpecifierList
	Case                    StructDeclarationCase `PrettyPrint:"stringer,zero"`
	SpecifierQualifierList  *SpecifierQualifierList
	StaticAssertDeclaration *StaticAssertDeclaration
	StructDeclaratorList    *StructDeclaratorList
	Token                   Token
}

StructDeclaration represents data reduced by productions:

StructDeclaration:
        SpecifierQualifierList StructDeclaratorList ';'  // Case StructDeclarationDecl
|       StaticAssertDeclaration                          // Case StructDeclarationAssert
Example (Assert)
fmt.Println(exampleAST(147, "struct{ _Static_assert(x > y, \"abc\"); };"))
Output:

&cc.StructDeclaration{
· Case: StructDeclarationAssert,
· StaticAssertDeclaration: &cc.StaticAssertDeclaration{
· · ConstantExpression: &cc.ConstantExpression{
· · · ConditionalExpression: &cc.RelationalExpression{
· · · · Case: RelationalExpressionGt,
· · · · RelationalExpression: &cc.PrimaryExpression{
· · · · · Case: PrimaryExpressionIdent,
· · · · · Token: example.c:1:24: identifier "x",
· · · · },
· · · · ShiftExpression: &cc.PrimaryExpression{
· · · · · Case: PrimaryExpressionIdent,
· · · · · Token: example.c:1:28: identifier "y",
· · · · },
· · · · Token: example.c:1:26: '>' ">",
· · · },
· · },
· · Token: example.c:1:9: _Static_assert "_Static_assert",
· · Token2: example.c:1:23: '(' "(",
· · Token3: example.c:1:29: ',' ",",
· · Token4: example.c:1:31: string literal "\"abc\"",
· · Token5: example.c:1:36: ')' ")",
· },
· Token: example.c:1:37: ';' ";",
}
Example (Decl)
fmt.Println(exampleAST(146, "struct{ int i __attribute__((a)); };"))
Output:

&cc.StructDeclaration{
· AttributeSpecifierList: &cc.AttributeSpecifierList{
· · AttributeSpecifier: &cc.AttributeSpecifier{
· · · AttributeValueList: &cc.AttributeValueList{
· · · · AttributeValue: &cc.AttributeValue{
· · · · · Case: AttributeValueIdent,
· · · · · Token: example.c:1:30: identifier "a",
· · · · },
· · · },
· · · Token: example.c:1:15: '__attribute__' "__attribute__",
· · · Token2: example.c:1:28: '(' "(",
· · · Token3: example.c:1:29: '(' "(",
· · · Token4: example.c:1:31: ')' ")",
· · · Token5: example.c:1:32: ')' ")",
· · },
· },
· Case: StructDeclarationDecl,
· SpecifierQualifierList: &cc.SpecifierQualifierList{
· · Case: SpecifierQualifierListTypeSpec,
· · TypeSpecifier: &cc.TypeSpecifier{
· · · Case: TypeSpecifierInt,
· · · Token: example.c:1:9: 'int' "int",
· · },
· },
· StructDeclaratorList: &cc.StructDeclaratorList{
· · StructDeclarator: &cc.StructDeclarator{
· · · Case: StructDeclaratorDecl,
· · · Declarator: &cc.Declarator{
· · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · Case: DirectDeclaratorIdent,
· · · · · Token: example.c:1:13: identifier "i",
· · · · },
· · · },
· · },
· },
· Token: example.c:1:33: ';' ";",
}

func (*StructDeclaration) Position

func (n *StructDeclaration) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*StructDeclaration) String

func (n *StructDeclaration) String() string

String implements fmt.Stringer.

type StructDeclarationCase

type StructDeclarationCase int

StructDeclarationCase represents case numbers of production StructDeclaration

const (
	StructDeclarationDecl StructDeclarationCase = iota
	StructDeclarationAssert
)

Values of type StructDeclarationCase

func (StructDeclarationCase) String

func (n StructDeclarationCase) String() string

String implements fmt.Stringer

type StructDeclarationList

type StructDeclarationList struct {
	StructDeclaration     *StructDeclaration
	StructDeclarationList *StructDeclarationList
}

StructDeclarationList represents data reduced by productions:

StructDeclarationList:
        StructDeclaration
|       StructDeclarationList StructDeclaration
Example (Case0)
fmt.Println(exampleAST(144, "struct{ __attribute__((a)) int i; };"))
Output:

&cc.StructDeclarationList{
· StructDeclaration: &cc.StructDeclaration{
· · Case: StructDeclarationDecl,
· · SpecifierQualifierList: &cc.SpecifierQualifierList{
· · · Case: SpecifierQualifierListTypeQual,
· · · SpecifierQualifierList: &cc.SpecifierQualifierList{
· · · · Case: SpecifierQualifierListTypeSpec,
· · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · Case: TypeSpecifierInt,
· · · · · Token: example.c:1:28: 'int' "int",
· · · · },
· · · },
· · · TypeQualifier: &cc.TypeQualifier{
· · · · AttributeSpecifierList: &cc.AttributeSpecifierList{
· · · · · AttributeSpecifier: &cc.AttributeSpecifier{
· · · · · · AttributeValueList: &cc.AttributeValueList{
· · · · · · · AttributeValue: &cc.AttributeValue{
· · · · · · · · Case: AttributeValueIdent,
· · · · · · · · Token: example.c:1:24: identifier "a",
· · · · · · · },
· · · · · · },
· · · · · · Token: example.c:1:9: '__attribute__' "__attribute__",
· · · · · · Token2: example.c:1:22: '(' "(",
· · · · · · Token3: example.c:1:23: '(' "(",
· · · · · · Token4: example.c:1:25: ')' ")",
· · · · · · Token5: example.c:1:26: ')' ")",
· · · · · },
· · · · },
· · · · Case: TypeQualifierAttr,
· · · },
· · },
· · StructDeclaratorList: &cc.StructDeclaratorList{
· · · StructDeclarator: &cc.StructDeclarator{
· · · · Case: StructDeclaratorDecl,
· · · · Declarator: &cc.Declarator{
· · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · Case: DirectDeclaratorIdent,
· · · · · · Token: example.c:1:32: identifier "i",
· · · · · },
· · · · },
· · · },
· · },
· · Token: example.c:1:33: ';' ";",
· },
}
Example (Case1)
fmt.Println(exampleAST(145, "struct{ int i; double d; };"))
Output:

&cc.StructDeclarationList{
· StructDeclaration: &cc.StructDeclaration{
· · Case: StructDeclarationDecl,
· · SpecifierQualifierList: &cc.SpecifierQualifierList{
· · · Case: SpecifierQualifierListTypeSpec,
· · · TypeSpecifier: &cc.TypeSpecifier{
· · · · Case: TypeSpecifierInt,
· · · · Token: example.c:1:9: 'int' "int",
· · · },
· · },
· · StructDeclaratorList: &cc.StructDeclaratorList{
· · · StructDeclarator: &cc.StructDeclarator{
· · · · Case: StructDeclaratorDecl,
· · · · Declarator: &cc.Declarator{
· · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · Case: DirectDeclaratorIdent,
· · · · · · Token: example.c:1:13: identifier "i",
· · · · · },
· · · · },
· · · },
· · },
· · Token: example.c:1:14: ';' ";",
· },
· StructDeclarationList: &cc.StructDeclarationList{
· · StructDeclaration: &cc.StructDeclaration{
· · · Case: StructDeclarationDecl,
· · · SpecifierQualifierList: &cc.SpecifierQualifierList{
· · · · Case: SpecifierQualifierListTypeSpec,
· · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · Case: TypeSpecifierDouble,
· · · · · Token: example.c:1:16: 'double' "double",
· · · · },
· · · },
· · · StructDeclaratorList: &cc.StructDeclaratorList{
· · · · StructDeclarator: &cc.StructDeclarator{
· · · · · Case: StructDeclaratorDecl,
· · · · · Declarator: &cc.Declarator{
· · · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · · Case: DirectDeclaratorIdent,
· · · · · · · Token: example.c:1:23: identifier "d",
· · · · · · },
· · · · · },
· · · · },
· · · },
· · · Token: example.c:1:24: ';' ";",
· · },
· },
}

func (*StructDeclarationList) Position

func (n *StructDeclarationList) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*StructDeclarationList) String

func (n *StructDeclarationList) String() string

String implements fmt.Stringer.

type StructDeclarator

type StructDeclarator struct {
	Case               StructDeclaratorCase `PrettyPrint:"stringer,zero"`
	ConstantExpression ExpressionNode
	Declarator         *Declarator
	Token              Token
}

StructDeclarator represents data reduced by productions:

StructDeclarator:
        Declarator                         // Case StructDeclaratorDecl
|       Declarator ':' ConstantExpression  // Case StructDeclaratorBitField
Example (BitField)
fmt.Println(exampleAST(154, "struct{ int i:3; };"))
Output:

&cc.StructDeclarator{
· Case: StructDeclaratorBitField,
· ConstantExpression: &cc.ConstantExpression{
· · ConditionalExpression: &cc.PrimaryExpression{
· · · Case: PrimaryExpressionInt,
· · · Token: example.c:1:15: integer constant "3",
· · },
· },
· Declarator: &cc.Declarator{
· · DirectDeclarator: &cc.DirectDeclarator{
· · · Case: DirectDeclaratorIdent,
· · · Token: example.c:1:13: identifier "i",
· · },
· },
· Token: example.c:1:14: ':' ":",
}
Example (Decl)
fmt.Println(exampleAST(153, "struct{ int i; };"))
Output:

&cc.StructDeclarator{
· Case: StructDeclaratorDecl,
· Declarator: &cc.Declarator{
· · DirectDeclarator: &cc.DirectDeclarator{
· · · Case: DirectDeclaratorIdent,
· · · Token: example.c:1:13: identifier "i",
· · },
· },
}

func (*StructDeclarator) Position

func (n *StructDeclarator) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*StructDeclarator) String

func (n *StructDeclarator) String() string

String implements fmt.Stringer.

type StructDeclaratorCase

type StructDeclaratorCase int

StructDeclaratorCase represents case numbers of production StructDeclarator

const (
	StructDeclaratorDecl StructDeclaratorCase = iota
	StructDeclaratorBitField
)

Values of type StructDeclaratorCase

func (StructDeclaratorCase) String

func (n StructDeclaratorCase) String() string

String implements fmt.Stringer

type StructDeclaratorList

type StructDeclaratorList struct {
	StructDeclarator     *StructDeclarator
	StructDeclaratorList *StructDeclaratorList
	Token                Token
}

StructDeclaratorList represents data reduced by productions:

StructDeclaratorList:
        StructDeclarator
|       StructDeclaratorList ',' StructDeclarator
Example (Case0)
fmt.Println(exampleAST(151, "struct{ int i; };"))
Output:

&cc.StructDeclaratorList{
· StructDeclarator: &cc.StructDeclarator{
· · Case: StructDeclaratorDecl,
· · Declarator: &cc.Declarator{
· · · DirectDeclarator: &cc.DirectDeclarator{
· · · · Case: DirectDeclaratorIdent,
· · · · Token: example.c:1:13: identifier "i",
· · · },
· · },
· },
}
Example (Case1)
fmt.Println(exampleAST(152, "struct{ int i, j; };"))
Output:

&cc.StructDeclaratorList{
· StructDeclarator: &cc.StructDeclarator{
· · Case: StructDeclaratorDecl,
· · Declarator: &cc.Declarator{
· · · DirectDeclarator: &cc.DirectDeclarator{
· · · · Case: DirectDeclaratorIdent,
· · · · Token: example.c:1:13: identifier "i",
· · · },
· · },
· },
· StructDeclaratorList: &cc.StructDeclaratorList{
· · StructDeclarator: &cc.StructDeclarator{
· · · Case: StructDeclaratorDecl,
· · · Declarator: &cc.Declarator{
· · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · Case: DirectDeclaratorIdent,
· · · · · Token: example.c:1:16: identifier "j",
· · · · },
· · · },
· · },
· · Token: example.c:1:14: ',' ",",
· },
}

func (*StructDeclaratorList) Position

func (n *StructDeclaratorList) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*StructDeclaratorList) String

func (n *StructDeclaratorList) String() string

String implements fmt.Stringer.

type StructOrUnion

type StructOrUnion struct {
	Case  StructOrUnionCase `PrettyPrint:"stringer,zero"`
	Token Token
}

StructOrUnion represents data reduced by productions:

StructOrUnion:
        "struct"  // Case StructOrUnionStruct
|       "union"   // Case StructOrUnionUnion
Example (Struct)
fmt.Println(exampleAST(142, "struct { int i; } s;"))
Output:

&cc.StructOrUnion{
· Case: StructOrUnionStruct,
· Token: example.c:1:1: 'struct' "struct",
}
Example (Union)
fmt.Println(exampleAST(143, "union { int i; double d; } u;"))
Output:

&cc.StructOrUnion{
· Case: StructOrUnionUnion,
· Token: example.c:1:1: 'union' "union",
}

func (*StructOrUnion) Position

func (n *StructOrUnion) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*StructOrUnion) String

func (n *StructOrUnion) String() string

String implements fmt.Stringer.

type StructOrUnionCase

type StructOrUnionCase int

StructOrUnionCase represents case numbers of production StructOrUnion

const (
	StructOrUnionStruct StructOrUnionCase = iota
	StructOrUnionUnion
)

Values of type StructOrUnionCase

func (StructOrUnionCase) String

func (n StructOrUnionCase) String() string

String implements fmt.Stringer

type StructOrUnionSpecifier

type StructOrUnionSpecifier struct {
	AttributeSpecifierList  *AttributeSpecifierList
	AttributeSpecifierList2 *AttributeSpecifierList

	Case                  StructOrUnionSpecifierCase `PrettyPrint:"stringer,zero"`
	StructDeclarationList *StructDeclarationList
	StructOrUnion         *StructOrUnion
	Token                 Token
	Token2                Token
	Token3                Token
	// contains filtered or unexported fields
}

StructOrUnionSpecifier represents data reduced by productions:

StructOrUnionSpecifier:
        StructOrUnion IDENTIFIER '{' StructDeclarationList '}'  // Case StructOrUnionSpecifierDef
|       StructOrUnion IDENTIFIER                                // Case StructOrUnionSpecifierTag
Example (Def)
fmt.Println(exampleAST(140, "struct s { int i; } __attribute__((a));"))
Output:

&cc.StructOrUnionSpecifier{
· AttributeSpecifierList: &cc.AttributeSpecifierList{
· · AttributeSpecifier: &cc.AttributeSpecifier{
· · · AttributeValueList: &cc.AttributeValueList{
· · · · AttributeValue: &cc.AttributeValue{
· · · · · Case: AttributeValueIdent,
· · · · · Token: example.c:1:36: identifier "a",
· · · · },
· · · },
· · · Token: example.c:1:21: '__attribute__' "__attribute__",
· · · Token2: example.c:1:34: '(' "(",
· · · Token3: example.c:1:35: '(' "(",
· · · Token4: example.c:1:37: ')' ")",
· · · Token5: example.c:1:38: ')' ")",
· · },
· },
· Case: StructOrUnionSpecifierDef,
· StructDeclarationList: &cc.StructDeclarationList{
· · StructDeclaration: &cc.StructDeclaration{
· · · Case: StructDeclarationDecl,
· · · SpecifierQualifierList: &cc.SpecifierQualifierList{
· · · · Case: SpecifierQualifierListTypeSpec,
· · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · Case: TypeSpecifierInt,
· · · · · Token: example.c:1:12: 'int' "int",
· · · · },
· · · },
· · · StructDeclaratorList: &cc.StructDeclaratorList{
· · · · StructDeclarator: &cc.StructDeclarator{
· · · · · Case: StructDeclaratorDecl,
· · · · · Declarator: &cc.Declarator{
· · · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · · Case: DirectDeclaratorIdent,
· · · · · · · Token: example.c:1:16: identifier "i",
· · · · · · },
· · · · · },
· · · · },
· · · },
· · · Token: example.c:1:17: ';' ";",
· · },
· },
· StructOrUnion: &cc.StructOrUnion{
· · Case: StructOrUnionStruct,
· · Token: example.c:1:1: 'struct' "struct",
· },
· Token: example.c:1:8: identifier "s",
· Token2: example.c:1:10: '{' "{",
· Token3: example.c:1:19: '}' "}",
}
Example (Tag)
fmt.Println(exampleAST(141, "struct __attribute__((a)) s v;"))
Output:

&cc.StructOrUnionSpecifier{
· AttributeSpecifierList: &cc.AttributeSpecifierList{
· · AttributeSpecifier: &cc.AttributeSpecifier{
· · · AttributeValueList: &cc.AttributeValueList{
· · · · AttributeValue: &cc.AttributeValue{
· · · · · Case: AttributeValueIdent,
· · · · · Token: example.c:1:23: identifier "a",
· · · · },
· · · },
· · · Token: example.c:1:8: '__attribute__' "__attribute__",
· · · Token2: example.c:1:21: '(' "(",
· · · Token3: example.c:1:22: '(' "(",
· · · Token4: example.c:1:24: ')' ")",
· · · Token5: example.c:1:25: ')' ")",
· · },
· },
· Case: StructOrUnionSpecifierTag,
· StructOrUnion: &cc.StructOrUnion{
· · Case: StructOrUnionStruct,
· · Token: example.c:1:1: 'struct' "struct",
· },
· Token: example.c:1:27: identifier "s",
}

func (StructOrUnionSpecifier) LexicalScope

func (n StructOrUnionSpecifier) LexicalScope() *Scope

LexicalScope provides the scope a node appears in.

func (*StructOrUnionSpecifier) Position

func (n *StructOrUnionSpecifier) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*StructOrUnionSpecifier) String

func (n *StructOrUnionSpecifier) String() string

String implements fmt.Stringer.

func (StructOrUnionSpecifier) Type

func (t StructOrUnionSpecifier) Type() Type

Type returns the type of a node or an *InvalidType type value, if the type is unknown/undetermined.

func (StructOrUnionSpecifier) Visible

func (v StructOrUnionSpecifier) Visible() int

Visible reports the token sequence number where the visibility of a name starts.

type StructOrUnionSpecifierCase

type StructOrUnionSpecifierCase int

StructOrUnionSpecifierCase represents case numbers of production StructOrUnionSpecifier

const (
	StructOrUnionSpecifierDef StructOrUnionSpecifierCase = iota
	StructOrUnionSpecifierTag
)

Values of type StructOrUnionSpecifierCase

func (StructOrUnionSpecifierCase) String

String implements fmt.Stringer

type StructType

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

func (*StructType) Align

func (n *StructType) Align() int

Align implements Type.

func (*StructType) Attributes

func (n *StructType) Attributes() *Attributes

Attributes implemets Type.

func (StructType) BitField added in v4.1.1

func (StructType) BitField() *Field

BitField implements Type.

func (*StructType) Decay

func (n *StructType) Decay() Type

Decay implements Type.

func (*StructType) FieldAlign

func (n *StructType) FieldAlign() int

FieldAlign implements Type.

func (*StructType) FieldByIndex

func (n *StructType) FieldByIndex(i int) *Field

FieldByIndex returns a member field by index, if any.

func (*StructType) FieldByName

func (n *StructType) FieldByName(nm string) *Field

FieldByName returns the shallowest member field by name, if any.

func (*StructType) FlexibleArrayMember

func (n *StructType) FlexibleArrayMember() *Field

FlexibleArrayMember returns the flexible array member of n, if any.

func (*StructType) HasFlexibleArrayMember

func (n *StructType) HasFlexibleArrayMember() bool

HasFlexibleArrayMember reports whether n has a flexible array member:

https://en.wikipedia.org/wiki/Flexible_array_member

func (*StructType) IsCompatible

func (n *StructType) IsCompatible(t Type) (r bool)

func (*StructType) IsIncomplete

func (n *StructType) IsIncomplete() bool

IsIncomplete implements Type.

func (*StructType) Kind

func (n *StructType) Kind() Kind

Kind implements Type.

func (*StructType) LexicalScope

func (n *StructType) LexicalScope() *Scope

LexicalScope provides the scope the definition of n appears in.

func (*StructType) NamedFieldByIndex

func (n *StructType) NamedFieldByIndex(i int) (r *Field)

NamedFieldByIndex returns the first named member field at or after index, if any.

func (*StructType) NumFields

func (n *StructType) NumFields() int

NumFields reports the number of n's fields.

func (*StructType) Padding

func (n *StructType) Padding() int

Padding reports how many bytes at the end of a struct/union should be additionally reserved. Consider:

struct {
	int a:1;
}

Alignment of the above struct is that of an int, but the 'a' field uses only one byte. Padding will report 3 in this case.

func (*StructType) Pointer

func (n *StructType) Pointer() Type

Pointer implements Type.

func (*StructType) Size

func (n *StructType) Size() int64

Size implements Type.

func (*StructType) String

func (n *StructType) String() string

String implements Type.

func (*StructType) Tag

func (n *StructType) Tag() Token

Tag returns n's tag, if any.

func (StructType) Typedef

func (n StructType) Typedef() *Declarator

Typedef implements Type

func (*StructType) Undecay

func (n *StructType) Undecay() Type

Undecay implements Type.

func (StructType) VectorSize

func (StructType) VectorSize() int64

VectorSize implements Type.

type Token

type Token struct {
	Ch rune // '*' or IDENTIFIER etc.
	// contains filtered or unexported fields
}

Token is the lexical token produced by the scanner.

func NodeTokens

func NodeTokens(n Node) (r []Token)

NodeTokens returns the source tokens n consists of.

func (*Token) Name

func (t *Token) Name() string

Name returns a human readable representation of t.Ch.

func (Token) Position

func (t Token) Position() (r token.Position)

Position implements Node.

func (*Token) Sep

func (t *Token) Sep() []byte

Sep returns any white space, including comments, that precede t. The result is R/O but it's okay to append to it.

func (*Token) Seq

func (t *Token) Seq() int

Seq returns t's sequence number in the token stream. The information determines scope boundaries.

func (*Token) Set

func (t *Token) Set(sep, src []byte) error

Set sets the values Sep and Src will report.

func (*Token) Src

func (t *Token) Src() []byte

Src returns the source representation of t. The result is R/O but it's okay to append to it.

func (*Token) SrcStr

func (t *Token) SrcStr() string

SrcStr returns the source representation of t as a string. To avoid allocations, consider using Src.

func (Token) String

func (t Token) String() string

String implements fmt.Stringer.

type TranslationUnit

type TranslationUnit struct {
	ExternalDeclaration *ExternalDeclaration
	TranslationUnit     *TranslationUnit
}

TranslationUnit represents data reduced by productions:

TranslationUnit:
        ExternalDeclaration
|       TranslationUnit ExternalDeclaration
Example (Case0)
fmt.Println(exampleAST(246, "int i;"))
Output:

&cc.TranslationUnit{
· ExternalDeclaration: &cc.ExternalDeclaration{
· · Case: ExternalDeclarationDecl,
· · Declaration: &cc.Declaration{
· · · Case: DeclarationDecl,
· · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · Case: DeclarationSpecifiersTypeSpec,
· · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · Case: TypeSpecifierInt,
· · · · · Token: example.c:1:1: 'int' "int",
· · · · },
· · · },
· · · InitDeclaratorList: &cc.InitDeclaratorList{
· · · · InitDeclarator: &cc.InitDeclarator{
· · · · · Case: InitDeclaratorDecl,
· · · · · Declarator: &cc.Declarator{
· · · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · · Case: DirectDeclaratorIdent,
· · · · · · · Token: example.c:1:5: identifier "i",
· · · · · · },
· · · · · },
· · · · },
· · · },
· · · Token: example.c:1:6: ';' ";",
· · },
· },
}
Example (Case1)
fmt.Println(exampleAST(247, "int i; int j;"))
Output:

&cc.TranslationUnit{
· ExternalDeclaration: &cc.ExternalDeclaration{
· · Case: ExternalDeclarationDecl,
· · Declaration: &cc.Declaration{
· · · Case: DeclarationDecl,
· · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · Case: DeclarationSpecifiersTypeSpec,
· · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · Case: TypeSpecifierInt,
· · · · · Token: example.c:1:1: 'int' "int",
· · · · },
· · · },
· · · InitDeclaratorList: &cc.InitDeclaratorList{
· · · · InitDeclarator: &cc.InitDeclarator{
· · · · · Case: InitDeclaratorDecl,
· · · · · Declarator: &cc.Declarator{
· · · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · · Case: DirectDeclaratorIdent,
· · · · · · · Token: example.c:1:5: identifier "i",
· · · · · · },
· · · · · },
· · · · },
· · · },
· · · Token: example.c:1:6: ';' ";",
· · },
· },
· TranslationUnit: &cc.TranslationUnit{
· · ExternalDeclaration: &cc.ExternalDeclaration{
· · · Case: ExternalDeclarationDecl,
· · · Declaration: &cc.Declaration{
· · · · Case: DeclarationDecl,
· · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{
· · · · · Case: DeclarationSpecifiersTypeSpec,
· · · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · · Case: TypeSpecifierInt,
· · · · · · Token: example.c:1:8: 'int' "int",
· · · · · },
· · · · },
· · · · InitDeclaratorList: &cc.InitDeclaratorList{
· · · · · InitDeclarator: &cc.InitDeclarator{
· · · · · · Case: InitDeclaratorDecl,
· · · · · · Declarator: &cc.Declarator{
· · · · · · · DirectDeclarator: &cc.DirectDeclarator{
· · · · · · · · Case: DirectDeclaratorIdent,
· · · · · · · · Token: example.c:1:12: identifier "j",
· · · · · · · },
· · · · · · },
· · · · · },
· · · · },
· · · · Token: example.c:1:13: ';' ";",
· · · },
· · },
· },
}

func (*TranslationUnit) Position

func (n *TranslationUnit) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*TranslationUnit) String

func (n *TranslationUnit) String() string

String implements fmt.Stringer.

type Type

type Type interface {
	// Align reports the minimum alignment required by a type.
	Align() int

	Attributes() *Attributes

	// Bitfield backlink to the bit fields a type comes from, if any.
	BitField() *Field

	// Decay returns a pointer to array element for array types, a pointer to a
	// function for function types and itself for all other type kinds.
	Decay() Type

	// FieldAlign reports the minimum alignment required by a type when it's used
	// in a struct/union.
	FieldAlign() int

	// IsCompatible reports type compatibility as defined in [0]6.2.7/1.
	IsCompatible(Type) bool

	// IsIncomplete reports whether the size of a type is not determined.
	IsIncomplete() bool

	// Kind reports the kind of a type.
	Kind() Kind

	// Pointer returns a pointer to a type.
	Pointer() Type

	// Size reports the size of a type in bytes. Incomplete or invalid types may
	// report a negative size.
	Size() int64

	// String produces a human readable representation of a type or an
	// approximation of the same. The particular form is not specified and
	// may change. Namely, the returned value is not suitable for directly
	// determining type identity.
	String() string

	// Typedef returns the associated typedef declarator of this type, if any.
	Typedef() *Declarator

	// Undecay reverses Decay() if the type is a pointer and was produced by
	// Decay() and the result was different than the Decay() receiver. Otherwise
	// Undecay() returns its receiver.
	Undecay() Type

	// VectorSize reports N from __attribute__((vector_size(N))). Valid if
	// > 0.
	VectorSize() int64
	// contains filtered or unexported methods
}

Type is the representation of a C type.

The dynamic type of a Type is one of

*ArrayType
*EnumType
*FunctionType
*InvalidType
*PointerType
*PredefinedType
*StructType
*UnionType
var (
	// Invalid is a singleton representing an invalid/undetermined type.  Invalid
	// is comparable.
	Invalid Type = &InvalidType{}
)

func IntegerPromotion

func IntegerPromotion(t Type) Type

IntegerPromotion performs the type conversion defined in [0]6.3.1.1-2.

If an int can represent all values of the original type, the value is converted to an int; otherwise, it is converted to an unsigned int. These are called the integer promotions. All other types are unchanged by the integer promotions.

func LeastCommonAncestorType added in v4.3.0

func LeastCommonAncestorType(s []*Initializer) (r Type)

LeastCommonAncestorType returns the LCA type containing all field initializers in s.

func UsualArithmeticConversions

func UsualArithmeticConversions(a, b Type) (r Type)

UsualArithmeticConversions returns the common type of a binary operation.

[0] 6.3.1.8 Usual arithmetic conversions

type TypeName

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

TypeName represents data reduced by production:

TypeName:
        SpecifierQualifierList AbstractDeclarator
Example (Case0)
fmt.Println(exampleAST(194, "int i = (int)x;"))
Output:

&cc.TypeName{
· SpecifierQualifierList: &cc.SpecifierQualifierList{
· · Case: SpecifierQualifierListTypeSpec,
· · TypeSpecifier: &cc.TypeSpecifier{
· · · Case: TypeSpecifierInt,
· · · Token: example.c:1:10: 'int' "int",
· · },
· },
}

func (*TypeName) Position

func (n *TypeName) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*TypeName) String

func (n *TypeName) String() string

String implements fmt.Stringer.

func (TypeName) Type

func (t TypeName) Type() Type

Type returns the type of a node or an *InvalidType type value, if the type is unknown/undetermined.

type TypeQualifier

type TypeQualifier struct {
	AttributeSpecifierList *AttributeSpecifierList
	Case                   TypeQualifierCase `PrettyPrint:"stringer,zero"`
	Token                  Token
}

TypeQualifier represents data reduced by productions:

TypeQualifier:
        "const"          // Case TypeQualifierConst
|       "restrict"       // Case TypeQualifierRestrict
|       "volatile"       // Case TypeQualifierVolatile
|       "_Atomic"        // Case TypeQualifierAtomic
|       "_Nonnull"       // Case TypeQualifierNonnull
|       "__attribute__"  // Case TypeQualifierAttr
Example (Atomic)
fmt.Println(exampleAST(165, "_Atomic int i;"))
Output:

&cc.TypeQualifier{
· Case: TypeQualifierAtomic,
· Token: example.c:1:1: '_Atomic' "_Atomic",
}
Example (Attr)
fmt.Println(exampleAST(167, "struct { __attribute__((a)) int i; };"))
Output:

&cc.TypeQualifier{
· AttributeSpecifierList: &cc.AttributeSpecifierList{
· · AttributeSpecifier: &cc.AttributeSpecifier{
· · · AttributeValueList: &cc.AttributeValueList{
· · · · AttributeValue: &cc.AttributeValue{
· · · · · Case: AttributeValueIdent,
· · · · · Token: example.c:1:25: identifier "a",
· · · · },
· · · },
· · · Token: example.c:1:10: '__attribute__' "__attribute__",
· · · Token2: example.c:1:23: '(' "(",
· · · Token3: example.c:1:24: '(' "(",
· · · Token4: example.c:1:26: ')' ")",
· · · Token5: example.c:1:27: ')' ")",
· · },
· },
· Case: TypeQualifierAttr,
}
Example (Const)
fmt.Println(exampleAST(162, "const int i;"))
Output:

&cc.TypeQualifier{
· Case: TypeQualifierConst,
· Token: example.c:1:1: 'const' "const",
}
Example (Nonnull)
fmt.Println(exampleAST(166, "_Nonnull int i;"))
Output:

&cc.TypeQualifier{
· Case: TypeQualifierNonnull,
· Token: example.c:1:1: '_Nonnull' "_Nonnull",
}
Example (Restrict)
fmt.Println(exampleAST(163, "restrict int i;"))
Output:

&cc.TypeQualifier{
· Case: TypeQualifierRestrict,
· Token: example.c:1:1: 'restrict' "restrict",
}
Example (Volatile)
fmt.Println(exampleAST(164, "volatile int i;"))
Output:

&cc.TypeQualifier{
· Case: TypeQualifierVolatile,
· Token: example.c:1:1: 'volatile' "volatile",
}

func (*TypeQualifier) Position

func (n *TypeQualifier) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*TypeQualifier) String

func (n *TypeQualifier) String() string

String implements fmt.Stringer.

type TypeQualifierCase

type TypeQualifierCase int

TypeQualifierCase represents case numbers of production TypeQualifier

const (
	TypeQualifierConst TypeQualifierCase = iota
	TypeQualifierRestrict
	TypeQualifierVolatile
	TypeQualifierAtomic
	TypeQualifierNonnull
	TypeQualifierAttr
)

Values of type TypeQualifierCase

func (TypeQualifierCase) String

func (n TypeQualifierCase) String() string

String implements fmt.Stringer

type TypeQualifiers

type TypeQualifiers struct {
	Case           TypeQualifiersCase `PrettyPrint:"stringer,zero"`
	TypeQualifier  *TypeQualifier
	TypeQualifiers *TypeQualifiers
}

TypeQualifiers represents data reduced by productions:

TypeQualifiers:
        TypeQualifier                 // Case TypeQualifiersTypeQual
|       TypeQualifiers TypeQualifier  // Case 1
Example (Case1)
fmt.Println(exampleAST(185, "int * const volatile i;"))
Output:

&cc.TypeQualifiers{
· Case: TypeQualifiersTypeQual,
· TypeQualifier: &cc.TypeQualifier{
· · Case: TypeQualifierVolatile,
· · Token: example.c:1:13: 'volatile' "volatile",
· },
· TypeQualifiers: &cc.TypeQualifiers{
· · Case: TypeQualifiersTypeQual,
· · TypeQualifier: &cc.TypeQualifier{
· · · Case: TypeQualifierConst,
· · · Token: example.c:1:7: 'const' "const",
· · },
· },
}
Example (TypeQual)
fmt.Println(exampleAST(184, "int * __attribute__((a)) const i;"))
Output:

&cc.TypeQualifiers{
· Case: TypeQualifiersTypeQual,
· TypeQualifier: &cc.TypeQualifier{
· · Case: TypeQualifierConst,
· · Token: example.c:1:26: 'const' "const",
· },
· TypeQualifiers: &cc.TypeQualifiers{
· · Case: TypeQualifiersTypeQual,
· · TypeQualifier: &cc.TypeQualifier{
· · · AttributeSpecifierList: &cc.AttributeSpecifierList{
· · · · AttributeSpecifier: &cc.AttributeSpecifier{
· · · · · AttributeValueList: &cc.AttributeValueList{
· · · · · · AttributeValue: &cc.AttributeValue{
· · · · · · · Case: AttributeValueIdent,
· · · · · · · Token: example.c:1:22: identifier "a",
· · · · · · },
· · · · · },
· · · · · Token: example.c:1:7: '__attribute__' "__attribute__",
· · · · · Token2: example.c:1:20: '(' "(",
· · · · · Token3: example.c:1:21: '(' "(",
· · · · · Token4: example.c:1:23: ')' ")",
· · · · · Token5: example.c:1:24: ')' ")",
· · · · },
· · · },
· · · Case: TypeQualifierAttr,
· · },
· },
}

func (*TypeQualifiers) Position

func (n *TypeQualifiers) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*TypeQualifiers) String

func (n *TypeQualifiers) String() string

String implements fmt.Stringer.

type TypeQualifiersCase

type TypeQualifiersCase int

TypeQualifiersCase represents case numbers of production TypeQualifiers

const (
	TypeQualifiersTypeQual TypeQualifiersCase = iota
)

Values of type TypeQualifiersCase

func (TypeQualifiersCase) String

func (n TypeQualifiersCase) String() string

String implements fmt.Stringer

type TypeSpecifier

type TypeSpecifier struct {
	AtomicTypeSpecifier    *AtomicTypeSpecifier
	Case                   TypeSpecifierCase `PrettyPrint:"stringer,zero"`
	EnumSpecifier          *EnumSpecifier
	ExpressionList         ExpressionNode
	StructOrUnionSpecifier *StructOrUnionSpecifier
	Token                  Token
	Token2                 Token
	Token3                 Token
	TypeName               *TypeName
	// contains filtered or unexported fields
}

TypeSpecifier represents data reduced by productions:

TypeSpecifier:
        "void"                           // Case TypeSpecifierVoid
|       "char"                           // Case TypeSpecifierChar
|       "short"                          // Case TypeSpecifierShort
|       "int"                            // Case TypeSpecifierInt
|       "__int128"                       // Case TypeSpecifierInt128
|       "__uint128_t"                    // Case TypeSpecifierUint128
|       "long"                           // Case TypeSpecifierLong
|       "float"                          // Case TypeSpecifierFloat
|       "_Float16"                       // Case TypeSpecifierFloat16
|       "_Decimal32"                     // Case TypeSpecifierDecimal32
|       "_Decimal64"                     // Case TypeSpecifierDecimal64
|       "_Decimal128"                    // Case TypeSpecifierDecimal128
|       "_Float128"                      // Case TypeSpecifierFloat128
|       "_Float128x"                     // Case TypeSpecifierFloat128x
|       "double"                         // Case TypeSpecifierDouble
|       "signed"                         // Case TypeSpecifierSigned
|       "unsigned"                       // Case TypeSpecifierUnsigned
|       "_Bool"                          // Case TypeSpecifierBool
|       "_Complex"                       // Case TypeSpecifierComplex
|       "_Imaginary"                     // Case TypeSpecifierImaginary
|       StructOrUnionSpecifier           // Case TypeSpecifierStructOrUnion
|       EnumSpecifier                    // Case TypeSpecifierEnum
|       TYPENAME                         // Case TypeSpecifierTypeName
|       "typeof" '(' ExpressionList ')'  // Case TypeSpecifierTypeofExpr
|       "typeof" '(' TypeName ')'        // Case TypeSpecifierTypeofType
|       AtomicTypeSpecifier              // Case TypeSpecifierAtomic
|       "_Float32"                       // Case TypeSpecifierFloat32
|       "_Float64"                       // Case TypeSpecifierFloat64
|       "_Float32x"                      // Case TypeSpecifierFloat32x
|       "_Float64x"                      // Case TypeSpecifierFloat64x
Example (Atomic)
fmt.Println(exampleAST(135, "_Atomic(int) i;"))
Output:

&cc.TypeSpecifier{
· AtomicTypeSpecifier: &cc.AtomicTypeSpecifier{
· · Token: example.c:1:1: '_Atomic' "_Atomic",
· · Token2: example.c:1:8: '(' "(",
· · Token3: example.c:1:12: ')' ")",
· · TypeName: &cc.TypeName{
· · · SpecifierQualifierList: &cc.SpecifierQualifierList{
· · · · Case: SpecifierQualifierListTypeSpec,
· · · · TypeSpecifier: &cc.TypeSpecifier{
· · · · · Case: TypeSpecifierInt,
· · · · · Token: example.c:1:9: 'int' "int",
· · · · },
· · · },
· · },
· },
· Case: TypeSpecifierAtomic,
}
Example (Bool)
fmt.Println(exampleAST(127, "_Bool i;"))
Output:

&cc.TypeSpecifier{
· Case: TypeSpecifierBool,
· Token: example.c:1:1: '_Bool' "_Bool",
}
Example (Char)
fmt.Println(exampleAST(111, "char i;"))
Output:

&cc.TypeSpecifier{
· Case: TypeSpecifierChar,
· Token: example.c:1:1: 'char' "char",
}
Example (Complex)
fmt.Println(exampleAST(128, "_Complex i;"))
Output:

&cc.TypeSpecifier{
· Case: TypeSpecifierComplex,
· Token: example.c:1:1: '_Complex' "_Complex",
}
Example (Decimal128)
fmt.Println(exampleAST(121, "_Decimal128 i;"))
Output:

&cc.TypeSpecifier{
· Case: TypeSpecifierDecimal128,
· Token: example.c:1:1: '_Decimal128' "_Decimal128",
}
Example (Decimal32)
fmt.Println(exampleAST(119, "_Decimal32 i;"))
Output:

&cc.TypeSpecifier{
· Case: TypeSpecifierDecimal32,
· Token: example.c:1:1: '_Decimal32' "_Decimal32",
}
Example (Decimal64)
fmt.Println(exampleAST(120, "_Decimal64 i;"))
Output:

&cc.TypeSpecifier{
· Case: TypeSpecifierDecimal64,
· Token: example.c:1:1: '_Decimal64' "_Decimal64",
}
Example (Double)
fmt.Println(exampleAST(124, "double i;"))
Output:

&cc.TypeSpecifier{
· Case: TypeSpecifierDouble,
· Token: example.c:1:1: 'double' "double",
}
Example (Enum)
fmt.Println(exampleAST(131, "enum e i;"))
Output:

&cc.TypeSpecifier{
· Case: TypeSpecifierEnum,
· EnumSpecifier: &cc.EnumSpecifier{
· · Case: EnumSpecifierTag,
· · Token: example.c:1:1: 'enum' "enum",
· · Token2: example.c:1:6: identifier "e",
· },
}
Example (Float)
fmt.Println(exampleAST(117, "float i;"))
Output:

&cc.TypeSpecifier{
· Case: TypeSpecifierFloat,
· Token: example.c:1:1: 'float' "float",
}
Example (Float128)
fmt.Println(exampleAST(122, "_Float128 i;"))
Output:

&cc.TypeSpecifier{
· Case: TypeSpecifierFloat128,
· Token: example.c:1:1: '_Float128' "_Float128",
}
Example (Float128x)
fmt.Println(exampleAST(123, "_Float128x i;"))
Output:

&cc.TypeSpecifier{
· Case: TypeSpecifierFloat128x,
· Token: example.c:1:1: '_Float128x' "_Float128x",
}
Example (Float16)
fmt.Println(exampleAST(118, "_Float16 i;"))
Output:

&cc.TypeSpecifier{
· Case: TypeSpecifierFloat16,
· Token: example.c:1:1: '_Float16' "_Float16",
}
Example (Float32)
fmt.Println(exampleAST(136, "_Float32 i;"))
Output:

&cc.TypeSpecifier{
· Case: TypeSpecifierFloat32,
· Token: example.c:1:1: '_Float32' "_Float32",
}
Example (Float32x)
fmt.Println(exampleAST(138, "_Float32x i;"))
Output:

&cc.TypeSpecifier{
· Case: TypeSpecifierFloat32x,
· Token: example.c:1:1: '_Float32x' "_Float32x",
}
Example (Float64)
fmt.Println(exampleAST(137, "_Float64 i;"))
Output:

&cc.TypeSpecifier{
· Case: TypeSpecifierFloat64,
· Token: example.c:1:1: '_Float64' "_Float64",
}
Example (Float64x)
fmt.Println(exampleAST(139, "_Float64x i;"))
Output:

&cc.TypeSpecifier{
· Case: TypeSpecifierFloat64x,
· Token: example.c:1:1: '_Float64x' "_Float64x",
}
Example (Imaginary)
fmt.Println(exampleAST(129, "_Imaginary i;"))
Output:

&cc.TypeSpecifier{
· Case: TypeSpecifierImaginary,
· Token: example.c:1:1: '_Imaginary' "_Imaginary",
}
Example (Int)
fmt.Println(exampleAST(113, "int i;"))
Output:

&cc.TypeSpecifier{
· Case: TypeSpecifierInt,
· Token: example.c:1:1: 'int' "int",
}
Example (Int128)
fmt.Println(exampleAST(114, "__int128 i;"))
Output:

&cc.TypeSpecifier{
· Case: TypeSpecifierInt128,
· Token: example.c:1:1: '__int128' "__int128",
}
Example (Long)
fmt.Println(exampleAST(116, "long i;"))
Output:

&cc.TypeSpecifier{
· Case: TypeSpecifierLong,
· Token: example.c:1:1: 'long' "long",
}
Example (Short)
fmt.Println(exampleAST(112, "short i;"))
Output:

&cc.TypeSpecifier{
· Case: TypeSpecifierShort,
· Token: example.c:1:1: 'short' "short",
}
Example (Signed)
fmt.Println(exampleAST(125, "signed i;"))
Output:

&cc.TypeSpecifier{
· Case: TypeSpecifierSigned,
· Token: example.c:1:1: 'signed' "signed",
}
Example (StructOrUnion)
fmt.Println(exampleAST(130, "struct s i;"))
Output:

&cc.TypeSpecifier{
· Case: TypeSpecifierStructOrUnion,
· StructOrUnionSpecifier: &cc.StructOrUnionSpecifier{
· · Case: StructOrUnionSpecifierTag,
· · StructOrUnion: &cc.StructOrUnion{
· · · Case: StructOrUnionStruct,
· · · Token: example.c:1:1: 'struct' "struct",
· · },
· · Token: example.c:1:8: identifier "s",
· },
}
Example (TypeName)
fmt.Println(exampleAST(132, "typedef int T; T i;"))
Output:

&cc.TypeSpecifier{
· Case: TypeSpecifierInt,
· Token: example.c:1:9: 'int' "int",
}
Example (TypeofExpr)
fmt.Println(exampleAST(133, "typeof(42) i;"))
Output:

&cc.TypeSpecifier{
· Case: TypeSpecifierTypeofExpr,
· ExpressionList: &cc.PrimaryExpression{
· · Case: PrimaryExpressionInt,
· · Token: example.c:1:8: integer constant "42",
· },
· Token: example.c:1:1: 'typeof' "typeof",
· Token2: example.c:1:7: '(' "(",
· Token3: example.c:1:10: ')' ")",
}
Example (TypeofType)
fmt.Println(exampleAST(134, "typedef int T; typeof(T) i;"))
Output:

&cc.TypeSpecifier{
· Case: TypeSpecifierInt,
· Token: example.c:1:9: 'int' "int",
}
Example (Uint128)
fmt.Println(exampleAST(115, "__uint128_t i;"))
Output:

&cc.TypeSpecifier{
· Case: TypeSpecifierUint128,
· Token: example.c:1:1: '__uint128_t' "__uint128_t",
}
Example (Unsigned)
fmt.Println(exampleAST(126, "unsigned i;"))
Output:

&cc.TypeSpecifier{
· Case: TypeSpecifierUnsigned,
· Token: example.c:1:1: 'unsigned' "unsigned",
}
Example (Void)
fmt.Println(exampleAST(110, "void i();"))
Output:

&cc.TypeSpecifier{
· Case: TypeSpecifierVoid,
· Token: example.c:1:1: 'void' "void",
}

func (TypeSpecifier) LexicalScope

func (n TypeSpecifier) LexicalScope() *Scope

LexicalScope provides the scope a node appears in.

func (*TypeSpecifier) Position

func (n *TypeSpecifier) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*TypeSpecifier) String

func (n *TypeSpecifier) String() string

String implements fmt.Stringer.

type TypeSpecifierCase

type TypeSpecifierCase int

TypeSpecifierCase represents case numbers of production TypeSpecifier

const (
	TypeSpecifierVoid TypeSpecifierCase = iota
	TypeSpecifierChar
	TypeSpecifierShort
	TypeSpecifierInt
	TypeSpecifierInt128
	TypeSpecifierUint128
	TypeSpecifierLong
	TypeSpecifierFloat
	TypeSpecifierFloat16
	TypeSpecifierDecimal32
	TypeSpecifierDecimal64
	TypeSpecifierDecimal128
	TypeSpecifierFloat128
	TypeSpecifierFloat128x
	TypeSpecifierDouble
	TypeSpecifierSigned
	TypeSpecifierUnsigned
	TypeSpecifierBool
	TypeSpecifierComplex
	TypeSpecifierImaginary
	TypeSpecifierStructOrUnion
	TypeSpecifierEnum
	TypeSpecifierTypeName
	TypeSpecifierTypeofExpr
	TypeSpecifierTypeofType
	TypeSpecifierAtomic
	TypeSpecifierFloat32
	TypeSpecifierFloat64
	TypeSpecifierFloat32x
	TypeSpecifierFloat64x
)

Values of type TypeSpecifierCase

func (TypeSpecifierCase) String

func (n TypeSpecifierCase) String() string

String implements fmt.Stringer

type UInt64Value

type UInt64Value uint64

func (UInt64Value) Convert

func (n UInt64Value) Convert(to Type) Value

type UTF16StringValue

type UTF16StringValue []uint16

func (UTF16StringValue) Convert

func (n UTF16StringValue) Convert(to Type) Value

type UTF32StringValue

type UTF32StringValue []rune

func (UTF32StringValue) Convert

func (n UTF32StringValue) Convert(to Type) Value

type UnaryExpression

type UnaryExpression struct {
	Case              UnaryExpressionCase `PrettyPrint:"stringer,zero"`
	CastExpression    ExpressionNode
	PostfixExpression ExpressionNode
	Token             Token
	Token2            Token
	Token3            Token
	TypeName          *TypeName
	UnaryExpression   ExpressionNode
	// contains filtered or unexported fields
}

UnaryExpression represents data reduced by productions:

UnaryExpression:
        PostfixExpression            // Case UnaryExpressionPostfix
|       "++" UnaryExpression         // Case UnaryExpressionInc
|       "--" UnaryExpression         // Case UnaryExpressionDec
|       '&' CastExpression           // Case UnaryExpressionAddrof
|       '*' CastExpression           // Case UnaryExpressionDeref
|       '+' CastExpression           // Case UnaryExpressionPlus
|       '-' CastExpression           // Case UnaryExpressionMinus
|       '~' CastExpression           // Case UnaryExpressionCpl
|       '!' CastExpression           // Case UnaryExpressionNot
|       "sizeof" UnaryExpression     // Case UnaryExpressionSizeofExpr
|       "sizeof" '(' TypeName ')'    // Case UnaryExpressionSizeofType
|       "&&" IDENTIFIER              // Case UnaryExpressionLabelAddr
|       "_Alignof" UnaryExpression   // Case UnaryExpressionAlignofExpr
|       "_Alignof" '(' TypeName ')'  // Case UnaryExpressionAlignofType
|       "__imag__" UnaryExpression   // Case UnaryExpressionImag
|       "__real__" UnaryExpression   // Case UnaryExpressionReal
Example (Addrof)
fmt.Println(exampleAST(29, "int *i = &x;"))
Output:

&cc.UnaryExpression{
· Case: UnaryExpressionAddrof,
· CastExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:11: identifier "x",
· },
· Token: example.c:1:10: '&' "&",
}
Example (AlignofExpr)
fmt.Println(exampleAST(38, "int i = _Alignof(x);"))
Output:

&cc.UnaryExpression{
· Case: UnaryExpressionAlignofExpr,
· Token: example.c:1:9: '_Alignof' "_Alignof",
· UnaryExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionExpr,
· · ExpressionList: &cc.PrimaryExpression{
· · · Case: PrimaryExpressionIdent,
· · · Token: example.c:1:18: identifier "x",
· · },
· · Token: example.c:1:17: '(' "(",
· · Token2: example.c:1:19: ')' ")",
· },
}
Example (AlignofType)
fmt.Println(exampleAST(39, "int i = _Alignof(int);"))
Output:

&cc.UnaryExpression{
· Case: UnaryExpressionAlignofType,
· Token: example.c:1:9: '_Alignof' "_Alignof",
· Token2: example.c:1:17: '(' "(",
· Token3: example.c:1:21: ')' ")",
· TypeName: &cc.TypeName{
· · SpecifierQualifierList: &cc.SpecifierQualifierList{
· · · Case: SpecifierQualifierListTypeSpec,
· · · TypeSpecifier: &cc.TypeSpecifier{
· · · · Case: TypeSpecifierInt,
· · · · Token: example.c:1:18: 'int' "int",
· · · },
· · },
· },
}
Example (Cpl)
fmt.Println(exampleAST(33, "int i = ~x;"))
Output:

&cc.UnaryExpression{
· Case: UnaryExpressionCpl,
· CastExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:10: identifier "x",
· },
· Token: example.c:1:9: '~' "~",
}
Example (Dec)
fmt.Println(exampleAST(28, "int i = --x;"))
Output:

&cc.UnaryExpression{
· Case: UnaryExpressionDec,
· Token: example.c:1:9: '--' "--",
· UnaryExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:11: identifier "x",
· },
}
Example (Deref)
fmt.Println(exampleAST(30, "int i = *x;"))
Output:

&cc.UnaryExpression{
· Case: UnaryExpressionDeref,
· CastExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:10: identifier "x",
· },
· Token: example.c:1:9: '*' "*",
}
Example (Imag)
fmt.Println(exampleAST(40, "double i = __imag__ x;"))
Output:

&cc.UnaryExpression{
· Case: UnaryExpressionImag,
· Token: example.c:1:12: '__imag__' "__imag__",
· UnaryExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:21: identifier "x",
· },
}
Example (Inc)
fmt.Println(exampleAST(27, "int i = ++x;"))
Output:

&cc.UnaryExpression{
· Case: UnaryExpressionInc,
· Token: example.c:1:9: '++' "++",
· UnaryExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:11: identifier "x",
· },
}
Example (LabelAddr)
fmt.Println(exampleAST(37, "int f() { L: &&L; }"))
Output:

&cc.UnaryExpression{
· Case: UnaryExpressionLabelAddr,
· Token: example.c:1:14: '&&' "&&",
· Token2: example.c:1:16: identifier "L",
}
Example (Minus)
fmt.Println(exampleAST(32, "int i = -x;"))
Output:

&cc.UnaryExpression{
· Case: UnaryExpressionMinus,
· CastExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:10: identifier "x",
· },
· Token: example.c:1:9: '-' "-",
}
Example (Not)
fmt.Println(exampleAST(34, "int i = !x;"))
Output:

&cc.UnaryExpression{
· Case: UnaryExpressionNot,
· CastExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:10: identifier "x",
· },
· Token: example.c:1:9: '!' "!",
}
Example (Plus)
fmt.Println(exampleAST(31, "int i = +x;"))
Output:

&cc.UnaryExpression{
· Case: UnaryExpressionPlus,
· CastExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:10: identifier "x",
· },
· Token: example.c:1:9: '+' "+",
}
Example (Real)
fmt.Println(exampleAST(41, "double i = __real__ x;"))
Output:

&cc.UnaryExpression{
· Case: UnaryExpressionReal,
· Token: example.c:1:12: '__real__' "__real__",
· UnaryExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:21: identifier "x",
· },
}
Example (SizeofExpr)
fmt.Println(exampleAST(35, "int i = sizeof x;"))
Output:

&cc.UnaryExpression{
· Case: UnaryExpressionSizeofExpr,
· Token: example.c:1:9: 'sizeof' "sizeof",
· UnaryExpression: &cc.PrimaryExpression{
· · Case: PrimaryExpressionIdent,
· · Token: example.c:1:16: identifier "x",
· },
}
Example (SizeofType)
fmt.Println(exampleAST(36, "int i = sizeof(int);"))
Output:

&cc.UnaryExpression{
· Case: UnaryExpressionSizeofType,
· Token: example.c:1:9: 'sizeof' "sizeof",
· Token2: example.c:1:15: '(' "(",
· Token3: example.c:1:19: ')' ")",
· TypeName: &cc.TypeName{
· · SpecifierQualifierList: &cc.SpecifierQualifierList{
· · · Case: SpecifierQualifierListTypeSpec,
· · · TypeSpecifier: &cc.TypeSpecifier{
· · · · Case: TypeSpecifierInt,
· · · · Token: example.c:1:16: 'int' "int",
· · · },
· · },
· },
}

func (*UnaryExpression) Position

func (n *UnaryExpression) Position() (r token.Position)

Position reports the position of the first component of n, if available.

func (*UnaryExpression) Pure added in v4.6.0

func (p *UnaryExpression) Pure() bool

Pure implements ExpressionNode.

func (*UnaryExpression) String

func (n *UnaryExpression) String() string

String implements fmt.Stringer.

func (UnaryExpression) Type

func (t UnaryExpression) Type() Type

Type returns the type of a node or an *InvalidType type value, if the type is unknown/undetermined.

func (UnaryExpression) Value

func (v UnaryExpression) Value() Value

Value returns the value of a node or UnknownValue if it is undetermined. The dynamic type of a Value is one of

*ComplexLongDoubleValue
*LongDoubleValue
*UnknownValue
*ZeroValue
Complex128Value
Complex64Value
Float64Value
Int64Value
StringValue
UInt64Value
UTF16StringValue
UTF32StringValue
VoidValue

type UnaryExpressionCase

type UnaryExpressionCase int

UnaryExpressionCase represents case numbers of production UnaryExpression

const (
	UnaryExpressionPostfix UnaryExpressionCase = iota
	UnaryExpressionInc
	UnaryExpressionDec
	UnaryExpressionAddrof
	UnaryExpressionDeref
	UnaryExpressionPlus
	UnaryExpressionMinus
	UnaryExpressionCpl
	UnaryExpressionNot
	UnaryExpressionSizeofExpr
	UnaryExpressionSizeofType
	UnaryExpressionLabelAddr
	UnaryExpressionAlignofExpr
	UnaryExpressionAlignofType
	UnaryExpressionImag
	UnaryExpressionReal
)

Values of type UnaryExpressionCase

func (UnaryExpressionCase) String

func (n UnaryExpressionCase) String() string

String implements fmt.Stringer

type UnionType

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

func (*UnionType) Align

func (n *UnionType) Align() int

Align implements Type.

func (*UnionType) Attributes

func (n *UnionType) Attributes() *Attributes

Attributes implemets Type.

func (UnionType) BitField added in v4.1.1

func (UnionType) BitField() *Field

BitField implements Type.

func (*UnionType) Decay

func (n *UnionType) Decay() Type

Decay implements Type.

func (*UnionType) FieldAlign

func (n *UnionType) FieldAlign() int

FieldAlign implements Type.

func (*UnionType) FieldByIndex

func (n *UnionType) FieldByIndex(i int) *Field

FieldByIndex returns a member field by index, if any.

func (*UnionType) FieldByName

func (n *UnionType) FieldByName(nm string) *Field

FieldByName returns member field nm of n or nil if n does not have such member.

func (*UnionType) IsCompatible

func (n *UnionType) IsCompatible(t Type) (r bool)

func (*UnionType) IsIncomplete

func (n *UnionType) IsIncomplete() bool

IsIncomplete implements Type.

func (*UnionType) Kind

func (n *UnionType) Kind() Kind

Kind implements Type.

func (*UnionType) LexicalScope

func (n *UnionType) LexicalScope() *Scope

LexicalScope provides the scope the definition of n appears in.

func (*UnionType) NamedFieldByIndex

func (n *UnionType) NamedFieldByIndex(i int) (r *Field)

NamedFieldByIndex returns the first named member field at or after index, if any.

func (*UnionType) NumFields

func (n *UnionType) NumFields() int

NumFields reports the number of n's fields.

func (*UnionType) Padding

func (n *UnionType) Padding() int

Padding reports how many bytes at the end of a struct/union should be additionally reserved. Consider:

struct {
	int a:1;
}

Alignment of the above struct is that of an int, but the 'a' field uses only one byte. Padding will report 3 in this case.

func (*UnionType) Pointer

func (n *UnionType) Pointer() Type

Pointer implements Type.

func (*UnionType) Size

func (n *UnionType) Size() int64

Size implements Type.

func (*UnionType) String

func (n *UnionType) String() string

String implements Type.

func (*UnionType) Tag

func (n *UnionType) Tag() Token

Tag returns n's tag, if any.

func (UnionType) Typedef

func (n UnionType) Typedef() *Declarator

Typedef implements Type

func (*UnionType) Undecay

func (n *UnionType) Undecay() Type

Undecay implements Type.

func (UnionType) VectorSize

func (UnionType) VectorSize() int64

VectorSize implements Type.

type UnknownValue

type UnknownValue struct{}

func (*UnknownValue) Convert

func (*UnknownValue) Convert(to Type) Value

func (*UnknownValue) String

func (*UnknownValue) String() string

type Value

type Value interface {
	// Convert attempts to convert the value to a different type. It returns
	// Unknown values unchanged.  Convert returns Unknown for values it does not
	// support.
	Convert(to Type) Value
}
var (
	// Unknown is a singleton representing an undetermined value.  Unknown is
	// comparable.
	Unknown Value = &UnknownValue{}

	// Zero is a singleton representing a zero value of a type. Zero is comparable.
	Zero Value = &ZeroValue{}
)

type VoidValue

type VoidValue struct{}

func (VoidValue) Convert

func (n VoidValue) Convert(to Type) Value

type ZeroValue

type ZeroValue struct{}

func (*ZeroValue) Convert

func (n *ZeroValue) Convert(to Type) Value

func (*ZeroValue) String

func (*ZeroValue) String() string

Jump to

Keyboard shortcuts

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