diff options
author | Karl Berry <karl@freefriends.org> | 2011-05-28 02:18:52 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2011-05-28 02:18:52 +0000 |
commit | c59fe5fe4739f0c61560f05d4e42b4e552219b27 (patch) | |
tree | 8cf79e85e394b3177a28d374415840a4e0a025ad /Build/source/utils/asymptote/camp.y | |
parent | 771db15706dbf3f4af8b630dcb15646a3e5fda00 (diff) |
asy 2.10
git-svn-id: svn://tug.org/texlive/trunk@22633 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/utils/asymptote/camp.y')
-rw-r--r-- | Build/source/utils/asymptote/camp.y | 58 |
1 files changed, 35 insertions, 23 deletions
diff --git a/Build/source/utils/asymptote/camp.y b/Build/source/utils/asymptote/camp.y index 94feb807c32..26d5a834e2a 100644 --- a/Build/source/utils/asymptote/camp.y +++ b/Build/source/utils/asymptote/camp.y @@ -37,6 +37,19 @@ void yyerror(const char *s) } } +// Check if the symbol given is "keyword". Returns true in this case and +// returns false and reports an error otherwise. +bool checkKeyword(position pos, symbol sym) +{ + if (sym != symbol::trans("keyword")) { + em.error(pos); + em << "expected 'keyword' here"; + + return false; + } + return true; +} + namespace absyntax { file *root; } using namespace absyntax; @@ -148,7 +161,7 @@ using mem::string; %type <vi> varinit %type <ai> arrayinit basearrayinit varinits %type <fl> formal -%type <fls> formals baseformals +%type <fls> formals %type <e> value exp fortest %type <arg> argument %type <slice> slice @@ -156,7 +169,7 @@ using mem::string; %type <e> tension controls %type <se> dir %type <elist> dimexps -%type <alist> arglist basearglist +%type <alist> arglist %type <s> stm stmexp blockstm %type <run> forinit %type <sel> forupdate stmexplist @@ -253,7 +266,7 @@ idpairlist: strid: ID { $$ = $1; } | STRING { $$.pos = $1->getPos(); - $$.sym = symbol::trans($1->getString()); } + $$.sym = symbol::literalTrans($1->getString()); } ; stridpair: @@ -351,16 +364,12 @@ varinits: ; formals: - baseformals { $$ = $1; } -| baseformals ELLIPSIS formal - { $$ = $1; $$->addRest($3); } -| ELLIPSIS formal { $$ = new formals($1); $$->addRest($2); } -; - -baseformals: formal { $$ = new formals($1->getPos()); $$->add($1); } -| baseformals ',' formal +| ELLIPSIS formal { $$ = new formals($1); $$->addRest($2); } +| formals ',' formal { $$ = $1; $$->add($3); } +| formals ELLIPSIS formal + { $$ = $1; $$->addRest($3); } ; explicitornot: @@ -370,11 +379,18 @@ explicitornot: formal: explicitornot type - { $$ = new formal($2->getPos(), $2, 0, 0, $1); } + { $$ = new formal($2->getPos(), $2, 0, 0, $1, 0); } | explicitornot type decidstart - { $$ = new formal($2->getPos(), $2, $3, 0, $1); } + { $$ = new formal($2->getPos(), $2, $3, 0, $1, 0); } | explicitornot type decidstart ASSIGN varinit - { $$ = new formal($2->getPos(), $2, $3, $5, $1); } + { $$ = new formal($2->getPos(), $2, $3, $5, $1, 0); } +/* The uses of ID below are 'keyword' qualifiers before the parameter name. */ +| explicitornot type ID decidstart + { bool k = checkKeyword($3.pos, $3.sym); + $$ = new formal($2->getPos(), $2, $4, 0, $1, k); } +| explicitornot type ID decidstart ASSIGN varinit + { bool k = checkKeyword($3.pos, $3.sym); + $$ = new formal($2->getPos(), $2, $4, $6, $1, k); } ; fundec: @@ -427,19 +443,15 @@ argument: ; arglist: - basearglist { $$ = $1; } -| basearglist ELLIPSIS argument - { $$ = $1; $$->rest = $3; } -| ELLIPSIS argument { $$ = new arglist(); $$->rest = $2; } -; - -basearglist: argument { $$ = new arglist(); $$->add($1); } -| basearglist ',' argument +| ELLIPSIS argument + { $$ = new arglist(); $$->addRest($2); } +| arglist ',' argument { $$ = $1; $$->add($3); } +| arglist ELLIPSIS argument + { $$ = $1; $$->addRest($3); } ; - exp: name { $$ = new nameExp($1->getPos(), $1); } | value { $$ = $1; } |