[pure-lang-svn] SF.net SVN: pure-lang:[515] pure/trunk
Status: Beta
Brought to you by:
agraef
From: <ag...@us...> - 2008-08-16 23:13:27
|
Revision: 515 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=515&view=rev Author: agraef Date: 2008-08-16 23:13:37 +0000 (Sat, 16 Aug 2008) Log Message: ----------- Revised 'using' syntax so that script names are now separated with a comma. Modified Paths: -------------- pure/trunk/ChangeLog pure/trunk/lexer.ll pure/trunk/lib/prelude.pure pure/trunk/parser.yy pure/trunk/test/test015.pure Modified: pure/trunk/ChangeLog =================================================================== --- pure/trunk/ChangeLog 2008-08-16 22:46:01 UTC (rev 514) +++ pure/trunk/ChangeLog 2008-08-16 23:13:37 UTC (rev 515) @@ -1,3 +1,9 @@ +2008-08-17 Albert Graef <Dr....@t-...> + + * parser.yy, lexer.ll: Revised 'using' syntax so that script names + are now separated with a comma. Updated library and sample scripts + accordingly. + 2008-08-16 Albert Graef <Dr....@t-...> * pure.cc (main): More robust test for presence of the prelude. Modified: pure/trunk/lexer.ll =================================================================== --- pure/trunk/lexer.ll 2008-08-16 22:46:01 UTC (rev 514) +++ pure/trunk/lexer.ll 2008-08-16 23:13:37 UTC (rev 515) @@ -229,7 +229,7 @@ strtag ::{blank}*string ptrtag ::{blank}*pointer -%x comment xdecl xdecl_comment +%x comment xdecl xdecl_comment xusing xusing_comment %{ # define YY_USER_ACTION yylloc->columns(yyleng); @@ -266,13 +266,42 @@ interp.error(*yylloc, msg); BEGIN(INITIAL); return token::ERRTOK; } - <xdecl_comment>[^*\n]* yylloc->step(); <xdecl_comment>"*"+[^*/\n]* yylloc->step(); <xdecl_comment>[\n]+ yylloc->lines(yyleng); yylloc->step(); <xdecl_comment>"*"+"/" yylloc->step(); BEGIN(xdecl); +<xusing>{id} yylval->sval = new string(yytext); return token::ID; +<xusing>, return yy::parser::token_type(yytext[0]); +<xusing>"//".* yylloc->step(); +<xusing>"/*" BEGIN(xusing_comment); +<xusing>; BEGIN(INITIAL); return yy::parser::token_type(yytext[0]); +<xusing>{blank}+ yylloc->step(); +<xusing>[\n]+ yylloc->lines(yyleng); yylloc->step(); +<xusing>\"{str}\" { + char *msg; + yytext[yyleng-1] = 0; + yylval->csval = parsestr(yytext+1, msg); + yytext[yyleng-1] = '"'; + if (msg) interp.error(*yylloc, msg); + return token::STR; +} +<xusing>\"{str} { + interp.error(*yylloc, "unterminated string constant"); + BEGIN(INITIAL); return token::ERRTOK; +} +<xusing>. { + string msg = "invalid character '"+string(yytext)+"'"; + interp.error(*yylloc, msg); + BEGIN(INITIAL); return token::ERRTOK; +} + +<xusing_comment>[^*\n]* yylloc->step(); +<xusing_comment>"*"+[^*/\n]* yylloc->step(); +<xusing_comment>[\n]+ yylloc->lines(yyleng); yylloc->step(); +<xusing_comment>"*"+"/" yylloc->step(); BEGIN(xusing); + ^!{blank}*.* { // shell escape is only permitted in interactive mode if (!interp.interactive) REJECT; @@ -801,7 +830,7 @@ otherwise return token::OTHERWISE; when return token::WHEN; with return token::WITH; -using return token::USING; +using BEGIN(xusing); return token::USING; {id} { if (interp.declare_op) { yylval->sval = new string(yytext); Modified: pure/trunk/lib/prelude.pure =================================================================== --- pure/trunk/lib/prelude.pure 2008-08-16 22:46:01 UTC (rev 514) +++ pure/trunk/lib/prelude.pure 2008-08-16 23:13:37 UTC (rev 515) @@ -72,7 +72,7 @@ Note that the math and system modules are *not* included here, so you have to do that yourself if your program requires any of those operations. */ -using primitives strings; +using primitives, strings; /* Basic combinators. */ Modified: pure/trunk/parser.yy =================================================================== --- pure/trunk/parser.yy 2008-08-16 22:46:01 UTC (rev 514) +++ pure/trunk/parser.yy 2008-08-16 23:13:37 UTC (rev 515) @@ -313,8 +313,8 @@ names : name { $$ = new list<string>; $$->push_back(*$1); delete $1; } -| names name -{ $$ = $1; $$->push_back(*$2); delete $2; } +| names ',' name +{ $$ = $1; $$->push_back(*$3); delete $3; } ; name Modified: pure/trunk/test/test015.pure =================================================================== --- pure/trunk/test/test015.pure 2008-08-16 22:46:01 UTC (rev 514) +++ pure/trunk/test/test015.pure 2008-08-16 23:13:37 UTC (rev 515) @@ -1,6 +1,6 @@ // Some tests for set and bag data containers -using array dict heap set; +using array, dict, heap, set; // List of 1000 random integers from interval <0; 99> for stress tests let randlist = This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |