[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [GNU-COBOL] GNU-COBOL list reborn



Tim Josling wrote:
> I will check out pccts tomorrow. Would you mind sending me your
> latest grammar?
> 
> Btyacc does it by backtracking. This does make good error
> messages hard to come by (even compared to yacc!).
> 
> Tim Josling
> 
I haven't really done too much with this, Tim.  It's really the phase one
grammar which is still available on the Gnu-COBOL web site.  I just added
the syntactic predicates that permit us to use an LL/1 grammar.  Look ahead
only when you need to.  I'll even admit that it could probably be done with
fewer and cheaper predicates, but it's good enough to demonstrate the
principle.  I was thinking that we might also go back to the pccts lexer
(dlg) since you've taken care of the hard stuff in the pre-processor.  Dlg
is weaker than flex, but it does have a few nice features and it integrates
nicely with the parser.

The pccts that I'm using is pccts-1.33mr18 which I installed from an RPM on
my RedHat box. There's quite a lot of documentation on the web, but I'm
using what I pulled down and printed three or four years ago.  Try a search.
I think most of the important stuff is in the FAQ -- the Q's are FA because
the answers are missing in the other docs.

I also included the makefile that I'm using, because it might save you the
trouble of getting rid of CVS and local directory references.  Those are
the only changes I made.  So, just pull down the tar from the Gnu_COBOL 
site, apply the patch file below, tweak the makefile to your liking and
let me know what you think.  I'll try to field your questions -- there is
a bit of a hump getting started with this thing.

~~~~~~~~~~ the diff ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

diff -Naur Cobol2C/src/clause-arithmetic.g Cobol2C.new/src/clause-arithmetic.g
--- Cobol2C/src/clause-arithmetic.g	Thu Dec 11 09:01:20 1997
+++ Cobol2C.new/src/clause-arithmetic.g	Sun Jul 25 13:51:06 1999
@@ -24,7 +24,7 @@
 	;
 expr0
 	: ( numeric << ExprStringAdd(Numeric_s); >>
-	  | ident << ExprStringAdd(Ident); >>
+	  | identifier  << ExprStringAdd(Ident); >>
 	  )
 	;
 uni_op
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	Sun Aug  1 15:15:16 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	Sun Aug  1 15:15:35 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	Sun Aug  1 15:15:52 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	Sun Jul 25 20:42:01 1999
@@ -1,14 +1,10 @@
 /* size err */
 
 size_err
-	: {NOT} {ON} SIZE ERROR imperative
-	  second_size_line
+	: {ON} SIZE {ERROR} imperative
+	  { ( NOT {ON} SIZE )? NOT {ON} SIZE ERROR (statement)+ }
+
+	| NOT {ON} SIZE {ERROR} imperative
+	  { ( {ON} SIZE )? {ON} SIZE ERROR (statement)+ }
 	;
-second_size_line
-	: {{NOT} {ON} SIZE ERROR imperative}
-	;
-/*
-	: ({NOT} {ON} SIZE ERROR imperative)?
-	|
-	;
-*/
+
diff -Naur Cobol2C/src/cob-lex.l Cobol2C.new/src/cob-lex.l
--- Cobol2C/src/cob-lex.l	Thu Dec 11 09:05:46 1997
+++ Cobol2C.new/src/cob-lex.l	Sat Oct 30 09:35:58 1999
@@ -382,6 +382,7 @@
 "<"				{ ErrLine = zzline; return(LESSSIGN); }
 ">="				{ ErrLine = zzline; return(GESIGN); }
 "<="				{ ErrLine = zzline; return(LESIGN); }
+":"				{ ErrLine = zzline; return(COLON); }
 
 ("picture"|"pic")[\t ]		{ BEGIN PICSTATE; return(PICTURE); }
 <PICSTATE>{dot}({notdot}+({reps})?)+	|
diff -Naur Cobol2C/src/cob-nonterminals.g Cobol2C.new/src/cob-nonterminals.g
--- Cobol2C/src/cob-nonterminals.g	Thu Dec 11 09:01:21 1997
+++ Cobol2C.new/src/cob-nonterminals.g	Sun Oct 31 16:06:07 1999
@@ -9,10 +9,36 @@
 	>>
 	;
 
-ident   : PROG_NAME <<  CheckIdentLen(zzlextext);
+identifier
+	: ident (qualifier)*
+		( (OPAREN arith_expr COLON)? refmod	
+		| 	( (OPAREN)? subscripts { refmod }
+			|
+			)
+		)
+	;
+
+ident   
+	: PROG_NAME <<  CheckIdentLen(zzlextext);
 			strcpy(Ident, zzlextext); >> 
 	;
 
+qualifier
+	: ( OF | IN ) ident 
+	;
+
+subscripts
+	: OPAREN (subscript)+ CPAREN
+	;
+
+refmod
+	: OPAREN arith_expr COLON { arith_expr } CPAREN
+	;
+
+subscript
+	: (ident ( qualifier )* { (PLUS|MINUS) integer } | integer) 
+	;
+
 string_literal
 	: NONNUMERIC << /*CheckIdentLen(zzlextext);*/
 			TerminalType = 'S';
@@ -53,6 +79,6 @@
 integer
 	: numeric << VerifyInteger(); >>
 	;
-cd_name
-	: ident;
+//cd_name
+//	: ident;
 
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	Sun Jul 25 15:43:05 1999
@@ -1,16 +1,16 @@
 accept_stmt
-	: ACCEPT (
-		  ident << 
-			   { int rv = emit_accept(Ident); 
-			     if (rv != 0) ErrUndefVar(Ident);
-			   }
-			>>
-		  { FROM ident }
-		    /* from mnemonic name */
-        	| ident FROM ( DAY_OF_WEEK << emit_accept_dow(Ident); >>
-			    | DATE << emit_accept_date(Ident); >>
-			    | DAY  << emit_accept_day(Ident); >>
-			    | TIME << emit_accept_time(Ident); >>
-			    )
-		)
+	: ACCEPT identifier 
+	  ( FROM 
+	    ( DAY_OF_WEEK << emit_accept_dow(Ident); >>
+	    | DATE << emit_accept_date(Ident); >>
+	    | DAY  << emit_accept_day(Ident); >>
+	    | TIME << emit_accept_time(Ident); >>
+	    | ident /* from mnemonic name */
+	    )
+	  | // vanilla accept
+	    << { int rv = emit_accept(Ident); 
+		 if (rv != 0) ErrUndefVar(Ident);
+	       }
+	    >>
+	  )
         ;      
diff -Naur Cobol2C/src/verb-add.g Cobol2C.new/src/verb-add.g
--- Cobol2C/src/verb-add.g	Thu Dec 11 09:01:21 1997
+++ Cobol2C.new/src/verb-add.g	Sun Jul 25 12:20:18 1999
@@ -1,54 +1,19 @@
 
 add_stmt
-	: add_main
-	  add_sizing
-	  add_ending
+	: ADD 
+	  ( CORR identifier TO identifier { ROUNDED }
+	  |  ( identifier | numeric )+
+	     ( giving_phrase   	
+	     ! TO ( identifier | numeric ) giving_phrase
+	     | TO ( identifier { ROUNDED } )+
+	     )
+	  )
+	  { size_err }
+	  { END_ADD }
 	  << /*VerbAddActions(); */>>
 	;
-add_main
-	: ADD_C ident1_line TO ident2_line
-	;
-ident1_line
-	: {CORR << SetFlag(&verb_flags, ADD_CORR); >>}
-		( ident << Enqueue(arg1, Ident); >>
-		| numeric << Enqueue(arg2, Numeric_s); >>
-		)+
-	;
-ident2_line
-	: ( ( ident {ROUNDED << SetFlag(&verb_flags, ROUNDED); >>} 
-		<<	Enqueue(arg2, Ident); 
-			ClearFlag(&verb_flags, ROUNDED); 
-		>>
-	    )+ 
-	  | numeric /*<< Enqueue(arg2, Numeric_s); >>*/
-	  ) { giving_line }
-	;
-/*
-	: (( ident {ROUNDED} )+)?
-	| ( ident | numeric ) giving_line
-	;
-*/
-giving_line
-	: GIVING (ident {ROUNDED << SetFlag(&verb_flags, ROUNDED); >>}
-			<<	Enqueue(giving, Ident); 
-				ClearFlag(&verb_flags, ROUNDED); 
-			>>
-		 )+
-	;
 
-add_sizing
-	: {size_err}
+giving_phrase
+	: GIVING ( identifier { ROUNDED } )+
 	;
-/*
-	: (size_err)?
-	| 
-	;
-*/
-add_ending
-	: {END_ADD}
-	;
-/*
-	: (END_ADD)?
-	|
-	;
-*/
+
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	Sun Jul 25 15:21:42 1999
@@ -1,31 +1,13 @@
 
 compute_stmt
-	: COMPUTE (ident << VerifyIdent(Ident); >>
-		    {ROUNDED << SetFlag(&verb_flags, VERB_ROUNDED); >>}
+	: COMPUTE (identifier << VerifyIdent(Ident); >>
+		    { ROUNDED << SetFlag(&verb_flags, VERB_ROUNDED); >> }
 		   <<	Enqueue(arg1, Ident); 
 			ClearFlag(&verb_flags, VERB_ROUNDED);
 		   >>
 		  )+ 
 		  (EQUALSIGN | EQUAL) << ExprInit(); >> arith_expr
-	  compute_sizing
-	  compute_ending
-	<< ComputeActions(); 
-	   ExprStringDelete();
-	>>
+	  { ( {NOT} {ON} SIZE)? size_err }
+	  { ( END_COMPUTE )? END_COMPUTE }
+	<< ComputeActions(); ExprStringDelete(); >>
 	;
-compute_sizing
-	: {size_err}
-	;
-/*
-	: (size_err)?
-	|
-	;
-*/
-compute_ending
-	: {END_COMPUTE}
-	;
-/*
-	: (END_COMPUTE)?
-	|
-	;
-*/
diff -Naur Cobol2C/src/verb-copy.g Cobol2C.new/src/verb-copy.g
--- Cobol2C/src/verb-copy.g	Thu Dec 11 09:01:21 1997
+++ Cobol2C.new/src/verb-copy.g	Sun Jul 25 12:50:22 1999
@@ -9,8 +9,8 @@
 
 /***
  {(OF | IN) library_name}
-	  { REPLACING ( (ident | numeric | string_literal | pseudo_text )
-			BY (ident | numeric | string_literal | pseudo_text) )+
+	  { REPLACING ( (identifier | numeric | string_literal | pseudo_text )
+			BY (identifier | numeric | string_literal | pseudo_text) )+
 	;
 replace_stmt
 	: REPLACE ( (pseudo_text BY pseudo_text)+
diff -Naur Cobol2C/src/verb-display.g Cobol2C.new/src/verb-display.g
--- Cobol2C/src/verb-display.g	Thu Dec 11 09:01:21 1997
+++ Cobol2C.new/src/verb-display.g	Sun Jul 25 12:50:21 1999
@@ -1,5 +1,5 @@
 display_stmt
-	: DISPLAY (ident << VerifyIdent(Ident); emit_display_ident(Ident); >>
+	: DISPLAY (identifier << VerifyIdent(Ident); emit_display_ident(Ident); >>
 		| numeric << emit_display_literal(Numeric_s); >>
 		| string_literal << emit_display_literal(StringLiteral); >>
 		)+
@@ -9,7 +9,7 @@
 	<< emit_display_advance(0); >>
 	;
 upon_line
-	: UPON ident 
+	: UPON identifier 
 	<< WarnNotImpl("UPON"); >>
 	/* ident => mnemonic_name */
 	;
diff -Naur Cobol2C/src/verb-divide.g Cobol2C.new/src/verb-divide.g
--- Cobol2C/src/verb-divide.g	Thu Dec 11 09:01:21 1997
+++ Cobol2C.new/src/verb-divide.g	Sun Jul 25 13:09:54 1999
@@ -1,25 +1,10 @@
 
 divide_stmt
-	: DIVIDE (ident | numeric)
-	  div2_line
-	  div_sizing
-	  div_ending
-	;
-div_sizing
-	: (size_err)?
-	|
-	;
-div_ending
-	: (END_DIVIDE)?
-	|
-	;
-div2_line
-	: (INTO | BY) ((ident {ROUNDED})+ | numeric)
-	  { div_giving_line } { remainder_clause }
-	;
-div_giving_line
-	: GIVING (ident {ROUNDED})+
-	;
-remainder_clause
-	: REMAINDER ident
+	: DIVIDE (identifier | numeric)
+	  ( INTO | BY ) (identifier | numeric) 
+	  GIVING identifier { ROUNDED }
+	  { REMAINDER identifier }
+     	  { size_err }
+	  { END_DIVIDE }
 	;
+
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	Sun Jul 25 16:36:00 1999
@@ -1,6 +1,7 @@
 
 go_stmt
-	: GO {TO} (ident /* procedure name */
-		  |(ident)+ DEPENDING {ON} ident
+	: GO {TO} (((identifier)+ DEPENDING)? 
+		    (identifier)+ DEPENDING {ON} identifier
+		  | identifier /* 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	Sun Jul 25 16:42:11 1999
@@ -6,19 +6,17 @@
 	: IF_C << emit_if_start(); >> 
 	  condition {THEN} << emit_if_block(); >>
 		( NEXT SENTENCE << emit_if_next_sentence(); >>
-		| (statement)+ ) << emit_if_end(); >>
-	  else_clause
+		| ((statement)? statement)* 
+		) << emit_if_end(); >>
+	  { ( ELSE_C )? else_clause }
+          { ( END_IF )? END_IF }
 	;
 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 << emit_else_start(); >> 
+		( NEXT SENTENCE << emit_else_next_sentence(); >>
+		| ((statement)? statement)* << emit_else_end(); >>
+		)
 	;
-
-
 
 /*
 if_stmt
diff -Naur Cobol2C/src/verb-initialize.g Cobol2C.new/src/verb-initialize.g
--- Cobol2C/src/verb-initialize.g	Thu Dec 11 09:01:22 1997
+++ Cobol2C.new/src/verb-initialize.g	Sun Jul 25 16:46:29 1999
@@ -1,6 +1,6 @@
 
 initialize_stmt
-	: INITIALIZE (ident)+
+	: INITIALIZE (identifier)+
 	  { replacing_line }
 	;
 replacing_line
@@ -11,5 +11,5 @@
 		|ALPHANUMERIC_EDITED | NUMERIC_EDITED)
 	;
 new_type
-	: (ident | numeric | string_literal)
+	: (identifier | numeric | string_literal)
 	;
diff -Naur Cobol2C/src/verb-inspect.g Cobol2C.new/src/verb-inspect.g
--- Cobol2C/src/verb-inspect.g	Thu Dec 11 09:01:22 1997
+++ Cobol2C.new/src/verb-inspect.g	Sun Jul 25 16:50:54 1999
@@ -1,26 +1,28 @@
 inspect_stmt
-	: INSPECT ident (tallying_clause | replacing_clause
-			    |converting_clause)
-	;
-inspect_arg
-	: (ident | NUMERIC | string_literal) 
+	: INSPECT identifier ( tallying_clause 
+			     | converting_clause
+			     | replacing_clause
+			     )
 	;
 tallying_clause
-	: TALLYING (ident FOR_C (char_clause | leading_clause))+
+	: TALLYING (identifier FOR_C (char_clause | leading_clause))+
 	;
 converting_clause
 	: CONVERTING inspect_arg TO inspect_arg
 		(before_after_clause)*
 	;
+replacing_clause
+	: REPLACING (char_by_clause | all_leading_first)
+	;
+inspect_arg
+	: (identifier | NUMERIC | string_literal) 
+	;
 char_clause
 	: CHARACTERS ( before_after_clause )*
 	;
 
 leading_clause
 	: (ALL | LEADING) ( inspect_arg (before_after_clause)* )+
-	;
-replacing_clause
-	: REPLACING (char_by_clause | all_leading_first)
 	;
 char_by_clause
 	: CHARACTERS BY inspect_arg (before_after_clause)*
diff -Naur Cobol2C/src/verb-move.g Cobol2C.new/src/verb-move.g
--- Cobol2C/src/verb-move.g	Thu Dec 11 09:01:22 1997
+++ Cobol2C.new/src/verb-move.g	Sun Jul 25 16:56:50 1999
@@ -1,11 +1,11 @@
 move_stmt
-        : MOVE ( CORR ident TO ident
-		| ( ident << TerminalType = GetSymbolType(Ident); 
-			     strcpy(move_src, Ident);
-			  >>
-		  | numeric <<	strcpy(move_src, Numeric_s); >>
-		  | string_literal << strcpy(move_src, StringLiteral); >>
-		  )
-			TO ( ident << VerifyEmitMove(Ident); >> )+
-	       )
+        : MOVE ( CORR identifier TO identifier
+	       | ( identifier << TerminalType = GetSymbolType(Ident); 
+			         strcpy(move_src, Ident);
+			      >>
+		 | numeric <<	strcpy(move_src, Numeric_s); >>
+		 | string_literal << strcpy(move_src, StringLiteral); >>
+		 )
+		 TO ( identifier << VerifyEmitMove(Ident); >> )+
+               )
         ;       
diff -Naur Cobol2C/src/verb-mult.g Cobol2C.new/src/verb-mult.g
--- Cobol2C/src/verb-mult.g	Thu Dec 11 09:01:22 1997
+++ Cobol2C.new/src/verb-mult.g	Sun Jul 25 13:32:02 1999
@@ -1,29 +1,11 @@
 multiply_stmt
-	: MULTIPLY (ident | numeric)
-	  mult2_line
-	  mult_sizing
-	  mult_ending
-	;
-mult_sizing
-	: {size_err}
-	;
-/*
-	: (size_err)?
-	|
-	;
-*/
-mult_ending
-	: {END_MULTIPLY}
-	;
-/*
-	: (END_MULTIPLY)?
-	|
-	;
-*/
-mult2_line
-	: BY ((ident {ROUNDED})+ | numeric)
-	  { div_giving_line }
-	;
-mult_giving_line
-	: GIVING (ident {ROUNDED})+
+	: MULTIPLY (identifier | numeric) BY
+	    ( numeric giving_phrase
+	    | identifier
+	      ( giving_phrase
+	      | { ROUNDED } ( identifier { ROUNDED } )*
+	      )
+	    )
+	  { size_err }
+	  { END_MULTIPLY }
 	;
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	Sun Jul 25 12:50:15 1999
@@ -1,13 +1,15 @@
 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_times_line 
-	    | { perform_test_line } perform_until_line 
+	  ( (perform_proc_phrase)?  perform_proc_phrase
+		( perform_times_phrase
+		| { perform_test_phrase } perform_until_phrase
+		|
+		)
+	  | ( perform_times_phrase 
+	    | { perform_test_phrase } perform_until_phrase 
 	    ) 
-	    perform_imperative_line
+	    perform_imperative_phrase
 		<< strcpy(PerformParagraph, ""); >>
 	  )
 	<< { int rv=0; 
@@ -21,26 +23,26 @@
 	   }
 	>>
 	;
-perform_proc_line
-	: ident << strcpy(PerformParagraph, Ident); >>
+perform_proc_phrase
+	: identifier << strcpy(PerformParagraph, Ident); >>
 	;
-perform_imperative_line
+perform_imperative_phrase
 	: imperative END_PERFORM
         ;
-perform_times_line
-	: ( ident << VerifyIdentType(Ident, 'N');
+perform_times_phrase
+	: ( identifier << VerifyIdentType(Ident, 'N');
 		     emit_perform_times(Ident, 0);
 		  >> 
 	  | integer << emit_perform_times(Numeric_s, 1); >>
 	  ) 
 	  TIMES
 	;
-perform_test_line
+perform_test_phrase
 	: {WITH} TEST ( BEFORE 
 		      | AFTER  << SetFlag(&verb_flags, PERFORM_AFTER); >>
 		      )
 	;
-perform_until_line
+perform_until_phrase
 	: << if (verb_flags & PERFORM_AFTER)
 		emit_perform_loop_after();
 	     else
@@ -50,15 +52,16 @@
 	UNTIL condition << emit_perform_loop_end(); >>
 	;
 
-perform_varying_line
-	: VARYING (ident | index_name) 
-	  perform_from_line
-	  perform_by_line
+perform_varying_phrase
+	: VARYING (identifier | index_name) 
+	  perform_from_phrase
+	  perform_by_phrase
 		<< WarnNotImpl("VARYING clause"); >>
 	;
-perform_from_line
-	: FROM (ident | index_name | numeric)
+perform_from_phrase
+	: FROM (identifier | numeric)
+//	: FROM (ident | index_name | numeric)
 	;
-perform_by_line
-	: BY (ident | numeric) UNTIL condition
+perform_by_phrase
+	: BY (identifier | numeric) UNTIL condition
 	;
diff -Naur Cobol2C/src/verb-read.g Cobol2C.new/src/verb-read.g
--- Cobol2C/src/verb-read.g	Thu Dec 11 09:01:22 1997
+++ Cobol2C.new/src/verb-read.g	Sun Jul 25 12:50:14 1999
@@ -1,6 +1,6 @@
 
 read_stmt
-	: READ file_name {NEXT} {RECORD} {INTO ident}
+	: READ file_name {NEXT} {RECORD} {INTO identifier}
 	  ( read_sri | read_r )
 	  { END_READ }
 	;
@@ -15,7 +15,7 @@
 */
 
 read_r
-	: { KEY {IS} ident }
+	: { KEY {IS} identifier }
 	  read_invalid_key_line
 	;
 read_invalid_key_line
diff -Naur Cobol2C/src/verb-rewrite.g Cobol2C.new/src/verb-rewrite.g
--- Cobol2C/src/verb-rewrite.g	Thu Dec 11 09:01:22 1997
+++ Cobol2C.new/src/verb-rewrite.g	Sun Jul 25 12:50:13 1999
@@ -1,6 +1,6 @@
 
 rewrite_stmt
-	: REWRITE ident {FROM ident}
+	: REWRITE identifier {FROM identifier}
 	  rewrite_ri
 	;
 rewrite_ri
diff -Naur Cobol2C/src/verb-search.g Cobol2C.new/src/verb-search.g
--- Cobol2C/src/verb-search.g	Thu Dec 11 09:01:22 1997
+++ Cobol2C.new/src/verb-search.g	Sun Jul 25 12:50:13 1999
@@ -6,7 +6,7 @@
 	  {END_SEARCH}
 	;
 std_search
-	: ident {VARYING (ident | index_name)}
+	: identifier {VARYING (identifier | index_name)}
 	  {at_end}
 	  (when_line)+
 	;
@@ -14,7 +14,7 @@
 	: WHEN condition (imperative | NEXT SENTENCE)
 	;
 search_all
-	: ALL ident {at_end}
+	: ALL identifier {at_end}
 	  when2_line
 	  ( and_line )*
 	  (imperative | NEXT SENTENCE)
@@ -30,7 +30,7 @@
 	      )
 	;
 eq_clause
-	: ident eq_line (ident | string_literal | numeric | arith_expr)
+	: identifier eq_line (identifier | string_literal | numeric | arith_expr)
 	;
 eq_line
 	: {IS} geneq
diff -Naur Cobol2C/src/verb-set.g Cobol2C.new/src/verb-set.g
--- Cobol2C/src/verb-set.g	Thu Dec 11 09:01:22 1997
+++ Cobol2C.new/src/verb-set.g	Sun Jul 25 12:50:12 1999
@@ -7,14 +7,14 @@
 	      )
 	;
 set_line1
-	: (index_name | ident)+ TO (index_name | ident | numeric |
+	: (index_name | identifier)+ TO (index_name | identifier | numeric |
 		string_literal)
 	;
 set_line2
-	: (index_name)+ (UP BY | DOWN BY) (ident | integer)
+	: (index_name)+ (UP BY | DOWN BY) (identifier | integer)
 	;
 set_line3
-	: ( (ident)+ TO (ON | OFF) )+
+	: ( (identifier)+ TO (ON | OFF) )+
 	;
 set_line4
 	: (condition)+ TO TRUE_C
diff -Naur Cobol2C/src/verb-start.g Cobol2C.new/src/verb-start.g
--- Cobol2C/src/verb-start.g	Thu Dec 11 09:01:22 1997
+++ Cobol2C.new/src/verb-start.g	Sun Jul 25 12:50:11 1999
@@ -6,5 +6,5 @@
 	  {END_START}
 	;
 key_line
-	: KEY {IS} (geneq | gengt | {NOT} genlt | genge) ident
+	: KEY {IS} (geneq | gengt | {NOT} genlt | genge) identifier
 	;
diff -Naur Cobol2C/src/verb-string.g Cobol2C.new/src/verb-string.g
--- Cobol2C/src/verb-string.g	Thu Dec 11 09:01:22 1997
+++ Cobol2C.new/src/verb-string.g	Sun Jul 25 12:50:11 1999
@@ -1,13 +1,13 @@
 
 string_stmt
 	: STRING ( string_delim_line )+
-	  INTO ident
-	  { {WITH} POINTER ident }
+	  INTO identifier
+	  { {WITH} POINTER identifier }
 	  { on_overflow }
 	  { not_on_overflow }
 	  {END_STRING}
 	;
 string_delim_line
-	: (ident | string_literal)+ DELIMITED {BY}
-			(ident | string_literal | numeric | SIZE)
+	: (identifier | string_literal)+ DELIMITED {BY}
+			(identifier | string_literal | numeric | SIZE)
 	;
diff -Naur Cobol2C/src/verb-subtract.g Cobol2C.new/src/verb-subtract.g
--- Cobol2C/src/verb-subtract.g	Thu Dec 11 09:01:22 1997
+++ Cobol2C.new/src/verb-subtract.g	Sun Jul 25 12:22:29 1999
@@ -1,38 +1,14 @@
 
 subtract_stmt
-	: subtract_main
-	  subtract_sizing
-	  subtract_ending
-	;
-subtract_sizing
-	: {size_err}
-	;
-/*
-	: (size_err)?
-	|
-	;
-*/
-subtract_ending
-	: {END_SUBTRACT}
-	;
-/*
-	: (END_SUBTRACT)?
-	|
-	;
-*/
-subtract_main
-	: SUBTRACT sub_ident1_line FROM sub_ident2_line
-	;
-sub_ident1_line
-	: {CORR} (ident | numeric)+
-	;
-sub_ident2_line
-	: ( (ident {ROUNDED})+ | numeric ) {sub_giving_line}
-	;
-/* Not using this b/c caused errors w/ giving clause  11-25-97
-	: (( ident {ROUNDED} )+)?
-	| ( ident | numeric ) sub_giving_line
-*/
-sub_giving_line
-	: GIVING (ident {ROUNDED})+
+	: SUBTRACT
+	  ( CORR identifier FROM identifier { ROUNDED }
+	  |  ( identifier | numeric )+
+	     ( giving_phrase   	
+	     ! FROM ( identifier | numeric ) giving_phrase
+	     | FROM ( identifier { ROUNDED } )+
+	     )
+	  )
+	  { ( {NOT} {ON} SIZE )? size_err }
+	  { ( END_SUBTRACT)? END_SUBTRACT }
 	;
+
diff -Naur Cobol2C/src/verb-unstring.g Cobol2C.new/src/verb-unstring.g
--- Cobol2C/src/verb-unstring.g	Thu Dec 11 09:01:22 1997
+++ Cobol2C.new/src/verb-unstring.g	Sun Jul 25 12:50:09 1999
@@ -1,22 +1,22 @@
 
 unstring_stmt
-	: UNSTRING ident { unstring_delim_line }
+	: UNSTRING identifier { unstring_delim_line }
 	  { unstring_into_line }
-	  { {WITH} POINTER ident }
-	  { TALLYING {IN} ident }
+	  { {WITH} POINTER identifier }
+	  { TALLYING {IN} identifier }
 	  { on_overflow }
 	  { not_on_overflow }
 	  { END_UNSTRING }
 	;
 unstring_into_line
-	: INTO ( ident 
-		 {DELIMITER {IN} ident}
-		 {COUNT {IN} ident}
+	: INTO ( identifier 
+		 {DELIMITER {IN} identifier}
+		 {COUNT {IN} identifier}
 	       )+
 	;
 unstring_delim_line
 	: DELIMITED {BY} {ALL} delim_arg ( OR {ALL} delim_arg )*
 	;
 delim_arg
-	: (ident | string_literal | numeric)
+	: (identifier | string_literal | numeric)
 	;
diff -Naur Cobol2C/src/verb-write.g Cobol2C.new/src/verb-write.g
--- Cobol2C/src/verb-write.g	Thu Dec 11 09:01:22 1997
+++ Cobol2C.new/src/verb-write.g	Sun Jul 25 12:50:07 1999
@@ -1,6 +1,6 @@
 
 write_stmt
-	: WRITE ident /* was record_name */ {FROM ident}
+	: WRITE identifier /* was record_name */ {FROM identifier}
 	   ( write1 | write2 )
 	  {END_WRITE}
 	;

~~~~~~~~~~ the make file ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# COBOL compiler makefile
# uses Purdue Compiler-Construction Tool Set (PCCTS)
#
# Start Date: 6/10/97

.SILENT:
#
# Shell env.
SHELL=/bin/csh -f 
# directory with *.h files for pccts
#CWD=Cobol2C
#CWD=dev
CWD=$(notdir $(PWD))

PCCTS=/usr/include/pccts
PCCTS_H=$(PCCTS)
#GPL=/umr/u/slaught/p/333/libgpl
GPL_H=gpl
GPL_L=gpl

#binaries
#ifeq ("$(shell /umr/bin/umr_arch)","solaris")
ANTLER=/usr/bin/antlr
#else
#ifeq ("$(shell /umr/bin/umr_arch)","hpux10")
#ANTLER=/umr/u/slaught/bin/HP-UX-B.10.20/antlr
#else
#ANTLER=
#endif
#endif

FLEX=flex
CC=gcc
LD=gcc

# antlr flags
AFLAGS=-e3 -k 1 -w1 -gl -gs -gk
APFLAGS=-e1 -k 1 -p
# dlg flags
DFLAGS=-ci
# compiler flags
CFLAGS= -I$(PCCTS_H) -I. -Iemit -Isym -Istack -Iqueue -Isrc -I$(GPL_H)
LDFLAGS=$(CFLAGS) 
LIBS=-lm -L $(GPL_L) -lgpl2
FLFLAGS=-i

FLEX_L=cob-lex.l
FLEX_C=$(FLEX_L:.l=.c)
FLEX_O=$(FLEX_C:.c=.o)

# grammar files
GF=cob-main.g  cob-nonterminals.g cob-stmts.g
GFC=${GF:.g=.c}
GFO=${GFC:.c=.o}

ID_FILES=div-id.g div-env.g sec-io.g div-data.g div-proc.g 
clause-file-control.g clause-file-descr.g clause-record-descr.g 
clause-condition.g clause-size-err.g clause-arithmetic.g clause-relation.g 
clause-keys.g clause-end.g
ID_FILES_C=$(ID_FILES:.g=.c)
ID_FILES_O=$(ID_FILES_C:.c=.o)

ENV_FILES=verb-accept.g verb-add.g verb-compute.g verb-copy.g verb-display.g 
verb-divide.g verb-go.g verb-if.g verb-initialize.g verb-move.g verb-mult.g 
verb-subtract.g verb-stop.g verb-perform.g
ENV_FILES_C=$(ENV_FILES:.g=.c)
ENV_FILES_O=$(ENV_FILES_C:.c=.o)

LAST_FILE_G=cob-stmts.g
LAST_FILE_C=$(LAST_FILE_G:.g=.c)
LAST_FILE_O=$(LAST_FILE_C:.c=.o)

SUPPORT_FILES_C=c-support.c c-errors.c c-vars.c c-types.c
SUPPORT_FILES_O=$(SUPPORT_FILES_C:.c=.o)

GRAMMAR=$(GF) $(ID_FILES) $(ENV_FILES) $(LAST_FILE_G)
GRAMMAR_C=$(GFC) $(ID_FILES_C) $(ENV_FILES_C) $(LAST_FILES_C)
GRAMMAR_O=$(GFO) $(ID_FILES_O) $(ENV_FILES_O) $(LAST_FILE_O)

EMIT_O=emit/emit.o emit/emit_impl.o
SYM_O=sym/symtable.o
STACK_O=stack/stack.o
QUEUE_O=queue/queue.o

CHAD_O=$(EMIT_O) $(SYM_O) $(STACK_O) $(QUEUE_O)

# generated files
SCAN=scan
ERROR=err
ERROR_C=err.c
ERROR_O=err.o

# output file
PROGRAM=cobol2c

.SUFFIXES	: .o .c .g

VPATH=src 

VERSION=1.0

start: printbanner
	@$(MAKE) all || $(MAKE) all || $(MAKE) all

run: start
	cobol p.cbl

printbanner: FORCE
	@echo Building Cobol2C package...


all: cpfiles gpl emit sym stack queue $(GRAMMAR_C) $(PROGRAM) cobolpp
	@echo Package Build complete.

$(PROGRAM):$(SUPPORT_FILES_O) $(GRAMMAR_O) $(CHAD_O) $(FLEX_O) $(ERROR_O) 
dlgflex.o
	@$(LD) $(LDFLAGS) -o $(PROGRAM) $^ $(LIBS)
	@echo Cobol2c - Translator Built.
	
dlgflex.o: dlgflex.c ZZLEXBUFSIZE.h LL_K.h setNLA.h
	@$(CC) $(CFLAGS) -c src/dlgflex.c -o dlgflex.o

#
# Added by cms
c-support.o:c-support.c 
	@$(CC) $(CFLAGS) -Wall -c $<

c-vars.o:c-vars.c
	@$(CC) $(CFLAGS) -Wall -c $<

c-errors.o:c-errors.c 
	@$(CC) $(CFLAGS) -Wall -c $<

c-types.o:c-types.c
	@$(CC) $(CFLAGS) -Wall -c $<
	
#$(SUPPORT_FILES_O): $(SUPPORT_FILES_C) c-global.h
#	$(CC) $(CFLAGS) -c $(<:.o=.c)   
#
#.g.c:
#	$(ANTLER) $(AFLAGS) $< 

.c.o: ZZLEXBUFSIZE.h LL_K.h
	@$(CC) $(CFLAGS) -w -c $< -o $(<:.c=.o)

$(FLEX_C): $(FLEX_L) tokens_only.h
	@$(FLEX) $(FLFLAGS) -o$(FLEX_C) $^
	
ZZLEXBUFSIZE.h:
	@grep "#define ZZLEXBUFSIZE" $(PCCTS_H)/antlr.h \
	 > ZZLEXBUFSIZE.h

tokens_only.h: $(GRAMMAR_C)
	@grep define tokens.h > tokens_only.h

LL_K.h: $(GRAMMAR_C)
	@grep "LL_K" parser.dlg > LL_K.h

$(GRAMMAR_C): $(GRAMMAR) 
#	@$(ANTLER) $(AFLAGS)  -o $(PWD) $^ >&/dev/null
	@$(ANTLER) $(AFLAGS)  -o $(PWD) $^ >& /tmp/antlr.log
	@echo "Expect to see a make error about err.o. Just ignore it."

emit: dummy
	@cd emit;$(MAKE) emitobj ;cd ..
sym: dummy
	@cd sym;$(MAKE) symtable.o;cd ..
stack: dummy
	@cd stack;$(MAKE) stack.o; cd ..
queue: dummy
	@cd queue;$(MAKE) queue.o; cd ..
cobolpp: dummy
	@cd cobolpp;$(MAKE) ;cd ..
gpl: dummy
	@cd gpl;$(MAKE);cd ..

# used to always run make on subdir modules
dummy:
	
FORCE:
	
	
cvs: 
	@cvs co emit
	@cvs co sym
	@cvs co stack
	@cvs co queue
	@cvs co cobolpp
	@cvs co gpl
	@cvs co src


install:
	@if (! -d bin ) then; mkdir bin;endif
#	@if [ ! -d bin ]; then mkdir bin; fi
	@cp ./cobol2c bin
	@cp cobolpp/cobpp bin
	@cp devmake/cobol.sh bin/cobol
	@echo Install Complete.

cpfiles:
	@touch mode.h

clean:
	-@rm -rf bin
	-@cd sym;  $(MAKE) clean;cd ..
	-@cd emit; $(MAKE) clean;cd ..
	-@cd stack;$(MAKE) clean;cd .. 
	-@cd queue;$(MAKE) clean; cd ..
	-@cd cobolpp;$(MAKE) clean; cd ..
	-@cd gpl;$(MAKE) clean; cd ..
	-@rm -f $(GRAMMAR_C) $(GRAMMAR_O)  $(ERROR_C) $(ERROR_O)\
		$(LAST_FILE_C)  $(LAST_FILE_O)
	-@rm -f $(PROGRAM) dlgflex.o parser.dlg
	-@rm -f $(FLEX_C) $(FLEX_O)
	-@rm -f LL_K.h ZZLEXBUFSIZE.h mode.h setNLA.h tokens.h tokens_only.h
	-@rm -f *.c *.h *.o
	-@rm -f src/*.o 






--
This message was sent through the gnu-cobol mailing list.  To remove yourself
from this mailing list, send a message to majordomo@lusars.net with the
words "unsubscribe gnu-cobol" in the message body.  For more information on
the GNU COBOL project, send mail to gnu-cobol-owner@lusars.net.