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