summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorclifford <clifford@b57f626f-c46c-0410-a088-ec61d464b74c>2009-11-01 10:09:37 (GMT)
committerclifford <clifford@b57f626f-c46c-0410-a088-ec61d464b74c>2009-11-01 10:09:37 (GMT)
commit2104ddafd9ea2866bfadb03f0c0286ca30696500 (patch)
tree9e7e02babec5b33baba0a29c89d87a06ffaa3130
parent1b2caba2f55b826d3efc849dead388956040c7d8 (diff)
Clifford Wolf:
Added parser support for optional commas git-svn-id: http://svn.clifford.at/openscad/trunk@126 b57f626f-c46c-0410-a088-ec61d464b74c
-rw-r--r--parser.y33
1 files changed, 18 insertions, 15 deletions
diff --git a/parser.y b/parser.y
index 26acb99..8578fdd 100644
--- a/parser.y
+++ b/parser.y
@@ -116,7 +116,7 @@ statement:
module->assignments_expr.append($3);
free($1);
} |
- TOK_MODULE TOK_ID '(' arguments_decl ')' {
+ TOK_MODULE TOK_ID '(' arguments_decl optional_commas ')' {
Module *p = module;
module_stack.append(module);
module = new Module();
@@ -129,11 +129,11 @@ statement:
module = module_stack.last();
module_stack.pop_back();
} |
- TOK_FUNCTION TOK_ID '(' arguments_decl ')' '=' expr {
+ TOK_FUNCTION TOK_ID '(' arguments_decl optional_commas ')' '=' expr {
Function *func = new Function();
func->argnames = $4->argnames;
func->argexpr = $4->argexpr;
- func->expr = $7;
+ func->expr = $8;
module->functions[$2] = func;
free($2);
delete $4;
@@ -270,13 +270,13 @@ expr:
$$->children.append($4);
$$->children.append($6);
} |
- '[' ']' {
+ '[' optional_commas ']' {
$$ = new Expression();
$$->type = "C";
$$->const_value = new Value();
$$->const_value->type = Value::VECTOR;
} |
- '[' vector_expr ']' {
+ '[' vector_expr optional_commas ']' {
$$ = $2;
} |
expr '*' expr {
@@ -396,15 +396,18 @@ expr:
delete $3;
} ;
+optional_commas:
+ ',' optional_commas | ;
+
vector_expr:
expr {
$$ = new Expression();
$$->type = 'V';
$$->children.append($1);
} |
- vector_expr ',' expr {
+ vector_expr ',' optional_commas expr {
$$ = $1;
- $$->children.append($3);
+ $$->children.append($4);
} ;
arguments_decl:
@@ -417,11 +420,11 @@ arguments_decl:
$$->argexpr.append($1->argexpr);
delete $1;
} |
- arguments_decl ',' argument_decl {
+ arguments_decl ',' optional_commas argument_decl {
$$ = $1;
- $$->argnames.append($3->argname);
- $$->argexpr.append($3->argexpr);
- delete $3;
+ $$->argnames.append($4->argname);
+ $$->argexpr.append($4->argexpr);
+ delete $4;
} ;
argument_decl:
@@ -448,11 +451,11 @@ arguments_call:
$$->argexpr.append($1->argexpr);
delete $1;
} |
- arguments_call ',' argument_call {
+ arguments_call ',' optional_commas argument_call {
$$ = $1;
- $$->argnames.append($3->argname);
- $$->argexpr.append($3->argexpr);
- delete $3;
+ $$->argnames.append($4->argname);
+ $$->argexpr.append($4->argexpr);
+ delete $4;
} ;
argument_call:
contact: Jan Huwald // Impressum