[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNU-COBOL] PCCTS again and a question
Alright, I couldn't help myself. Last night I got rid of the
remaining ambiguities in the old pccts grammar, so now it's an
unambiguous LL(1) grammar unless, of course, I've covered something
up that I shouldn't have :)
It's still incomplete, of course, and may not be entirely correct,
but it generates a parser in seconds and creates no significant
strain on resources.
I should mention that there was a rule in verb-perform.g which was
truly ambiguous, so forcing a parse would have made no sense.
perform_from_line
: FROM (ident | index_name | numeric)
;
The non-terminals "index_name" and "numeric" derive precisely the
same terminal. I did not try to work out the significance of these
terms, but simply removed "index_name" leaving the original line as a
comment.
I had also broken the "if" rule in my last submission. It's better
now.
What's going on with respect to the tool search these days? I am
interested know which parser generators have been considered, and
which are still in the running.
Mike
Here's the new diff.
diff -Naur Cobol2C/src/clause-condition.g Cobol2C.new/src/clause-condition.g
--- Cobol2C/src/clause-condition.g Thu Dec 11 09:01:20 1997
+++ Cobol2C.new/src/clause-condition.g Fri Jul 16 09:35:48 1999
@@ -12,9 +12,10 @@
;
general_cond
: arith_expr
- ( cond_arg
- | class_arg /* need to check if above arith_expr is ident */
- | sign_arg
+ ( (cond_arg)? cond_arg
+ | ((class_arg)? class_arg /* need to check if arith_expr is ident */
+ | sign_arg
+ )
)
;
/*: (string_literal | arith_expr | index_name)*/
diff -Naur Cobol2C/src/clause-file-control.g Cobol2C.new/src/clause-file-contro
l.g
--- Cobol2C/src/clause-file-control.g Thu Dec 11 09:01:21 1997
+++ Cobol2C.new/src/clause-file-control.g Thu Jul 22 22:11:58 1999
@@ -5,8 +5,6 @@
<< CheckFlag(&file_control_flags, FC_ASSIGN, "ASSIGN"); >>
| padding_line
<< CheckFlag(&file_control_flags, FC_PADDING, "PADDING"); >>
- | record_line
- << CheckFlag(&file_control_flags, FC_RECORD_DELIM, "RECORD"); >>
| reserve_line
<< CheckFlag(&file_control_flags, FC_RESERVE, "RESERVE"); >>
| org_line
@@ -15,10 +13,14 @@
<< CheckFlag(&file_control_flags, FC_ACCESS_MODE, "ACCESS MODE"); >>
| file_status_line
<< CheckFlag(&file_control_flags, FC_FILE_STATUS, "FILE STATUS"); >>
- | record_key_line
- << CheckFlag(&file_control_flags, FC_RECORD_KEY, "RECORD"); >>
| alt_key_line
<< CheckFlag(&file_control_flags, FC_ALT_RECORD, "ALTERNATE"); >>
+ | ((RECORD DELIMITER)?
+ record_line
+ << CheckFlag(&file_control_flags, FC_RECORD_DELIM, "RECORD"); >>
+ | record_key_line
+ << CheckFlag(&file_control_flags, FC_RECORD_KEY, "RECORD"); >>
+ )
)*
PERIOD
<< FileControlActions();
diff -Naur Cobol2C/src/clause-file-descr.g Cobol2C.new/src/clause-file-descr.g
--- Cobol2C/src/clause-file-descr.g Thu Dec 11 09:01:21 1997
+++ Cobol2C.new/src/clause-file-descr.g Thu Jul 22 22:04:45 1999
@@ -4,10 +4,11 @@
#endif
>>
fd_line
- ( external_line
+ ( ((external_line)? external_line
<< CheckFlag(&file_descr_flags, FD_EXTERNAL, "EXTERNAL"); >>
| global_line
<< CheckFlag(&file_descr_flags, FD_GLOBAL, "GLOBAL"); >>
+ )
| block_line
<< CheckFlag(&file_descr_flags, FD_BLOCK, "BLOCK"); >>
| record_line_f
@@ -41,7 +42,7 @@
<< WarnNotImpl("GLOBAL clause"); >>
;
block_line
- : BLOCK {CONTAINS} {integer TO} integer (RECORDS | CHARACTERS)
+ : BLOCK {CONTAINS} integer {TO integer} (RECORDS | CHARACTERS)
<< WarnNotImpl("BLOCK clause"); >>
;
record_line_f
diff -Naur Cobol2C/src/clause-record-descr.g Cobol2C.new/src/clause-record-desc
r.g
--- Cobol2C/src/clause-record-descr.g Thu Dec 11 09:01:21 1997
+++ Cobol2C.new/src/clause-record-descr.g Thu Jul 22 21:18:16 1999
@@ -2,10 +2,10 @@
: level_number (ident << strcpy(DDIdent, Ident); >>
| {FILLER} << strcpy(DDIdent, ""); >>
)
- ( redefines_line
- << CheckFlag(&data_descr_flags, DD_REDEFINES, "REDEFINES"); >>
- | external_line_r
+ ( (external_line_r)? external_line_r
<< CheckFlag(&data_descr_flags, DD_EXTERNAL, "EXTERNAL"); >>
+ | redefines_line
+ << CheckFlag(&data_descr_flags, DD_REDEFINES, "REDEFINES"); >>
| global_line_r
<< CheckFlag(&data_descr_flags, DD_GLOBAL, "GLOBAL"); >>
| picture_line
@@ -45,7 +45,7 @@
<< WarnNotImpl("EXTERNAL clause"); >>
;
global_line_r
- : IS GLOBAL
+ : {IS} GLOBAL
<< WarnNotImpl("IS GLOBAL clause"); >>
;
picture_line
diff -Naur Cobol2C/src/clause-relation.g Cobol2C.new/src/clause-relation.g
--- Cobol2C/src/clause-relation.g Thu Dec 11 09:01:21 1997
+++ Cobol2C.new/src/clause-relation.g Fri Jul 16 10:25:16 1999
@@ -1,10 +1,10 @@
relation
: {IS} {NOT << SetFlag(&verb_flags, RELATION_NOT); >> }
( geneq
- | gengt
- | genlt
- | genge
- | genle
+ | ((genge)? genge
+ | gengt)
+ | ((genle)? genle
+ | genlt)
)
<< ClearFlag(&verb_flags, RELATION_NOT); >>
;
diff -Naur Cobol2C/src/clause-size-err.g Cobol2C.new/src/clause-size-err.g
--- Cobol2C/src/clause-size-err.g Thu Dec 11 09:01:21 1997
+++ Cobol2C.new/src/clause-size-err.g Thu Jul 22 22:09:55 1999
@@ -2,10 +2,10 @@
size_err
: {NOT} {ON} SIZE ERROR imperative
- second_size_line
+ {({NOT} {ON} SIZE)? second_size_line}
;
second_size_line
- : {{NOT} {ON} SIZE ERROR imperative}
+ : {NOT} {ON} SIZE ERROR imperative
;
/*
: ({NOT} {ON} SIZE ERROR imperative)?
diff -Naur Cobol2C/src/verb-accept.g Cobol2C.new/src/verb-accept.g
--- Cobol2C/src/verb-accept.g Thu Dec 11 09:01:21 1997
+++ Cobol2C.new/src/verb-accept.g Fri Jul 16 10:28:32 1999
@@ -1,6 +1,6 @@
accept_stmt
: ACCEPT (
- ident <<
+ (ident FROM ident)? ident <<
{ int rv = emit_accept(Ident);
if (rv != 0) ErrUndefVar(Ident);
}
diff -Naur Cobol2C/src/verb-compute.g Cobol2C.new/src/verb-compute.g
--- Cobol2C/src/verb-compute.g Thu Dec 11 09:01:21 1997
+++ Cobol2C.new/src/verb-compute.g Thu Jul 22 21:11:11 1999
@@ -14,7 +14,8 @@
>>
;
compute_sizing
- : {size_err}
+ : ({NOT} {ON} SIZE)? size_err
+ |
;
/*
: (size_err)?
@@ -22,7 +23,8 @@
;
*/
compute_ending
- : {END_COMPUTE}
+ : (END_COMPUTE)? END_COMPUTE
+ |
;
/*
: (END_COMPUTE)?
diff -Naur Cobol2C/src/verb-go.g Cobol2C.new/src/verb-go.g
--- Cobol2C/src/verb-go.g Thu Dec 11 09:01:21 1997
+++ Cobol2C.new/src/verb-go.g Fri Jul 16 11:23:51 1999
@@ -1,6 +1,6 @@
go_stmt
- : GO {TO} (ident /* procedure name */
- |(ident)+ DEPENDING {ON} ident
+ : GO {TO} (((ident)+ DEPENDING)? (ident)+ DEPENDING {ON} ident
+ | ident /* procedure name */
)
;
diff -Naur Cobol2C/src/verb-if.g Cobol2C.new/src/verb-if.g
--- Cobol2C/src/verb-if.g Thu Dec 11 09:01:21 1997
+++ Cobol2C.new/src/verb-if.g Wed Jul 21 11:11:02 1999
@@ -6,19 +6,22 @@
: IF_C << emit_if_start(); >>
condition {THEN} << emit_if_block(); >>
( NEXT SENTENCE << emit_if_next_sentence(); >>
- | (statement)+ ) << emit_if_end(); >>
+ | ((statement)? statement)* ) << emit_if_end(); >>
else_clause
+ if_ending
;
else_clause
- : ( ELSE_C << emit_else_start(); >>
- NEXT SENTENCE << emit_else_next_sentence(); >>
- | ELSE_C << emit_else_start(); >>
- (statement)+ {END_IF} << emit_else_end(); >>
- | {END_IF}
- )
+ : (ELSE_C)? ELSE_C << emit_else_start(); >>
+ ( NEXT SENTENCE << emit_else_next_sentence(); >>
+ | ((statement)? statement)* << emit_else_end(); >>
+ )
+ |
;
-
+if_ending
+ : (END_IF)? END_IF
+ |
+ ;
/*
if_stmt
diff -Naur Cobol2C/src/verb-perform.g Cobol2C.new/src/verb-perform.g
--- Cobol2C/src/verb-perform.g Thu Dec 11 09:01:22 1997
+++ Cobol2C.new/src/verb-perform.g Thu Jul 22 21:34:51 1999
@@ -1,9 +1,11 @@
perform_stmt
: PERFORM << { int rv=0; rv = emit_perform_start();
if (rv != 0) ErrEmit(); } >>
- ( perform_proc_line { perform_times_line
- | { perform_test_line } perform_until_line
- }
+ ( (perform_proc_line)? perform_proc_line
+ ( perform_times_line
+ | { perform_test_line } perform_until_line
+ |
+ )
| ( perform_times_line
| { perform_test_line } perform_until_line
)
@@ -57,7 +59,8 @@
<< WarnNotImpl("VARYING clause"); >>
;
perform_from_line
- : FROM (ident | index_name | numeric)
+ : FROM (ident | numeric)
+// : FROM (ident | index_name | numeric)
;
perform_by_line
: BY (ident | numeric) UNTIL condition
--
This message was sent through the gnu-cobol mailing list. To remove yourself
from this mailing list, send a message to majordomo@acm.cs.umr.edu with the
words "unsubscribe gnu-cobol" in the message body. For more information on
the GNU COBOL project, send mail to gnu-cobol-owner@acm.cs.umr.edu.