View source code
Display the source code in dmd/cparse.d from which this page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone.

Class dmd.cparse.CParser

class CParser(AST) ;

Fields

NameTypeDescription
addFuncName booladd declaration of _func__ to function symbol table
importBuiltins boolseen use of C compiler builtins, so import _importc_builtins;
typedefTab Array!(void*)Array of AST.Type[Identifier], typedef's indexed by Identifier

Methods

NameDescription
addDefines () #define Parser
applySpecifier (s, specifier) Apply specifier to a Dsymbol.
cparseAddExp () C11 6.5.6 additive-expression multiplicative-expression additive-expression + multiplicative-expression additive-expression - multiplicative-expression
cparseAndAndExp () C11 6.5.13 logical-AND-expression inclusive-OR-expression logical-AND-expression && inclusive-OR-expression
cparseAndExp () C11 6.5.10 AND-expression equality-expression AND-expression & equality-expression
cparseArguments () Collect argument list. Parser is on opening parenthesis.
cparseAssignExp () C11 6.5.16 assignment-expression: conditional-expression unary-expression assignment-operator assignment-expression
cparseBuiltin_va_arg () gcc extension: type _builtin_va_arg(assign-expression, type) Rewrite as va_arg template from core.stdc.stdarg: va_arg!(type)(assign-expression); Lexer is on __builtin_va_arg
cparseCastExp () C11 6.5.4 cast-expression unary-expression ( type-name ) cast-expression
cparseCondExp () C11 6.5.15 conditional-expression: logical-OR-expression logical-OR-expression ? expression : conditional-expression
cparseConstantExp () C11 6.6 Constant expressions constant-expression: conditional-expression
cparseDeclaration (level) Declaration Parser
cparseDeclarationSpecifiers (level, specifier) C11 6.7 declaration-specifier: storage-class-specifier declaration-specifiers (opt) type-specifier declaration-specifiers (opt) type-qualifier declaration-specifiers (opt) function-specifier declaration-specifiers (opt) alignment-specifier declaration-specifiers (opt)
cparseDeclarator (declarator, tbase, pident, specifier) C11 6.7.6 Parse a declarator (including function definitions).
cparseDeclspec (specifier) _declspec parser
cparseEnum (symbols) Struct & Enum Parser
cparseEqualityExp () C11 6.5.9 equality-expression relational-expression equality-expression == relational-expression equality-expression != relational-expression
cparseExpression () Expression Parser
cparseFunctionDefinition (id, ft, specifier) C11 Function Definitions function-definition declaration-specifiers declarator declaration-list (opt) compound-statement
cparseGenericSelection () C11 6.5.1.1 Generic ( assignment-expression, generic-assoc-list )
cparseGnuAsm () Parse C inline assembler statement in Gnu format.
cparseGnuAsmLabel () Parser for asm label. It appears after the declarator, and has apparently nothing to do with inline assembler.
cparseGnuAttribute (specifier) Parse a single GNU attribute gnu-attribute: gnu-attribute-name gnu-attribute-name ( identifier ) gnu-attribute-name ( identifier , expression-list ) gnu-attribute-name ( expression-list (opt) )
cparseGnuAttributes (specifier) _attribute__ parser
cparseInitializer () C11 Initialization
cparseMulExp () C11 6.5.5 multiplicative-expression cast-expression multiplicative-expression * cast-expression multiplicative-expression / cast-expression multiplicative-expression % cast-expression
cparseOrExp () C11 6.5.12 inclusive-OR-expression exclusive-OR-expression inclusive-OR-expression | exclusive-OR-expression
cparseOrOrExp () C11 6.5.14 logical-OR-expression logical-AND-expression logical-OR-expression || logical-AND-expression
cparseParameterList () C11 6.7.6.3 ( parameter-type-list ) ( identifier-list (opt) )
cparseParens () Like skipParens(), but consume the tokens.
cparsePostfixExp (e) C11 6.5.2 postfix-expression: primary-expression postfix-expression [ expression ] postfix-expression ( argument-expression-list (opt) ) postfix-expression . identifier postfix-expression -> identifier postfix-expression ++ postfix-expression -- ( type-name ) { initializer-list } ( type-name ) { initializer-list , }
cparsePostfixOperators (e) C11 6.5.2 Parse a series of operators for a postfix expression after already parsing a primary-expression or compound literal expression.
cparsePrimaryExp () C11 6.5.1 primary-expression: identifier constant string-literal ( expression ) generic-selection _builtin_va_arg(assign_expression, type)
cparseRelationalExp () C11 6.5.8 relational-expression shift-expression relational-expression < shift-expression relational-expression > shift-expression relational-expression <= shift-expression relational-expression >= shift-expression
cparseShiftExp () C11 6.5.7 shift-expression additive-expression shift-expression << additive-expression shift-expression >> additive-expression
cparseSpecifierQualifierList (level, specifier) C11 6.7.2.1 specifier-qualifier-list: type-specifier specifier-qualifier-list (opt) type-qualifier specifier-qualifier-list (opt)
cparseStatement (flags, endPtr, pEndloc) Statement Parser
cparseStatementExpression () gcc extension: https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html Represent as a function literal, then call the function literal. Parser is on opening curly brace.
cparseStaticAssert () C11 6.7.10 Static_assert ( constant-expression , string-literal ) ;
cparseStruct (loc, structOrUnion, packalign, symbols) C11 6.7.2.1 Parse struct and union specifiers. Parser is advanced to the tag identifier or brace. struct-or-union-specifier: struct-or-union identifier (opt) { struct-declaration-list } struct-or-union identifier
cparseStructDeclaration (members) C11 6.7.2.1 Parse a struct declaration member. struct-declaration: specifier-qualifier-list struct-declarator-list (opt) ; static_assert-declaration
cparseTypeName () C11 6.7.7
cparseTypeQualifierList () C11 6.7.3 type-qualifier: const restrict volatile Atomic _stdcall
cparseUnaryExp () C11 6.5.3 unary-expression: postfix-expression ++ unary-expression -- unary-expression unary-operator cast-expression sizeof unary-expression sizeof ( type-name ) Alignof ( type-name )
cparseXorExp () C11 6.5.11 exclusive-OR-expression AND-expression exclusive-OR-expression ^ AND-expression
createFuncName (loc, id) C11 6.4.2.2 Create declaration to predefine _func__ static const char __func__[] = " function-name ";
insertIdToTypedefTab (id) Add id to typedefTab[], but only if it will mask an existing typedef.
insertTypedefToTypedefTab (id, t) Add id to typedefTab[]
integerTypeForSize (size) Return suitable signed integer type for the given size
isAssignmentExpression (pt) See if match for assignment-expression.
isCastExpression (pt, afterParenType) Looking at the leading left parenthesis, and determine if it is either of the following: ( type-name ) cast-expression ( type-name ) { initializer-list } as opposed to: ( expression )
isCDeclaration (pt) Lookahead Parser
isCDeclarator (pt, declarator) Check to see if tokens starting with *pt form a declarator.
isConstantExpression (pt) See if match for constant-expression.
isDeclarationList (pt) See if declaration-list is present.
isDeclarationSpecifiers (pt) See if match for declaration-specifiers. No errors are diagnosed.
isFunctionCall (pt) See if match for: postfix-expression ( argument-expression-list(opt) )
isFunctionTypedef (t) typedefTab symbol table
isGnuAttributeName () See if match for GNU attribute name, which may be any identifier, storage-class-specifier, type-specifier, or type-qualifier.
isInitializer (pt) See if match for initializer.
isPrimaryExpression (pt) See if match for primary-expression.
isSpecifierQualifierList (pt) Is this the start of a specifier-qualifier-list?
isTypedef (id) Determine if id is a symbol for a Typedef.
isTypeName (pt) Is this the start of a type-name?
isTypeQualifierList (pt) Is this the start of a type-qualifier-list? (Can be empty.)
isUnaryExpression (pt, afterParenType) See if match for unary-expression.
lookupTypedef (id) Lookup id in typedefTab[].
panic () After encountering an error, scan forward until a right brace or ; is found or the end of the file.
parseModule () Parse translation unit. C11 6.9 translation-unit: external-declaration translation-unit external-declaration
parseSpecialTokenSequence () Directive Parser
pragmaDirective (loc) C11 6.10.6 Pragma directive # pragma pp-tokens(opt) new-line The C preprocessor sometimes leaves pragma directives in the preprocessed output. Ignore them. Upon return, p is at start of next line.
pragmaPack (startloc, useScan) # pragma pack
realType (flags) Return suitable D float type for C long double
skipBraces (pt) Skip braces.
skipBrackets (pt) Skip brackets.
specifiersToFuncDeclaration (fd, specifier) Add attributes from Specifier to function
specifiersToSTC (level, specifier) Convert from C specifiers to D storage class
specifiersToVarDeclaration (vd, specifier) Add attributes from Specifier to variable
toConst (t) Apply const to a type.
unsignedTypeForSize (size) Return suitable unsigned integer type for the given size
uupragmaDirective (startloc) VC _pragma
factory (classname) Create instance of class specified by the fully qualified name classname. The class must either have no constructors or have a default constructor.
opCmp (o) Compare with another Object obj.
opEquals (o) Test whether this is equal to o. The default implementation only compares by identity (using the is operator). Generally, overrides and overloads for opEquals should attempt to compare objects by their contents. A class will most likely want to add an overload that takes your specific type as the argument and does the content comparison. Then you can override this and forward it to your specific typed overload with a cast. Remember to check for null on the typed overload.
toHash () Compute hash function for Object.
toString () Convert Object to a human readable string.

Inner structs

NameDescription
Specifier Aggregate for all the various specifiers

Enums

NameDescription
DTR Types of declarator to parse
LVL More
MOD C11 6.7.3 Type qualifiers
RTFlags Flags for realType
SCW C11 6.7.1 Storage-class specifiers

Authors

Walter Bright

License

Boost License 1.0