Skip to content

Commit

Permalink
parser.y: added section titles to improve readability
Browse files Browse the repository at this point in the history
  • Loading branch information
wpwrak committed Dec 30, 2011
1 parent 01c5e10 commit b933013
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/compiler/parser.y
Expand Up @@ -202,6 +202,10 @@ start ::= TOK_START_ASSIGN sections. {
state->success = 1;
}


/* ----- Sections and assignments ------------------------------------------ */


sections ::= assignments.
sections ::= assignments per_frame_label assignments.
sections ::= assignments per_frame_label assignments per_vertex_label
Expand Down Expand Up @@ -278,6 +282,10 @@ opt_semi ::= opt_semi TOK_SEMI.

opt_semi ::= .


/* ----- Operators --------------------------------------------------------- */


expr(N) ::= cond_expr(A). {
N = A;
}
Expand Down Expand Up @@ -326,6 +334,10 @@ unary_expr(N) ::= TOK_MINUS unary_expr(A). {
FOLD_UNARY(N, op_not, "!", A, -a);
}


/* ----- Unary functions --------------------------------------------------- */


primary_expr(N) ::= unary_misc(I) TOK_LPAREN expr(A) TOK_RPAREN. {
N = node(I->token, I->label, A, NULL, NULL);
free(I);
Expand All @@ -336,6 +348,10 @@ primary_expr(N) ::= TOK_SQR(I) TOK_LPAREN expr(A) TOK_RPAREN. {
free(I);
}


/* ----- Binary functions -------------------------------------------------- */


primary_expr(N) ::= binary_misc(I) TOK_LPAREN expr(A) TOK_COMMA expr(B)
TOK_RPAREN. {
N = node(I->token, I->label, A, B, NULL);
Expand Down Expand Up @@ -372,12 +388,20 @@ primary_expr(N) ::= TOK_MIN(I) TOK_LPAREN expr(A) TOK_COMMA expr(B)
free(I);
}


/* ----- Trinary functions ------------------------------------------------- */


primary_expr(N) ::= TOK_IF(I) TOK_LPAREN expr(A) TOK_COMMA expr(B) TOK_COMMA
expr(C) TOK_RPAREN. {
N = conditional(A, B, C);
free(I);
}


/* ----- Primary expressions ----------------------------------------------- */


primary_expr(N) ::= TOK_LPAREN expr(A) TOK_RPAREN. {
N = A;
}
Expand All @@ -392,6 +416,19 @@ primary_expr(N) ::= ident(I). {
free(I);
}


/* ----- Identifiers ------------------------------------------------------- */

/*
* Function names are not reserved words. If not followed by an opening
* parenthesis, they become regular identifiers.
*
* {u,bi,ter}nary are identifiers that have an individual rule, e.g., because
* they have function-specific code for constant folding. {u,bi,ter}nary_misc
* are identifiers the parser treats as generic functions, without knowing
* anything about their semantics.
*/

ident(O) ::= TOK_IDENT(I). { O = I; }
ident(O) ::= unary(I). { O = I; }
ident(O) ::= unary_misc(I). { O = I; }
Expand Down

0 comments on commit b933013

Please sign in to comment.