CSC448: Parsing: Clogs: Grammar [9/26] Previous pageContentsNext page

Precedence in C http://www.difranco.net/cop2220/op-prec.htm

00001: translation_unit
00002:  ::=  ( external_declaration )+
00003: 
00004: external_declaration
00005:  ::= declaration
00006:    | function_definition
00007: 
00008: declaration
00009:  ::= type_specifier IDENTIFIER SEMI
00010:    | type_specifier IDENTIFIER EQUALS assignment_expression SEMI
00011: 
00012: function_definition
00013:  ::= type_specifier IDENTIFIER
00014:      LPAREN ( parameter_declaration ( COMMA parameter_declaration )*)? RPAREN
00015:      compound_statement
00016: 
00017: type_specifier
00018:  ::= VOID
00019:    | INT
00020:    | type_specifier LBRACK RBRACK
00021: 
00022: parameter_declaration
00023:  ::= type_specifier IDENTIFIER
00024: 
00025: ========================================================================
00026: 
00027: statement
00028:  ::= labeled_statement
00029:    | expression_statement
00030:    | compound_statement
00031:    | selection_statement
00032:    | iteration_statement
00033:    | jump_statement
00034: 
00035: labeled_statement
00036:  ::= IDENTIFIER COLON statement
00037: 
00038: expression_statement
00039:  ::= ( expression )? SEMI
00040:    | SKIP SEMI
00041: 
00042: compound_statement
00043:  ::= LBRACE ( declaration )* ( statement )* RBRACE
00044: 
00045: selection_statement
00046:  ::= IF LPAREN expression RPAREN statement 
00047:    | IF LPAREN expression RPAREN statement ELSE statement
00048: 
00049: iteration_statement
00050:  ::= WHILE LPAREN expression RPAREN statement
00051: 
00052: jump_statement
00053:  ::= GOTO IDENTIFIER SEMI
00054:    | RETURN ( expression )? SEMI
00055: 
00056: ========================================================================
00057: 
00058: expression
00059:  ::= assignment_expression
00060:    | expression COMMA assignment_expression
00061: 
00062: assignment_expression
00063:  ::= conditional_expression
00064:    | unary_expression EQUALS assignment_expression
00065: 
00066: conditional_expression
00067:  ::= binary_expression
00068:      /* ignored cases */
00069: 
00070: precedence left BARBAR
00071: precedence left AMPAMP
00072: precedence left BAR
00073: precedence left CARET
00074: precedence left AMP
00075: precedence left EQUALSEQUALS, BANGEQUALS
00076: precedence left LESSTHAN, GREATERTHAN, LEQ, GEQ
00077: precedence left PLUS, MINUS
00078: precedence left TIMES, DIVIDE, MOD
00079: 
00080: binary_op
00081:  ::= BARBAR | AMPAMP | BAR | CARET | AMP
00082:    | EQUALSEQUALS | BANGEQUALS
00083:    | LESSTHAN | GREATERTHAN | LEQ | GEQ
00084:    | PLUS | MINUS | TIMES | DIVIDE | MOD
00085: 
00086: binary_expression
00087:  ::= unary_expression
00088:    | binary_expression binary_op binary_expression
00089: 
00090: unary_expression
00091:  ::= postfix_expression
00092:    | MINUS cast_expression
00093:    | BANG cast_expression
00094:      /* ignored cases PLUSPLUS, MINUSMINUS */
00095: 
00096: postfix_expression
00097:  ::= primary_expression
00098:    | postfix_expression LBRACK expression RBRACK
00099:    | IDENTIFIER
00100:      LPAREN ( assignment_expression ( COMMA assignment_expression )* )? RPAREN
00101:      /* ignored cases PLUSPLUS, MINUSMINUS */
00102: 
00103: primary_expression
00104:  ::= IDENTIFIER
00105:    | INTEGER_CONSTANT
00106:    | CHARACTER_CONSTANT
00107:    | STRING_CONSTANT
00108:    | NEW type_specifier LBRACK expression RBRACK
00109:    | LPAREN expression ( COLONCOLON type_specifier )? RPAREN
00110: 

Previous pageContentsNext page