Skip to content

Commit

Permalink
Fix #4: rename Parser package into Lex_Parser
Browse files Browse the repository at this point in the history
- update the grammar to use Lex_Parser to avoid the same
  package name as Ayacc which conflicts when Aflex and Ayacc
  are with'ed within a same Alire project (even if both are
  built separately, gprbuild will bark when aflex.gpr and ayacc.gpr
  are included)
- rebuild the parser
  • Loading branch information
stcarrez committed May 14, 2023
1 parent b3c21d9 commit 3c2add0
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 30 deletions.
21 changes: 4 additions & 17 deletions src/parser.adb → src/lex_parser.adb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ with Parse_Tokens, Parse_Goto, Parse_Shift_Reduce, Text_IO;
with NFA, ccl, misc, misc_defs, sym, ecs, aflex_scanner;
with tstring, int_io, main_body;
use aflex_scanner;
package body parser is
package body Lex_Parser is
-- build_eof_action - build the "<<EOF>>" action for the active start
-- conditions

Expand Down Expand Up @@ -44,12 +44,8 @@ package body parser is
null;
end yyerror;

-- Warning: This file is automatically generated by AYACC.
-- It is useless to modify it. Change the ".Y" & ".L" files instead.


procedure YYParse is

-- Rename User Defined Packages to Internal Names.
package yy_goto_tables renames
Parse_Goto;
Expand All @@ -59,6 +55,7 @@ package body parser is
Parse_Tokens;

use yy_tokens, yy_goto_tables, yy_shift_reduce_tables;

procedure handle_error;

subtype goto_row is yy_goto_tables.Row;
Expand All @@ -68,7 +65,7 @@ package body parser is

-- the size of the value and state stacks
-- Affects error 'Stack size exceeded on state_stack'
stack_size : constant Natural := 300;
stack_size : constant Natural := 300;

-- subtype rule is Natural;
subtype parse_state is Natural;
Expand Down Expand Up @@ -99,7 +96,6 @@ package body parser is

-- Is Debugging option on or off
debug : constant Boolean := False;

end yy;

procedure shift_debug (state_id : yy.parse_state; lexeme : yy_tokens.Token);
Expand Down Expand Up @@ -230,20 +226,17 @@ package body parser is
& yy.parse_state'Image (state_id));
end reduce_debug;


begin
-- initialize by pushing state 0 and getting the first input symbol
yy.state_stack (yy.tos) := 0;


loop
yy.index := Shift_Reduce_Offset (yy.state_stack (yy.tos));
if Integer (Shift_Reduce_Matrix (yy.index).T) = yy.default then
yy.action := Integer (Shift_Reduce_Matrix (yy.index).Act);
else
if yy.look_ahead then
yy.look_ahead := False;

yy.input_symbol := YYLex;
end if;
yy.action := parse_action (yy.state_stack (yy.tos), yy.input_symbol);
Expand Down Expand Up @@ -273,7 +266,6 @@ package body parser is
yy.look_ahead := True;

elsif yy.action = yy.error_code then -- ERROR

handle_error;

elsif yy.action = yy.accept_code then
Expand All @@ -289,7 +281,6 @@ package body parser is

-- Execute User Action
-- user_action(yy.rule_id);

case yy.rule_id is
pragma Style_Checks (Off);

Expand Down Expand Up @@ -855,7 +846,6 @@ when 59 => -- #line 625

when 60 => -- #line 638
YYVal := nfa.mkstate( SYM_EPSILON );

pragma Style_Checks (On);

when others => null;
Expand All @@ -871,17 +861,14 @@ when 60 => -- #line 638
Get_LHS_Rule (yy.rule_id));

yy.value_stack (yy.tos) := YYVal;

if yy.debug then
reduce_debug (yy.rule_id,
goto_state (yy.state_stack (yy.tos - 1),
Get_LHS_Rule (yy.rule_id)));
end if;

end if;

end loop;

end YYParse;

end parser;
end Lex_Parser;
9 changes: 9 additions & 0 deletions src/lex_parser.ads
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- Warning: This file is automatically generated by AYACC.
-- It is useless to modify it. Change the ".Y" & ".L" files instead.

package Lex_Parser is
procedure build_eof_action;
procedure yyerror(msg: string);
procedure YYParse;
def_rule:integer;
end Lex_Parser;
4 changes: 2 additions & 2 deletions src/main_body.adb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
-- high level routines from other packages.
-- $Header: /dc/uc/self/arcadia/aflex/ada/src/RCS/mainB.a,v 1.26 1992/12/29 22:46:15 self Exp self $

with Misc_Defs, Misc, Command_Line_Interface, Ecs, Text_Io, Parser;
with Misc_Defs, Misc, Command_Line_Interface, Ecs, Text_Io, Lex_Parser;
with Main_Body, Tstring, Parse_Tokens, Skeleton_Manager, External_File_Manager;
with Template_Manager;
with Int_Io;
Expand Down Expand Up @@ -532,7 +532,7 @@ package body Main_Body is
end if;
Misc.Line_Directive_Out;

Parser.Yyparse;
Lex_Parser.Yyparse;

if (Useecs) then
Ecs.Cre8ecs (Nextecm, Ecgroup, Csize, Numecs);
Expand Down
8 changes: 4 additions & 4 deletions src/parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -640,18 +640,18 @@ string : string CHAR
%%
package parser is
package Lex_Parser is
procedure build_eof_action;
procedure yyerror(msg: string);
procedure YYParse;
def_rule:integer;
end parser;
end Lex_Parser;
with Parse_Tokens, Parse_Goto, Parse_Shift_Reduce, Text_IO;
with NFA, ccl, misc, misc_defs, sym, ecs, aflex_scanner;
with tstring, int_io, main_body;
use aflex_scanner;
package body parser is
package body Lex_Parser is
-- build_eof_action - build the "<<EOF>>" action for the active start
-- conditions
Expand Down Expand Up @@ -693,4 +693,4 @@ package body parser is
end yyerror;
##
end parser;
end Lex_Parser;
7 changes: 0 additions & 7 deletions src/parser.ads

This file was deleted.

0 comments on commit 3c2add0

Please sign in to comment.