fix sample
This commit is contained in:
parent
1802175103
commit
a089fe73db
|
|
@ -48,7 +48,7 @@ PROCEDURE DIVISION.
|
||||||
PERFORM VARYING WS-INDEX FROM 1 BY 1
|
PERFORM VARYING WS-INDEX FROM 1 BY 1
|
||||||
UNTIL WS-INDEX > WS-SORT-MAX
|
UNTIL WS-INDEX > WS-SORT-MAX
|
||||||
DISPLAY "Element " WS-INDEX ": " WS-SORT-ROW(WS-INDEX)
|
DISPLAY "Element " WS-INDEX ": " WS-SORT-ROW(WS-INDEX)
|
||||||
END-PERFORM.
|
END-PERFORM
|
||||||
|
|
||||||
STOP RUN.
|
STOP RUN.
|
||||||
|
|
||||||
|
|
@ -20,7 +20,7 @@ scanner.c: scanner.flex parser.h
|
||||||
flex -oscanner.c scanner.flex
|
flex -oscanner.c scanner.flex
|
||||||
|
|
||||||
parser.c parser.h: parser.bison
|
parser.c parser.h: parser.bison
|
||||||
bison --defines=parser.h --output=parser.c -v parser.bison -Wconflicts-sr -Wcounterexamples
|
bison --defines=parser.h --output=parser.c -v parser.bison
|
||||||
|
|
||||||
# clean causes all intermediate files to be deleted.
|
# clean causes all intermediate files to be deleted.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,35 @@
|
||||||
%{
|
%{
|
||||||
#define YYDEBUG 1
|
#define YYDEBUG 1
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
extern int yylineno;
|
#include <math.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "expr.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
YYSTYPE is the lexical value returned by each rule in a bison grammar.
|
||||||
|
By default, it is an integer. In this example, we are returning a pointer to an expression.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define YYSTYPE struct expr *
|
||||||
|
|
||||||
|
/*
|
||||||
|
Clunky: Manually declare the interface to the scanner generated by flex.
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern char *yytext;
|
||||||
|
extern int yylex();
|
||||||
void yyerror(const char*);
|
void yyerror(const char*);
|
||||||
int yylex();
|
|
||||||
|
/*
|
||||||
|
Clunky: Keep the final result of the parse in a global variable,
|
||||||
|
so that it can be retrieved by main().
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct expr * parser_result = 0;
|
||||||
|
|
||||||
|
|
||||||
|
extern int yylineno;
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%debug
|
%debug
|
||||||
|
|
@ -63,7 +89,9 @@ int yylex();
|
||||||
|
|
||||||
|
|
||||||
%%
|
%%
|
||||||
file : statements
|
program : statements
|
||||||
|
{ parser_result = $1; return 0;}
|
||||||
|
;
|
||||||
statements : statement_list
|
statements : statement_list
|
||||||
;
|
;
|
||||||
statement_list : statement_list statement
|
statement_list : statement_list statement
|
||||||
|
|
@ -91,7 +119,7 @@ simple_stmt : cbl_func_stmt
|
||||||
| perform_stmt
|
| perform_stmt
|
||||||
;
|
;
|
||||||
cbl_func_stmt : cbl_function
|
cbl_func_stmt : cbl_function
|
||||||
| cbl_function op_parms
|
| cbl_function op_parms
|
||||||
| cbl_function assignment_stmt
|
| cbl_function assignment_stmt
|
||||||
| cbl_function op_parm assignment_stmt
|
| cbl_function op_parm assignment_stmt
|
||||||
;
|
;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue