Author: kjs
Date: Mon Apr 2 05:47:05 2007
New Revision: 17946
Modified:
trunk/compilers/pirc/src/pirlexer.c
trunk/compilers/pirc/src/pirparser.c
Log:
compilers/pirc:
* fixed comments
* fixed grammar documentation errors and inconsistencies.
Modified: trunk/compilers/pirc/src/pirlexer.c
==============================================================================
--- trunk/compilers/pirc/src/pirlexer.c (original)
+++ trunk/compilers/pirc/src/pirlexer.c Mon Apr 2 05:47:05 2007
@@ -104,6 +104,13 @@
=cut
+
+Note w.r.t. dictionary:
+
+Make sure that the spelling can /only/ be a single word if it is a keyword
+(or directive etc.). If it is a description, make sure the word cannot occurr
+as such, for instance, by using an embedded space.
+
*/
static char const * dictionary[] = {
"global", /* T_GLOBAL, */
Modified: trunk/compilers/pirc/src/pirparser.c
==============================================================================
--- trunk/compilers/pirc/src/pirparser.c (original)
+++ trunk/compilers/pirc/src/pirparser.c Mon Apr 2 05:47:05 2007
@@ -547,21 +547,6 @@
}
-/*
-
-=item
-
- global_definition -> '.global' IDENTIFIER
-
-=cut
-
-*/
-static void
-global_definition(parser_state *p) {
- match(p, T_GLOBAL_DECL);
- match(p, T_IDENTIFIER);
-}
-
/*
@@ -679,7 +664,6 @@
*/
static void
parrot_instruction(parser_state *p) {
- /* emit the op */
emit_op_start(p, get_current_token(p->lexer));
match(p, T_PARROT_OP);
@@ -706,14 +690,14 @@
=item
assignment -> '=' ( unop expression
- | expression [binop expression]
+ | expression arith_expr
| target ( keylist | [ '->' method ] arguments )
| STRINGC arguments
| 'global' STRINGC
| heredocstring
| methodcall
| 'null'
- | PARROT_OP [ expression { ',' expression } ]
+ | parrot_instruction
)
unop -> '-' | '!' | '~'
@@ -728,7 +712,7 @@
switch (p->curtoken) {
case T_NOT:
case T_MINUS:
- case T_BXOR: /* '~' used as binary 'not' op */
+ case T_BXOR: /* '~' used as 'bnot' op */
next(p);
expression(p);
break;
@@ -1499,7 +1483,7 @@
=item
- get_results_instr -> '.get_results' '(' target_list ')' '\n'
+ get_results_instr -> '.get_results' target_list '\n'
=cut
@@ -1556,7 +1540,9 @@
=item
- instruction -> {LABEL '\n'} instr
+ instructions -> {instruction}
+
+ instruction -> {LABEL '\n'} instr
instr -> if_statement
| unless_statement
@@ -1688,6 +1674,21 @@
=item
+ global_definition -> '.global' IDENTIFIER
+
+=cut
+
+*/
+static void
+global_definition(parser_state *p) {
+ match(p, T_GLOBAL_DECL);
+ match(p, T_IDENTIFIER);
+}
+
+/*
+
+=item
+
multi-type-list -> '(' [multi-type {',' multi-type } ] ')'
multi-type -> IDENTIFIER | STRINGC | keylist | type
@@ -1830,8 +1831,6 @@
emit_type(p, get_current_token(p->lexer));
/* type(p); -- we know what it is; just skip it! */
next(p);
-
- /* Maybe combine these 2 statements into an 'identifier'()
function? */
emit_name(p, get_current_token(p->lexer));
match(p, T_IDENTIFIER);
param_flags(p);
@@ -1869,7 +1868,7 @@
=item
- sub_definition -> '.sub' (IDENTIFIER | STRINGC) subflags '\n' parameters
body '.end'
+ sub_definition -> '.sub' (IDENTIFIER | STRINGC) subflags '\n' parameters
instructions '.end'
=cut