/*--- C Syntactical Grammar, by Paul B Mann, 1990, tabs=3. ---*/ /*--- Input Actions --- */ "tab=3" T_ERROR => error () T_EOF ; T_IDENT => lookup() // Symbol table and keyword lookup. T_CONSTANT => lookup() T_STRING => lookup() T_LITERAL => lookup() /*--- Operator prec. ---*/ { '?' } << { '||' } << { '&&' } << { '|' } << { '^' } << { '&' } << { '==' '!=' } << { '<' '>' '<=' '>=' } << { '<<' '>>' } << { '+' '-' } << { '*' '/' '%' } << /*--- Productions. ---*/ Start -> [ExternalDef]... => eof() ExternalDef -> ExtDeclaration -> FunctionDef => extdef() ExtDeclaration -> [DeclarationSpec]... InitDeclarator /','... ';' => extdecl() Declaration -> DeclarationSpec... InitDeclarator /','... ';' FunctionDef -> FunctionDecl FunctionBody +> funcdef FunctionDecl -> [DeclarationSpec]... Declarator [Declaration]... +> funcdecl FunctionBody -> Block => funcbody() DeclarationSpec -> TypeSpec +> type -> StorageClassSpec +> class TypeSpec -> int | char | long | void | short | const | float | double | signed | unsigned | volatile | far | near | huge | cdecl | pascal | interrupt | EnumSpec | StructSpec | UnionSpec | {typedef} StorageClassSpec -> typedef -> extern -> static -> auto -> register InitDeclarator -> Declarator -> Declarator '=' Init +> init StructSpec -> struct +> struct -> struct '{' StructDeclaration... '}' +> struct -> struct '{' StructDeclaration... '}' +> struct UnionSpec -> union +> union -> union '{' StructDeclaration... '}' +> union -> union '{' StructDeclaration... '}' +> union StructDeclaration -> TypeSpec... StructDeclarator /','... ';' StructDeclarator -> ':' ConstExp +> struconst -> Declarator ':' ConstExp +> struconst -> Declarator +> strucdecl EnumSpec -> enum -> enum '{' Enumerator /','... '}' +> struct -> enum '{' Enumerator /','... '}' +> struct Enumerator -> +> enumident -> '=' ConstExp +> enumequals Declarator -> DirectDeclarator -> Pointer DirectDeclarator DirectDeclarator -> Identifier -> '(' Declarator ')' -> DirectDeclarator '[' [ConstExp] ']' +> array -> DirectDeclarator '(' Arguments ')' +> function -> DirectDeclarator '(' AbsArguments ')' +> function Pointer -> '*' [TypeSpec]... +> pointer -> '*' [TypeSpec]... Pointer +> pointer Arguments -> ArgDecl /','... -> ArgDecl /','... ',' '...' AbsArguments -> AbsArgDecl /','... -> AbsArgDecl /','... ',' '...' ArgDecl -> Declarator +> arg -> DeclarationSpec... Declarator +> arg AbsArgDecl -> +> absarg -> DeclarationSpec... +> absarg -> AbstractDeclarator +> absarg -> DeclarationSpec... AbstractDeclarator +> absarg TypeName -> TypeSpec... -> TypeSpec... AbstractDeclarator AbstractDeclarator -> Pointer -> DirectAbstractDeclarator -> Pointer DirectAbstractDeclarator DirectAbstractDeclarator -> '[' [ConstExp] ']' -> '(' AbstractDeclarator ')' -> DirectAbstractDeclarator '[' [ConstExp] ']' +> absarray -> DirectAbstractDeclarator '(' AbsArguments ')' +> absfunc Init -> AssignExp +> assign -> '{' Init /','... [','] '}' +> init /*--- Statements ---*/ Stmt -> ';' +> empty -> Exp ';' +> exp -> goto Identifier ';' +> goto -> continue ';' +> continue -> break ';' +> break -> return [Exp] ';' +> return -> Label Stmt -> Block -> if '(' Exp ')' Stmt +> if -> if '(' Exp ')' Stmt else Stmt +> ifelse -> switch '(' Exp ')' '{' Case Default '}' +> switch -> while '(' Exp ')' Stmt +> while -> do Stmt while '(' Exp ')' ';' +> do -> for '(' Exp1 ';' Exp2 ';' Exp3 ')' Stmt +> for Case -> [case ConstExp ':' [Stmt]...]... +> case Default -> [default ':' [Stmt]...] +> default Exp1 -> -> Exp +> exp1 Exp2 -> -> Exp +> exp2 Exp3 -> -> Exp +> exp3 Label /-> Identifier ':' +> label Block -> '{' '}' -> '{' Declaration... '}' -> '{' Stmt... '}' -> '{' Declaration... Stmt... '}' /*--- Expressions ---*/ ConstExp -> CondExp Exp -> AssignExp -> Exp ',' AssignExp +> comma AssignExp -> CondExp /-> UnaryExp '=' AssignExp +> equals /-> UnaryExp '*=' AssignExp +> muleq /-> UnaryExp '/=' AssignExp +> diveq /-> UnaryExp '%=' AssignExp +> modeq /-> UnaryExp '+=' AssignExp +> addeq /-> UnaryExp '-=' AssignExp +> subeq /-> UnaryExp '<<=' AssignExp +> shleq /-> UnaryExp '>>=' AssignExp +> shreq /-> UnaryExp '&=' AssignExp +> andeq /-> UnaryExp '^=' AssignExp +> xoreq /-> UnaryExp '|=' AssignExp +> oreq CondExp -> CastExp -> CondExp '?' CondExp ':' CondExp +> question -> CondExp '||' CondExp +> or -> CondExp '&&' CondExp +> and -> CondExp '|' CondExp +> bitor -> CondExp '^' CondExp +> bitxor -> CondExp '&' CondExp +> bitand -> CondExp '==' CondExp +> eq -> CondExp '!=' CondExp +> ne -> CondExp '<' CondExp +> lt -> CondExp '>' CondExp +> gt -> CondExp '<=' CondExp +> le -> CondExp '>=' CondExp +> ge -> CondExp '<<' CondExp +> shl -> CondExp '>>' CondExp +> shr -> CondExp '+' CondExp +> add -> CondExp '-' CondExp +> sub -> CondExp '*' CondExp +> mul -> CondExp '/' CondExp +> div -> CondExp '%' CondExp +> mod CastExp -> UnaryExp -> '(' TypeName ')' CastExp +> cast UnaryExp -> PostfixExp -> '++' UnaryExp +> preinc -> '--' UnaryExp +> predec -> '~' CastExp +> complement -> '&' CastExp +> addressof -> '*' CastExp +> contentsof -> '+' CastExp +> positive -> '-' CastExp +> negative -> '!' CastExp +> not -> sizeof UnaryExp +> sizeof -> sizeof '(' TypeName ')' +> sizeof PostfixExp -> PrimaryExp -> PostfixExp '[' Subscript ']' +> array -> PostfixExp '.' Identifier +> member -> PostfixExp '(' Args ')' +> funccall -> PostfixExp '->' Identifier +> ptrto -> PostfixExp '++' +> postinc -> PostfixExp '--' +> postdec Subscript -> Exp +> subscript Args -> [AssignExp] /','... +> arguments PrimaryExp -> ... +> string -> +> const -> Identifier // -> $keyword -> '(' Exp ')' Identifier -> +> ident(1) /*--- End. ---*/