Author: kjs
Date: Sun Mar 25 08:07:49 2007
New Revision: 17729
Modified:
trunk/compilers/pirc/src/pirlexer.c
trunk/compilers/pirc/src/pirlexer.h
trunk/compilers/pirc/src/pirparser.c
Log:
compilers/pirc:
* added var '=' null statement
* added .= operator.
Modified: trunk/compilers/pirc/src/pirlexer.c
==============================================================================
--- trunk/compilers/pirc/src/pirlexer.c (original)
+++ trunk/compilers/pirc/src/pirlexer.c Sun Mar 25 08:07:49 2007
@@ -38,6 +38,7 @@
is not null"), so you don't have to look into a section
that is not of interest. (not implemented right now)
+ global
goto
if
int
@@ -191,6 +192,7 @@
"*=", /* T_MULTIPLY_ASSIGN, */
"+=", /* T_PLUS_ASSIGN, */
"-=", /* T_MINUS_ASSIGN, */
+ ".=", /* T_CONCAT_ASSIGN */
"'register'", /* T_REGISTER, */
"/=", /* T_DIVIDE_ASSIGN, */
"//=", /* T_FDIVIDE_ASSIGN, */
@@ -882,6 +884,7 @@
c = read_char(lexer->curfile);
if (c == EOF_MARKER) return T_EOF;
+ if (c == '=') return T_CONCAT_ASSIGN;
if (c == '.') return T_DOTDOT; /* ".." */
if ( isspace(c) ) { /* a dot followed by a space */
@@ -1008,7 +1011,7 @@
=head3 Augmented operators
- **= *= %= /= //= += -= >>= >>>= <<= &= |= ~=
+ **= *= %= /= //= += -= .= >>= >>>= <<= &= |= ~=
=head3 Conditional operators
Modified: trunk/compilers/pirc/src/pirlexer.h
==============================================================================
--- trunk/compilers/pirc/src/pirlexer.h (original)
+++ trunk/compilers/pirc/src/pirlexer.h Sun Mar 25 08:07:49 2007
@@ -130,6 +130,7 @@
T_MULTIPLY_ASSIGN, /* "*=", */
T_PLUS_ASSIGN, /* "+=", */
T_MINUS_ASSIGN, /* "-=", */
+ T_CONCAT_ASSIGN, /* ".=" */
T_REGISTER, /* "'register'", */
T_DIVIDE_ASSIGN, /* "/=", */
T_FDIVIDE_ASSIGN, /* "//=", */
Modified: trunk/compilers/pirc/src/pirparser.c
==============================================================================
--- trunk/compilers/pirc/src/pirparser.c (original)
+++ trunk/compilers/pirc/src/pirparser.c Sun Mar 25 08:07:49 2007
@@ -458,7 +458,8 @@
match(p, T_RPAREN);
/* do NOT match() for T_NEWLINE, it will get the next token, but it might
- * be a heredoc, which needs a special lexer function */
+ * be a heredoc, which needs a special lexer function
+ */
if (p->curtoken != T_NEWLINE) {
syntax_error(p, 1, "'\\n' expected");
}
@@ -488,7 +489,8 @@
arith_expr -> [ binop expression ]
- binop -> '+' | '-' | '*' | '/' | '//' | '%' | '~~' | '~' | '&&' | '&' |
'||' | '|' | '<<' | '>>' | '>>>' | '.'
+ binop -> '+' | '-' | '*' | '/' | '//' | '%' | '~~' | '~'
+ | '&&' | '&' | '||' | '|' | '<<' | '>>' | '>>>' | '.'
=cut
@@ -525,11 +527,12 @@
=item assignment()
- assignment -> '=' ( unop expr
- | expr [binop expr]
+ assignment -> '=' ( unop expression
+ | expression [binop expression]
| target (keylist|arguments)
| 'global' stringconstant
| heredocstring
+ | 'null'
) '\n'
unop -> '-' | '!' | '~'
@@ -569,6 +572,9 @@
next(p);
stringconstant(p);
break;
+ case T_NULL:
+ next(p);
+ break;
case T_HEREDOC_ID: { /* parse heredoc string */
char *heredocid = clone_string(get_current_token(p->lexer));
/* read_heredoc() returns a special token */
@@ -1108,7 +1114,8 @@
| target '->' (stringconstant|IDENT) arguments '\n'
| target arguments '\n'
- augmented_op -> '+=' | '-=' | '%=' | '/=' | '//=' | '*=' | '~=' | '&=' |
'|=' | '**=' | '<<=' | '>>=' | '>>>='
+ augmented_op -> '+=' | '-=' | '%=' | '/=' | '//=' | '*=' | '.='
+ | '~=' | '&=' | '|=' | '**=' | '<<=' | '>>=' | '>>>='
=cut
@@ -1124,6 +1131,7 @@
break;
case T_PLUS_ASSIGN: /* target '+=' simple_expr '\n' (and '-=' etc.) */
case T_MINUS_ASSIGN:
+ case T_CONCAT_ASSIGN:
case T_DIVIDE_ASSIGN:
case T_FDIVIDE_ASSIGN:
case T_POWER_ASSIGN: