develooper Front page | perl.cvs.parrot | Postings from January 2009

[svn:parrot] r34980 - trunk/compilers/pirc/src

From:
kjs
Date:
January 5, 2009 03:40
Subject:
[svn:parrot] r34980 - trunk/compilers/pirc/src
Message ID:
20090105113959.15586CB9F9@x12.develooper.com
Author: kjs
Date: Mon Jan  5 03:39:56 2009
New Revision: 34980

Modified:
   trunk/compilers/pirc/src/pir.l
   trunk/compilers/pirc/src/pir.y
   trunk/compilers/pirc/src/pirparser.c

Log:
[pirc] improve error checking in PASM mode.
+ some refactoring of regular expressions.

Modified: trunk/compilers/pirc/src/pir.l
==============================================================================
--- trunk/compilers/pirc/src/pir.l	(original)
+++ trunk/compilers/pirc/src/pir.l	Mon Jan  5 03:39:56 2009
@@ -1090,13 +1090,13 @@
                           return TK_LABEL;
                         }
 
-<PASM>"$"[SNIP]{DIGIT}+ { yypirerror(yyscanner, yypirget_extra(yyscanner),
+<PASM>{REGISTER}        { yypirerror(yyscanner, yypirget_extra(yyscanner),
                                      "symbolic registers are not allowed in PASM mode");
                         }
-<PASM>"P"{DIGIT}+       { yylval->ival = atoi(yytext + 1); return TK_PREG; }
-<PASM>"N"{DIGIT}+       { yylval->ival = atoi(yytext + 1); return TK_NREG; }
-<PASM>"I"{DIGIT}+       { yylval->ival = atoi(yytext + 1); return TK_IREG; }
-<PASM>"S"{DIGIT}+       { yylval->ival = atoi(yytext + 1); return TK_SREG; }
+<PASM>"P"{DIGITS}       { yylval->ival = atoi(yytext + 1); return TK_PREG; }
+<PASM>"N"{DIGITS}       { yylval->ival = atoi(yytext + 1); return TK_NREG; }
+<PASM>"I"{DIGITS}       { yylval->ival = atoi(yytext + 1); return TK_IREG; }
+<PASM>"S"{DIGITS}       { yylval->ival = atoi(yytext + 1); return TK_SREG; }
 
 <PASM>{IDENT}           { /* can be a parrot op or a label; the check is done in the parser. */
                           yylval->sval = dupstr(yypirget_extra(yyscanner), yytext);

Modified: trunk/compilers/pirc/src/pir.y
==============================================================================
--- trunk/compilers/pirc/src/pir.y	(original)
+++ trunk/compilers/pirc/src/pir.y	Mon Jan  5 03:39:56 2009
@@ -2223,8 +2223,11 @@
 
 pasm_instruction          : parrot_op op_args "\n"
                                 {
-                                  if (is_parrot_op(lexer, $1))
-                                      get_opinfo(lexer);
+
+                                  if (is_parrot_op(lexer, $1)) {
+                                      check_op_args_for_symbols(lexer);
+                                      /* get_opinfo(lexer); */
+                                  }
                                   else /* not a parrot op */
                                       yypirerror(yyscanner, lexer, "'%s' is not a parrot op", $1);
 
@@ -3459,6 +3462,12 @@
 */
 static void
 undeclared_symbol(lexer_state * const lexer, char const * const symbol) {
+    if (TEST_FLAG(lexer->flags, LEXER_FLAG_PASMFILE)) {
+        yypirerror(lexer->yyscanner, lexer,
+                   "cannot use symbols in PASM mode ('%s')", symbol);
+        return;
+    }
+
     yypirerror(lexer->yyscanner, lexer, "symbol '%s' not declared", symbol);
 
     /* maybe user tried to use PASM register? */

Modified: trunk/compilers/pirc/src/pirparser.c
==============================================================================
--- trunk/compilers/pirc/src/pirparser.c	(original)
+++ trunk/compilers/pirc/src/pirparser.c	Mon Jan  5 03:39:56 2009
@@ -4756,8 +4756,11 @@
   case 429:
 #line 2225 "pir.y"
     {
-                                  if (is_parrot_op(lexer, (yyvsp[(1) - (3)].sval)))
-                                      get_opinfo(lexer);
+
+                                  if (is_parrot_op(lexer, (yyvsp[(1) - (3)].sval))) {
+                                      check_op_args_for_symbols(lexer);
+                                      /* get_opinfo(lexer); */
+                                  }
                                   else /* not a parrot op */
                                       yypirerror(yyscanner, lexer, "'%s' is not a parrot op", (yyvsp[(1) - (3)].sval));
 
@@ -4766,7 +4769,7 @@
 
 
 /* Line 1267 of yacc.c.  */
-#line 4770 "pirparser.c"
+#line 4773 "pirparser.c"
       default: break;
     }
   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
@@ -4980,7 +4983,7 @@
 }
 
 
-#line 2236 "pir.y"
+#line 2239 "pir.y"
 
 
 
@@ -6207,6 +6210,12 @@
 */
 static void
 undeclared_symbol(lexer_state * const lexer, char const * const symbol) {
+    if (TEST_FLAG(lexer->flags, LEXER_FLAG_PASMFILE)) {
+        yypirerror(lexer->yyscanner, lexer,
+                   "cannot use symbols in PASM mode ('%s')", symbol);
+        return;
+    }
+
     yypirerror(lexer->yyscanner, lexer, "symbol '%s' not declared", symbol);
 
     /* maybe user tried to use PASM register? */



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About