fix some identification

This commit is contained in:
vel 2024-11-07 10:44:19 -08:00
parent 243faa8e15
commit 363f816531
Signed by: velvox
GPG Key ID: 59D9762F674151DF
2 changed files with 23 additions and 19 deletions

View File

@ -10,7 +10,7 @@ int yylex();
%define parse.error detailed %define parse.error detailed
%token TOKEN_EOF %token TOKEN_EOF
%token TOKEN_IDENTIFICATION %token TOKEN_KEYWORD_IDENTIFICATION
%token TOKEN_KEYWORD_DIVISION %token TOKEN_KEYWORD_DIVISION
%token TOKEN_KEYWORD_DATA %token TOKEN_KEYWORD_DATA
%token TOKEN_KEYWORD_SECTION %token TOKEN_KEYWORD_SECTION
@ -73,26 +73,35 @@ statement : section
| data_space | data_space
| data_declaration | data_declaration
; ;
section : type TOKEN_KEYWORD_DIVISION TOKEN_DOT section : type TOKEN_KEYWORD_DIVISION TOKEN_DOT
| type TOKEN_RUN TOKEN_DOT | type TOKEN_RUN TOKEN_DOT
; ;
sect_data : TOKEN_PROGRAM_ID TOKEN_DOT TOKEN_IDENT TOKEN_DOT sect_data : TOKEN_PROGRAM_ID TOKEN_DOT TOKEN_IDENT TOKEN_DOT
; ;
type : TOKEN_IDENTIFICATION type : TOKEN_KEYWORD_IDENTIFICATION
| TOKEN_PROCEDURE | TOKEN_PROCEDURE
| TOKEN_STOP | TOKEN_STOP
| TOKEN_KEYWORD_DATA | TOKEN_KEYWORD_DATA
; ;
simple_stmt : function simple_stmt : cbl_function
| TOKEN_KEYWORD_FUNCTION cbl_function | cbl_function params
| cbl_function assignment_stmt
| cbl_function params assignment_stmt
; ;
cbl_function : TOKEN_KEYWORD_COMPUTE parms assignment_stmt : TOKEN_EQUAL ext_function
| TOKEN_KEYWORD_TO TOKEN_IDENT
| TOKEN_KEYWORD_TO TOKEN_IDENT categry_contain
; ;
function : TOKEN_DISPLAY parms params: : TOKEN_IDENT
| function simple_stmt | TOKEN_STRING
| if_branch
; ;
parms : TOKEN_STRING ext_function: : TOKEN_KEYWORD_FUNCTION TOKEN_IDENT TOKEN_LEFT_PARENTHESIS TOKEN_IDENT TOKEN_RIGHT_PARENTHESIS
;
cbl_function : TOKEN_DISPLAY
| TOKEN_MOVE
| TOKEN_KEYWORD_COMPUTE
| TOKEN_PERFORM
; ;
if_branch : if_branch parms if_branch if_branch : if_branch parms if_branch
| TOKEN_IF | TOKEN_IF
@ -111,7 +120,6 @@ data_category : TOKEN_ALPHANUMERIC
; ;
categry_contain : TOKEN_LEFT_PARENTHESIS TOKEN_INTEGER TOKEN_RIGHT_PARENTHESIS categry_contain : TOKEN_LEFT_PARENTHESIS TOKEN_INTEGER TOKEN_RIGHT_PARENTHESIS
; ;
complete_category: complete_category complete_category complete_category: complete_category complete_category
| data_category categry_contain | data_category categry_contain
; ;
@ -125,19 +133,15 @@ data_clause : TOKEN_COMPUTATION_LEVEL_0
full_data_clause: data_clause data_clause full_data_clause: data_clause data_clause
| data_clause | data_clause
; ;
data_declaration: simple_decl
| full_decl
;
simple_decl : TOKEN_INTEGER TOKEN_IDENT TOKEN_DOT simple_decl : TOKEN_INTEGER TOKEN_IDENT TOKEN_DOT
; ;
full_decl : TOKEN_INTEGER TOKEN_IDENT TOKEN_PICTURE complete_category TOKEN_DOT full_decl : TOKEN_INTEGER TOKEN_IDENT TOKEN_PICTURE complete_category TOKEN_DOT
| TOKEN_INTEGER TOKEN_IDENT TOKEN_PICTURE complete_category full_data_clause TOKEN_DOT | TOKEN_INTEGER TOKEN_IDENT TOKEN_PICTURE complete_category full_data_clause TOKEN_DOT
| TOKEN_INTEGER TOKEN_IDENT TOKEN_PICTURE complete_category full_data_clause TOKEN_INTEGER TOKEN_DOT | TOKEN_INTEGER TOKEN_IDENT TOKEN_PICTURE complete_category full_data_clause TOKEN_INTEGER TOKEN_DOT
; ;
data_declaration: simple_decl
| full_decl
;
%% %%

View File

@ -7,7 +7,7 @@ DIGIT [0-9]+
(" "|\t|\n) /* skip whitespace */ (" "|\t|\n) /* skip whitespace */
\*>\ ?.* { return TOKEN_COMMENT; } \*>\ ?.* { return TOKEN_COMMENT; }
IDENTIFICATION { return TOKEN_IDENTIFICATION; } IDENTIFICATION { return TOKEN_KEYWORD_IDENTIFICATION; }
DIVISION { return TOKEN_KEYWORD_DIVISION; } DIVISION { return TOKEN_KEYWORD_DIVISION; }
PROGRAM-ID { return TOKEN_PROGRAM_ID; } PROGRAM-ID { return TOKEN_PROGRAM_ID; }
PROCEDURE { return TOKEN_PROCEDURE; } PROCEDURE { return TOKEN_PROCEDURE; }