mojoshader_parser_hlsl.lemon
author Ryan C. Gordon <icculus@icculus.org>
Wed, 25 Feb 2009 23:47:02 -0500
changeset 702 7bf680ef6fc3
child 703 8bc7b33377e7
permissions -rw-r--r--
Added Jeff Lee's ANSI C yacc grammar. This isn't actually a Lemon-compatible grammar, nor HLSL at all. Just a starting point.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
702
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     1
%token IDENTIFIER CONSTANT STRING_LITERAL SIZEOF
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     2
%token PTR_OP INC_OP DEC_OP LEFT_OP RIGHT_OP LE_OP GE_OP EQ_OP NE_OP
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     3
%token AND_OP OR_OP MUL_ASSIGN DIV_ASSIGN MOD_ASSIGN ADD_ASSIGN
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     4
%token SUB_ASSIGN LEFT_ASSIGN RIGHT_ASSIGN AND_ASSIGN
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     5
%token XOR_ASSIGN OR_ASSIGN TYPE_NAME
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     6
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     7
%token TYPEDEF EXTERN STATIC AUTO REGISTER
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     8
%token CHAR SHORT INT LONG SIGNED UNSIGNED FLOAT DOUBLE CONST VOLATILE VOID
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     9
%token STRUCT UNION ENUM ELIPSIS RANGE
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    10
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    11
%token CASE DEFAULT IF ELSE SWITCH WHILE DO FOR GOTO CONTINUE BREAK RETURN
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    12
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    13
%start file
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    14
%%
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    15
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    16
primary_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    17
	: identifier
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    18
	| CONSTANT
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    19
	| STRING_LITERAL
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    20
	| '(' expr ')'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    21
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    22
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    23
postfix_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    24
	: primary_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    25
	| postfix_expr '[' expr ']'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    26
	| postfix_expr '(' ')'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    27
	| postfix_expr '(' argument_expr_list ')'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    28
	| postfix_expr '.' identifier
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    29
	| postfix_expr PTR_OP identifier
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    30
	| postfix_expr INC_OP
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    31
	| postfix_expr DEC_OP
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    32
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    33
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    34
argument_expr_list
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    35
	: assignment_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    36
	| argument_expr_list ',' assignment_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    37
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    38
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    39
unary_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    40
	: postfix_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    41
	| INC_OP unary_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    42
	| DEC_OP unary_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    43
	| unary_operator cast_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    44
	| SIZEOF unary_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    45
	| SIZEOF '(' type_name ')'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    46
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    47
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    48
unary_operator
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    49
	: '&'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    50
	| '*'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    51
	| '+'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    52
	| '-'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    53
	| '~'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    54
	| '!'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    55
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    56
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    57
cast_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    58
	: unary_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    59
	| '(' type_name ')' cast_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    60
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    61
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    62
multiplicative_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    63
	: cast_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    64
	| multiplicative_expr '*' cast_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    65
	| multiplicative_expr '/' cast_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    66
	| multiplicative_expr '%' cast_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    67
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    68
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    69
additive_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    70
	: multiplicative_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    71
	| additive_expr '+' multiplicative_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    72
	| additive_expr '-' multiplicative_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    73
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    74
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    75
shift_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    76
	: additive_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    77
	| shift_expr LEFT_OP additive_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    78
	| shift_expr RIGHT_OP additive_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    79
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    80
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    81
relational_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    82
	: shift_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    83
	| relational_expr '<' shift_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    84
	| relational_expr '>' shift_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    85
	| relational_expr LE_OP shift_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    86
	| relational_expr GE_OP shift_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    87
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    88
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    89
equality_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    90
	: relational_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    91
	| equality_expr EQ_OP relational_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    92
	| equality_expr NE_OP relational_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    93
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    94
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    95
and_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    96
	: equality_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    97
	| and_expr '&' equality_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    98
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    99
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   100
exclusive_or_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   101
	: and_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   102
	| exclusive_or_expr '^' and_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   103
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   104
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   105
inclusive_or_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   106
	: exclusive_or_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   107
	| inclusive_or_expr '|' exclusive_or_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   108
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   109
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   110
logical_and_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   111
	: inclusive_or_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   112
	| logical_and_expr AND_OP inclusive_or_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   113
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   114
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   115
logical_or_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   116
	: logical_and_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   117
	| logical_or_expr OR_OP logical_and_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   118
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   119
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   120
conditional_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   121
	: logical_or_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   122
	| logical_or_expr '?' logical_or_expr ':' conditional_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   123
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   124
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   125
assignment_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   126
	: conditional_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   127
	| unary_expr assignment_operator assignment_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   128
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   129
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   130
assignment_operator
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   131
	: '='
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   132
	| MUL_ASSIGN
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   133
	| DIV_ASSIGN
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   134
	| MOD_ASSIGN
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   135
	| ADD_ASSIGN
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   136
	| SUB_ASSIGN
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   137
	| LEFT_ASSIGN
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   138
	| RIGHT_ASSIGN
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   139
	| AND_ASSIGN
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   140
	| XOR_ASSIGN
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   141
	| OR_ASSIGN
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   142
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   143
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   144
expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   145
	: assignment_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   146
	| expr ',' assignment_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   147
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   148
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   149
constant_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   150
	: conditional_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   151
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   152
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   153
declaration
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   154
	: declaration_specifiers ';'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   155
	| declaration_specifiers init_declarator_list ';'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   156
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   157
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   158
declaration_specifiers
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   159
	: storage_class_specifier
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   160
	| storage_class_specifier declaration_specifiers
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   161
	| type_specifier
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   162
	| type_specifier declaration_specifiers
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   163
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   164
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   165
init_declarator_list
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   166
	: init_declarator
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   167
	| init_declarator_list ',' init_declarator
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   168
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   169
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   170
init_declarator
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   171
	: declarator
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   172
	| declarator '=' initializer
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   173
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   174
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   175
storage_class_specifier
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   176
	: TYPEDEF
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   177
	| EXTERN
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   178
	| STATIC
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   179
	| AUTO
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   180
	| REGISTER
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   181
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   182
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   183
type_specifier
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   184
	: CHAR
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   185
	| SHORT
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   186
	| INT
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   187
	| LONG
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   188
	| SIGNED
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   189
	| UNSIGNED
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   190
	| FLOAT
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   191
	| DOUBLE
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   192
	| CONST
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   193
	| VOLATILE
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   194
	| VOID
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   195
	| struct_or_union_specifier
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   196
	| enum_specifier
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   197
	| TYPE_NAME
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   198
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   199
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   200
struct_or_union_specifier
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   201
	: struct_or_union identifier '{' struct_declaration_list '}'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   202
	| struct_or_union '{' struct_declaration_list '}'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   203
	| struct_or_union identifier
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   204
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   205
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   206
struct_or_union
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   207
	: STRUCT
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   208
	| UNION
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   209
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   210
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   211
struct_declaration_list
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   212
	: struct_declaration
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   213
	| struct_declaration_list struct_declaration
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   214
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   215
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   216
struct_declaration
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   217
	: type_specifier_list struct_declarator_list ';'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   218
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   219
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   220
struct_declarator_list
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   221
	: struct_declarator
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   222
	| struct_declarator_list ',' struct_declarator
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   223
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   224
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   225
struct_declarator
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   226
	: declarator
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   227
	| ':' constant_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   228
	| declarator ':' constant_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   229
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   230
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   231
enum_specifier
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   232
	: ENUM '{' enumerator_list '}'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   233
	| ENUM identifier '{' enumerator_list '}'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   234
	| ENUM identifier
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   235
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   236
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   237
enumerator_list
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   238
	: enumerator
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   239
	| enumerator_list ',' enumerator
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   240
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   241
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   242
enumerator
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   243
	: identifier
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   244
	| identifier '=' constant_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   245
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   246
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   247
declarator
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   248
	: declarator2
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   249
	| pointer declarator2
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   250
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   251
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   252
declarator2
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   253
	: identifier
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   254
	| '(' declarator ')'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   255
	| declarator2 '[' ']'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   256
	| declarator2 '[' constant_expr ']'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   257
	| declarator2 '(' ')'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   258
	| declarator2 '(' parameter_type_list ')'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   259
	| declarator2 '(' parameter_identifier_list ')'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   260
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   261
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   262
pointer
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   263
	: '*'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   264
	| '*' type_specifier_list
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   265
	| '*' pointer
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   266
	| '*' type_specifier_list pointer
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   267
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   268
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   269
type_specifier_list
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   270
	: type_specifier
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   271
	| type_specifier_list type_specifier
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   272
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   273
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   274
parameter_identifier_list
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   275
	: identifier_list
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   276
	| identifier_list ',' ELIPSIS
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   277
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   278
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   279
identifier_list
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   280
	: identifier
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   281
	| identifier_list ',' identifier
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   282
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   283
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   284
parameter_type_list
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   285
	: parameter_list
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   286
	| parameter_list ',' ELIPSIS
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   287
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   288
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   289
parameter_list
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   290
	: parameter_declaration
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   291
	| parameter_list ',' parameter_declaration
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   292
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   293
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   294
parameter_declaration
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   295
	: type_specifier_list declarator
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   296
	| type_name
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   297
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   298
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   299
type_name
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   300
	: type_specifier_list
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   301
	| type_specifier_list abstract_declarator
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   302
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   303
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   304
abstract_declarator
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   305
	: pointer
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   306
	| abstract_declarator2
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   307
	| pointer abstract_declarator2
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   308
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   309
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   310
abstract_declarator2
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   311
	: '(' abstract_declarator ')'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   312
	| '[' ']'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   313
	| '[' constant_expr ']'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   314
	| abstract_declarator2 '[' ']'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   315
	| abstract_declarator2 '[' constant_expr ']'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   316
	| '(' ')'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   317
	| '(' parameter_type_list ')'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   318
	| abstract_declarator2 '(' ')'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   319
	| abstract_declarator2 '(' parameter_type_list ')'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   320
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   321
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   322
initializer
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   323
	: assignment_expr
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   324
	| '{' initializer_list '}'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   325
	| '{' initializer_list ',' '}'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   326
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   327
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   328
initializer_list
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   329
	: initializer
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   330
	| initializer_list ',' initializer
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   331
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   332
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   333
statement
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   334
	: labeled_statement
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   335
	| compound_statement
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   336
	| expression_statement
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   337
	| selection_statement
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   338
	| iteration_statement
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   339
	| jump_statement
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   340
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   341
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   342
labeled_statement
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   343
	: identifier ':' statement
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   344
	| CASE constant_expr ':' statement
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   345
	| DEFAULT ':' statement
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   346
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   347
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   348
compound_statement
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   349
	: '{' '}'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   350
	| '{' statement_list '}'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   351
	| '{' declaration_list '}'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   352
	| '{' declaration_list statement_list '}'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   353
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   354
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   355
declaration_list
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   356
	: declaration
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   357
	| declaration_list declaration
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   358
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   359
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   360
statement_list
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   361
	: statement
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   362
	| statement_list statement
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   363
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   364
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   365
expression_statement
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   366
	: ';'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   367
	| expr ';'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   368
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   369
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   370
selection_statement
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   371
	: IF '(' expr ')' statement
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   372
	| IF '(' expr ')' statement ELSE statement
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   373
	| SWITCH '(' expr ')' statement
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   374
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   375
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   376
iteration_statement
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   377
	: WHILE '(' expr ')' statement
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   378
	| DO statement WHILE '(' expr ')' ';'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   379
	| FOR '(' ';' ';' ')' statement
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   380
	| FOR '(' ';' ';' expr ')' statement
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   381
	| FOR '(' ';' expr ';' ')' statement
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   382
	| FOR '(' ';' expr ';' expr ')' statement
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   383
	| FOR '(' expr ';' ';' ')' statement
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   384
	| FOR '(' expr ';' ';' expr ')' statement
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   385
	| FOR '(' expr ';' expr ';' ')' statement
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   386
	| FOR '(' expr ';' expr ';' expr ')' statement
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   387
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   388
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   389
jump_statement
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   390
	: GOTO identifier ';'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   391
	| CONTINUE ';'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   392
	| BREAK ';'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   393
	| RETURN ';'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   394
	| RETURN expr ';'
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   395
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   396
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   397
file
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   398
	: external_definition
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   399
	| file external_definition
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   400
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   401
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   402
external_definition
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   403
	: function_definition
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   404
	| declaration
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   405
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   406
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   407
function_definition
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   408
	: declarator function_body
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   409
	| declaration_specifiers declarator function_body
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   410
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   411
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   412
function_body
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   413
	: compound_statement
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   414
	| declaration_list compound_statement
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   415
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   416
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   417
identifier
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   418
	: IDENTIFIER
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   419
	;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   420
%%
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   421
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   422
#include <stdio.h>
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   423
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   424
extern char yytext[];
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   425
extern int column;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   426
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   427
yyerror(s)
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   428
char *s;
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   429
{
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   430
	fflush(stdout);
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   431
	printf("\n%*s\n%*s\n", column, "^", column, s);
7bf680ef6fc3 Added Jeff Lee's ANSI C yacc grammar.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   432
}