Previously, ast transformations were performed informally as ad-hoc modifications to the generated C source code. In this commit, the same transformations are performed by rewriting the ast prior to code generation time. The most significant new transformer is transform_assignment_list. This transforms assignments such as: a, b, c = f(b, c, d) To: a = f(&b, &c, d) The former syntax is used frequently in the manual's description of FPU-related instructions.
138 lines
2.9 KiB
Plaintext
138 lines
2.9 KiB
Plaintext
identifier:
|
|
identifier-start
|
|
identifier identifier-continue
|
|
|
|
identifier-start:
|
|
nondigit
|
|
|
|
identifier-contine:
|
|
digit
|
|
nondigit
|
|
|
|
primary-expression:
|
|
identifier
|
|
constant
|
|
"(" expression ")"
|
|
|
|
postfix-expression:
|
|
primary-expression
|
|
postfix-expression "[" expression "]"
|
|
postfix-expression "(" argument-expression-list? ")"
|
|
postfix-expression "<" for-expression ">"
|
|
postfix-expression "." identifier
|
|
|
|
for-expression:
|
|
primary-expression
|
|
primary-expression "FOR" primary-expression
|
|
|
|
argument-expression-list:
|
|
assignment-expression
|
|
argument-expression-list "," assignment-expression
|
|
|
|
unary-expression:
|
|
postfix-expression
|
|
"NOT" unary-expression
|
|
"INT" unary-expression
|
|
"~" unary-expression # bitwise complement
|
|
"-" unary-expression # integer negation
|
|
"|" unary-expression "|" # integer absolute value
|
|
|
|
multiplicative-expression:
|
|
unary-expression
|
|
multiplicative-expression "×" unary-expression
|
|
multiplicative-expression "/" unary-expression
|
|
|
|
additive-expression:
|
|
multiplicative-expression
|
|
additive-expression "+" multiplicative-expression
|
|
additive-expression "-" multiplicative-expression
|
|
|
|
shift-expression:
|
|
additive-expression
|
|
shift-expression "<<" additive-expression
|
|
shift-expression ">>" additive-expression
|
|
|
|
relational-expression:
|
|
shift-expression
|
|
relational-expression "<" shift-expression
|
|
relational-expression ">" shift-expression
|
|
relational-expression "≤" shift-expression
|
|
relational-expression "≥" shift-expression
|
|
|
|
equality-expression:
|
|
relational-expression
|
|
equality-expression "=" relational-expression
|
|
equality-expression "≠" relational-expression
|
|
|
|
bitwise-AND-expression:
|
|
equality-expression
|
|
bitwise-AND-expression "∧" equality-expression
|
|
|
|
bitwise-XOR-expression:
|
|
bitwise-AND-expression
|
|
bitwise-XOR-expression "⊕" bitwise-AND-expression
|
|
|
|
bitwise-OR-expression:
|
|
bitwise-XOR-expression
|
|
bitwise-OR-expression "∨" bitwise-XOR-expression
|
|
|
|
logical-AND-expression:
|
|
bitwise-OR-expression
|
|
logical-AND-expression "AND" bitwise-OR-expression
|
|
|
|
logical-XOR-expression:
|
|
logical-AND-expression
|
|
logical-XOR-expression "XOR" logical-AND-expression
|
|
|
|
logical-OR-expression:
|
|
logical-XOR-expression
|
|
logical-OR-expression "OR" logical-XOR-expression
|
|
|
|
assignment-list:
|
|
unary-expression
|
|
assignment-lhs "," unary-expression
|
|
|
|
assignment-expression:
|
|
logical-OR-expression
|
|
assignment-list "←" assignment-expression
|
|
|
|
expression:
|
|
assignment-expression
|
|
|
|
# statement
|
|
|
|
statement:
|
|
unlabeled-statement
|
|
|
|
unlabeled-statement:
|
|
expression-statement
|
|
primary-block
|
|
|
|
primary-block:
|
|
compound-statement
|
|
selection-statement
|
|
throw-statement
|
|
|
|
secondary-block:
|
|
statement
|
|
|
|
compound-statement:
|
|
"{" block-item-list? "}"
|
|
|
|
block-item-list:
|
|
block-item
|
|
block-item-list block-item
|
|
|
|
block-item:
|
|
unlabeled-statement
|
|
|
|
expression-statement:
|
|
expression ";"
|
|
|
|
selection-statement:
|
|
"IF" "(" expression ")" secondary-block
|
|
"IF" "(" expression ")" secondary-block "ELSE" secondary-block
|
|
|
|
throw-statement:
|
|
"THROW" secondary-block
|