diff --git a/Utils/Parser Generator/BIN/ALex.exe b/Utils/Parser Generator/BIN/ALex.exe new file mode 100644 index 000000000..e320f4d9a Binary files /dev/null and b/Utils/Parser Generator/BIN/ALex.exe differ diff --git a/Utils/Parser Generator/BIN/PARGEN.HLP b/Utils/Parser Generator/BIN/PARGEN.HLP new file mode 100644 index 000000000..bb1a8fc4e Binary files /dev/null and b/Utils/Parser Generator/BIN/PARGEN.HLP differ diff --git a/Utils/Parser Generator/BIN/ParGen.cnt b/Utils/Parser Generator/BIN/ParGen.cnt new file mode 100644 index 000000000..f7cffc22e --- /dev/null +++ b/Utils/Parser Generator/BIN/ParGen.cnt @@ -0,0 +1,562 @@ +:Base ParGen.hlp +1 Parser Generator +2 How to... +3 Setup Visual C++ Version 4.00=setup_visual_cpp_version_400 +3 Setup Visual C++ Version 1.52=setup_visual_cpp_version_152 +3 Setup Borland C++ Builder Version 3.0=setup_borland_cpp_builder_version_30 +3 Setup Borland C++ Version 4.52=setup_borland_cpp_version_452 +3 Setup Other C/C++ Compilers=setup_other_c_cpp_compilers +3 Solve Common Linker Problems=solve_common_linker_problems +2 Menus +3 File Menu=menu_file +3 Edit Menu=menu_edit +3 View Menu=menu_view +3 Project Menu=menu_project +3 Options Menu=menu_options +3 Window Menu=menu_window +3 Help Menu=menu_help +2 Control Bars +3 Toolbar=AFX_HIDW_TOOLBAR +3 Status Bar=AFX_HIDW_STATUS_BAR +2 Windows +3 Editor Window=HIDR_EDITORTYPE +3 Output Window=HIDR_OUTPUTTYPE +1 Options +2 AYACC Options +3 Operation=ayacc_operation +3 -? Option=ayacc_option_question +3 -$ Option=ayacc_option_dollar +3 -E Option=ayacc_option_capital_e +3 -G Option=ayacc_option_capital_g +3 -I Option=ayacc_option_capital_i +3 -N Option=ayacc_option_capital_n +3 -R Option=ayacc_option_capital_r +3 -S Option=ayacc_option_capital_s +3 -T Option=ayacc_option_capital_t +3 -c Option=ayacc_option_c +3 -d Option=ayacc_option_d +3 -e Option=ayacc_option_e +3 -f Option=ayacc_option_f +3 -l Option=ayacc_option_l +3 -m Option=ayacc_option_m +3 -o Option=ayacc_option_o +3 -p Option=ayacc_option_p +3 -s Option=ayacc_option_s +3 -v Option=ayacc_option_v +3 -x Option=ayacc_option_x +3 -z Option=ayacc_option_z +2 ALex Options +3 Operation=alex_operation +3 -? Option=alex_option_question +3 -$ Option=alex_option_dollar +3 -E Option=alex_option_capital_e +3 -R Option=alex_option_capital_r +3 -S Option=alex_option_capital_s +3 -T Option=alex_option_capital_t +3 -c Option=alex_option_c +3 -d Option=alex_option_d +3 -e Option=alex_option_e +3 -f Option=alex_option_f +3 -i Option=alex_option_i +3 -l Option=alex_option_l +3 -m Option=alex_option_m +3 -o Option=alex_option_o +3 -r Option=alex_option_r +3 -s Option=alex_option_s +3 -t Option=alex_option_t +3 -u Option=alex_option_u +3 -x Option=alex_option_x +3 -z Option=alex_option_z +1 Errors +2 AYACC Errors +2 AYACC Errors=ayacc_errors +3 Fatal Errors +4 Fatal Error Y1001=Y1001 +4 Fatal Error Y1002=Y1002 +4 Fatal Error Y1003=Y1003 +4 Fatal Error Y1004=Y1004 +4 Fatal Error Y1005=Y1005 +4 Fatal Error Y1006=Y1006 +4 Fatal Error Y1007=Y1007 +4 Fatal Error Y1008=Y1008 +4 Fatal Error Y1009=Y1009 +4 Fatal Error Y1010=Y1010 +4 Fatal Error Y1011=Y1011 +4 Fatal Error Y1012=Y1012 +4 Fatal Error Y1013=Y1013 +4 Fatal Error Y1014=Y1014 +4 Fatal Error Y1015=Y1015 +4 Fatal Error Y1016=Y1016 +4 Fatal Error Y1017=Y1017 +4 Fatal Error Y1018=Y1018 +3 Errors +4 Error Y2001=Y2001 +4 Error Y2002=Y2002 +4 Error Y2003=Y2003 +4 Error Y2004=Y2004 +4 Error Y2005=Y2005 +4 Error Y2006=Y2006 +4 Error Y2007=Y2007 +4 Error Y2008=Y2008 +4 Error Y2009=Y2009 +4 Error Y2010=Y2010 +4 Error Y2011=Y2011 +4 Error Y2012=Y2012 +4 Error Y2013=Y2013 +4 Error Y2014=Y2014 +4 Error Y2015=Y2015 +4 Error Y2016=Y2016 +4 Error Y2017=Y2017 +4 Error Y2018=Y2018 +4 Error Y2019=Y2019 +4 Error Y2020=Y2020 +4 Error Y2021=Y2021 +4 Error Y2022=Y2022 +4 Error Y2023=Y2023 +4 Error Y2024=Y2024 +4 Error Y2025=Y2025 +4 Error Y2026=Y2026 +4 Error Y2027=Y2027 +4 Error Y2028=Y2028 +4 Error Y2029=Y2029 +4 Error Y2030=Y2030 +4 Error Y2031=Y2031 +3 Warnings +4 Warning Y4001=Y4001 +4 Warning Y4002=Y4002 +4 Warning Y4003=Y4003 +4 Warning Y4004=Y4004 +4 Warning Y4005=Y4005 +4 Warning Y4006=Y4006 +4 Warning Y4007=Y4007 +4 Warning Y4008=Y4008 +4 Warning Y4009=Y4009 +4 Warning Y4010=Y4010 +4 Warning Y4011=Y4011 +2 ALex Errors +3 ALex Errors=alex_errors +3 Fatal Errors +4 Fatal Error L1001=L1001 +4 Fatal Error L1002=L1002 +4 Fatal Error L1003=L1003 +4 Fatal Error L1004=L1004 +4 Fatal Error L1005=L1005 +4 Fatal Error L1006=L1006 +4 Fatal Error L1007=L1007 +4 Fatal Error L1008=L1008 +4 Fatal Error L1009=L1009 +4 Fatal Error L1010=L1010 +4 Fatal Error L1011=L1011 +4 Fatal Error L1012=L1012 +4 Fatal Error L1013=L1013 +4 Fatal Error L1014=L1014 +4 Fatal Error L1015=L1015 +4 Fatal Error L1016=L1016 +4 Fatal Error L1017=L1017 +4 Fatal Error L1018=L1018 +3 Errors +4 Error L2001=L2001 +4 Error L2002=L2002 +4 Error L2003=L2003 +4 Error L2004=L2004 +4 Error L2005=L2005 +4 Error L2006=L2006 +4 Error L2007=L2007 +4 Error L2008=L2008 +4 Error L2009=L2009 +4 Error L2010=L2010 +4 Error L2011=L2011 +4 Error L2012=L2012 +4 Error L2013=L2013 +4 Error L2014=L2014 +4 Error L2015=L2015 +4 Error L2016=L2016 +4 Error L2017=L2017 +4 Error L2018=L2018 +4 Error L2019=L2019 +4 Error L2020=L2020 +4 Error L2021=L2021 +3 Warnings +4 Warning L4001=L4001 +4 Warning L4002=L4002 +4 Warning L4003=L4003 +4 Warning L4004=L4004 +4 Warning L4005=L4005 +4 Warning L4006=L4006 +4 Warning L4007=L4007 +4 Warning L4008=L4008 +4 Warning L4009=L4009 +4 Warning L4010=L4010 +4 Warning L4011=L4011 +4 Warning L4012=L4012 +4 Warning L4013=L4013 +1 YACC Language +2 YACC Language=yacc_language +2 Introduction=yacc_introduction +3 Grammar Summary=yacc_grammar_summary +2 Tokens +3 Tokens=yacc_tokens +3 Keywords=yacc_keywords +3 Identifiers=yacc_identifiers +3 Character Tokens=yacc_character_tokens +3 Integers=yacc_integers +3 Tags=yacc_tags +3 Actions=yacc_actions +3 Attributes=yacc_attributes +3 Comments=yacc_comments +3 Program Code=yacc_program_code +3 Declaration Code Block=yacc_declaration_code_block +3 Code Block=yacc_code_block +3 Other Tokens=yacc_other_tokens +2 Grammar +3 Grammar=yacc_grammar +2 Declarations Section +3 Declarations Section=yacc_declarations_section +3 Token Declaration=yacc_token_declaration +3 Start Declaration=yacc_start_declaration +3 Type Declaration=yacc_type_declaration +3 Union Declaration=yacc_union_declaration +3 Name Declaration=yacc_name_declaration +3 Include Declaration=yacc_include_declaration +3 Defines=yacc_defines +2 Rules Section +3 Rules Section=yacc_rules_section +3 Grammar Rule=yacc_grammar_rule +3 Production=yacc_production +3 Grammar Symbol=yacc_grammar_symbol +3 Action Symbol=yacc_action_symbol +3 Precedence Symbol=yacc_precedence_symbol +3 Symbol Destructor Rule=yacc_symbol_destructor_rule +3 Ambiguity Resolution=yacc_ambiguity_resolution +3 Error Recovery=yacc_error_recovery +3 Operator Precedence Grammars=yacc_operator_precedence_grammars +2 Programs Section +3 Programs Section=yacc_programs_section +2 Quick Reference Topics +3 Multiple C Parsers=yacc_multiple_parsers +1 Lex Language +2 Lex Language=lex_language +2 Introduction=lex_introduction +2 Grammar Summary=lex_grammar_summary +2 Tokens +3 Keywords=lex_keywords +3 Identifiers=lex_identifiers +3 Integers=lex_integers +3 Characters=lex_characters +3 Character Strings=lex_character_strings +3 Character Classes=lex_character_classes +3 Action=lex_action +3 Separator=lex_separator +3 Comments=lex_comments +3 Program Code=lex_program_code +3 Code Block=lex_code_block +3 Code Line=lex_code_line +3 Macro Name=lex_macro_name +3 Translation String=lex_translation_string +3 Macro Reference=lex_macro_reference +3 Declaration Code Block=lex_declaration_code_block +3 Other Tokens=lex_other_tokens +2 Grammar +3 Grammar=lex_grammar +2 Declarations Section +3 Declarations Section=lex_declarations_section +3 Start Declaration=lex_start_declaration +3 Table Declaration=lex_table_declaration +3 Macro Declaration=lex_macro_declaration +3 Array Declaration=lex_array_declaration +3 Option Declaration=lex_option_declaration +3 Name Declaration=lex_name_declaration +3 Include Declaration=lex_include_declaration +3 Defines=lex_defines +2 Rules Section +3 Rules Section=lex_rules_section +3 Group Rule=lex_group_rule +3 Expression Rule=lex_expression_rule +3 Left Context=lex_left_context +3 Right Context Expression=lex_right_context_expression +3 Union Expression=lex_union_expression +3 Concatenation Expression=lex_concatenation_expression +3 Repetition Expression=lex_repetition_expression +3 Primary Expression=lex_primary_expression +3 Ambiguity Resolution=lex_ambiguity_resolution +2 Programs Section +3 Programs Section=lex_programs_section +2 Quick Reference Topics +3 Multiple C Lexical Analysers=lex_multiple_lexical_analysers +3 Operator Summary=lex_operator_summary +3 ASCII Character Set=ascii_character_set +1 YACC And Lex Library +2 YACC And Lex Library=library +2 Classes +3 Classes=classes +3 yyparser +4 yyparser=yyparser +4 yyparser Members=yyparser_members +4 yyparser Member Variables +5 yychar=yyparser_yychar +5 yydebug=yyparser_yydebug +5 yydebugflush=yyparser_yydebugflush +5 yydebugout=yyparser_yydebugout +5 yydebugstack=yyparser_yydebugstack +5 yyerr=yyparser_yyerr +5 yyerrorcount=yyparser_yyerrorcount +5 yylookahead=yyparser_yylookahead +5 yystackgrow=yyparser_yystackgrow +5 yywipeflg=yyparser_yywipeflg +4 yyparser Construction Member Functions +5 yyparser=yyparser_yyparser +5 yycreate=yyparser_yycreate +5 yydestroy=yyparser_yydestroy +4 yyparser General Member Functions +5 yycleanup=yyparser_yycleanup +5 yydestructpop=yyparser_yydestructpop +5 yyparse=yyparser_yyparse +5 yysetstacksize=yyparser_yysetstacksize +5 yysetup=yyparser_yysetup +5 yywipe=yyparser_yywipe +5 yywork=yyparser_yywork +4 yyparser Service Member Functions +5 yydiscard=yyparser_yydiscard +5 yyerror=yyparser_yyerror +5 yygettoken=yyparser_yygettoken +5 yystackoverflow=yyparser_yystackoverflow +5 yysyntaxerror=yyparser_yysyntaxerror +4 yyparser Action Member Functions +5 yyabort=yyparser_yyabort +5 yyaccept=yyparser_yyaccept +5 yyclearin=yyparser_yyclearin +5 yydestructclearin=yyparser_yydestructclearin +5 yyerrok=yyparser_yyerrok +5 yyexit=yyparser_yyexit +5 yyforceerror=yyparser_yyforceerror +5 yypopping=yyparser_yypopping +5 yyrecovering=yyparser_yyrecovering +5 yyretire=yyparser_yyretire +5 yysetin=yyparser_yysetin +5 yythrowerror=yyparser_yythrowerror +5 yyunclearin=yyparser_yyunclearin +3 yyfparser +4 yyfparser=yyfparser +3 yycparser +4 yycparser=yycparser +3 yylexer +4 yylexer=yylexer +4 yylexer Members=yylexer_members +4 yylexer Member Variables +5 yyin=yylexer_yyin +5 yyeol=yylexer_yyeol +5 yydebug=yylexer_yydebug +5 yydebugout=yylexer_yydebugout +5 yyerr=yylexer_yyerr +5 yyleng=yylexer_yyleng +5 yylineno=yylexer_yylineno +5 yyout=yylexer_yyout +5 yystart=yylexer_yystart +5 yytext=yylexer_yytext +5 yytextgrow=yylexer_yytextgrow +5 yyunputgrow=yylexer_yyunputgrow +4 yylexer Construction Member Functions +5 yylexer=yylexer_yylexer +5 yycreate=yylexer_yycreate +5 yydestroy=yylexer_yydestroy +4 yylexer General Member Functions +5 yycleanup=yylexer_yycleanup +5 yylex=yylexer_yylex +5 yyreset=yylexer_yyreset +5 yysettextsize=yylexer_yysettextsize +5 yysetunputsize=yylexer_yysetunputsize +4 yylexer Service Member Functions +5 yygetchar=yylexer_yygetchar +5 yyinput=yylexer_yyinput +5 yyoutput=yylexer_yyoutput +5 yytextoverflow=yylexer_yytextoverflow +5 yyunput=yylexer_yyunput +5 yyunputoverflow=yylexer_yyunputoverflow +5 yywrap=yylexer_yywrap +4 yylexer Action Member Functions +5 yybegin=yylexer_yybegin +5 yyecho=yylexer_yyecho +5 yyless=yylexer_yyless +5 yymore=yylexer_yymore +5 yynewline=yylexer_yynewline +5 yyreject=yylexer_yyreject +5 yyunputcount=yylexer_yyunputcount +3 yyflexer +4 yyflexer=yyflexer +3 yyclexer +4 yyclexer=yyclexer +2 Functions +3 Functions=functions +3 Parser Instance Functions +4 Parser Instance Functions=parser_instance_functions +4 yymcreateparse=yymcreateparse +4 yymdestroyparse=yymdestroyparse +3 Parser General Functions +4 Parser General Functions=parser_general_functions +4 yycparse=yyparse +4 yycwipe=yycwipe +4 yycwork=yywork +4 yydestructpop=yydestructpop +4 yyparse=yyparse +4 yyparsecleanup=yyparsecleanup +4 yyparseinit=yyparseinit +4 yysetstacksize=yysetstacksize +4 yysetup=yysetup +4 yywipe=yywipe +4 yywork=yywork +4 yymcparse=yymparse +4 yymcwipe=yymcwipe +4 yymcwork=yymwork +4 yymdestructpop=yymdestructpop +4 yymparse=yymparse +4 yymparsecleanup=yymparsecleanup +4 yymparseinit=yymparseinit +4 yymsetstacksize=yymsetstacksize +4 yymsetup=yymsetup +4 yymwipe=yymwipe +4 yymwork=yymwork +3 Parser Service Functions +4 Parser Service Functions=parser_service_functions +4 yydiscard=yydiscard +4 yyerror=yyerror +4 yygettoken=yygettoken +4 yystackoverflow=yystackoverflow +4 yysyntaxerror=yysyntaxerror +4 yymdiscard=yymdiscard +4 yymerror=yymerror +4 yymgettoken=yymgettoken +4 yymstackoverflow=yymstackoverflow +4 yymsyntaxerror=yymsyntaxerror +3 Parser Action Functions +4 Parser Action Functions=parser_action_functions +4 yyabort=yyabort +4 yyaccept=yyaccept +4 yyclearin=yyclearin +4 yycdestructclearin=yycdestructclearin +4 yydestructclearin=yydestructclearin +4 yyerrok=yyerrok +4 yyexit=yyexit +4 yyforceerror=yyforceerror +4 yypopping=yypopping +4 yyrecovering=yyrecovering +4 yyretire=yyretire +4 yysetin=yysetin +4 yythrowerror=yythrowerror +4 yyunclearin=yyunclearin +4 yymcdestructclearin=yymcdestructclearin +4 yymdestructclearin=yymdestructclearin +4 yymabort=yymabort +4 yymaccept=yymaccept +4 yymclearin=yymclearin +4 yymerrok=yymerrok +4 yymexit=yymexit +4 yymforceerror=yymforceerror +4 yympopping=yympopping +4 yymrecovering=yymrecovering +4 yymretire=yymretire +4 yymsetin=yymsetin +4 yymthrowerror=yymthrowerror +4 yymunclearin=yymunclearin +3 Lexical Analyser Instance Functions +4 Lexical Analyser Instance Functions=lexical_analyser_instance_functions +4 yymcreatelex=yymcreatelex +4 yymdestroylex=yymdestroylex +3 Lexical Analyser General Functions +4 Lexical Analyser General Functions=lexical_analyser_general_functions +4 yyclex=yylex +4 yylex=yylex +4 yylexcleanup=yylexcleanup +4 yylexinit=yylexinit +4 yyreset=yyreset +4 yysettextsize=yysettextsize +4 yysetunputsize=yysetunputsize +4 yymclex=yymlex +4 yymlex=yymlex +4 yymlexcleanup=yymlexcleanup +4 yymlexinit=yymlexinit +4 yymreset=yymreset +4 yymsettextsize=yymsettextsize +4 yymsetunputsize=yymsetunputsize +3 Lexical Analyser Service Functions +4 Lexical Analyser Service Functions=lexical_analyser_service_functions +4 yygetchar=yygetchar +4 yyinput=yyinput +4 yyoutput=yyoutput +4 yytextoverflow=yytextoverflow +4 yyunput=yyunput +4 yyunputoverflow=yyunputoverflow +4 yywrap=yywrap +4 yymgetchar=yymgetchar +4 yyminput=yyminput +4 yymoutput=yymoutput +4 yymtextoverflow=yymtextoverflow +4 yymunput=yymunput +4 yymunputoverflow=yymunputoverflow +4 yymwrap=yymwrap +3 Lexical Analyser Action Functions +4 Lexical Analyser Action Functions=lexical_analyser_action_functions +4 yybegin=yybegin +4 yyecho=yyecho +4 yyless=yyless +4 yymore=yymore +4 yynewline=yynewline +4 yyreject=yyreject +4 yyunputcount=yyunputcount +4 yymbegin=yymbegin +4 yymecho=yymecho +4 yymless=yymless +4 yymmore=yymmore +4 yymnewline=yymnewline +4 yymreject=yymreject +4 yymunputcount=yymunputcount +2 Variables +3 Variables=variables +3 Parser Variables +4 Parser Variables=parser_variables +4 yychar=yychar +4 yyerrorcount=yyerrorcount +4 yylookahead=yylookahead +4 yyparsedebug=yyparsedebug +4 yyparsedebugflush=yyparsedebugflush +4 yyparsedebugout=yyparsedebugout +4 yyparsedebugstack=yyparsedebugstack +4 yyparseerr=yyparseerr +4 yystackgrow=yystackgrow +4 yywipeflg=yywipeflg +3 Lexical Analyser Variables +4 Lexical Analyser Variables=lexical_analyser_variables +4 yyin=yyin +4 yyeol=yyeol +4 yyleng=yyleng +4 yylexdebug=yylexdebug +4 yylexdebugflush=yylexdebugflush +4 yylexdebugout=yylexdebugout +4 yylexerr=yylexerr +4 yylineno=yylineno +4 yyout=yyout +4 yystart=yystart +4 yytext=yytext +4 yytextgrow=yytextgrow +4 yyunputgrow=yyunputgrow +3 Common Variables +4 Common Variables=common_variables +4 yydebug=yydebug +4 yydebugflush=yydebugflush +4 yydebugstack=yydebugstack +2 Types +3 Types=types +3 yymparse_t=yymparse_t +3 yymlex_t=yymlex_t +2 Constants +3 Constants=constants +2 Modifiers +3 Modifiers=modifiers +2 Flags +3 Flags=flags +2 Include Files +3 Include Files=include_files +1 License +2 License=license +2 License Agreement=license_agreement +2 Ordering Information=ordering_information +2 Parser Generator Order Form=parser_generator_order_form diff --git a/Utils/Parser Generator/BIN/ParGen.exe b/Utils/Parser Generator/BIN/ParGen.exe new file mode 100644 index 000000000..fd58476bd Binary files /dev/null and b/Utils/Parser Generator/BIN/ParGen.exe differ diff --git a/Utils/Parser Generator/BIN/ParGen.pgw b/Utils/Parser Generator/BIN/ParGen.pgw new file mode 100644 index 000000000..69207fc39 --- /dev/null +++ b/Utils/Parser Generator/BIN/ParGen.pgw @@ -0,0 +1,18 @@ +[Application] +WindowPlacement=0 1 -1 -1 -1 -1 367 176 1437 1061 +[Editor1] +FileName=C:\spongebob\Utils\scripter\parser.y +ReadOnly=0 +WindowPlacement1=0 1 -1 -1 -1 -1 81 81 896 612 +WindowOrder1=2 +Position001=0 1 +Cursor001=0 1 0 1 +SyntaxColouring=2 +[Editor2] +FileName=C:\spongebob\Utils\scripter\lexer.l +ReadOnly=0 +WindowPlacement1=0 1 -1 -1 -1 -1 108 108 923 639 +WindowOrder1=1 +Position001=0 1 +Cursor001=0 1 0 1 +SyntaxColouring=1 diff --git a/Utils/Parser Generator/BIN/ayacc.exe b/Utils/Parser Generator/BIN/ayacc.exe new file mode 100644 index 000000000..34e02e185 Binary files /dev/null and b/Utils/Parser Generator/BIN/ayacc.exe differ diff --git a/Utils/Parser Generator/BIN/pgvars16.bat b/Utils/Parser Generator/BIN/pgvars16.bat new file mode 100644 index 000000000..69e57d96e --- /dev/null +++ b/Utils/Parser Generator/BIN/pgvars16.bat @@ -0,0 +1,3 @@ +set PATH=C:\PROGRA~1\PARSER~1\BIN;%PATH% +set INCLUDE=C:\PROGRA~1\PARSER~1\INCLUDE;%INCLUDE% +set LIB=C:\PROGRA~1\PARSER~1\LIB\MSVC;%LIB% diff --git a/Utils/Parser Generator/BIN/pgvars32.bat b/Utils/Parser Generator/BIN/pgvars32.bat new file mode 100644 index 000000000..5547032f9 --- /dev/null +++ b/Utils/Parser Generator/BIN/pgvars32.bat @@ -0,0 +1,3 @@ +set PATH=C:\Program Files\Parser Generator\BIN;%PATH% +set INCLUDE=C:\Program Files\Parser Generator\INCLUDE;%INCLUDE% +set LIB=C:\Program Files\Parser Generator\LIB\MSDEV;%LIB% diff --git a/Utils/Parser Generator/DeIsL1.isu b/Utils/Parser Generator/DeIsL1.isu new file mode 100644 index 000000000..dc8057532 Binary files /dev/null and b/Utils/Parser Generator/DeIsL1.isu differ diff --git a/Utils/Parser Generator/INCLUDE/clex.h b/Utils/Parser Generator/INCLUDE/clex.h new file mode 100644 index 000000000..837df08aa --- /dev/null +++ b/Utils/Parser Generator/INCLUDE/clex.h @@ -0,0 +1,237 @@ +#ifndef CLEX_H +#define CLEX_H + +/************************************************************ +clex.h +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include + +// defines +#include + +// user defines +#if defined(YYTUDEFS) || defined(YYUDEFS) +#include +#endif + +#define YY_ALEX + +// modifiers +#ifndef YYCDECL +#define YYCDECL +#endif +#ifndef YYDCDECL +#define YYDCDECL +#endif +#ifndef YYNEAR +#define YYNEAR +#endif +#ifndef YYFAR +#define YYFAR +#endif +#ifndef YYNEARFAR +#define YYNEARFAR +#endif +#ifndef YYBASED_CODE +#define YYBASED_CODE +#endif + +// forward references +class YYFAR yyparser; + +// yylex return values +#define YYEOF 0 // end of file + +#ifndef YYSTATE_T +#define YYSTATE_T +typedef struct yystate { + short def; // default state + short base; // base + short match; // action associated with state +} yystate_t; +#endif + +#ifndef YYTRANSITION_T +#define YYTRANSITION_T +typedef struct yytransition { + short next; // next state on transition + short check; // check +} yytransition_t; +#endif + +#ifndef YYCTRANSITION_T +#define YYCTRANSITION_T +typedef struct yyctransition { + unsigned char first; // first character in range + unsigned char last; // last character in range + short next; // next state on transition +} yyctransition_t; +#endif + +typedef short yymatch_t; +typedef unsigned char yybackup_t; + +class YYFAR yylexer { +public: + yylexer(); + virtual ~yylexer(); + +// Attributes +protected: + // left context + int yystart; // current start state + unsigned char yyeol; // whether an end-of-line '\n' has been seen + unsigned char yyoldeol; // previous end-of-line value + + // text buffer + int YYFAR* yystatebuf; // state buffer + int YYFAR* yysstatebuf; // initial (static) state buffer + char YYFAR* yystext; // initial (static) text buffer + int yytext_size; // text buffer size + int yystext_size; // initial (static) text buffer size + + // unput buffer + int YYFAR* yyunputbufptr; // unput buffer + int YYFAR* yysunputbufptr; // initial (static) unput buffer + int yyunput_size; // unput buffer size + int yysunput_size; // initial (static) unput buffer size + int yyunputindex; // unput buffer position + + // actions + unsigned char yymoreflg; // concatenate matched strings + unsigned char yyrejectflg; // yyreject called from an action + unsigned char yyreturnflg; // return from an action +public: + yyparser YYFAR* yyparserptr; // pointer to the attached parser + + // buffer flags + unsigned char yytextgrow; // whether text buffer is allowed to grow + unsigned char yyunputgrow; // whether unput buffer is allowed to grow + + // streams + FILE YYFAR* yyin; // input text stream + FILE YYFAR* yyout; // output text stream + FILE YYFAR* yyerr; // error stream + + // matched string + char YYFAR* yytext; // text buffer + int yyleng; // matched string length + int yylineno; // current line number + +// Operations +protected: + // helper functions + int yyback(const yymatch_t YYNEARFAR* p, int action) const; +public: + // instance functions + int yycreate(yyparser YYFAR* parserptr = NULL); + void yydestroy(); + + // general functions + void yycleanup(); + virtual int yylex() = 0; + void yyreset(); + int yysettextsize(int size); + int yysetunputsize(int size); + + // service functions + virtual int yyinput(); + virtual void yyoutput(int ch); + virtual void yyunput(int ch); + virtual int yywrap(); + virtual int yygetchar(); + virtual void yytextoverflow(); + virtual void yyunputoverflow(); + virtual int yyaction(int action) = 0; + + // action functions + void yyecho(); + void yyless(int length); + void yybegin(int state) { yystart = state; } + void yymore() { yymoreflg = 1; } + void yynewline(int newline) { newline ? yyeol = 1 : (yyeol = 0); } + void yyreject() { yyrejectflg = 1; } + int yyunputcount() const { return yyunputindex; } + + // compatibility + int yyclex() { return yylex(); } + void yylexcleanup() { yycleanup(); } + void yylexinit() { /* do nothing */ } +#define BEGIN yystart = +#define ECHO yyecho() +#define REJECT yyreject() +#define YYSTATE yystart +#define YY_START yystart + +// Tables +protected: + const yymatch_t YYNEARFAR* yymatch; + const yystate_t YYNEARFAR* yystate; + const yybackup_t YYNEARFAR* yybackup; + +// Debugging +#ifdef YYDEBUG +public: + int yydebug; // whether debug information should be output + int yydebugflush; // whether debug output should be flushed + FILE YYFAR* yydebugout; // debug output file +protected: + void yydebugoutput(int ch) const; + void yydmatch(int expr) const; + void yydebugoutput(const char* string) const; +#endif +}; + +class YYFAR yyflexer : public yylexer { +public: + yyflexer() { /* do nothing */ } + +// Operations +public: + virtual int yylex(); + +// Tables +protected: + const yytransition_t YYNEARFAR* yytransition; + int yytransitionmax; +}; + +class YYFAR yyclexer : public yylexer { +public: + yyclexer() { /* do nothing */ } + +// Operations +public: + virtual int yylex(); + +// Tables +protected: + const yyctransition_t YYNEARFAR* yyctransition; +}; + +// helper functions +#ifndef yyassert +#define yyassert(expr) assert(expr) +#endif + +// debugging variables +#ifdef YYDEBUG +extern "C" int YYNEAR YYDCDECL yydebug; +extern "C" int YYNEAR YYDCDECL yydebugflush; +#endif + +// user defines +#if defined(YYBUDEFS) || defined(YYUDEFS) +#include +#endif + +// defines +#include + +#endif diff --git a/Utils/Parser Generator/INCLUDE/cyacc.h b/Utils/Parser Generator/INCLUDE/cyacc.h new file mode 100644 index 000000000..a4c7ee593 --- /dev/null +++ b/Utils/Parser Generator/INCLUDE/cyacc.h @@ -0,0 +1,375 @@ +#ifndef CYACC_H +#define CYACC_H + +/************************************************************ +cyacc.h +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include +#include + +// defines +#include + +// user defines +#if defined(YYTUDEFS) || defined(YYUDEFS) +#include +#endif + +#define YY_AYACC + +// modifiers +#ifndef YYCDECL +#define YYCDECL +#endif +#ifndef YYDCDECL +#define YYDCDECL +#endif +#ifndef YYNEAR +#define YYNEAR +#endif +#ifndef YYFAR +#define YYFAR +#endif +#ifndef YYNEARFAR +#define YYNEARFAR +#endif +#ifndef YYBASED_CODE +#define YYBASED_CODE +#endif + +// forward references +class YYFAR yylexer; + +typedef short yystack_t; + +// yyparse return values +#define YYEXIT_SUCCESS 0 +#define YYEXIT_FAILURE 1 + +// common tokens +#define YYTK_ALL (-1) // match all tokens +#define YYTK_END 0 // $end token +#define YYTK_ERROR 256 // error token + +#ifndef YYCSTATEGOTO_T +#define YYCSTATEGOTO_T +typedef short yycstategoto_t; +#endif + +#ifndef YYCNONTERMGOTO_T +#define YYCNONTERMGOTO_T +typedef struct yycnontermgoto { + short nonterm; // nonterminal + short next; // next state +} yycnontermgoto_t; +#endif + +#ifndef YYSTATEGOTO_T +#define YYSTATEGOTO_T +typedef struct yystategoto { + short base; // base + short def; // default state +} yystategoto_t; +#endif + +#ifndef YYNONTERMGOTO_T +#define YYNONTERMGOTO_T +typedef struct yynontermgoto { + short check; // check + short next; // next state +} yynontermgoto_t; +#endif + +// action types +#define YYAT_SHIFT 0 // shift action +#define YYAT_REDUCE 1 // reduce action +#define YYAT_ERROR 2 // error +#define YYAT_ACCEPT 3 // accept +#define YYAT_DEFAULT 4 // default state + +#ifndef YYCSTATEACTION_T +#define YYCSTATEACTION_T +typedef short yycstateaction_t; +#endif + +#ifndef YYCTOKENACTION_T +#define YYCTOKENACTION_T +typedef struct yyctokenaction { + int token; // lookahead token + unsigned char type; // action to perform + short sr; // state to shift/production to reduce +} yyctokenaction_t; +#endif + +#ifndef YYSTATEACTION_T +#define YYSTATEACTION_T +typedef struct yystateaction { + short base; // base + unsigned char lookahead; // lookahead needed + unsigned char type; // action to perform + short sr; // shift/reduce +} yystateaction_t; +#endif + +#ifndef YYTOKENACTION_T +#define YYTOKENACTION_T +typedef struct yytokenaction { + short check; // check + unsigned char type; // action type + short sr; // shift/reduce +} yytokenaction_t; +#endif + +// nonterminals +#define YYNT_ALL (-1) // match all nonterminals + +// states +#define YYST_ERROR (-1) // goto error + +#ifndef YYREDUCTION_T +#define YYREDUCTION_T +typedef struct yyreduction { + short nonterm; // the rhs symbol + short length; // number of symbols on lhs + short action; // the user action +} yyreduction_t; +#endif + +typedef short yydestructor_t; + +typedef short yytokendest_t; + +#ifndef YYCTOKENDEST_T +#define YYCTOKENDEST_T +typedef struct yyctokendest { + int token; /* token */ + short action; /* the user action */ +} yyctokendest_t; +#endif + +// debugging +#ifdef YYDEBUG +#ifndef YYSYMBOL_T +#define YYSYMBOL_T +typedef struct yysymbol { + const char* name; // symbol name + int token; // symbol token +} yysymbol_t; +#endif +#endif + +class YYFAR yyparser { +public: + yyparser(); + virtual ~yyparser(); + +// Attributes +protected: + // stack + yystack_t YYFAR* yystackptr; // (state) stack + yystack_t YYFAR* yysstackptr; // static (state) stack + void YYFAR* yyattributestackptr; // attribute stack + void YYFAR* yysattributestackptr; // static attribute stack + int yystack_size; // number of elements in stack + int yysstack_size; // initial number of elements in stack + + int yytop; // the current top of the stack + size_t yyattribute_size; // size of attribute + + void YYFAR* yyvalptr; // attribute for $$ + + // lookahead token + unsigned char yylookahead; // whether current lookahead token is valid + int yychar; // current lookahead token + + // error recovery + unsigned char yywipeflg; // whether to "wipe" stack on abort + unsigned char yypopflg; // popping symbols during error recovery + int yyskip; // error recovery token shift counter + + // actions + unsigned char yyexitflg; // whether yymexit called + unsigned char yyretireflg; // whether yymretire called + unsigned char yyerrorflg; // whether yymforceerror called + int yyexitcode; // yymexit exit code + int yyretirecode; // yymretire exit code + int yyerrorpop; // how many error transitions to pop +public: + yylexer YYFAR* yylexerptr; // pointer to the attached lexical analyser + + unsigned char yystackgrow; // whether stack can grow + void YYFAR* yylvalptr; // current token attribute + FILE YYFAR* yyerr; // error output file + int yyerrorcount; // how many syntax errors have occurred + +// Operations +protected: + virtual void yyaction(int action) = 0; + +// utility functions +#ifdef YYDEBUG + void yypop(int num); + void yysetskip(int skip); +#else + void yypop(int num) { yytop -= num; } + void yysetskip(int skip) { yyskip = skip; } +#endif + int yypush(yystack_t state); + yystack_t yypeek() const { return yystackptr[yytop]; } + +public: + // instance functions + int yycreate(yylexer YYFAR* lexerptr = NULL); + void yydestroy(); + + // general functions + void yydestructpop(int num); + int yyparse(); + void yycleanup(); + int yysetstacksize(int size); + int yysetup(); + void yywipe(); + virtual int yywork() = 0; + virtual void yydestructclearin() = 0; + + // service functions + virtual void yystackoverflow(); + virtual void yyerror(const char YYFAR* text); + virtual void yysyntaxerror(); + virtual void yydiscard(int token); + virtual int yygettoken(); + + // action functions + void yysetin(int token); + int yyunclearin(); + void yyabort() { yyexit(1); } + void yyaccept() { yyexit(0); } +#ifndef YY_COMPATIBLE + void yyclearin() { yylookahead = 0; } + void yyerrok() { yysetskip(0); } +#else + void _yyclearin() { yylookahead = 0; } + void _yyerrok() { yysetskip(0); } +#endif + void yyexit(int exitcode) { yyexitflg = 1; yyexitcode = exitcode; } + void yyforceerror() { yythrowerror(0); } + int yypopping() const { return yypopflg; } + int yyrecovering() const { return yyskip > 0; } + void yyretire(int retirecode) { yyretireflg = 1; yyretirecode = retirecode; } + void yythrowerror(int pop) { yyerrorflg = 1; yyerrorpop = pop; } + + // compatibility + int yycparse() { return yyparse(); } + int yycwork() { return yywork(); } + void yyparsecleanup() { yycleanup(); } + void yyparseinit() { /* do nothing */ } +#ifdef YY_COMPATIBLE +#define yyclearin _yyclearin() +#define yyerrok _yyerrok() +#endif +#define YYABORT yyexit(1) +#define YYACCEPT yyexit(0) +#define YYERROR yyforceerror() +#define YYRECOVERING yyrecovering() + +// Tables +protected: + const yyreduction_t YYNEARFAR* yyreduction; + const yydestructor_t YYNEARFAR* yydestructorptr; + +// Debugging +#ifdef YYDEBUG +public: + int yydebug; // whether debug information should be output + int yydebugstack; // whether stack debug information should be output + int yydebugflush; // whether debug output should be flushed + FILE YYFAR* yydebugout; // debug output file +protected: + const yysymbol_t YYNEARFAR* yysymbol; + const char* const YYNEARFAR* yyrule; + + // debugging functions +protected: + const char* yytokenstring(int token) const; + void yydgettoken(int token) const; + void yydshift(int token) const; + void yydreduce(int rule) const; + void yydsyntaxerror() const; + void yydaccept() const; + void yydabort() const; + void yyddiscard(int token) const; + void yydexit(int exitcode) const; + void yydthrowerror(int errorpop) const; + void yydretire(int retirecode) const; + void yydattemptrecovery() const; + void yydebugoutput(const char *string) const; +#endif +}; + +class YYFAR yyfparser : public yyparser { +public: + yyfparser() { /* do nothing */ } + +// Operations +public: + virtual int yywork(); + virtual void yydestructclearin(); + +// Tables +protected: + const yystateaction_t YYNEARFAR* yystateaction; + const yytokenaction_t YYNEARFAR* yytokenaction; + int yytokenaction_size; + const yystategoto_t YYNEARFAR* yystategoto; + const yynontermgoto_t YYNEARFAR* yynontermgoto; + int yynontermgoto_size; + const yytokendest_t YYNEARFAR* yytokendestptr; + int yytokendest_size; + int yytokendestbase; +}; + +class YYFAR yycparser : public yyparser { +public: + yycparser() { /* do nothing */ } + +// Operations +public: + virtual int yywork(); + virtual void yydestructclearin(); + +// Tables +protected: + const yycstateaction_t YYNEARFAR* yycstateaction; + const yyctokenaction_t YYNEARFAR* yyctokenaction; + const yycstategoto_t YYNEARFAR* yycstategoto; + const yycnontermgoto_t YYNEARFAR* yycnontermgoto; + const yyctokendest_t YYNEARFAR* yyctokendestptr; +}; + +// utility functions +#ifndef yyassert +#define yyassert(expr) assert(expr) +#endif + +// debugging variables +#ifdef YYDEBUG +extern "C" int YYNEAR YYDCDECL yydebug; +extern "C" int YYNEAR YYDCDECL yydebugstack; +extern "C" int YYNEAR YYDCDECL yydebugflush; +#endif + +// user defines +#if defined(YYBUDEFS) || defined(YYUDEFS) +#include +#endif + +// defines +#include + +#endif diff --git a/Utils/Parser Generator/INCLUDE/lex.h b/Utils/Parser Generator/INCLUDE/lex.h new file mode 100644 index 000000000..3bc12dc94 --- /dev/null +++ b/Utils/Parser Generator/INCLUDE/lex.h @@ -0,0 +1,259 @@ +#ifndef LEX_H +#define LEX_H + +/************************************************************ +lex.h +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include + +/* defines */ +#include + +/* user defines */ +#if defined(YYTUDEFS) || defined(YYUDEFS) +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define YY_ALEX + +/* modifiers */ +#ifndef YYCDECL +#define YYCDECL +#endif +#ifndef YYDCDECL +#define YYDCDECL +#endif +#ifndef YYNEAR +#define YYNEAR +#endif +#ifndef YYFAR +#define YYFAR +#endif +#ifndef YYNEARFAR +#define YYNEARFAR +#endif +#ifndef YYBASED_CODE +#define YYBASED_CODE +#endif + +/* function prototypes */ +#ifndef YYPROTOTYPE +#if defined(__STDC__) || defined(__cplusplus) +#define YYPROTOTYPE +#endif +#endif + +/* qualifiers */ +#ifndef YYCONST +#if defined(__STDC__) || defined(__cplusplus) +#define YYCONST const +#else +#define YYCONST +#endif +#endif + +/* testing */ +#ifdef YYNOPROTOTYPE +#undef YYPROTOTYPE +#endif +#ifdef YYNOCONST +#undef YYCONST +#define YYCONST +#endif + +/* yylex return values */ +#define YYEOF 0 /* end of file */ + +#ifndef YYSTATE_T +#define YYSTATE_T +typedef struct yystate { + short def; /* default state */ + short base; /* base */ + short match; /* action associated with state */ +} yystate_t; +#endif + +#ifndef YYTRANSITION_T +#define YYTRANSITION_T +typedef struct yytransition { + short next; /* next state on transition */ + short check; /* check */ +} yytransition_t; +#endif + +#ifndef YYCTRANSITION_T +#define YYCTRANSITION_T +typedef struct yyctransition { + unsigned char first; /* first character in range */ + unsigned char last; /* last character in range */ + short next; /* next state on transition */ +} yyctransition_t; +#endif + +typedef short yymatch_t; +typedef unsigned char yybackup_t; + +/* general functions */ +#ifdef YYPROTOTYPE +int YYCDECL yyclex(void); +int YYCDECL yylex(void); +void YYCDECL yylexcleanup(void); +void YYCDECL yylexinit(void); +void YYCDECL yyreset(void); +int YYCDECL yysettextsize(int size); +int YYCDECL yysetunputsize(int size); +#else +int YYCDECL yyclex(); +int YYCDECL yylex(); +void YYCDECL yylexcleanup(); +void YYCDECL yylexinit(); +void YYCDECL yyreset(); +int YYCDECL yysettextsize(); +int YYCDECL yysetunputsize(); +#endif + +/* service functions */ +#ifdef YYPROTOTYPE +int YYCDECL yygetchar(void); +int YYCDECL yyinput(void); +void YYCDECL yyoutput(int ch); +void YYCDECL yytextoverflow(void); +void YYCDECL yyunput(int ch); +void YYCDECL yyunputoverflow(void); +int YYCDECL yywrap(void); +#else +int YYCDECL yygetchar(); +int YYCDECL yyinput(); +void YYCDECL yyoutput(); +void YYCDECL yytextoverflow(); +void YYCDECL yyunput(); +void YYCDECL yyunputoverflow(); +int YYCDECL yywrap(); +#endif + +/* action functions */ +#ifdef YYPROTOTYPE +void YYCDECL yyecho(void); +void YYCDECL yyless(int length); +#else +void YYCDECL yyecho(); +void YYCDECL yyless(); +#endif +#define yybegin(state) (yystart = (state)) +#define yymore() (yymoreflg = 1) +#define yynewline(newline) ((newline) ? yyeol = 1 : (yyeol = 0)) +#define yyreject() (yyrejectflg = 1) +#define yyunputcount() yyunputindex + +/* compatibility */ +#define BEGIN yystart = +#define ECHO yyecho() +#define REJECT yyreject() +#define YYSTATE yystart +#define YY_START yystart + +/* helper functions */ +#ifdef YYPROTOTYPE +int YYCDECL yyback(YYCONST yymatch_t YYNEARFAR *p, int action); +#else +int YYCDECL yyback(); +#endif +#ifndef yyassert +#define yyassert(expr) assert(expr) +#endif + +/* variables */ +extern unsigned char YYNEAR YYDCDECL yymoreflg; +extern unsigned char YYNEAR YYDCDECL yyrejectflg; +extern unsigned char YYNEAR YYDCDECL yyreturnflg; +extern unsigned char YYNEAR YYDCDECL yytextgrow; +extern unsigned char YYNEAR YYDCDECL yyunputgrow; +extern unsigned char YYNEAR YYDCDECL yyeol; +extern unsigned char YYNEAR YYDCDECL yyoldeol; +extern int YYNEAR YYDCDECL yystart; + +extern FILE YYFAR *YYNEAR YYDCDECL yyin; +extern FILE YYFAR *YYNEAR YYDCDECL yyout; +extern FILE YYFAR *YYNEAR YYDCDECL yylexerr; + +extern int YYNEAR YYDCDECL yyleng; +extern int YYNEAR YYDCDECL yylineno; +extern int YYNEAR YYDCDECL yyunputindex; + +/* debugging functions */ +#ifdef YYDEBUG +#ifdef YYPROTOTYPE +void YYCDECL yydebugoutput(int ch); +void YYCDECL yydmatch(int expr); +void YYCDECL yylexdebugoutput(YYCONST char *string); +#else +void YYCDECL yydebugoutput(); +void YYCDECL yydmatch(); +void YYCDECL yylexdebugoutput(); +#endif +#endif + +/* debugging variables */ +#ifdef YYDEBUG +extern int YYNEAR YYDCDECL yydebug; +extern int YYNEAR YYDCDECL yydebugflush; +extern int YYNEAR YYDCDECL yylexdebug; +extern int YYNEAR YYDCDECL yylexdebugflush; +extern FILE YYFAR *YYNEAR YYDCDECL yylexdebugout; +#endif + +/* externally defined */ +#ifdef YYPROTOTYPE +int YYCDECL yylexaction(int action); +#else +int YYCDECL yylexaction(); +#endif + +extern char YYFAR *YYNEAR YYDCDECL yytext; +extern char YYFAR *YYNEAR YYDCDECL yystext; +extern int YYNEAR YYDCDECL yytext_size; +extern int YYNEAR YYDCDECL yystext_size; + +extern int YYFAR *YYNEAR YYDCDECL yystatebuf; +extern int YYFAR *YYNEAR YYDCDECL yysstatebuf; + +/* unput buffer */ +extern int YYFAR *YYNEAR YYDCDECL yyunputbufptr; +extern int YYFAR *YYNEAR YYDCDECL yysunputbufptr; +extern int YYNEAR YYDCDECL yyunput_size; +extern int YYNEAR YYDCDECL yysunput_size; + +/* fast lexical analyser */ +extern YYCONST yytransition_t YYNEARFAR YYDCDECL yytransition[]; +extern int YYNEAR YYDCDECL yytransitionmax; + +/* compact lexical analyser */ +extern YYCONST yyctransition_t YYNEARFAR YYDCDECL yyctransition[]; + +extern YYCONST yymatch_t YYNEARFAR YYDCDECL yymatch[]; +extern YYCONST yystate_t YYNEARFAR YYDCDECL yystate[]; +extern YYCONST yybackup_t YYNEARFAR YYDCDECL yybackup[]; + +#ifdef __cplusplus +} +#endif + +/* user defines */ +#if defined(YYBUDEFS) || defined(YYUDEFS) +#include +#endif + +/* defines */ +#include + +#endif diff --git a/Utils/Parser Generator/INCLUDE/milconv.h b/Utils/Parser Generator/INCLUDE/milconv.h new file mode 100644 index 000000000..363fc8c23 --- /dev/null +++ b/Utils/Parser Generator/INCLUDE/milconv.h @@ -0,0 +1,88 @@ +#ifndef MILCONV_H +#define MILCONV_H + +/************************************************************ +milconv.h +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +/* variables */ +#define yymoreflg (yy)->yymmoreflg +#define yyrejectflg (yy)->yymrejectflg +#define yyreturnflg (yy)->yymreturnflg +#define yytextgrow (yy)->yymtextgrow +#define yyunputgrow (yy)->yymunputgrow +#define yyeol (yy)->yymeol +#define yyoldeol (yy)->yymoldeol +#define yystart (yy)->yymstart +#define yyin (yy)->yymin +#define yyout (yy)->yymout +#define yylexerr (yy)->yymerr +#define yyleng (yy)->yymleng +#define yylineno (yy)->yymlineno +#define yyunputindex (yy)->yymunputindex +#define yytext (yy)->yymtext +#define yystext (yy)->yymstext +#define yytext_size (yy)->yymtext_size +#define yystext_size (yy)->yymstext_size +#define yystatebuf (yy)->yymstatebuf +#define yysstatebuf (yy)->yymsstatebuf +#define yyunputbufptr (yy)->yymunputbufptr +#define yysunputbufptr (yy)->yymsunputbufptr +#define yyunput_size (yy)->yymunputbufptr +#define yysunput_size (yy)->yymsunput_size +#define yylexdebug (yy)->yymdebug +#define yylexdebugflush (yy)->yymdebugflush +#define yylexdebugout (yy)->yymdebugout + +/* general functions */ +#define yylexinit() yymlexinit(yy) +#define yylex() yymlex(yy) +#define yyclex() yymclex(yy) +#define yyreset() yymreset(yy) +#define yylexcleanup() yymlexcleanup(yy) +#define yysettextsize(size) yymsettextsize(yy, (size)) +#define yysetunputsize(size) yymsetunputsize(yy, (size)) + +/* service functions */ +#define yyinput() (*yy->yyminput)(yy) +#define yyoutput(ch) (*yy->yymoutput)(yy, (ch)) +#define yyunput(ch) (*yy->yymunput)(yy, (ch)) +#define yywrap() (*yy->yymwrap)(yy) +#define yygetchar() (*yy->yymgetchar)(yy) +#define yytextoverflow() (*yy->yymtextoverflow)(yy) +#define yyunputoverflow() (*yy->yymunputoverflow)(yy) + +/* action functions */ +#define yybegin(state) yymbegin(yy, (state)) +#define yyecho() yymecho(yy) +#define yyless(length) yymless(yy, (length)) +#define yymore() yymmore(yy) +#define yynewline(newline) yymnewline(yy, (newline)) +#define yyreject() yymreject(yy) +#define yyunputcount() yymunputcount(yy) + +/* compatibility */ +#define ECHO yyecho() +#define REJECT yyreject() +#define BEGIN (yy)->yymstart = +#define YYSTATE (yy)->yymstart +#define YY_START (yy)->yymstart + +#ifndef input +#define input() (*yy->yyminput)(yy) +#define YY_INPUT +#endif +#ifndef output +#define output(ch) (*yy->yymoutput)(yy, (ch)) +#define YY_OUTPUT +#endif +#ifdef unput +#define unput(ch) (*yy->yymunput)(yy, (ch)) +#define YY_UNPUT +#endif + +#endif diff --git a/Utils/Parser Generator/INCLUDE/miyconv.h b/Utils/Parser Generator/INCLUDE/miyconv.h new file mode 100644 index 000000000..0f10f5e90 --- /dev/null +++ b/Utils/Parser Generator/INCLUDE/miyconv.h @@ -0,0 +1,90 @@ +#ifndef MIYCONV_H +#define MIYCONV_H + +/************************************************************ +miyconv.h +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +/* variables */ +#define yylookahead (yy)->yymlookahead +#define yystackgrow (yy)->yymstackgrow +#define yyexitflg (yy)->yymexitflg +#define yyretireflg (yy)->yymretireflg +#define yyerrorflg (yy)->yymerrorflg +#define yypopflg (yy)->yympopflg +#define yywipeflg (yy)->yymwipeflg +#define yytop (yy)->yymtop +#define yychar (yy)->yymchar +#define yyskip (yy)->yymskip +#define yyerrorcount (yy)->yymerrorcount +#define yyexitcode (yy)->yymexitcode +#define yyretirecode (yy)->yymretirecode +#define yyerrorpop (yy)->yymerrorpop +#define yyparseerr (yy)->yymerr +#define yystackptr (yy)->yymstackptr +#define yysstackptr (yy)->yymsstackptr +#define yystack_size (yy)->yymstack_size +#define yysstack_size (yy)->yymsstack_size +#define yyattribute_size (yy)->yymattribute_size +#define yyvalptr (yy)->yymvalptr +#define yylvalptr (yy)->yymlvalptr +#define yyattributestackptr (yy)->yymattributestackptr +#define yysattributestackptr (yy)->yymsattributestackptr +#define yyparsedebug (yy)->yymdebug +#define yyparsedebugstack (yy)->yymdebugstack +#define yyparsedebugflush (yy)->yymdebugflush +#define yyparsedebugout (yy)->yymdebugout + +/* general functions */ +#define yycparse() yymcparse(yy) +#define yycwipe() yymcwipe(yy) +#define yycwork() yymcwork(yy) +#define yydestructpop(num) yymdestructpop(yy, (pop)) +#define yyparse() yymparse(yy) +#define yyparsecleanup() yymparsecleanup(yy) +#define yyparseinit() yymparseinit(yy) +#define yysetstacksize(size) yymsetstacksize(yy, (size)) +#define yysetup() yymsetup(yy) +#define yywipe() yymwipe(yy) +#define yywork() yymwork(yy) + +/* service functions */ +#define yygettoken() (*yy->yymgettoken)(yy) +#define yystackoverflow() (*yy->yymstackoverflow)(yy) +#define yyerror(text) (*yy->yymerror)(yy, text) +#define yysyntaxerror() (*yy->yymsyntaxerror)(yy) +#define yydiscard() (*yy->yymdiscard)(yy) + +/* action functions */ +#define yycdestructclearin() yymcdestructclearin(yy) +#define yydestructclearin() yymdestructclearin(yy) +#define yysetin(token) yymsetin(yy, (token) +#define yyunclearin() yymunclearin(yy) +#define yyabort() yymabort(yy) +#define yyaccept() yymaccept(yy) +#define yyclearin() yymclearin(yy) +#define yydestructclearin() yymdestructclearin(yy) +#define yyerrok() yymerrok(yy) +#define yyexit(exitcode) yymexit(yy, (exitcode)) +#define yyforceerror() yymforceerror(yy) +#define yypopping() yympopping(yy) +#define yyrecovering() yymrecovering(yy) +#define yyretire(retirecode) yymretire(yy, (retirecode)) +#define yythrowerror(pop) yymthrowerror(yy, (pop)) + +#ifdef YY_COMPATIBLE +#undef yyerrok +#define yyerrok yymerrok(yy) +#undef yyclearin +#define yyclearin yymclearin(yy) +#endif +#define YYACCEPT yymaccept(yy) +#define YYABORT yymabort(yy) +#define YYERROR yymforceerror(yy) +#define YYRECOVERING yymrecovering(yy) + +#endif diff --git a/Utils/Parser Generator/INCLUDE/mlconv.h b/Utils/Parser Generator/INCLUDE/mlconv.h new file mode 100644 index 000000000..62e24367b --- /dev/null +++ b/Utils/Parser Generator/INCLUDE/mlconv.h @@ -0,0 +1,88 @@ +#ifndef MLCONV_H +#define MLCONV_H + +/************************************************************ +mlconv.h +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +/* variables */ +#define yymoreflg (YYLEXNAME).yymmoreflg +#define yyrejectflg (YYLEXNAME).yymrejectflg +#define yyreturnflg (YYLEXNAME).yymreturnflg +#define yytextgrow (YYLEXNAME).yymtextgrow +#define yyunputgrow (YYLEXNAME).yymunputgrow +#define yyeol (YYLEXNAME).yymeol +#define yyoldeol (YYLEXNAME).yymoldeol +#define yystart (YYLEXNAME).yymstart +#define yyin (YYLEXNAME).yymin +#define yyout (YYLEXNAME).yymout +#define yylexerr (YYLEXNAME).yymerr +#define yyleng (YYLEXNAME).yymleng +#define yylineno (YYLEXNAME).yymlineno +#define yyunputindex (YYLEXNAME).yymunputindex +#define yytext (YYLEXNAME).yymtext +#define yystext (YYLEXNAME).yymstext +#define yytext_size (YYLEXNAME).yymtext_size +#define yystext_size (YYLEXNAME).yymstext_size +#define yystatebuf (YYLEXNAME).yymstatebuf +#define yysstatebuf (YYLEXNAME).yymsstatebuf +#define yyunputbufptr (YYLEXNAME).yymunputbufptr +#define yysunputbufptr (YYLEXNAME).yymsunputbufptr +#define yyunput_size (YYLEXNAME).yymunputbufptr +#define yysunput_size (YYLEXNAME).yymsunput_size +#define yylexdebug (YYLEXNAME).yymdebug +#define yylexdebugflush (YYLEXNAME).yymdebugflush +#define yylexdebugout (YYLEXNAME).yymdebugout + +/* general functions */ +#define yylexinit() yymlexinit(&(YYLEXNAME)) +#define yylex() yymlex(&(YYLEXNAME)) +#define yyclex() yymclex(&(YYLEXNAME)) +#define yyreset() yymreset(&(YYLEXNAME)) +#define yylexcleanup() yymlexcleanup(&(YYLEXNAME)) +#define yysettextsize(size) yymsettextsize(&(YYLEXNAME), (size)) +#define yysetunputsize(size) yymsetunputsize(&(YYLEXNAME), (size)) + +/* service functions */ +#define yyinput() (*(YYLEXNAME).yyminput)(&(YYLEXNAME)) +#define yyoutput(ch) (*(YYLEXNAME).yymoutput)(&(YYLEXNAME), (ch)) +#define yyunput(ch) (*(YYLEXNAME).yymunput)(&(YYLEXNAME), (ch)) +#define yywrap() (*(YYLEXNAME).yymwrap)(&(YYLEXNAME)) +#define yygetchar() (*(YYLEXNAME).yymgetchar)(&(YYLEXNAME)) +#define yytextoverflow() (*(YYLEXNAME).yymtextoverflow)(&(YYLEXNAME)) +#define yyunputoverflow() (*(YYLEXNAME).yymunputoverflow)(&(YYLEXNAME)) + +/* action functions */ +#define yybegin(state) yymbegin(&(YYLEXNAME), (state)) +#define yyecho() yymecho(&(YYLEXNAME)) +#define yyless(length) yymless(&(YYLEXNAME), (length)) +#define yymore() yymmore(&(YYLEXNAME)) +#define yynewline(newline) yymnewline(&(YYLEXNAME), (newline)) +#define yyreject() yymreject(&(YYLEXNAME)) +#define yyunputcount() yymunputcount(&(YYLEXNAME)) + +/* compatibility */ +#define ECHO yyecho() +#define REJECT yyreject() +#define BEGIN (YYLEXNAME).yymstart = +#define YYSTATE (YYLEXNAME).yymstart +#define YY_START (YYLEXNAME).yymstart + +#ifndef input +#define input() (*(YYLEXNAME)->yyminput)(&(YYLEXNAME)) +#define YY_INPUT +#endif +#ifndef output +#define output(ch) (*(YYLEXNAME)->yymoutput)(&(YYLEXNAME), (ch)) +#define YY_OUTPUT +#endif +#ifdef unput +#define unput(ch) (*(YYLEXNAME)->yymunput)(&(YYLEXNAME), (ch)) +#define YY_UNPUT +#endif + +#endif diff --git a/Utils/Parser Generator/INCLUDE/mlex.h b/Utils/Parser Generator/INCLUDE/mlex.h new file mode 100644 index 000000000..89d5c7305 --- /dev/null +++ b/Utils/Parser Generator/INCLUDE/mlex.h @@ -0,0 +1,287 @@ +#ifndef MLEX_H +#define MLEX_H + +/************************************************************ +mlex.h +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include + +/* defines */ +#include + +/* user defines */ +#if defined(YYTUDEFS) || defined(YYUDEFS) +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define YY_ALEX + +/* modifiers */ +#ifndef YYCDECL +#define YYCDECL +#endif +#ifndef YYDCDECL +#define YYDCDECL +#endif +#ifndef YYNEAR +#define YYNEAR +#endif +#ifndef YYFAR +#define YYFAR +#endif +#ifndef YYNEARFAR +#define YYNEARFAR +#endif +#ifndef YYBASED_CODE +#define YYBASED_CODE +#endif + +/* function prototypes */ +#ifndef YYPROTOTYPE +#if defined(__STDC__) || defined(__cplusplus) +#define YYPROTOTYPE +#endif +#endif + +/* qualifiers */ +#ifndef YYCONST +#if defined(__STDC__) || defined(__cplusplus) +#define YYCONST const +#else +#define YYCONST +#endif +#endif + +/* testing */ +#ifdef YYNOPROTOTYPE +#undef YYPROTOTYPE +#endif +#ifdef YYNOCONST +#undef YYCONST +#define YYCONST +#endif + +/* yylex return values */ +#define YYEOF 0 /* end of file */ + +#ifndef YYSTATE_T +#define YYSTATE_T +typedef struct yystate { + short def; /* default state */ + short base; /* base */ + short match; /* action associated with state */ +} yystate_t; +#endif + +#ifndef YYTRANSITION_T +#define YYTRANSITION_T +typedef struct yytransition { + short next; /* next state on transition */ + short check; /* check */ +} yytransition_t; +#endif + +#ifndef YYCTRANSITION_T +#define YYCTRANSITION_T +typedef struct yyctransition { + unsigned char first; /* first character in range */ + unsigned char last; /* last character in range */ + short next; /* next state on transition */ +} yyctransition_t; +#endif + +typedef short yymatch_t; +typedef unsigned char yybackup_t; + +typedef struct yymlex { + /* flags */ + unsigned char yymmoreflg; /* concatenate matched strings */ + unsigned char yymrejectflg; /* yyreject called from an action */ + unsigned char yymreturnflg; /* return from an action */ + unsigned char yymtextgrow; /* whether text buffer is allowed to grow */ + unsigned char yymunputgrow; /* whether unput buffer is allowed to grow */ + unsigned char yymeol; /* whether an end-of-line '\n' has been seen */ + unsigned char yymoldeol; /* previous end-of-line value */ + int yymstart; /* current start state */ + + /* streams */ + FILE YYFAR *yymin; /* input text stream */ + FILE YYFAR *yymout; /* output text stream */ + FILE YYFAR *yymerr; /* error stream */ + + int yymleng; /* matched string length */ + int yymlineno; /* current line number */ + int yymunputindex; /* unput buffer position */ + + char YYFAR *yymtext; /* text buffer */ + char YYFAR *yymstext; /* initial (static) text buffer */ + int yymtext_size; /* text buffer size */ + int yymstext_size; /* initial (static) text buffer size */ + + int YYFAR *yymstatebuf; /* state buffer */ + int YYFAR *yymsstatebuf; /* initial (static) state buffer */ + + /* unput buffer */ + int YYFAR *yymunputbufptr; /* unput buffer */ + int YYFAR *yymsunputbufptr; /* initial (static) unput buffer */ + int yymunput_size; /* unput buffer size */ + int yymsunput_size; /* initial (static) unput buffer size */ + + /* functions */ +#ifdef YYPROTOTYPE + int (YYCDECL *yyminput)(struct yymlex YYFAR *yy); + void (YYCDECL *yymoutput)(struct yymlex YYFAR *yy, int ch); + void (YYCDECL *yymunput)(struct yymlex YYFAR *yy, int ch); + int (YYCDECL *yymwrap)(struct yymlex YYFAR *yy); + int (YYCDECL *yymgetchar)(struct yymlex YYFAR *yy); + void (YYCDECL *yymtextoverflow)(struct yymlex YYFAR *yy); + void (YYCDECL *yymunputoverflow)(struct yymlex YYFAR *yy); + int (YYCDECL *yymlexaction)(struct yymlex YYFAR *yy, int action); +#else + int (YYCDECL *yyminput)(); + void (YYCDECL *yymoutput)(); + void (YYCDECL *yymunput)(); + int (YYCDECL *yymwrap)(); + int (YYCDECL *yymgetchar)(); + void (YYCDECL *yymtextoverflow)(); + void (YYCDECL *yymunputoverflow)(); + int (YYCDECL *yymlexaction)(); +#endif + + /* tables */ + /* fast lexical analyser */ + YYCONST yytransition_t YYNEARFAR *yymtransition; + int yymtransitionmax; + /* compact lexical analyser */ + YYCONST yyctransition_t YYNEARFAR *yymctransition; + /* common */ + YYCONST yymatch_t YYNEARFAR *yymmatch; + YYCONST yystate_t YYNEARFAR *yymstate; + YYCONST yybackup_t YYNEARFAR *yymbackup; + + void YYFAR *yymdata; /* user data */ + + /* debugging */ +#ifdef YYDEBUG + int yymdebug; + int yymdebugflush; + FILE YYFAR *yymdebugout; +#endif +} yymlex_t; + +/* instance functions */ +#ifdef YYPROTOTYPE +int YYCDECL yymcreatelex(yymlex_t YYFAR *yy, YYCONST yymlex_t YYFAR *src); +void YYCDECL yymdestroylex(yymlex_t YYFAR *yy); +#else +int YYCDECL yymcreatelex(); +void YYCDECL yymdestroylex(); +#endif + +/* general functions */ +#ifdef YYPROTOTYPE +int YYCDECL yymclex(yymlex_t YYFAR *yy); +int YYCDECL yymlex(yymlex_t YYFAR *yy); +void YYCDECL yymlexcleanup(yymlex_t YYFAR *yy); +void YYCDECL yymlexinit(yymlex_t YYFAR *yy); +void YYCDECL yymreset(yymlex_t YYFAR *yy); +int YYCDECL yymsettextsize(yymlex_t YYFAR *yy, int size); +int YYCDECL yymsetunputsize(yymlex_t YYFAR *yy, int size); +#else +int YYCDECL yymclex(); +int YYCDECL yymlex(); +void YYCDECL yymlexcleanup(); +void YYCDECL yymlexinit(); +void YYCDECL yymreset(); +int YYCDECL yymsettextsize(); +int YYCDECL yymsetunputsize(); +#endif + +/* service functions */ +#ifdef YYPROTOTYPE +int YYCDECL yymgetchar(yymlex_t YYFAR *yy); +int YYCDECL yyminput(yymlex_t YYFAR *yy); +void YYCDECL yymoutput(yymlex_t YYFAR *yy, int ch); +void YYCDECL yymtextoverflow(yymlex_t YYFAR *yy); +void YYCDECL yymunput(yymlex_t YYFAR *yy, int ch); +void YYCDECL yymunputoverflow(yymlex_t YYFAR *yy); +int YYCDECL yymwrap(yymlex_t YYFAR *yy); +#else +int YYCDECL yymgetchar(); +int YYCDECL yyminput(); +void YYCDECL yymoutput(); +void YYCDECL yymtextoverflow(); +void YYCDECL yymunput(); +void YYCDECL yymunputoverflow(); +int YYCDECL yymwrap(); +#endif + +/* action functions */ +#ifdef YYPROTOTYPE +void YYCDECL yymecho(yymlex_t YYFAR *yy); +void YYCDECL yymless(yymlex_t YYFAR *yy, int length); +#else +void YYCDECL yymecho(); +void YYCDECL yymless(); +#endif +#define yymbegin(yy, state) ((yy)->yymstart = (state)) +#define yymmore(yy) ((yy)->yymmoreflg = 1) +#define yymnewline(yy, newline) ((newline) ? (yy)->yymeol = 1 : ((yy)->yymeol = 0)) +#define yymreject(yy) ((yy)->yymrejectflg = 1) +#define yymunputcount(yy) (yy)->yymunputindex + +/* helper functions */ +#ifdef YYPROTOTYPE +int YYCDECL yymback(YYCONST yymatch_t YYNEARFAR *p, int action); +#else +int YYCDECL yymback(); +#endif +#ifndef yyassert +#define yyassert(expr) assert(expr) +#endif + +/* debugging functions */ +#ifdef YYDEBUG +#ifdef YYPROTOTYPE +void YYCDECL yymdebugoutput(yymlex_t YYFAR *yy, int ch); +void YYCDECL yymdmatch(yymlex_t YYFAR *yy, int expr); +void YYCDECL yymlexdebugoutput(yymlex_t YYFAR *yy, YYCONST char *string); +#else +void YYCDECL yymdebugoutput(); +void YYCDECL yymdmatch(); +void YYCDECL yymlexdebugoutput(); +#endif +#endif + +#define yymisfastlexer(yy) ((yy)->yymtransition != NULL) +#define yymiscompactlexer(yy) ((yy)->yymctransition != NULL) + +/* debugging variables */ +#ifdef YYDEBUG +extern int YYNEAR YYDCDECL yydebug; +extern int YYNEAR YYDCDECL yydebugflush; +#endif + +#ifdef __cplusplus +} +#endif + +/* user defines */ +#if defined(YYBUDEFS) || defined(YYUDEFS) +#include +#endif + +/* defines */ +#include + +#endif diff --git a/Utils/Parser Generator/INCLUDE/myacc.h b/Utils/Parser Generator/INCLUDE/myacc.h new file mode 100644 index 000000000..ffa4b1a0a --- /dev/null +++ b/Utils/Parser Generator/INCLUDE/myacc.h @@ -0,0 +1,436 @@ +#ifndef MYACC_H +#define MYACC_H + +/************************************************************ +myacc.h +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include +#include + +/* defines */ +#include + +/* user defines */ +#if defined(YYTUDEFS) || defined(YYUDEFS) +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define YY_AYACC + +/* modifiers */ +#ifndef YYCDECL +#define YYCDECL +#endif +#ifndef YYDCDECL +#define YYDCDECL +#endif +#ifndef YYNEAR +#define YYNEAR +#endif +#ifndef YYFAR +#define YYFAR +#endif +#ifndef YYNEARFAR +#define YYNEARFAR +#endif +#ifndef YYBASED_CODE +#define YYBASED_CODE +#endif + +/* function prototypes */ +#ifndef YYPROTOTYPE +#if defined(__STDC__) || defined(__cplusplus) +#define YYPROTOTYPE +#endif +#endif + +/* qualifiers */ +#ifndef YYCONST +#if defined(__STDC__) || defined(__cplusplus) +#define YYCONST const +#else +#define YYCONST +#endif +#endif + +/* testing */ +#ifdef YYNOPROTOTYPE +#undef YYPROTOTYPE +#endif +#ifdef YYNOCONST +#undef YYCONST +#define YYCONST +#endif + +typedef short yystack_t; + +/* yyparse return values */ +#define YYEXIT_SUCCESS 0 +#define YYEXIT_FAILURE 1 + +/* common tokens */ +#define YYTK_ALL (-1) /* match all tokens */ +#define YYTK_END 0 /* $end token */ +#define YYTK_ERROR 256 /* error token */ + +#ifndef YYCSTATEGOTO_T +#define YYCSTATEGOTO_T +typedef short yycstategoto_t; +#endif + +#ifndef YYCNONTERMGOTO_T +#define YYCNONTERMGOTO_T +typedef struct yycnontermgoto { + short nonterm; /* nonterminal */ + short next; /* next state */ +} yycnontermgoto_t; +#endif + +#ifndef YYSTATEGOTO_T +#define YYSTATEGOTO_T +typedef struct yystategoto { + short base; /* base */ + short def; /* default state */ +} yystategoto_t; +#endif + +#ifndef YYNONTERMGOTO_T +#define YYNONTERMGOTO_T +typedef struct yynontermgoto { + short check; /* check */ + short next; /* next state */ +} yynontermgoto_t; +#endif + +/* action types */ +#define YYAT_SHIFT 0 /* shift action */ +#define YYAT_REDUCE 1 /* reduce action */ +#define YYAT_ERROR 2 /* error */ +#define YYAT_ACCEPT 3 /* accept */ +#define YYAT_DEFAULT 4 /* default state */ + +#ifndef YYCSTATEACTION_T +#define YYCSTATEACTION_T +typedef short yycstateaction_t; +#endif + +#ifndef YYCTOKENACTION_T +#define YYCTOKENACTION_T +typedef struct yyctokenaction { + int token; /* lookahead token */ + unsigned char type; /* action to perform */ + short sr; /* state to shift/production to reduce */ +} yyctokenaction_t; +#endif + +#ifndef YYSTATEACTION_T +#define YYSTATEACTION_T +typedef struct yystateaction { + short base; /* base */ + unsigned char lookahead; /* lookahead needed */ + unsigned char type; /* action to perform */ + short sr; /* shift/reduce */ +} yystateaction_t; +#endif + +#ifndef YYTOKENACTION_T +#define YYTOKENACTION_T +typedef struct yytokenaction { + short check; /* check */ + unsigned char type; /* action type */ + short sr; /* shift/reduce */ +} yytokenaction_t; +#endif + +/* nonterminals */ +#define YYST_ALL (-1) /* match all states */ + +/* states */ +#define YYST_ERROR (-1) /* goto error */ + +#ifndef YYREDUCTION_T +#define YYREDUCTION_T +typedef struct yyreduction { + short nonterm; /* the rhs symbol */ + short length; /* number of symbols on lhs */ + short action; /* the user action */ +} yyreduction_t; +#endif + +typedef short yydestructor_t; + +typedef short yytokendest_t; + +#ifndef YYCTOKENDEST_T +#define YYCTOKENDEST_T +typedef struct yyctokendest { + int token; /* token */ + short action; /* the user action */ +} yyctokendest_t; +#endif + +/* debugging */ +#ifdef YYDEBUG +#ifndef YYSYMBOL_T +#define YYSYMBOL_T +typedef struct yysymbol { + YYCONST char *name; /* symbol name */ + int token; /* symbol token */ +} yysymbol_t; +#endif +#endif + +typedef struct yymparse { + /* flags */ + unsigned char yymlookahead; /* whether current lookahead token is valid */ + unsigned char yymstackgrow; /* whether stack can grow */ + unsigned char yymexitflg; /* whether yymexit called */ + unsigned char yymretireflg; /* whether yymretire called */ + unsigned char yymerrorflg; /* whether yymforceerror called */ + unsigned char yympopflg; /* popping symbols during error recovery */ + unsigned char yymwipeflg; /* whether to "wipe" stack on abort */ + + int yymtop; /* the current top of the stack */ + int yymchar; /* current lookahead token */ + int yymskip; /* error recovery token shift counter */ + int yymerrorcount; /* how many syntax errors have occurred */ + int yymexitcode; /* yymexit exit code */ + int yymretirecode; /* yymretire exit code */ + int yymerrorpop; /* how many error transitions to pop */ + FILE YYFAR *yymerr; /* error output file */ + + /* stack */ + yystack_t YYFAR *yymstackptr; /* (state) stack */ + yystack_t YYFAR *yymsstackptr; /* static (state) stack */ + int yymstack_size; /* number of elements in stack */ + int yymsstack_size; /* initial number of elements in stack */ + + size_t yymattribute_size; /* size of attribute */ + +#ifdef YYPROTOTYPE + void YYFAR *yymvalptr; /* attribute for $$ */ + void YYFAR *yymlvalptr; /* current token attribute */ + void YYFAR *yymattributestackptr; /* attribute stack */ + void YYFAR *yymsattributestackptr; /* static attribute stack */ +#else + char YYFAR *yymvalptr; /* attribute for $$ */ + char YYFAR *yymlvalptr; /* current token attribute */ + char YYFAR *yymattributestackptr; /* attribute stack */ + char YYFAR *yymsattributestackptr; /* static attribute stack */ +#endif + + /* service functions */ +#ifdef YYPROTOTYPE + void (YYCDECL *yymstackoverflow)(struct yymparse YYFAR *yy); + void (YYCDECL *yymerror)(struct yymparse YYFAR *yy, YYCONST char YYFAR *text); + void (YYCDECL *yymsyntaxerror)(struct yymparse YYFAR *yy); + void (YYCDECL *yymdiscard)(struct yymparse YYFAR *yy, int token); + int (YYCDECL *yymgettoken)(struct yymparse YYFAR *yy); + void (YYCDECL *yymparseaction)(struct yymparse YYFAR *yy, int action); +#else + void (YYCDECL *yymstackoverflow)(); + void (YYCDECL *yymerror)(); + void (YYCDECL *yymsyntaxerror)(); + void (YYCDECL *yymdiscard)(); + int (YYCDECL *yymgettoken)(); + void (YYCDECL *yymparseaction)(); +#endif + + /* tables */ + /* fast parser */ + YYCONST yystateaction_t YYNEARFAR *yymstateaction; + YYCONST yytokenaction_t YYNEARFAR *yymtokenaction; + int yymtokenaction_size; + YYCONST yystategoto_t YYNEARFAR *yymstategoto; + YYCONST yynontermgoto_t YYNEARFAR *yymnontermgoto; + int yymnontermgoto_size; + YYCONST yytokendest_t YYNEARFAR *yymtokendestptr; + int yymtokendest_size; + int yymtokendestbase; + /* compact parser */ + YYCONST yycstateaction_t YYNEARFAR *yymcstateaction; + YYCONST yyctokenaction_t YYNEARFAR *yymctokenaction; + YYCONST yycstategoto_t YYNEARFAR *yymcstategoto; + YYCONST yycnontermgoto_t YYNEARFAR *yymcnontermgoto; + YYCONST yyctokendest_t YYNEARFAR *yymctokendestptr; + /* common */ + YYCONST yyreduction_t YYNEARFAR *yymreduction; + + YYCONST yydestructor_t YYNEARFAR *yymdestructorptr; + + void YYFAR *yymdata; /* user data */ + + /* debugging */ +#ifdef YYDEBUG + int yymdebug; + int yymdebugstack; + int yymdebugflush; + FILE YYFAR *yymdebugout; + YYCONST yysymbol_t YYNEARFAR *yymsymbol; + YYCONST char *YYCONST YYNEARFAR *yymrule; +#endif +} yymparse_t; + +/* instance functions */ +#ifdef YYPROTOTYPE +int YYCDECL yymcreateparse(yymparse_t YYFAR *yy, YYCONST yymparse_t YYFAR *src); +void YYCDECL yymdestroyparse(yymparse_t YYFAR *yy); +#else +int YYCDECL yymcreateparse(); +void YYCDECL yymdestroyparse(); +#endif + +/* general functions */ +#ifdef YYPROTOTYPE +int YYCDECL yymcparse(yymparse_t YYFAR *yy); +void YYCDECL yymcwipe(yymparse_t YYFAR *yy); +int YYCDECL yymcwork(yymparse_t YYFAR *yy); +void YYCDECL yymdestructpop(yymparse_t YYFAR *yy, int num); +int YYCDECL yymparse(yymparse_t YYFAR *yy); +void YYCDECL yymparsecleanup(yymparse_t YYFAR *yy); +void YYCDECL yymparseinit(yymparse_t YYFAR *yy); +int YYCDECL yymsetstacksize(yymparse_t YYFAR *yy, int size); +int YYCDECL yymsetup(yymparse_t YYFAR *yy); +void YYCDECL yymwipe(yymparse_t YYFAR *yy); +int YYCDECL yymwork(yymparse_t YYFAR *yy); +#else +int YYCDECL yymcparse(); +void YYCDECL yymcwipe(); +int YYCDECL yymcwork(); +void YYCDECL yymdestructpop(); +int YYCDECL yymparse(); +void YYCDECL yymparsecleanup(); +void YYCDECL yymparseinit(); +int YYCDECL yymsetstacksize(); +int YYCDECL yymsetup(); +void YYCDECL yymwipe(); +int YYCDECL yymwork(); +#endif + +/* service functions */ +#ifdef YYPROTOTYPE +void YYCDECL yymdiscard(yymparse_t YYFAR *yy, int token); +void YYCDECL yymerror(yymparse_t YYFAR *yy, YYCONST char YYFAR *text); +int YYCDECL yymgettoken(yymparse_t YYFAR *yy); +void YYCDECL yymstackoverflow(yymparse_t YYFAR *yy); +void YYCDECL yymsyntaxerror(yymparse_t YYFAR *yy); +#else +void YYCDECL yymdiscard(); +void YYCDECL yymerror(); +int YYCDECL yymgettoken(); +void YYCDECL yymstackoverflow(); +void YYCDECL yymsyntaxerror(); +#endif + +/* action functions */ +#ifdef YYPROTOTYPE +void YYCDECL yymcdestructclearin(yymparse_t YYFAR *yy); +void YYCDECL yymdestructclearin(yymparse_t YYFAR *yy); +void YYCDECL yymsetin(yymparse_t YYFAR *yy, int token); +int YYCDECL yymunclearin(yymparse_t YYFAR *yy); +#else +void YYCDECL yymcdestructclearin(); +void YYCDECL yymdestructclearin(); +void YYCDECL yymsetin(); +int YYCDECL yymunclearin(); +#endif +#define yymabort(yy) yymexit(1) +#define yymaccept(yy) yymexit(0) +#define yymclearin(yy) ((yy)->yymlookahead = 0) +#define yymerrok(yy) yymsetskip((yy), 0) +#define yymexit(yy, exitcode) ((yy)->yymexitflg = 1, (yy)->yymexitcode = (exitcode)) +#define yymforceerror(yy) yymthrowerror(0) +#define yympopping(yy) (yy)->yympopflg +#define yymrecovering(yy) ((yy)->yymskip > 0) +#define yymretire(yy, retirecode) ((yy)->yymretireflg = 1, (yy)->yymretirecode = (retirecode)) +#define yymthrowerror(yy, pop) ((yy)->yymerrorflg = 1, (yy)->yymerrorpop = (pop)) + +/* utility functions */ +#ifdef YYPROTOTYPE +#ifdef YYDEBUG +void YYCDECL yympop(yymparse_t YYFAR *yy, int num); +void YYCDECL yymsetskip(yymparse_t YYFAR *yy, int skip); +#endif +int YYCDECL yympush(yymparse_t YYFAR *yy, yystack_t state); +#else +#ifdef YYDEBUG +void YYCDECL yympop(); +void YYCDECL yymsetskip(); +#endif +int YYCDECL yympush(); +#endif +#ifndef yyassert +#define yyassert(expr) assert(expr) +#endif +#define yympeek(yy) ((yy)->yymstackptr[(yy)->yymtop]) +#ifndef YYDEBUG +#define yympop(yy, num) ((yy)->yymtop -= (num)) +#define yymsetskip(yy, skip) ((yy)->yymskip = (skip)) +#endif + +/* debugging functions */ +#ifdef YYDEBUG +#ifdef YYPROTOTYPE +YYCONST char *YYCDECL yymtokenstring(yymparse_t YYFAR *yy, int token); +void YYCDECL yymdgettoken(yymparse_t YYFAR *yy, int token); +void YYCDECL yymdshift(yymparse_t YYFAR *yy, int token); +void YYCDECL yymdreduce(yymparse_t YYFAR *yy, int rule); +void YYCDECL yymdsyntaxerror(yymparse_t YYFAR *yy); +void YYCDECL yymdaccept(yymparse_t YYFAR *yy); +void YYCDECL yymdabort(yymparse_t YYFAR *yy); +void YYCDECL yymddiscard(yymparse_t YYFAR *yy, int token); +void YYCDECL yymdexit(yymparse_t YYFAR *yy, int exitcode); +void YYCDECL yymdthrowerror(yymparse_t YYFAR *yy, int errorpop); +void YYCDECL yymdretire(yymparse_t YYFAR *yy, int retirecode); +void YYCDECL yymdattemptrecovery(yymparse_t YYFAR *yy); +void YYCDECL yymparsedebugoutput(yymparse_t YYFAR *yy, YYCONST char *string); +#else +YYCONST char *YYCDECL yymtokenstring(); +void YYCDECL yymdgettoken(); +void YYCDECL yymdshift(); +void YYCDECL yymdreduce(); +void YYCDECL yymdsyntaxerror(); +void YYCDECL yymdaccept(); +void YYCDECL yymdabort(); +void YYCDECL yymddiscard(); +void YYCDECL yymdexit(); +void YYCDECL yymdthrowerror(); +void YYCDECL yymdretire(); +void YYCDECL yymdattemptrecovery(); +void YYCDECL yymparsedebugoutput(); +#endif +#endif + +#define yymisfastparser(yy) ((yy)->yymstateaction != NULL) +#define yymiscompactparser(yy) ((yy)->yymcstateaction != NULL) + +/* debugging variables */ +#ifdef YYDEBUG +extern int YYNEAR YYDCDECL yydebug; +extern int YYNEAR YYDCDECL yydebugstack; +extern int YYNEAR YYDCDECL yydebugflush; +#endif + +#ifdef __cplusplus +} +#endif + +/* user defines */ +#if defined(YYBUDEFS) || defined(YYUDEFS) +#include +#endif + +/* defines */ +#include + +#endif diff --git a/Utils/Parser Generator/INCLUDE/myconv.h b/Utils/Parser Generator/INCLUDE/myconv.h new file mode 100644 index 000000000..38c705204 --- /dev/null +++ b/Utils/Parser Generator/INCLUDE/myconv.h @@ -0,0 +1,90 @@ +#ifndef MYCONV_H +#define MYCONV_H + +/************************************************************ +myconv.h +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +/* variables */ +#define yylookahead (YYPARSENAME).yymlookahead +#define yystackgrow (YYPARSENAME).yymstackgrow +#define yyexitflg (YYPARSENAME).yymexitflg +#define yyretireflg (YYPARSENAME).yymretireflg +#define yyerrorflg (YYPARSENAME).yymerrorflg +#define yypopflg (YYPARSENAME).yympopflg +#define yywipeflg (YYPARSENAME).yymwipeflg +#define yytop (YYPARSENAME).yymtop +#define yychar (YYPARSENAME).yymchar +#define yyskip (YYPARSENAME).yymskip +#define yyerrorcount (YYPARSENAME).yymerrorcount +#define yyexitcode (YYPARSENAME).yymexitcode +#define yyretirecode (YYPARSENAME).yymretirecode +#define yyerrorpop (YYPARSENAME).yymerrorpop +#define yyparseerr (YYPARSENAME).yymerr +#define yystackptr (YYPARSENAME).yymstackptr +#define yysstackptr (YYPARSENAME).yymsstackptr +#define yystack_size (YYPARSENAME).yymstack_size +#define yysstack_size (YYPARSENAME).yymsstack_size +#define yyattribute_size (YYPARSENAME).yymattribute_size +#define yyvalptr (YYPARSENAME).yymvalptr +#define yylvalptr (YYPARSENAME).yymlvalptr +#define yyattributestackptr (YYPARSENAME).yymattributestackptr +#define yysattributestackptr (YYPARSENAME).yymsattributestackptr +#define yyparsedebug (YYPARSENAME).yymdebug +#define yyparsedebugstack (YYPARSENAME)->yymdebugstack +#define yyparsedebugflush (YYPARSENAME).yymdebugflush +#define yyparsedebugout (YYPARSENAME).yymdebugout + +/* general functions */ +#define yycparse() yymcparse(&(YYPARSENAME)) +#define yycwipe() yymcwipe(&(YYPARSENAME)) +#define yycwork() yymcwork(&(YYPARSENAME)) +#define yydestructpop(num) yymdestructpop(&(YYPARSENAME), (pop)) +#define yyparse() yymparse(&(YYPARSENAME)) +#define yyparsecleanup() yymparsecleanup(&(YYPARSENAME)) +#define yyparseinit() yymparseinit(&(YYPARSENAME)) +#define yysetstacksize(size) yymsetstacksize(&(YYPARSENAME), (size)) +#define yysetup() yymsetup(&(YYPARSENAME)) +#define yywipe() yymwipe(&(YYPARSENAME)) +#define yywork() yymwork(&(YYPARSENAME)) + +/* service functions */ +#define yygettoken() (*(YYPARSENAME).yymgettoken)(&(YYPARSENAME)) +#define yystackoverflow() (*(YYPARSENAME).yymstackoverflow)(&(YYPARSENAME)) +#define yyerror(text) (*(YYPARSENAME).yymerror)(&(YYPARSENAME), (text)) +#define yysyntaxerror() (*(YYPARSENAME).yymsyntaxerror)(&(YYPARSENAME)) +#define yydiscard() (*(YYPARSENAME).yymdiscard)(&(YYPARSENAME)) + +/* action functions */ +#define yycdestructclearin() yymcdestructclearin(&(YYPARSENAME)) +#define yydestructclearin() yymdestructclearin(&(YYPARSENAME)) +#define yysetin(token) yymsetin(&(YYPARSENAME), (token) +#define yyunclearin() yymunclearin(&(YYPARSENAME)) +#define yyabort() yymabort(&(YYPARSENAME)) +#define yyaccept() yymaccept(&(YYPARSENAME)) +#define yyclearin() yymclearin(&(YYPARSENAME)) +#define yydestructclearin() yymdestructclearin(&(YYPARSENAME)) +#define yyerrok() yymerrok(&(YYPARSENAME)) +#define yyexit(exitcode) yymexit(&(YYPARSENAME), (exitcode)) +#define yyforceerror() yymforceerror(&(YYPARSENAME)) +#define yypopping() yympopping(&(YYPARSENAME)) +#define yyrecovering() yymrecovering(&(YYPARSENAME)) +#define yyretire(retirecode) yymretire(&(YYPARSENAME), (retirecode)) +#define yythrowerror(pop) yymthrowerror(&YYPARSENAME), (pop)) + +#ifdef YY_COMPATIBLE +#undef yyerrok +#define yyerrok yymerrok(&(YYPARSENAME)) +#undef yyclearin +#define yyclearin yymclearin(&(YYPARSENAME)) +#endif +#define YYACCEPT yymaccept(&(YYPARSENAME)) +#define YYABORT yymabort(&(YYPARSENAME)) +#define YYERROR yymforceerror(&(YYPARSENAME)) +#define YYRECOVERING yymrecovering(&(YYPARSENAME)) + +#endif diff --git a/Utils/Parser Generator/INCLUDE/yacc.h b/Utils/Parser Generator/INCLUDE/yacc.h new file mode 100644 index 000000000..a496a63b1 --- /dev/null +++ b/Utils/Parser Generator/INCLUDE/yacc.h @@ -0,0 +1,418 @@ +#ifndef YACC_H +#define YACC_H + +/************************************************************ +yacc.h +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include +#include + +/* defines */ +#include + +/* user defines */ +#if defined(YYTUDEFS) || defined(YYUDEFS) +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define YY_AYACC + +/* modifiers */ +#ifndef YYCDECL +#define YYCDECL +#endif +#ifndef YYDCDECL +#define YYDCDECL +#endif +#ifndef YYNEAR +#define YYNEAR +#endif +#ifndef YYFAR +#define YYFAR +#endif +#ifndef YYNEARFAR +#define YYNEARFAR +#endif +#ifndef YYBASED_CODE +#define YYBASED_CODE +#endif + +/* function prototypes */ +#ifndef YYPROTOTYPE +#if defined(__STDC__) || defined(__cplusplus) +#define YYPROTOTYPE +#endif +#endif + +/* qualifiers */ +#ifndef YYCONST +#if defined(__STDC__) || defined(__cplusplus) +#define YYCONST const +#else +#define YYCONST +#endif +#endif + +/* testing */ +#ifdef YYNOPROTOTYPE +#undef YYPROTOTYPE +#endif +#ifdef YYNOCONST +#undef YYCONST +#define YYCONST +#endif + +typedef short yystack_t; + +/* yyparse return values */ +#define YYEXIT_SUCCESS 0 +#define YYEXIT_FAILURE 1 + +/* common tokens */ +#define YYTK_ALL (-1) /* match all tokens */ +#define YYTK_END 0 /* $end token */ +#define YYTK_ERROR 256 /* error token */ + +#ifndef YYCSTATEGOTO_T +#define YYCSTATEGOTO_T +typedef short yycstategoto_t; +#endif + +#ifndef YYCNONTERMGOTO_T +#define YYCNONTERMGOTO_T +typedef struct yycnontermgoto { + short nonterm; /* nonterminal */ + short next; /* next state */ +} yycnontermgoto_t; +#endif + +#ifndef YYSTATEGOTO_T +#define YYSTATEGOTO_T +typedef struct yystategoto { + short base; /* base */ + short def; /* default state */ +} yystategoto_t; +#endif + +#ifndef YYNONTERMGOTO_T +#define YYNONTERMGOTO_T +typedef struct yynontermgoto { + short check; /* check */ + short next; /* next state */ +} yynontermgoto_t; +#endif + +/* action types */ +#define YYAT_SHIFT 0 /* shift action */ +#define YYAT_REDUCE 1 /* reduce action */ +#define YYAT_ERROR 2 /* error */ +#define YYAT_ACCEPT 3 /* accept */ +#define YYAT_DEFAULT 4 /* default state */ + +#ifndef YYCSTATEACTION_T +#define YYCSTATEACTION_T +typedef short yycstateaction_t; +#endif + +#ifndef YYCTOKENACTION_T +#define YYCTOKENACTION_T +typedef struct yyctokenaction { + int token; /* lookahead token */ + unsigned char type; /* action to perform */ + short sr; /* state to shift/production to reduce */ +} yyctokenaction_t; +#endif + +#ifndef YYSTATEACTION_T +#define YYSTATEACTION_T +typedef struct yystateaction { + short base; /* base */ + unsigned char lookahead; /* lookahead needed */ + unsigned char type; /* action to perform */ + short sr; /* shift/reduce */ +} yystateaction_t; +#endif + +#ifndef YYTOKENACTION_T +#define YYTOKENACTION_T +typedef struct yytokenaction { + short check; /* check */ + unsigned char type; /* action type */ + short sr; /* shift/reduce */ +} yytokenaction_t; +#endif + +/* nonterminals */ +#define YYNT_ALL (-1) /* match all nonterminals */ + +/* states */ +#define YYST_ERROR (-1) /* goto error */ + +#ifndef YYREDUCTION_T +#define YYREDUCTION_T +typedef struct yyreduction { + short nonterm; /* the rhs symbol */ + short length; /* number of symbols on lhs */ + short action; /* the user action */ +} yyreduction_t; +#endif + +typedef short yydestructor_t; + +typedef short yytokendest_t; + +#ifndef YYCTOKENDEST_T +#define YYCTOKENDEST_T +typedef struct yyctokendest { + int token; /* token */ + short action; /* the user action */ +} yyctokendest_t; +#endif + +/* debugging */ +#ifdef YYDEBUG +#ifndef YYSYMBOL_T +#define YYSYMBOL_T +typedef struct yysymbol { + YYCONST char *name; /* symbol name */ + int token; /* symbol token */ +} yysymbol_t; +#endif +#endif + +/* general functions */ +#ifdef YYPROTOTYPE +int YYCDECL yycparse(void); +void YYCDECL yycwipe(void); +int YYCDECL yycwork(void); +void YYCDECL yydestructpop(int num); +int YYCDECL yyparse(void); +void YYCDECL yyparsecleanup(void); +void YYCDECL yyparseinit(void); +int YYCDECL yysetstacksize(int size); +int YYCDECL yysetup(void); +void YYCDECL yywipe(void); +int YYCDECL yywork(void); +#else +int YYCDECL yycparse(); +void YYCDECL yycwipe(); +int YYCDECL yycwork(); +void YYCDECL yydestructpop(); +int YYCDECL yyparse(); +void YYCDECL yyparsecleanup(); +void YYCDECL yyparseinit(); +int YYCDECL yysetstacksize(); +int YYCDECL yysetup(); +void YYCDECL yywipe(); +int YYCDECL yywork(); +#endif + +/* service functions */ +#ifdef YYPROTOTYPE +void YYCDECL yydiscard(int token); +void YYCDECL yyerror(YYCONST char YYFAR *text); +int YYCDECL yygettoken(void); +void YYCDECL yystackoverflow(void); +void YYCDECL yysyntaxerror(void); +#else +void YYCDECL yydiscard(); +void YYCDECL yyerror(); +int YYCDECL yygettoken(); +void YYCDECL yystackoverflow(); +void YYCDECL yysyntaxerror(); +#endif + +/* action functions */ +#ifdef YYPROTOTYPE +void YYCDECL yycdestructclearin(void); +void YYCDECL yydestructclearin(void); +void YYCDECL yysetin(int token); +int YYCDECL yyunclearin(void); +#else +void YYCDECL yycdestructclearin(); +void YYCDECL yydestructclearin(); +void YYCDECL yysetin(); +int YYCDECL yyunclearin(); +#endif +#define yyabort() yyexit(1) +#define yyaccept() yyexit(0) +#define yyclearin() (yylookahead = 0) +#define yyerrok() yysetskip(0) +#define yyexit(exitcode) (yyexitflg = 1, yyexitcode = (exitcode)) +#define yyforceerror() yythrowerror(0) +#define yypopping() yypopflg +#define yyrecovering() (yyskip > 0) +#define yyretire(retirecode) (yyretireflg = 1, yyretirecode = (retirecode)) +#define yythrowerror(pop) (yyerrorflg = 1, yyerrorpop = (pop)) + +/* compatibility */ +#ifdef YY_COMPATIBLE +#undef yyclearin +#define yyclearin (yylookahead = 0) +#undef yyerrok +#define yyerrok yysetskip(0) +#endif +#define YYABORT yyexit(1) +#define YYACCEPT yyexit(0) +#define YYERROR yyforceerror() +#define YYRECOVERING yyrecovering() + +/* helper functions */ +#ifdef YYPROTOTYPE +#ifdef YYDEBUG +void YYCDECL yypop(int num); +void YYCDECL yysetskip(int skip); +#endif +int YYCDECL yypush(yystack_t state); +#else +#ifdef YYDEBUG +void YYCDECL yypop(); +void YYCDECL yysetskip(); +#endif +int YYCDECL yypush(); +#endif +#ifndef yyassert +#define yyassert(expr) assert(expr) +#endif +#define yypeek() (yystackptr[yytop]) +#ifndef YYDEBUG +#define yypop(num) (yytop -= (num)) +#define yysetskip(skip) (yyskip = (skip)) +#endif + +/* variables */ +extern unsigned char YYNEAR YYDCDECL yylookahead; +extern unsigned char YYNEAR YYDCDECL yystackgrow; +extern unsigned char YYNEAR YYDCDECL yyexitflg; +extern unsigned char YYNEAR YYDCDECL yyretireflg; +extern unsigned char YYNEAR YYDCDECL yyerrorflg; +extern unsigned char YYNEAR YYDCDECL yypopflg; +extern unsigned char YYNEAR YYDCDECL yywipeflg; +extern int YYNEAR YYDCDECL yytop; /* the current top of the stack */ +extern int YYNEAR YYDCDECL yychar; +extern int YYNEAR YYDCDECL yyskip; +extern int YYNEAR YYDCDECL yyerrorcount; +extern FILE YYFAR *YYNEAR YYDCDECL yyparseerr; +extern int YYNEAR YYDCDECL yyexitcode; +extern int YYNEAR YYDCDECL yyretirecode; +extern int YYNEAR YYDCDECL yyerrorpop; + +/* debugging functions */ +#ifdef YYDEBUG +#ifdef YYPROTOTYPE +YYCONST char *YYCDECL yytokenstring(int token); +void YYCDECL yydgettoken(int token); +void YYCDECL yydshift(int token); +void YYCDECL yydreduce(int rule); +void YYCDECL yydsyntaxerror(void); +void YYCDECL yydaccept(void); +void YYCDECL yydabort(void); +void YYCDECL yyddiscard(int token); +void YYCDECL yydexit(int exitcode); +void YYCDECL yydthrowerror(int errorpop); +void YYCDECL yydretire(int retirecode); +void YYCDECL yydattemptrecovery(void); +void YYCDECL yyparsedebugoutput(YYCONST char *string); +#else +YYCONST char *YYCDECL yytokenstring(); +void YYCDECL yydgettoken(); +void YYCDECL yydshift(); +void YYCDECL yydreduce(); +void YYCDECL yydsyntaxerror(); +void YYCDECL yydaccept(); +void YYCDECL yydabort(); +void YYCDECL yyddiscard(); +void YYCDECL yydexit(); +void YYCDECL yydthrowerror(); +void YYCDECL yydretire(); +void YYCDECL yydattemptrecovery(); +void YYCDECL yyparsedebugoutput(); +#endif +#endif + +/* debugging variables */ +#ifdef YYDEBUG +extern int YYNEAR YYDCDECL yydebug; +extern int YYNEAR YYDCDECL yydebugstack; +extern int YYNEAR YYDCDECL yydebugflush; +extern int YYNEAR YYDCDECL yyparsedebug; +extern int YYNEAR YYDCDECL yyparsedebugstack; +extern int YYNEAR YYDCDECL yyparsedebugflush; +extern FILE YYFAR *YYNEAR YYDCDECL yyparsedebugout; +extern YYCONST yysymbol_t YYNEARFAR YYDCDECL yysymbol[]; +extern YYCONST char *YYCONST YYNEARFAR YYDCDECL yyrule[]; +#endif + +/* externally defined */ +#ifdef YYPROTOTYPE +int YYCDECL yylex(void); +void YYCDECL yyparseaction(int action); +#else +int YYCDECL yylex(); +void YYCDECL yyparseaction(); +#endif + +extern yystack_t YYFAR *YYNEAR YYDCDECL yystackptr; /* (state) stack */ +extern yystack_t YYFAR *YYNEAR YYDCDECL yysstackptr; /* static (state) stack */ +extern int YYNEAR YYDCDECL yystack_size; /* number of elements in stack */ +extern int YYNEAR YYDCDECL yysstack_size; /* initial number of elements in stack */ + +extern size_t YYNEAR YYDCDECL yyattribute_size; /* size of attribute */ + +#ifdef YYPROTOTYPE +extern void YYFAR *YYNEAR YYDCDECL yyvalptr; /* attribute for $$ */ +extern void YYFAR *YYNEAR YYDCDECL yylvalptr; /* current token attribute */ +extern void YYFAR *YYNEAR YYDCDECL yyattributestackptr; /* attribute stack */ +extern void YYFAR *YYNEAR YYDCDECL yysattributestackptr; /* static attribute stack */ +#else +extern char YYFAR *YYNEAR YYDCDECL yyvalptr; /* attribute for $$ */ +extern char YYFAR *YYNEAR YYDCDECL yylvalptr; /* current token attribute */ +extern char YYFAR *YYNEAR YYDCDECL yyattributestackptr; /* attribute stack */ +extern char YYFAR *YYNEAR YYDCDECL yysattributestackptr; /* static attribute stack */ +#endif + +/* compact parser */ +extern YYCONST yycstateaction_t YYNEARFAR YYDCDECL yycstateaction[]; +extern YYCONST yyctokenaction_t YYNEARFAR YYDCDECL yyctokenaction[]; +extern YYCONST yycstategoto_t YYNEARFAR YYDCDECL yycstategoto[]; +extern YYCONST yycnontermgoto_t YYNEARFAR YYDCDECL yycnontermgoto[]; +extern YYCONST yyctokendest_t YYNEARFAR *YYNEAR YYDCDECL yyctokendestptr; + +/* fast parser */ +extern YYCONST yystateaction_t YYNEARFAR YYDCDECL yystateaction[]; +extern YYCONST yytokenaction_t YYNEARFAR YYDCDECL yytokenaction[]; +extern int YYNEAR YYDCDECL yytokenaction_size; +extern YYCONST yystategoto_t YYNEARFAR YYDCDECL yystategoto[]; +extern YYCONST yynontermgoto_t YYNEARFAR YYDCDECL yynontermgoto[]; +extern int YYNEAR YYDCDECL yynontermgoto_size; +extern YYCONST yytokendest_t YYNEARFAR *YYNEAR YYDCDECL yytokendestptr; +extern int YYNEAR YYDCDECL yytokendest_size; +extern int YYNEAR YYDCDECL yytokendestbase; + +extern YYCONST yyreduction_t YYNEARFAR YYDCDECL yyreduction[]; + +extern YYCONST yydestructor_t YYNEARFAR *YYNEAR YYDCDECL yydestructorptr; + +#ifdef __cplusplus +} +#endif + +/* user defines */ +#if defined(YYBUDEFS) || defined(YYUDEFS) +#include +#endif + +/* defines */ +#include + +#endif diff --git a/Utils/Parser Generator/INCLUDE/yybdefs.h b/Utils/Parser Generator/INCLUDE/yybdefs.h new file mode 100644 index 000000000..8c05ecba9 --- /dev/null +++ b/Utils/Parser Generator/INCLUDE/yybdefs.h @@ -0,0 +1,49 @@ +/************************************************************ +yybdefs.h +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Microsoft defines */ +#ifdef _MSC_VER + +/* structure alignment */ +#ifdef _WIN32 +#pragma pack(pop) +#else +#pragma pack() +#endif + +#endif + + +/* Borland defines */ +#ifdef __BORLANDC__ + +#if !defined(RC_INVOKED) + +#if (__BORLANDC__) >= 0x0530 +/* restore default packing */ +#pragma pack(pop) +#pragma nopackwarning +#else +#pragma option -a. /* restore default packing */ +#endif /* (__BORLANDC__) >= 0x0530 */ + +#if defined(__STDC__) +#pragma warn .nak +#endif + +#endif /* !RC_INVOKED */ + +#endif + +#ifdef __cplusplus +}; +#endif diff --git a/Utils/Parser Generator/INCLUDE/yytdefs.h b/Utils/Parser Generator/INCLUDE/yytdefs.h new file mode 100644 index 000000000..205662936 --- /dev/null +++ b/Utils/Parser Generator/INCLUDE/yytdefs.h @@ -0,0 +1,148 @@ +/************************************************************ +yytdefs.h +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Microsoft defines */ +#ifdef _MSC_VER + +/* version 6.0 compatibility */ +#if (_MSC_VER <= 600) +#define __cdecl _cdecl +#define __far _far +#define __near _near +#define __segname _segname +#endif + +/* structure alignment */ +#ifdef _WIN32 +/* + * Currently, all MS C compilers for Win32 platforms default to 8 byte + * alignment. + */ +#pragma pack(push,8) +#else +#pragma pack(2) +#endif + +/* stream initialisation */ +#ifdef _DLL +#define YYNINITSTREAM +#endif + +/* 32/16-bit modifiers */ +#ifndef YYCDECL +#define YYCDECL __cdecl +#endif + +/* 16-bit modifiers */ +#ifndef _WIN32 +#ifndef YYDCDECL +#define YYDCDECL __cdecl +#endif +#ifndef YYNEAR +#define YYNEAR __near +#endif +#ifndef YYNEARFAR +#if defined(M_I86TM) || defined(M_I86SM) +#define YYNEARFAR __near +#else +#define YYNEARFAR __far +#endif +#endif +#ifndef YYBASED_CODE +#if defined(M_I86MM) || defined(M_I86LM) || defined(M_I86HM) +#define YYBASED_CODE __based(__segname("_CODE")) +#endif +#endif +#endif + +/* function prototypes */ +#ifndef YYPROTOTYPE +#define YYPROTOTYPE +#endif + +/* qualifiers */ +#ifndef YYCONST +#define YYCONST const +#endif + +#endif + + +/* Borland defines */ +#ifdef __BORLANDC__ + +#if !defined(RC_INVOKED) + +#if defined(__STDC__) +#pragma warn -nak +#endif + +#if (__BORLANDC__) >= 0x0530 +#pragma pack(push, 1) +#pragma nopackwarning +#else +#pragma option -a- +#endif /* (__BORLANDC__) >= 0x0530 */ + +#pragma option -a- + +#endif /* !RC_INVOKED */ + +/* stream initialisation */ +#ifdef _RTLDLL +#if (__BORLANDC__) >= 0x0530 +#define YYNINITSTREAM +#endif +#endif + +/* 32/16-bit modifiers */ +#ifndef YYCDECL +#define YYCDECL __cdecl +#endif +#ifndef YYDCDECL +#define YYDCDECL __cdecl +#endif + +/* 16-bit modifiers */ +#ifndef __WIN32__ +#ifndef YYNEAR +#define YYNEAR __near +#endif +#ifndef YYFAR +#ifdef __DLL__ +#define YYFAR __far +#endif +#endif +#ifndef YYNEARFAR +#if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__) +#define YYNEARFAR __near +#else +#define YYNEARFAR __far +#endif +#endif +#endif + +/* function prototypes */ +#ifndef YYPROTOTYPE +#define YYPROTOTYPE +#endif + +/* qualifiers */ +#ifndef YYCONST +#define YYCONST const +#endif + +#endif + +#ifdef __cplusplus +}; +#endif diff --git a/Utils/Parser Generator/LIB/MSDEV/yl.lib b/Utils/Parser Generator/LIB/MSDEV/yl.lib new file mode 100644 index 000000000..abf77c57f Binary files /dev/null and b/Utils/Parser Generator/LIB/MSDEV/yl.lib differ diff --git a/Utils/Parser Generator/LIB/MSDEV/yld.lib b/Utils/Parser Generator/LIB/MSDEV/yld.lib new file mode 100644 index 000000000..b574be41a Binary files /dev/null and b/Utils/Parser Generator/LIB/MSDEV/yld.lib differ diff --git a/Utils/Parser Generator/LIB/MSDEV/ylmt.lib b/Utils/Parser Generator/LIB/MSDEV/ylmt.lib new file mode 100644 index 000000000..e5b9e53e9 Binary files /dev/null and b/Utils/Parser Generator/LIB/MSDEV/ylmt.lib differ diff --git a/Utils/Parser Generator/LIB/MSDEV/ylmtd.lib b/Utils/Parser Generator/LIB/MSDEV/ylmtd.lib new file mode 100644 index 000000000..b0fb11e44 Binary files /dev/null and b/Utils/Parser Generator/LIB/MSDEV/ylmtd.lib differ diff --git a/Utils/Parser Generator/LIB/MSDEV/ylmtdll.lib b/Utils/Parser Generator/LIB/MSDEV/ylmtdll.lib new file mode 100644 index 000000000..a93f801a3 Binary files /dev/null and b/Utils/Parser Generator/LIB/MSDEV/ylmtdll.lib differ diff --git a/Utils/Parser Generator/LIB/MSDEV/ylmtdlld.lib b/Utils/Parser Generator/LIB/MSDEV/ylmtdlld.lib new file mode 100644 index 000000000..8024b0cd9 Binary files /dev/null and b/Utils/Parser Generator/LIB/MSDEV/ylmtdlld.lib differ diff --git a/Utils/Parser Generator/Release.doc b/Utils/Parser Generator/Release.doc new file mode 100644 index 000000000..5f2e800fb Binary files /dev/null and b/Utils/Parser Generator/Release.doc differ diff --git a/Utils/Parser Generator/SOURCE/main.c b/Utils/Parser Generator/SOURCE/main.c new file mode 100644 index 000000000..11399ae10 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/main.c @@ -0,0 +1,18 @@ +/************************************************************ +main.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "yacc.h" + +#ifdef YYPROTOTYPE +int main(void) +#else +int main() +#endif +{ + return yyparse(); +} diff --git a/Utils/Parser Generator/SOURCE/yycback.cpp b/Utils/Parser Generator/SOURCE/yycback.cpp new file mode 100644 index 000000000..38602f1ee --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yycback.cpp @@ -0,0 +1,21 @@ +/************************************************************ +yycback.cpp +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "clex.h" + +int yylexer::yyback(const yymatch_t YYNEARFAR* p, int action) const +{ + yyassert(p != NULL); + yyassert(action < 0); + while (*p != 0) { + if (*p++ == action) { + return 1; + } + } + return 0; +} diff --git a/Utils/Parser Generator/SOURCE/yyccdeci.cpp b/Utils/Parser Generator/SOURCE/yyccdeci.cpp new file mode 100644 index 000000000..b52a3b893 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yyccdeci.cpp @@ -0,0 +1,40 @@ +/************************************************************ +yyccdeci.cpp +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include "cyacc.h" + +// the Visual C++ v1.52 compiler generates an error in NT if this isn't present! +#ifdef _MSC_VER +#if defined(M_I86HM) && defined(NDEBUG) +#pragma function(memcpy) +#endif +#endif + +void yycparser::yydestructclearin() +{ + if (yylookahead) { + // clean up any token attributes + if (yyctokendestptr != NULL) { + const yyctokendest_t YYNEARFAR* tokendestptr = yyctokendestptr; + while (tokendestptr->token != 0) { + if (tokendestptr->token == yychar) { + // user actions in here + memcpy(yyvalptr, yylvalptr, yyattribute_size); + + yyaction(tokendestptr->action); + + memcpy(yylvalptr, yyvalptr, yyattribute_size); + break; + } + tokendestptr++; + } + } + yylookahead = 0; + } +} diff --git a/Utils/Parser Generator/SOURCE/yycclex.cpp b/Utils/Parser Generator/SOURCE/yycclex.cpp new file mode 100644 index 000000000..b1a67cb86 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yycclex.cpp @@ -0,0 +1,217 @@ +/************************************************************ +yycclex.cpp +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include +#include +#include +#include "clex.h" + +int yyclexer::yylex() +{ + while (1) { + int state = 1 + yystart; + if (yyeol) { + state++; + } + + // yymore + if (yymoreflg) { + yymoreflg = 0; // clear flag + } + else { + yyleng = 0; + yyoldeol = yyeol; + } + int oldleng = yyleng; + + // look for a string + do { + // get input character (lookahead character) + int ch = yyinput(); + yyassert(ch >= 0 && ch <= UCHAR_MAX || ch == EOF); + if (ch == EOF) { + break; + } + + // check for possible overflow + if (yyleng == yytext_size) { + do { + if (yytextgrow) { + if (yytext_size != 0) { + int size = yytext_size * 2; + if (size / 2 == yytext_size) { // overflow check + if (yysettextsize(size)) { + break; + } + } + } + else { + if (yysettextsize(100)) { + break; + } + } + } + yytextoverflow(); + exit(EXIT_FAILURE); + } + while (0); + } + + // look for a transition + int index = yystate[state].base; + while (1) { + if (yyctransition[index].next == 0) { + state = yystate[state].def; + if (state <= 0) { + if (state < 0) { + if (ch >= 0 && ch <= 0xff) { + state = -state; + } + else { + state = 0; + } + } + break; + } + } + if (ch >= yyctransition[index].first && + ch <= yyctransition[index].last) { + state = yyctransition[index].next; + break; + } + index++; + } + + int leng = yyleng; // slightly more efficient code + yytext[leng] = (char)ch; + yystatebuf[leng] = state; + leng++; + yyleng = leng; + } + while (state != 0 && (yystate[state].def != 0 || yystate[state].base != 0)); + + // now find a match + if (yyleng > oldleng) { + int rejectmatch = 0; + while (1) { + int match = yystate[yystatebuf[yyleng - 1]].match; + if (rejectmatch != 0) { + if (match < 0) { + int index = -match; + do { + match = yymatch[index++]; + } + while (match > 0 && match <= rejectmatch); + } + else { + if (match == rejectmatch) { + match = 0; + } + } + rejectmatch = 0; + } + else { + if (match < 0) { + match = yymatch[-match]; + } + } + if (match > 0) { + // check for backup + if (yybackup[match]) { + while (yyleng > oldleng) { + int index = yystate[yystatebuf[yyleng - 1]].match; + if (index < 0) { + if (yyback(&yymatch[-index], -match)) { + break; // found an expression + } + } + yyleng--; + yyunput((unsigned char)yytext[yyleng]); + } + } + yytext[yyleng] = '\0'; +#ifdef YYDEBUG + yydmatch(match); +#endif + yyrejectflg = 0; // clear flag + int rejectleng = yyleng; + + if (yyleng > 0) { + yyeol = (unsigned char)(yytext[yyleng - 1] == '\n'); + } + else { + yyeol = yyoldeol; + } + + // perform user action + int token = yyaction(match); + + if (yyreturnflg) { + return token; + } + if (!yyrejectflg) { + break; + } + if (rejectleng == yyleng) { + rejectmatch = match; + } + } + else if (yyleng > oldleng + 1) { + yyleng--; + yyunput((unsigned char)yytext[yyleng]); + } + else { + yyeol = (unsigned char)(yytext[0] == '\n'); + yyoutput(yytext[0]); // non-matched character + break; + } + } + } + else { + yyassert(yyleng == oldleng); + + // handles <> rules + int index = 0; + int match = yystate[state].match; + if (match < 0) { + index = -match; + match = yymatch[index++]; + } + while (match > 0) { + yytext[yyleng] = '\0'; +#ifdef YYDEBUG + yydmatch(match); +#endif + yyrejectflg = 0; // clear flag + + // perform user action + int token = yyaction(match); + + if (yyreturnflg) { + return token; + } + if (!yyrejectflg) { + break; + } + + if (index == 0) { + break; + } + match = yymatch[index++]; + } + + if (yywrap()) { + yyoldeol = 1; + yyeol = 1; + yystart = 0; + return 0; // eof reached + } + } + } +} diff --git a/Utils/Parser Generator/SOURCE/yyccwork.cpp b/Utils/Parser Generator/SOURCE/yyccwork.cpp new file mode 100644 index 000000000..e0729d21e --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yyccwork.cpp @@ -0,0 +1,285 @@ +/************************************************************ +yyccwork.cpp +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include "cyacc.h" + +// the Visual C++ v1.52 compiler generates an error in NT if this isn't present! +#ifdef _MSC_VER +#if defined(M_I86HM) && defined(NDEBUG) +#pragma function(memcpy) +#endif +#endif + +int yycparser::yywork() +{ + int errorpop = 0; + while (1) { + yystack_t state = yypeek(); // get top state + + int index = yycstateaction[state]; + while (1) { + if (yyctokenaction[index].token == YYTK_ALL) { + if (yyctokenaction[index].type == YYAT_DEFAULT) { + state = yyctokenaction[index].sr; + index = yycstateaction[state]; + continue; + } + break; + } + + if (!yylookahead) { + yychar = yygettoken(); + if (yychar < 0) { + yychar = 0; + } + yylookahead = 1; +#ifdef YYDEBUG + yydgettoken(yychar); +#endif + } + if (yyctokenaction[index].token == yychar) { + break; + } + index++; + } + unsigned char type = yyctokenaction[index].type; + short sr = yyctokenaction[index].sr; + + // action + switch (type) { + case YYAT_SHIFT: +#ifdef YYDEBUG + yydshift(yychar); +#endif + if (yyskip > 0) { + yysetskip(yyskip - 1); + } + if (!yypush(sr)) { +#ifdef YYDEBUG + yydabort(); +#endif + if (yywipeflg) { + yywipe(); // clean up + } + return 1; + } + memcpy(&((char YYFAR*)yyattributestackptr)[yytop * yyattribute_size], + yylvalptr, yyattribute_size); + yylookahead = 0; + continue; // go to top of while loop + case YYAT_REDUCE: +#ifdef YYDEBUG + yydreduce(sr); +#endif + yyretireflg = 0; + if (yyreduction[sr].action != -1) { + // user actions in here + if (yyreduction[sr].length > 0) { + memcpy(yyvalptr, &((char YYFAR*)yyattributestackptr) + [(yytop + 1 - yyreduction[sr].length) * yyattribute_size], + yyattribute_size); + } + + yyerrorflg = 0; + yyexitflg = 0; + yyaction(yyreduction[sr].action); + + // check for special user requected actions + if (yyexitflg) { +#ifdef YYDEBUG + yydexit(yyexitcode); +#endif + return yyexitcode; + } + if (yyerrorflg) { + errorpop = yyerrorpop; +#ifdef YYDEBUG + yydthrowerror(yyerrorpop); +#endif + yyerrorcount++; + break; // go to error handler + } + } + + yypop(yyreduction[sr].length); + { + yystack_t state = yypeek(); // get top state + + int nonterm = yyreduction[sr].nonterm; + int index = yycstategoto[state]; + while (1) { + if (yycnontermgoto[index].nonterm == -1) { + if (yycnontermgoto[index].next != -1) { + state = yycnontermgoto[index].next; + index = yycstategoto[state]; + continue; + } + break; + } + if (yycnontermgoto[index].nonterm == nonterm) { + break; + } + index++; + } + short next = yycnontermgoto[index].next; + yyassert(next != -1); + + if (!yypush(next)) { +#ifdef YYDEBUG + yydabort(); +#endif + if (yywipeflg) { + yywipe(); // clean up + } + return 1; + } + } + if (yyreduction[sr].action != -1) { + memcpy(&((char YYFAR*)yyattributestackptr)[yytop * yyattribute_size], + yyvalptr, yyattribute_size); + } + if (yyretireflg) { +#ifdef YYDEBUG + yydretire(yyretirecode); +#endif + return yyretirecode; + } + continue; // go to top of while loop + case YYAT_ERROR: +#ifdef YYDEBUG + yydsyntaxerror(); +#endif + if (yyskip == 0) { + yyerrorcount++; + yysyntaxerror(); + } + break; // go to error handler + default: + yyassert(type == YYAT_ACCEPT); +#ifdef YYDEBUG + yydaccept(); +#endif + return 0; + } + + // error handler + if (yyskip < 3 || yyerrorpop > 0) { +#ifdef YYDEBUG + yydattemptrecovery(); +#endif + yypopflg = 0; // clear flag + while (yytop >= 0) { + state = yypeek(); // get top state + index = yycstateaction[state]; + while (1) { + if (yyctokenaction[index].token == YYTK_ALL) { + if (yyctokenaction[index].type == YYAT_DEFAULT) { + state = yyctokenaction[index].sr; + index = yycstateaction[state]; + continue; + } + break; + } + if (yyctokenaction[index].token == YYTK_ERROR) { + break; + } + index++; + } + type = yyctokenaction[index].type; + sr = yyctokenaction[index].sr; + + if (type == YYAT_SHIFT) { + if (errorpop <= 0) { +#ifdef YYDEBUG + yydshift(YYTK_ERROR); +#endif + if (!yypush(sr)) { +#ifdef YYDEBUG + yydabort(); +#endif + if (yywipeflg) { + yywipe(); // clean up + } + return 1; + } + yysetskip(3); // skip 3 erroneous characters + break; + } + errorpop--; + } + + yypopflg = 1; + + // clean up any symbol attributes + if (yydestructorptr != NULL) { + state = yypeek(); + int action = yydestructorptr[state]; + if (action != -1) { + // user actions in here + memcpy(yyvalptr, &((char YYFAR*)yyattributestackptr) + [yytop * yyattribute_size], yyattribute_size); + + yyaction(action); + + memcpy(&((char YYFAR*)yyattributestackptr) + [yytop * yyattribute_size], yyvalptr, yyattribute_size); + } + } + yypop(1); + if (yytop < 0) { +#ifdef YYDEBUG + yydabort(); +#endif + if (yywipeflg) { + yywipe(); // clean up + } + return 1; + } + } + } + else { + if (yylookahead) { + if (yychar != 0) { +#ifdef YYDEBUG + yyddiscard(yychar); +#endif + yydiscard(yychar); + + // clean up any token attributes + if (yyctokendestptr != NULL) { + const yyctokendest_t YYNEARFAR *tokendestptr = yyctokendestptr; + while (tokendestptr->token != 0) { + if (tokendestptr->token == yychar) { + // user actions in here + memcpy(yyvalptr, yylvalptr, yyattribute_size); + + yyaction(tokendestptr->action); + + memcpy(yylvalptr, yyvalptr, yyattribute_size); + break; + } + tokendestptr++; + } + } + + yylookahead = 0; // skip erroneous character + } + else { +#ifdef YYDEBUG + yydabort(); +#endif + if (yywipeflg) { + yywipe(); // clean up + } + return 1; + } + } + } + } +} diff --git a/Utils/Parser Generator/SOURCE/yycdeci.cpp b/Utils/Parser Generator/SOURCE/yycdeci.cpp new file mode 100644 index 000000000..de172c1d0 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yycdeci.cpp @@ -0,0 +1,39 @@ +/************************************************************ +yycdeci.cpp +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include "cyacc.h" + +// the Visual C++ v1.52 compiler generates an error in NT if this isn't present! +#ifdef _MSC_VER +#if defined(M_I86HM) && defined(NDEBUG) +#pragma function(memcpy) +#endif +#endif + +void yyfparser::yydestructclearin() +{ + if (yylookahead) { + // clean up any token attributes + if (yytokendestptr != NULL) { + int index = yytokendestbase + yychar; + if (index >= 0 && index < yytokendest_size) { + int action = yytokendestptr[index]; + if (action != -1) { + // user actions in here + memcpy(yyvalptr, yylvalptr, yyattribute_size); + + yyaction(action); + + memcpy(yylvalptr, yyvalptr, yyattribute_size); + } + } + } + yylookahead = 0; + } +} diff --git a/Utils/Parser Generator/SOURCE/yycdepop.cpp b/Utils/Parser Generator/SOURCE/yycdepop.cpp new file mode 100644 index 000000000..63ff37370 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yycdepop.cpp @@ -0,0 +1,45 @@ +/************************************************************ +yycdepop.cpp +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include "cyacc.h" + +// the Visual C++ v1.52 compiler generates an error in NT if this isn't present! +#ifdef _MSC_VER +#if defined(M_I86HM) && defined(NDEBUG) +#pragma function(memcpy) +#endif +#endif + +void yyparser::yydestructpop(int num) +{ + yyassert(num >= 0); + yyassert(yytop - num >= -1); + + if (yydestructorptr != NULL) { + while (num > 0) { + yystack_t state = yypeek(); + int action = yydestructorptr[state]; + if (action != -1) { + // user actions in here + memcpy(yyvalptr, &((char YYFAR*)yyattributestackptr) + [yytop * yyattribute_size], yyattribute_size); + + yyaction(action); + + memcpy(&((char YYFAR*)yyattributestackptr) + [yytop * yyattribute_size], yyvalptr, yyattribute_size); + } + yypop(1); + num--; + } + } + else { + yypop(num); + } +} diff --git a/Utils/Parser Generator/SOURCE/yycdisc.cpp b/Utils/Parser Generator/SOURCE/yycdisc.cpp new file mode 100644 index 000000000..fcaa074d0 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yycdisc.cpp @@ -0,0 +1,20 @@ +/************************************************************ +yycdisc.cpp +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include "cyacc.h" + +#ifdef __BORLANDC__ +#pragma argsused +#endif + +void yyparser::yydiscard(int token) +{ + yyassert(token > 0); + // do nothing +} diff --git a/Utils/Parser Generator/SOURCE/yycdoutp.cpp b/Utils/Parser Generator/SOURCE/yycdoutp.cpp new file mode 100644 index 000000000..40bbab78d --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yycdoutp.cpp @@ -0,0 +1,67 @@ +/************************************************************ +yycdoutp.cpp +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include +#include "clex.h" + +#ifdef YYDEBUG +void yylexer::yydebugoutput(int ch) const +{ + char string[32]; + switch (ch) { + case EOF: + strcpy(string, "EOF"); + break; + case '\n': + strcpy(string, "\\n"); + break; + case '\t': + strcpy(string, "\\t"); + break; + case '\v': + strcpy(string, "\\v"); + break; + case '\b': + strcpy(string, "\\b"); + break; + case '\r': + strcpy(string, "\\r"); + break; + case '\f': + strcpy(string, "\\f"); + break; + case '\a': + strcpy(string, "\\a"); + break; + case '\\': + strcpy(string, "\\"); + break; + case '\?': + strcpy(string, "\\\?"); + break; + case '\'': + strcpy(string, "\\\'"); + break; + case '\"': + strcpy(string, "\\\""); + break; + default: + if (isascii(ch) && isgraph(ch)) { + string[0] = (char)ch; + string[1] = '\0'; + } + else { + sprintf(string, "\\%03o", (unsigned int)(unsigned char)ch); + } + break; + } + yydebugoutput(string); +} + +#endif diff --git a/Utils/Parser Generator/SOURCE/yycecho.cpp b/Utils/Parser Generator/SOURCE/yycecho.cpp new file mode 100644 index 000000000..aeee75afb --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yycecho.cpp @@ -0,0 +1,17 @@ +/************************************************************ +yycecho.cpp +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include "clex.h" + +void yylexer::yyecho() +{ + for (int i = 0; i < yyleng; i++) { + yyoutput(yytext[i]); + } +} diff --git a/Utils/Parser Generator/SOURCE/yycerror.cpp b/Utils/Parser Generator/SOURCE/yycerror.cpp new file mode 100644 index 000000000..cac98727e --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yycerror.cpp @@ -0,0 +1,20 @@ +/************************************************************ +yycerror.cpp +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include "cyacc.h" + +void yyparser::yyerror(const char YYFAR* text) +{ + yyassert(text != NULL); + yyassert(yyerr != NULL); + while (*text != '\0') { + putc(*text++, yyerr); + } + putc('\n', yyerr); +} diff --git a/Utils/Parser Generator/SOURCE/yycflex.cpp b/Utils/Parser Generator/SOURCE/yycflex.cpp new file mode 100644 index 000000000..5bc118d12 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yycflex.cpp @@ -0,0 +1,214 @@ +/************************************************************ +yycflex.cpp +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include +#include +#include +#include "clex.h" + +int yyflexer::yylex() +{ + while (1) { + int state = 1 + yystart; + if (yyeol) { + state++; + } + + // yymore + if (yymoreflg) { + yymoreflg = 0; // clear flag + } + else { + yyleng = 0; + yyoldeol = yyeol; + } + int oldleng = yyleng; + + // look for a string + do { + // get input character (look ahead character) + int ch = yyinput(); + yyassert(ch >= 0 && ch <= UCHAR_MAX || ch == EOF); + if (ch == EOF) { + break; + } + + // check for possible overflow + if (yyleng == yytext_size) { + do { + if (yytextgrow) { + if (yytext_size != 0) { + int size = yytext_size * 2; + if (size / 2 == yytext_size) { // overflow check + if (yysettextsize(size)) { + break; + } + } + } + else { + if (yysettextsize(100)) { + break; + } + } + } + yytextoverflow(); + exit(EXIT_FAILURE); + } + while (0); + } + + // look for a transition + do { + int index = yystate[state].base + ch; + if (index >= 0 && index < yytransitionmax) { + if (yytransition[index].check == state) { + state = yytransition[index].next; + break; // found a transition + } + } + state = yystate[state].def; + if (state < 0) { + if (ch >= 0 && ch <= 0xff) { + state = -state; + } + else { + state = 0; + } + break; // default transition + } + } + while (state != 0); + + int leng = yyleng; // slightly more efficient + yytext[leng] = (char)ch; + yystatebuf[leng] = state; + leng++; + yyleng = leng; + } + while (state != 0 && (yystate[state].def != 0 || yystate[state].base != 0)); + + // now find a match + if (yyleng > oldleng) { + int rejectmatch = 0; + while (1) { + int match = yystate[yystatebuf[yyleng - 1]].match; + if (rejectmatch != 0) { + if (match < 0) { + int index = -match; + do { + match = yymatch[index++]; + } + while (match > 0 && match <= rejectmatch); + } + else { + if (match == rejectmatch) { + match = 0; + } + } + rejectmatch = 0; + } + else { + if (match < 0) { + match = yymatch[-match]; + } + } + if (match > 0) { + // check for backup + if (yybackup[match]) { + while (yyleng > oldleng) { + int index = yystate[yystatebuf[yyleng - 1]].match; + if (index < 0) { + if (yyback(&yymatch[-index], -match)) { + break; // found an expression + } + } + yyleng--; + yyunput((unsigned char)yytext[yyleng]); + } + } + yytext[yyleng] = '\0'; +#ifdef YYDEBUG + yydmatch(match); +#endif + yyrejectflg = 0; // clear flag + int rejectleng = yyleng; + + if (yyleng > 0) { + yyeol = (unsigned char)(yytext[yyleng - 1] == '\n'); + } + else { + yyeol = yyoldeol; + } + + // perform user action + int token = yyaction(match); + + if (yyreturnflg) { + return token; + } + if (!yyrejectflg) { + break; + } + if (rejectleng == yyleng) { + rejectmatch = match; + } + } + else if (yyleng > oldleng + 1) { + yyleng--; + yyunput((unsigned char)yytext[yyleng]); + } + else { + yyeol = (unsigned char)(yytext[0] == '\n'); + yyoutput(yytext[0]); // non-matched character + break; + } + } + } + else { + yyassert(yyleng == oldleng); + + // handles <> rules + int index = 0; + int match = yystate[state].match; + if (match < 0) { + index = -match; + match = yymatch[index++]; + } + while (match > 0) { + yytext[yyleng] = '\0'; +#ifdef YYDEBUG + yydmatch(match); +#endif + yyrejectflg = 0; // clear flag + + // perform user action + int token = yyaction(match); + + if (yyreturnflg) { + return token; + } + if (!yyrejectflg) { + break; + } + + if (index == 0) { + break; + } + match = yymatch[index++]; + } + + if (yywrap()) { + yyoldeol = 1; + yyeol = 1; + yystart = 0; + return 0; // eof reached + } + } + } +} diff --git a/Utils/Parser Generator/SOURCE/yycgetch.cpp b/Utils/Parser Generator/SOURCE/yycgetch.cpp new file mode 100644 index 000000000..f24eeaa04 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yycgetch.cpp @@ -0,0 +1,16 @@ +/************************************************************ +yycgetch.cpp +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include "clex.h" + +int yylexer::yygetchar() +{ + yyassert(yyin != NULL); + return getc(yyin); +} diff --git a/Utils/Parser Generator/SOURCE/yycgtok.cpp b/Utils/Parser Generator/SOURCE/yycgtok.cpp new file mode 100644 index 000000000..bf95bf88c --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yycgtok.cpp @@ -0,0 +1,16 @@ +/************************************************************ +yycgtok.cpp +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "cyacc.h" +#include "clex.h" + +int yyparser::yygettoken() +{ + yyassert(yylexerptr != NULL); + return yylexerptr->yylex(); +} diff --git a/Utils/Parser Generator/SOURCE/yycinput.cpp b/Utils/Parser Generator/SOURCE/yycinput.cpp new file mode 100644 index 000000000..3f5c8842a --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yycinput.cpp @@ -0,0 +1,38 @@ +/************************************************************ +yycinput.cpp +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include +#include "clex.h" + +int yylexer::yyinput() +{ + int ch; + if (yyunputindex > 0) { + ch = yyunputbufptr[--yyunputindex]; + } + else { + ch = yygetchar(); + } + if (ch == '\n') { + yylineno++; + } + +#ifdef YYDEBUG + if (::yydebug || yydebug) { + char string[128]; + + sprintf(string, "%p: input: \'", (void*)this); + yydebugoutput(string); + yydebugoutput(ch); + yydebugoutput("\'\n"); + } +#endif + + return ch; +} diff --git a/Utils/Parser Generator/SOURCE/yyclcln.cpp b/Utils/Parser Generator/SOURCE/yyclcln.cpp new file mode 100644 index 000000000..931b2c3d5 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yyclcln.cpp @@ -0,0 +1,35 @@ +/************************************************************ +yyclcln.cpp +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include +#include "clex.h" + +void yylexer::yycleanup() +{ + if (yytext != yystext) { + free(yytext); + yytext = yystext; + } + if (yystatebuf != yysstatebuf) { + free(yystatebuf); + yystatebuf = yysstatebuf; + } + if (yyunputbufptr != yysunputbufptr) { + free(yyunputbufptr); + yyunputbufptr = yysunputbufptr; + } + yytext_size = yystext_size; + yyunput_size = yysunput_size; + + if (yytext != NULL) { + *yytext = '\0'; + } + yyleng = 0; + yyunputindex = 0; +} diff --git a/Utils/Parser Generator/SOURCE/yyclcon.cpp b/Utils/Parser Generator/SOURCE/yyclcon.cpp new file mode 100644 index 000000000..f653f2b81 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yyclcon.cpp @@ -0,0 +1,50 @@ +/************************************************************ +yyclcon.cpp +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "clex.h" + +yylexer::yylexer() +{ + yystart = 0; + yyeol = 1; + yyoldeol = 1; + yystatebuf = NULL; + yysstatebuf = NULL; + yystext = NULL; + yytext_size = 0; + yystext_size = 0; + yyunputbufptr = NULL; + yysunputbufptr = NULL; + yyunput_size = 0; + yysunput_size = 0; + yyunputindex = 0; + yymoreflg = 0; + yyrejectflg = 0; + yyreturnflg = 0; + yyparserptr = NULL; + yytextgrow = 1; + yyunputgrow = 1; + yyin = stdin; + yyout = stdout; + yyerr = stderr; + yytext = NULL; + yyleng = 0; + yylineno = 1; + + // debugging +#ifdef YYDEBUG + yydebug = 0; + yydebugflush = 0; + yydebugout = stdout; +#endif +} + +yylexer::~yylexer() +{ + yydestroy(); +} diff --git a/Utils/Parser Generator/SOURCE/yyclcrea.cpp b/Utils/Parser Generator/SOURCE/yyclcrea.cpp new file mode 100644 index 000000000..a37cdf4b4 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yyclcrea.cpp @@ -0,0 +1,82 @@ +/************************************************************ +yyclcrea.cpp +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "clex.h" +#include + +int yylexer::yycreate(yyparser YYFAR* parserptr) +{ + yyparserptr = parserptr; + + size_t textcharsize; + size_t statebufcharsize; + size_t unputbufcharsize; + + // get sizes first + textcharsize = yystext_size + 1; // include the '\0' + if (textcharsize <= (size_t)yystext_size) { + return 0; // integer overflow + } + if (yystext_size != 0) { + statebufcharsize = yystext_size * sizeof(int); + if ((int)(statebufcharsize / sizeof(int)) != yystext_size) { + return 0; // integer overflow + } + } + else { + statebufcharsize = 0; + } + if (yysunput_size != 0) { + unputbufcharsize = yysunput_size * sizeof(int); + if ((int)(unputbufcharsize / sizeof(int)) != yysunput_size) { + return 0; // integer overflow + } + } + else { + unputbufcharsize = 0; + } + + // allocate the memory if necessary + yystext = (char YYFAR*)malloc(textcharsize); + if (yystext == NULL) { + return 0; + } + if (statebufcharsize != 0) { + yysstatebuf = (int YYFAR*)malloc(statebufcharsize); + if (yysstatebuf == NULL) { + free(yystext); + return 0; + } + } + else { + yysstatebuf = NULL; + } + if (unputbufcharsize != 0) { + yysunputbufptr = (int YYFAR*)malloc(unputbufcharsize); + if (yysunputbufptr == NULL) { + free(yystext); + free(yysstatebuf); + return 0; + } + } + else { + yysunputbufptr = NULL; + } + + // assign any other variables + yytext_size = yystext_size; + yytext = yystext; + yystatebuf = yysstatebuf; + yyunput_size = yysunput_size; + yyunputbufptr = yysunputbufptr; + + // makes sure we are ready to go + yyreset(); + + return 1; +} diff --git a/Utils/Parser Generator/SOURCE/yycldbug.cpp b/Utils/Parser Generator/SOURCE/yycldbug.cpp new file mode 100644 index 000000000..c977b6acd --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yycldbug.cpp @@ -0,0 +1,57 @@ +/************************************************************ +yycldbug.cpp +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#ifdef _WIN32 +#include +#include +#endif +#include "clex.h" + +#ifdef YYDEBUG + +void yylexer::yydmatch(int expr) const +{ + if (::yydebug || yydebug) { + char string[128]; + + sprintf(string, "%p: match: \"", (void*)this); + yydebugoutput(string); + for (int i = 0; i < yyleng; i++) { + yydebugoutput(yytext[i]); + } + sprintf(string, "\", %d\n", (int)expr); + yydebugoutput(string); + } +} + +void yylexer::yydebugoutput(const char *string) const +{ + yyassert(string != NULL); + +#ifdef _WIN32 + if (yydebugout != NULL) { +#else + yyassert(yydebugout != NULL); +#endif + while (*string != '\0') { + putc(*string++, yydebugout); + } + + if (::yydebugflush || yydebugflush) { + fflush(yydebugout); + } +#ifdef _WIN32 + } + else { + OutputDebugString(string); + } +#endif +} + +#endif diff --git a/Utils/Parser Generator/SOURCE/yycldest.cpp b/Utils/Parser Generator/SOURCE/yycldest.cpp new file mode 100644 index 000000000..2a460d578 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yycldest.cpp @@ -0,0 +1,18 @@ +/************************************************************ +yycldest.cpp +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "clex.h" +#include + +void yylexer::yydestroy() +{ + yycleanup(); + free(yystext); + free(yysstatebuf); + free(yysunputbufptr); +} diff --git a/Utils/Parser Generator/SOURCE/yycless.cpp b/Utils/Parser Generator/SOURCE/yycless.cpp new file mode 100644 index 000000000..229a8ecbb --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yycless.cpp @@ -0,0 +1,23 @@ +/************************************************************ +yycless.cpp +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "clex.h" + +void yylexer::yyless(int length) +{ + yyassert(length >= 0 && length <= yyleng); + while (yyleng > length) { + yyunput((unsigned char)yytext[--yyleng]); + } + if (yyleng > 0) { + yyeol = (unsigned char)(yytext[yyleng - 1] == '\n'); + } + else { + yyeol = yyoldeol; + } +} diff --git a/Utils/Parser Generator/SOURCE/yycoutpt.cpp b/Utils/Parser Generator/SOURCE/yycoutpt.cpp new file mode 100644 index 000000000..6e7d6d423 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yycoutpt.cpp @@ -0,0 +1,34 @@ +/************************************************************ +yycoutpt.cpp +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include +#include "clex.h" + +void yylexer::yyoutput(int ch) +{ + // debugging +#ifdef YYDEBUG + if (::yydebug || yydebug) { + char string[128]; + + sprintf(string, "%p: output: \'", (void*)this); + yydebugoutput(string); + yydebugoutput(ch); + yydebugoutput("\'\n"); + } +#endif + + yyassert(yyout != NULL); + +#ifdef __BORLANDC__ + putc((char)ch, yyout); +#else + putc(ch, yyout); +#endif +} diff --git a/Utils/Parser Generator/SOURCE/yycparse.cpp b/Utils/Parser Generator/SOURCE/yycparse.cpp new file mode 100644 index 000000000..d4bbcc6e0 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yycparse.cpp @@ -0,0 +1,18 @@ +/************************************************************ +yycparse.cpp +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "cyacc.h" + +int yyparser::yyparse() +{ + int n = yysetup(); + if (n != 0) { + return n; + } + return yywork(); +} diff --git a/Utils/Parser Generator/SOURCE/yycpcln.cpp b/Utils/Parser Generator/SOURCE/yycpcln.cpp new file mode 100644 index 000000000..2c2efd397 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yycpcln.cpp @@ -0,0 +1,25 @@ +/************************************************************ +yycpcln.cpp +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include "cyacc.h" + +void yyparser::yycleanup() +{ + if (yystackptr != yysstackptr) { + free(yystackptr); + yystackptr = yysstackptr; + } + if (yyattributestackptr != yysattributestackptr) { + free(yyattributestackptr); + yyattributestackptr = yysattributestackptr; + } + yystack_size = yysstack_size; + + yytop = -1; +} diff --git a/Utils/Parser Generator/SOURCE/yycpcon.cpp b/Utils/Parser Generator/SOURCE/yycpcon.cpp new file mode 100644 index 000000000..f50c8f92c --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yycpcon.cpp @@ -0,0 +1,50 @@ +/************************************************************ +yycpcon.cpp +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "cyacc.h" + +yyparser::yyparser() +{ + yystackptr = NULL; + yysstackptr = NULL; + yyattributestackptr = NULL; + yysattributestackptr = NULL; + yystack_size = 0; + yysstack_size = 0; + yytop = -1; + yyattribute_size = 0; + yyvalptr = NULL; + yylookahead = 0; + yychar = -1; + yywipeflg = 1; + yypopflg = 0; + yyskip = 0; + yyexitflg = 0; + yyretireflg = 0; + yyerrorflg = 0; + yyexitcode = 0; + yyretirecode = 0; + yyerrorpop = 0; + yylexerptr = NULL; + yystackgrow = 1; + yylvalptr = NULL; + yyerr = stderr; + yyerrorcount = 0; + +#ifdef YYDEBUG + yydebug = 0; + yydebugstack = 0; + yydebugflush = 0; + yydebugout = stdout; +#endif +} + +yyparser::~yyparser() +{ + yydestroy(); +} diff --git a/Utils/Parser Generator/SOURCE/yycpcrea.cpp b/Utils/Parser Generator/SOURCE/yycpcrea.cpp new file mode 100644 index 000000000..f3544523b --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yycpcrea.cpp @@ -0,0 +1,66 @@ +/************************************************************ +yycpcrea.cpp +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "cyacc.h" +#include + +int yyparser::yycreate(yylexer YYFAR* lexerptr) +{ + yylexerptr = lexerptr; + + // stack + if (yysstack_size != 0) { + size_t stackcharsize; + size_t attributestackcharsize; + + stackcharsize = yysstack_size * sizeof(yystack_t); + if ((int)(stackcharsize / sizeof(yystack_t)) != yysstack_size) { + return 0; // integer overflow + } + attributestackcharsize = yysstack_size * yyattribute_size; + if ((int)(attributestackcharsize / yyattribute_size) != yysstack_size) { + return 0; // integer overflow + } + + yysstackptr = (yystack_t YYFAR*)malloc(stackcharsize); + if (yysstackptr == NULL) { + return 0; + } + yysattributestackptr = malloc(attributestackcharsize); + if (yysattributestackptr == NULL) { + free(yysstackptr); + return 0; + } + } + else { + yysstackptr = NULL; + yysattributestackptr = NULL; + } + yystack_size = yysstack_size; + yystackptr = yysstackptr; + yyattributestackptr = yysattributestackptr; + + // yylval + yylvalptr = malloc(yyattribute_size); + if (yylvalptr == NULL) { + free(yysstackptr); + free(yysattributestackptr); + return 0; + } + + // yyval ($$) + yyvalptr = malloc(yyattribute_size); + if (yyvalptr == NULL) { + free(yysstackptr); + free(yysattributestackptr); + free(yylvalptr); + return 0; + } + + return 1; +} diff --git a/Utils/Parser Generator/SOURCE/yycpdbug.cpp b/Utils/Parser Generator/SOURCE/yycpdbug.cpp new file mode 100644 index 000000000..0b00bda48 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yycpdbug.cpp @@ -0,0 +1,189 @@ +/************************************************************ +yycpdbug.cpp +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#ifdef _WIN32 +#include +#include +#endif +#include "cyacc.h" + +#ifdef YYDEBUG + +const char* yyparser::yytokenstring(int token) const +{ + yyassert(token >= 0); + + const yysymbol_t YYNEARFAR* symbol = yysymbol; + while (symbol->name != NULL) { + if (symbol->token == token) { + return symbol->name; + } + symbol++; + } + return "illegal-token"; +} + +void yyparser::yydgettoken(int token) const +{ + yyassert(token >= 0); + if (::yydebug || yydebug) { + char string[128]; + const char* tokenstring = yytokenstring(token); + yyassert(tokenstring != NULL); + + sprintf(string, "%p: get token ", (void*)this); + yydebugoutput(string); + yydebugoutput(tokenstring); + sprintf(string, " (%d)\n", (int)token); + yydebugoutput(string); + } +} + +void yyparser::yydshift(int token) const +{ + yyassert(token >= 0); + if (::yydebug || yydebug) { + char string[128]; + const char* tokenstring = yytokenstring(token); + yyassert(tokenstring != NULL); + + sprintf(string, "%p: shift token ", (void*)this); + yydebugoutput(string); + yydebugoutput(tokenstring); + sprintf(string, " (%d)\n", (int)token); + yydebugoutput(string); + } +} + +void yyparser::yydreduce(int rule) const +{ + yyassert(rule >= 0); + if (::yydebug || yydebug) { + char string[128]; + + sprintf(string, "%p: reduce rule ", (void*)this); + yydebugoutput(string); + yydebugoutput(yyrule[rule]); + sprintf(string, " (%d)\n", (int)rule); + yydebugoutput(string); + } +} + +void yyparser::yydsyntaxerror() const +{ + if (::yydebug || yydebug) { + char string[128]; + + sprintf(string, "%p: syntax error\n", (void*)this); + yydebugoutput(string); + } +} + +void yyparser::yydaccept() const +{ + if (::yydebug || yydebug) { + char string[128]; + + sprintf(string, "%p: accept\n", (void*)this); + yydebugoutput(string); + } +} + +void yyparser::yydabort() const +{ + if (::yydebug || yydebug) { + char string[128]; + + sprintf(string, "%p: abort\n", (void*)this); + yydebugoutput(string); + } +} + +void yyparser::yyddiscard(int token) const +{ + yyassert(token >= 0); + if (::yydebug || yydebug) { + char string[128]; + const char* tokenstring = yytokenstring(token); + yyassert(tokenstring != NULL); + + sprintf(string, "%p: discard token ", (void*)this); + yydebugoutput(string); + yydebugoutput(tokenstring); + sprintf(string, " (%d)\n", (int)token); + yydebugoutput(string); + } +} + +void yyparser::yydexit(int exitcode) const +{ + if (::yydebug || yydebug) { + char string[128]; + + sprintf(string, "%p: exit with code %d\n", (void*)this, (int)exitcode); + yydebugoutput(string); + } +} + +void yyparser::yydthrowerror(int errorpop) const +{ + if (::yydebug || yydebug) { + char string[128]; + + sprintf(string, "%p: throw error and pop %d error handling state(s)\n", + (void*)this, (int)errorpop); + yydebugoutput(string); + } +} + +void yyparser::yydretire(int retirecode) const +{ + if (::yydebug || yydebug) { + char string[128]; + + sprintf(string, "%p: retire with code %d\n", (void*)this, (int)retirecode); + yydebugoutput(string); + } +} + +void yyparser::yydattemptrecovery() const +{ + if (::yydebug || yydebug) { + char string[128]; + + sprintf(string, "%p: attempting error recovery\n", (void*)this); + yydebugoutput(string); + } +} + +void yyparser::yydebugoutput(const char *string) const +{ + yyassert(string != NULL); + +#ifdef _WIN32 + if (yydebugout != NULL) { +#else + yyassert(yydebugout != NULL); +#endif + while (*string != '\0') { + putc(*string++, yydebugout); + } + + if (::yydebugflush || yydebugflush) { + fflush(yydebugout); + } +#ifdef _WIN32 + } + else { + OutputDebugString(string); + } +#endif +} + +#endif diff --git a/Utils/Parser Generator/SOURCE/yycpdest.cpp b/Utils/Parser Generator/SOURCE/yycpdest.cpp new file mode 100644 index 000000000..aa181ca12 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yycpdest.cpp @@ -0,0 +1,20 @@ +/************************************************************ +yycpdest.cpp +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "cyacc.h" +#include + +void yyparser::yydestroy() +{ + yycleanup(); + free(yysstackptr); + free(yysattributestackptr); + + free(yylvalptr); + free(yyvalptr); +} diff --git a/Utils/Parser Generator/SOURCE/yycpop.cpp b/Utils/Parser Generator/SOURCE/yycpop.cpp new file mode 100644 index 000000000..039830ffa --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yycpop.cpp @@ -0,0 +1,33 @@ +/************************************************************ +yycpop.cpp +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "cyacc.h" + +#ifdef YYDEBUG +void yyparser::yypop(int num) +{ + yyassert(num >= 0); + yytop -= num; + yyassert(yytop >= -1); + + // debugging + if (::yydebug || yydebug) { + if (num > 0) { + char string[128]; + + sprintf(string, "%p: pop %d state(s)", (void*)this, (int)num); + yydebugoutput(string); + if (yytop >= 0) { + sprintf(string, " uncovering state %d", (int)yystackptr[yytop]); + yydebugoutput(string); + } + yydebugoutput("\n"); + } + } +} +#endif diff --git a/Utils/Parser Generator/SOURCE/yycpush.cpp b/Utils/Parser Generator/SOURCE/yycpush.cpp new file mode 100644 index 000000000..4b4d39e95 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yycpush.cpp @@ -0,0 +1,98 @@ +/************************************************************ +yycpush.cpp +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include +#include "cyacc.h" + +int yyparser::yypush(yystack_t state) +{ + yytop++; // increment first + if (yytop == yystack_size) { + do { + if (yystackgrow) { + if (yystack_size != 0) { + int size = yystack_size * 2; + if (size / 2 == yystack_size) { // overflow check + if (yysetstacksize(size)) { + break; + } + } + } + else { + if (yysetstacksize(100)) { + break; + } + } + } + yytop--; + + // debugging +#ifdef YYDEBUG + if (::yydebug || yydebug) { + char string[128]; + + sprintf(string, "%p: stack overflow\n", (void*)this); + yydebugoutput(string); + } +#endif + + yystackoverflow(); + return 0; + } + while (0); + } + yystackptr[yytop] = state; + + // debugging +#ifdef YYDEBUG + if (::yydebug || yydebug) { + char string[128]; + + sprintf(string, "%p: push state %d", (void*)this, (int)state); + yydebugoutput(string); + if (yytop > 0) { + sprintf(string, " covering state %d", (int)yystackptr[yytop - 1]); + yydebugoutput(string); + } + yydebugoutput("\n"); + + // output stack contents + if (::yydebugstack || yydebugstack) { + yydebugoutput("\nstack"); + int n = sprintf(string, "\n +"); + int i; + for (i = 0; i < 10; i++) { + n += sprintf(&string[n], " %5d", (int) i); + } + yydebugoutput(string); + + int rows = 1; + if (yytop >= 0) { + rows += yytop / 10; + } + for (i = 0; i < rows; i++) { + n = sprintf(string, "\n %5d", (int) (10 * i)); + for (int j = 0; j < 10; j++) { + int index = 10 * i + j; + if (index <= yytop) { + n += sprintf(&string[n], " %5d", (int) yystackptr[index]); + } + else { + n += sprintf(&string[n], " -"); + } + } + yydebugoutput(string); + } + yydebugoutput("\n\n"); + } + } +#endif + + return 1; +} diff --git a/Utils/Parser Generator/SOURCE/yycreset.cpp b/Utils/Parser Generator/SOURCE/yycreset.cpp new file mode 100644 index 000000000..b326f4fa1 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yycreset.cpp @@ -0,0 +1,21 @@ +/************************************************************ +yycreset.cpp +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "clex.h" + +void yylexer::yyreset() +{ + yyleng = 0; + yylineno = 1; + yyunputindex = 0; + yymoreflg = 0; + yyrejectflg = 0; + yyeol = 1; + yyoldeol = 1; + yystart = 0; +} diff --git a/Utils/Parser Generator/SOURCE/yycsetin.cpp b/Utils/Parser Generator/SOURCE/yycsetin.cpp new file mode 100644 index 000000000..58d7c5335 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yycsetin.cpp @@ -0,0 +1,18 @@ +/************************************************************ +yycsetin.cpp +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "cyacc.h" + +void yyparser::yysetin(int token) +{ + if (token < 0) { + token = 0; + } + yychar = token; + yylookahead = 1; +} diff --git a/Utils/Parser Generator/SOURCE/yycsetup.cpp b/Utils/Parser Generator/SOURCE/yycsetup.cpp new file mode 100644 index 000000000..0d1c1ed38 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yycsetup.cpp @@ -0,0 +1,29 @@ +/************************************************************ +yycsetup.cpp +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "cyacc.h" + +int yyparser::yysetup() +{ + // initialise variables + yytop = -1; + yylookahead = 0; + yyskip = 0; + yyerrorcount = 0; + yychar = -1; + yypopflg = 0; + + // push initial state onto the stack + if (!yypush(0)) { +#ifdef YYDEBUG + yydabort(); +#endif + return 1; + } + return 0; +} diff --git a/Utils/Parser Generator/SOURCE/yycsoflw.cpp b/Utils/Parser Generator/SOURCE/yycsoflw.cpp new file mode 100644 index 000000000..d363594f6 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yycsoflw.cpp @@ -0,0 +1,15 @@ +/************************************************************ +yycsoflw.cpp +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include "cyacc.h" + +void yyparser::yystackoverflow() +{ + yyerror("yacc stack overflow"); +} diff --git a/Utils/Parser Generator/SOURCE/yycsskip.cpp b/Utils/Parser Generator/SOURCE/yycsskip.cpp new file mode 100644 index 000000000..27909a1b0 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yycsskip.cpp @@ -0,0 +1,39 @@ +/************************************************************ +yycsskip.cpp +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include "cyacc.h" + +#ifdef YYDEBUG +void yyparser::yysetskip(int skip) +{ + yyassert(skip >= 0); + + // debugging + if (::yydebug || yydebug) { + if (skip > 0) { + if (yyskip == 0) { + char string[128]; + + sprintf(string, "%p: entering error recovery\n", (void*)this); + yydebugoutput(string); + } + } + else { + if (yyskip > 0) { + char string[128]; + + sprintf(string, "%p: leaving error recovery\n", (void*)this); + yydebugoutput(string); + } + } + } + + yyskip = skip; +} +#endif diff --git a/Utils/Parser Generator/SOURCE/yycsssiz.cpp b/Utils/Parser Generator/SOURCE/yycsssiz.cpp new file mode 100644 index 000000000..a71a889af --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yycsssiz.cpp @@ -0,0 +1,85 @@ +/************************************************************ +yycsssiz.cpp +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include +#include "cyacc.h" + +#ifndef min +#define min(x, y) ((x) <= (y) ? (x) : (y)) +#endif + +// the Visual C++ v1.52 compiler generates an error in NT if this isn't present! +#ifdef _MSC_VER +#if defined(M_I86HM) && defined(NDEBUG) +#pragma function(memcpy) +#endif +#endif + +int yyparser::yysetstacksize(int size) +{ + yyassert(size >= 0); + if (yystack_size != size) { + if (size <= yytop) { + return 0; + } + + size_t stackcharsize = size * sizeof(yystack_t); + if ((int)(stackcharsize / sizeof(yystack_t)) != size) { + return 0; // integer overflow + } + size_t attributestackcharsize = size * yyattribute_size; + if ((int)(attributestackcharsize / yyattribute_size) != size) { + return 0; // integer overflow + } + + // allocate + yystack_t YYFAR* stackptr; + void YYFAR* attributestackptr; + if (size <= yysstack_size) { + stackptr = yysstackptr; + attributestackptr = yysattributestackptr; + } + else { + stackptr = (yystack_t YYFAR*)malloc(stackcharsize); + if (stackptr == NULL) { + return 0; + } + attributestackptr = malloc(attributestackcharsize); + if (attributestackptr == NULL) { + free(stackptr); // clean up + return 0; + } + } + + // copy + if (stackptr != yystackptr) { + size_t charsize = yystack_size * sizeof(yystack_t); + memcpy(stackptr, yystackptr, min(stackcharsize, charsize)); + } + if (attributestackptr != yyattributestackptr) { + size_t charsize = yystack_size * yyattribute_size; + memcpy(attributestackptr, yyattributestackptr, min(attributestackcharsize, + charsize)); + } + + // free + if (yystackptr != yysstackptr) { + free(yystackptr); + } + if (yyattributestackptr != yysattributestackptr) { + free(yyattributestackptr); + } + + // assign + yystackptr = stackptr; + yyattributestackptr = attributestackptr; + yystack_size = size; + } + return 1; +} diff --git a/Utils/Parser Generator/SOURCE/yycstsiz.cpp b/Utils/Parser Generator/SOURCE/yycstsiz.cpp new file mode 100644 index 000000000..239563025 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yycstsiz.cpp @@ -0,0 +1,84 @@ +/************************************************************ +yycstsiz.cpp +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include +#include "clex.h" + +#ifndef min +#define min(x, y) ((x) <= (y) ? (x) : (y)) +#endif + +// the Visual C++ v1.52 compiler generates an error in NT if this isn't present! +#ifdef _MSC_VER +#if defined(M_I86HM) && defined(NDEBUG) +#pragma function(memcpy) +#endif +#endif + +int yylexer::yysettextsize(int size) +{ + yyassert(size >= 0); + if (yytext_size != size) { + if (size < yyleng) { + return 0; + } + + size_t textcharsize = size + 1; // include the '\0' + if (textcharsize <= (size_t) size) { + return 0; // integer overflow + } + size_t statebufcharsize = size * sizeof(int); + if ((int)(statebufcharsize / sizeof(int)) != size) { + return 0; // integer overflow + } + + // allocate + char YYFAR* text; + int YYFAR* statebuf; + if (size <= yystext_size) { + text = yystext; + statebuf = yysstatebuf; + } + else { + text = (char YYFAR*)malloc(textcharsize); + if (text == NULL) { + return 0; + } + statebuf = (int YYFAR*)malloc(statebufcharsize); + if (statebuf == NULL) { + free(text); // clean up + return 0; + } + } + + // copy + if (text != yytext) { + size_t charsize = yytext_size + 1; + memcpy(text, yytext, min(textcharsize, charsize)); + } + if (statebuf != yystatebuf) { + size_t charsize = yytext_size * sizeof(int); + memcpy(statebuf, yystatebuf, min(statebufcharsize, charsize)); + } + + // free + if (yytext != yystext) { + free(yytext); + } + if (yystatebuf != yysstatebuf) { + free(yystatebuf); + } + + // assign + yytext = text; + yystatebuf = statebuf; + yytext_size = size; + } + return 1; +} diff --git a/Utils/Parser Generator/SOURCE/yycsusiz.cpp b/Utils/Parser Generator/SOURCE/yycsusiz.cpp new file mode 100644 index 000000000..4727cb3ea --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yycsusiz.cpp @@ -0,0 +1,65 @@ +/************************************************************ +yycsusiz.cpp +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include +#include "clex.h" + +#ifndef min +#define min(x, y) ((x) <= (y) ? (x) : (y)) +#endif + +// the Visual C++ v1.52 compiler generates an error in NT if this isn't present! +#ifdef _MSC_VER +#if defined(M_I86HM) && defined(NDEBUG) +#pragma function(memcpy) +#endif +#endif + +int yylexer::yysetunputsize(int size) +{ + yyassert(size >= 0); + if (yyunput_size != size) { + if (size < yyunputindex) { + return 0; + } + + size_t unputbufcharsize = size * sizeof(int); + if ((int)(unputbufcharsize / sizeof(int)) != size) { + return 0; // integer overflow + } + + // allocate + int YYFAR* unputbufptr; + if (size <= yysunput_size) { + unputbufptr = yysunputbufptr; + } + else { + unputbufptr = (int YYFAR*)malloc(unputbufcharsize); + if (unputbufptr == NULL) { + return 0; + } + } + + // copy + if (unputbufptr != yyunputbufptr) { + size_t charsize = yyunput_size * sizeof(int); + memcpy(unputbufptr, yyunputbufptr, min(unputbufcharsize, charsize)); + } + + // free + if (yyunputbufptr != yysunputbufptr) { + free(yyunputbufptr); + } + + // assign + yyunputbufptr = unputbufptr; + yyunput_size = size; + } + return 1; +} diff --git a/Utils/Parser Generator/SOURCE/yycsyner.cpp b/Utils/Parser Generator/SOURCE/yycsyner.cpp new file mode 100644 index 000000000..ad6789d50 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yycsyner.cpp @@ -0,0 +1,14 @@ +/************************************************************ +yycsyner.cpp +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "cyacc.h" + +void yyparser::yysyntaxerror(void) +{ + yyerror("syntax error"); +} diff --git a/Utils/Parser Generator/SOURCE/yyctoflw.cpp b/Utils/Parser Generator/SOURCE/yyctoflw.cpp new file mode 100644 index 000000000..14a978330 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yyctoflw.cpp @@ -0,0 +1,15 @@ +/************************************************************ +yyctoflw.cpp +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "clex.h" + +void yylexer::yytextoverflow() +{ + yyassert(yyerr != NULL); + fprintf(yyerr, "lex text buffer overflow (%d)\n", (int)yytext_size); +} diff --git a/Utils/Parser Generator/SOURCE/yycuncin.cpp b/Utils/Parser Generator/SOURCE/yycuncin.cpp new file mode 100644 index 000000000..92b12a56c --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yycuncin.cpp @@ -0,0 +1,18 @@ +/************************************************************ +yycuncin.cpp +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "cyacc.h" + +int yyparser::yyunclearin() +{ + if (!yylookahead && yychar != -1) { + yylookahead = 1; + return 1; + } + return 0; +} diff --git a/Utils/Parser Generator/SOURCE/yycunput.cpp b/Utils/Parser Generator/SOURCE/yycunput.cpp new file mode 100644 index 000000000..aab67426e --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yycunput.cpp @@ -0,0 +1,62 @@ +/************************************************************ +yycunput.cpp +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include +#include +#include +#include "clex.h" + +void yylexer::yyunput(int ch) +{ + yyassert(ch >= 0 && ch <= UCHAR_MAX || ch == EOF); + yyassert(yyunputindex >= 0 && yyunputindex <= yyunput_size); + + // check unput buffer size + if (yyunputindex == yyunput_size) { + do { + if (yyunputgrow) { + if (yyunput_size != 0) { + int size = yyunput_size * 2; + if (size / 2 == yyunput_size) { // overflow check + if (yysetunputsize(size)) { + break; + } + } + } + else { + if (yysetunputsize(100)) { + break; + } + } + } + yyunputoverflow(); + exit(EXIT_FAILURE); + } + while (0); + } + + yyunputbufptr[yyunputindex++] = ch; + + // check line number + if (ch == '\n') { + yylineno--; + } + + // debugging +#ifdef YYDEBUG + if (::yydebug || yydebug) { + char string[128]; + + sprintf(string, "%p: unput: \'", (void*)this); + yydebugoutput(string); + yydebugoutput(ch); + yydebugoutput("\'\n"); + } +#endif +} diff --git a/Utils/Parser Generator/SOURCE/yycuoflw.cpp b/Utils/Parser Generator/SOURCE/yycuoflw.cpp new file mode 100644 index 000000000..3f684c942 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yycuoflw.cpp @@ -0,0 +1,15 @@ +/************************************************************ +yycuoflw.cpp +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "clex.h" + +void yylexer::yyunputoverflow() +{ + yyassert(yyerr != NULL); + fprintf(yyerr, "lex unput buffer overflow (%d)\n", (int)yyunput_size); +} diff --git a/Utils/Parser Generator/SOURCE/yycwipe.cpp b/Utils/Parser Generator/SOURCE/yycwipe.cpp new file mode 100644 index 000000000..2cfb18597 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yycwipe.cpp @@ -0,0 +1,16 @@ +/************************************************************ +yycwipe.cpp +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include "cyacc.h" + +void yyparser::yywipe() +{ + yydestructpop(yytop + 1); + yydestructclearin(); +} diff --git a/Utils/Parser Generator/SOURCE/yycwork.cpp b/Utils/Parser Generator/SOURCE/yycwork.cpp new file mode 100644 index 000000000..bb25ef3e7 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yycwork.cpp @@ -0,0 +1,290 @@ +/************************************************************ +yycwork.cpp +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include "cyacc.h" + +// the Visual C++ v1.52 compiler generates an error in NT if this isn't present! +#ifdef _MSC_VER +#if defined(M_I86HM) && defined(NDEBUG) +#pragma function(memcpy) +#endif +#endif + +int yyfparser::yywork() +{ + int errorpop = 0; + while (1) { + unsigned char type; + short sr; + yystack_t state = yypeek(); // get top state + while (1) { + if (yystateaction[state].lookahead) { + int index; + if (!yylookahead) { + yychar = yygettoken(); + if (yychar < 0) { + yychar = 0; + } + yylookahead = 1; +#ifdef YYDEBUG + yydgettoken(yychar); +#endif + } + index = yystateaction[state].base + yychar; + if (index >= 0 && index < yytokenaction_size) { + if (yytokenaction[index].check == state) { + type = yytokenaction[index].type; + sr = yytokenaction[index].sr; + break; // escape from loop + } + } + } + + type = yystateaction[state].type; + sr = yystateaction[state].sr; + if (type != YYAT_DEFAULT) { + break; // escape from loop + } + state = sr; + } + + // action + switch (type) { + case YYAT_SHIFT: +#ifdef YYDEBUG + yydshift(yychar); +#endif + if (yyskip > 0) { + yysetskip(yyskip - 1); + } + if (!yypush(sr)) { +#ifdef YYDEBUG + yydabort(); +#endif + if (yywipeflg) { + yywipe(); // clean up + } + return 1; + } + memcpy(&((char YYFAR*)yyattributestackptr)[yytop * yyattribute_size], + yylvalptr, yyattribute_size); + yylookahead = 0; + continue; // go to top of while loop + case YYAT_REDUCE: +#ifdef YYDEBUG + yydreduce(sr); +#endif + yyretireflg = 0; + if (yyreduction[sr].action != -1) { + // user actions in here + if (yyreduction[sr].length > 0) { + memcpy(yyvalptr, &((char YYFAR*)yyattributestackptr) + [(yytop + 1 - yyreduction[sr].length) * yyattribute_size], + yyattribute_size); + } + + yyerrorflg = 0; + yyexitflg = 0; + yyaction(yyreduction[sr].action); + + // check for special user requected actions + if (yyexitflg) { +#ifdef YYDEBUG + yydexit(yyexitcode); +#endif + return yyexitcode; + } + if (yyerrorflg) { + errorpop = yyerrorpop; +#ifdef YYDEBUG + yydthrowerror(yyerrorpop); +#endif + yyerrorcount++; + break; // go to error handler + } + } + + yypop(yyreduction[sr].length); + { + yystack_t state = yypeek(); // get top state + short next; + + int nonterm = yyreduction[sr].nonterm; + while (1) { + int index = yystategoto[state].base + nonterm; + if (index >= 0 && index < yynontermgoto_size) { + if (yynontermgoto[index].check == state) { + next = yynontermgoto[index].next; + break; + } + } + + next = yystategoto[state].def; + if (next == -1) { + break; + } + state = next; + } + yyassert(next != -1); + + if (!yypush(next)) { +#ifdef YYDEBUG + yydabort(); +#endif + if (yywipeflg) { + yywipe(); // clean up + } + return 1; + } + } + if (yyreduction[sr].action != -1) { + memcpy(&((char YYFAR*)yyattributestackptr)[yytop * yyattribute_size], + yyvalptr, yyattribute_size); + } + if (yyretireflg) { +#ifdef YYDEBUG + yydretire(yyretirecode); +#endif + return yyretirecode; + } + continue; // go to top of while loop + case YYAT_ERROR: +#ifdef YYDEBUG + yydsyntaxerror(); +#endif + if (yyskip == 0) { + yyerrorcount++; + yysyntaxerror(); + } + break; // go to error handler + default: + yyassert(type == YYAT_ACCEPT); +#ifdef YYDEBUG + yydaccept(); +#endif + return 0; + } + + // error handler + if (yyskip < 3 || errorpop > 0) { +#ifdef YYDEBUG + yydattemptrecovery(); +#endif + yypopflg = 0; // clear flag + while (1) { + state = yypeek(); // get top state + while (1) { + if (yystateaction[state].lookahead) { + int index = yystateaction[state].base + YYTK_ERROR; + if (index >= 0 && index < yytokenaction_size) { + if (yytokenaction[index].check == state) { + type = yytokenaction[index].type; + sr = yytokenaction[index].sr; + break; // escape from loop + } + } + } + + type = yystateaction[state].type; + sr = yystateaction[state].sr; + if (type != YYAT_DEFAULT) { + break; // escape from loop + } + state = sr; + } + + if (type == YYAT_SHIFT) { + if (errorpop <= 0) { +#ifdef YYDEBUG + yydshift(YYTK_ERROR); +#endif + if (!yypush(sr)) { +#ifdef YYDEBUG + yydabort(); +#endif + if (yywipeflg) { + yywipe(); // clean up + } + return 1; + } + yysetskip(3); // skip 3 erroneous characters + break; + } + errorpop--; + } + + yypopflg = 1; + + // clean up any symbol attributes + if (yydestructorptr != NULL) { + int action; + state = yypeek(); + action = yydestructorptr[state]; + if (action != -1) { + // user actions in here + memcpy(yyvalptr, &((char YYFAR*)yyattributestackptr) + [yytop * yyattribute_size], yyattribute_size); + + yyaction(action); + + memcpy(&((char YYFAR*)yyattributestackptr) + [yytop * yyattribute_size], yyvalptr, yyattribute_size); + } + } + yypop(1); + if (yytop < 0) { +#ifdef YYDEBUG + yydabort(); +#endif + if (yywipeflg) { + yywipe(); // clean up + } + return 1; + } + } + } + else { + if (yylookahead) { + if (yychar != 0) { +#ifdef YYDEBUG + yyddiscard(yychar); +#endif + yydiscard(yychar); + + // clean up any token attributes + if (yytokendestptr != NULL) { + int index = yytokendestbase + yychar; + if (index >= 0 && index < yytokendest_size) { + int action = yytokendestptr[index]; + if (action != -1) { + // user actions in here + memcpy(yyvalptr, yylvalptr, yyattribute_size); + + yyaction(action); + + memcpy(yylvalptr, yyvalptr, yyattribute_size); + } + } + } + + yylookahead = 0; // skip erroneous character + } + else { +#ifdef YYDEBUG + yydabort(); +#endif + if (yywipeflg) { + yywipe(); // clean up + } + return 1; + } + } + } + } +} diff --git a/Utils/Parser Generator/SOURCE/yycwrap.cpp b/Utils/Parser Generator/SOURCE/yycwrap.cpp new file mode 100644 index 000000000..6745c6f7e --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yycwrap.cpp @@ -0,0 +1,14 @@ +/************************************************************ +yycwrap.cpp +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "clex.h" + +int yylexer::yywrap(void) +{ + return 1; +} diff --git a/Utils/Parser Generator/SOURCE/yydebug.c b/Utils/Parser Generator/SOURCE/yydebug.c new file mode 100644 index 000000000..856f26891 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yydebug.c @@ -0,0 +1,18 @@ +/************************************************************ +yydebug.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "yacc.h" +#include "lex.h" +#include "myacc.h" +#include "mlex.h" + +#ifdef YYDEBUG +int YYNEAR YYDCDECL yydebug = 0; +int YYNEAR YYDCDECL yydebugstack = 0; /* parsers only */ +int YYNEAR YYDCDECL yydebugflush = 0; +#endif diff --git a/Utils/Parser Generator/SOURCE/yymback.c b/Utils/Parser Generator/SOURCE/yymback.c new file mode 100644 index 000000000..0e9ce3098 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yymback.c @@ -0,0 +1,27 @@ +/************************************************************ +yymback.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "mlex.h" + +#ifdef YYPROTOTYPE +int YYCDECL yymback(YYCONST yymatch_t YYNEARFAR *p, int action) +#else +int YYCDECL yymback(p, action) +YYCONST yymatch_t YYNEARFAR *p; +int action; +#endif +{ + yyassert(p != NULL); + yyassert(action < 0); + while (*p != 0) { + if (*p++ == action) { + return 1; + } + } + return 0; +} diff --git a/Utils/Parser Generator/SOURCE/yymcdeci.c b/Utils/Parser Generator/SOURCE/yymcdeci.c new file mode 100644 index 000000000..532c34302 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yymcdeci.c @@ -0,0 +1,41 @@ +/************************************************************ +yymcdeci.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include "myacc.h" + +#ifdef YYPROTOTYPE +void YYCDECL yymcdestructclearin(yymparse_t YYFAR *yy) +#else +void YYCDECL yymcdestructclearin(yy) +yymparse_t YYFAR *yy; +#endif +{ + yyassert(yy != NULL); + yyassert(yymiscompactparser(yy)); /* make sure it's a compact parser */ + + if (yy->yymlookahead) { + /* clean up any token attributes */ + if (yy->yymctokendestptr != NULL) { + YYCONST yyctokendest_t YYNEARFAR *tokendestptr = yy->yymctokendestptr; + while (tokendestptr->token != 0) { + if (tokendestptr->token == yy->yymchar) { + /* user actions in here */ + memcpy(yy->yymvalptr, yy->yymlvalptr, yy->yymattribute_size); + + (*yy->yymparseaction)(yy, tokendestptr->action); + + memcpy(yy->yymlvalptr, yy->yymvalptr, yy->yymattribute_size); + break; + } + tokendestptr++; + } + } + yy->yymlookahead = 0; + } +} diff --git a/Utils/Parser Generator/SOURCE/yymclex.c b/Utils/Parser Generator/SOURCE/yymclex.c new file mode 100644 index 000000000..c5c02b216 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yymclex.c @@ -0,0 +1,236 @@ +/************************************************************ +yymclex.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include +#include +#include +#include "mlex.h" + +#ifdef YYPROTOTYPE +int YYCDECL yymclex(yymlex_t YYFAR *yy) +#else +int YYCDECL yymclex(yy) +yymlex_t YYFAR *yy; +#endif +{ + yyassert(yy != NULL); + yyassert(yymiscompactlexer(yy)); /* make sure it's a compact lexical analyser */ + + while (1) { + int oldleng; + int state = 1 + yy->yymstart; + if (yy->yymeol) { + state++; + } + + /* yymore */ + if (yy->yymmoreflg) { + yy->yymmoreflg = 0; /* clear flag */ + } + else { + yy->yymleng = 0; + yy->yymoldeol = yy->yymeol; + } + oldleng = yy->yymleng; + + /* look for a string */ + do { + int index; + int ch; /* lookahead character */ + + /* get input character */ + ch = (*yy->yyminput)(yy); + yyassert(ch >= 0 && ch <= UCHAR_MAX || ch == EOF); + if (ch == EOF) { + break; + } + + /* check for possible overflow */ + if (yy->yymleng == yy->yymtext_size) { + do { + if (yy->yymtextgrow) { + if (yy->yymtext_size != 0) { + int size = yy->yymtext_size * 2; + if (size / 2 == yy->yymtext_size) { /* overflow check */ + if (yymsettextsize(yy, size)) { + break; + } + } + } + else { + if (yymsettextsize(yy, 100)) { + break; + } + } + } + (*yy->yymtextoverflow)(yy); + exit(EXIT_FAILURE); + } + while (0); + } + + /* handles eof condition automatically */ + index = yy->yymstate[state].base; + while (1) { + if (yy->yymctransition[index].next == 0) { + state = yy->yymstate[state].def; + if (state <= 0) { + if (state < 0) { + if (ch >= 0 && ch <= 0xff) { + state = -state; + } + else { + state = 0; + } + } + break; + } + } + if (ch >= yy->yymctransition[index].first && + ch <= yy->yymctransition[index].last) { + state = yy->yymctransition[index].next; + break; + } + index++; + } + + { + int leng = yy->yymleng; /* slightly more efficient */ + yy->yymtext[leng] = (char) ch; + yy->yymstatebuf[leng] = state; + leng++; + yy->yymleng = leng; + } + } + while (state != 0 && (yy->yymstate[state].def != 0 || yy->yymstate[state].base != 0)); + + /* now find a match */ + if (yy->yymleng > oldleng) { + int rejectmatch = 0; + while (1) { + int match = yy->yymstate[yy->yymstatebuf[yy->yymleng - 1]].match; + if (rejectmatch != 0) { + if (match < 0) { + int index = -match; + do { + match = yy->yymmatch[index++]; + } + while (match > 0 && match <= rejectmatch); + } + else { + if (match == rejectmatch) { + match = 0; + } + } + rejectmatch = 0; + } + else { + if (match < 0) { + match = yy->yymmatch[-match]; + } + } + if (match > 0) { + int rejectleng; + int token; + /* check for backup */ + if (yy->yymbackup[match]) { + while (yy->yymleng > oldleng) { + int index = yy->yymstate[yy->yymstatebuf[yy->yymleng - 1]].match; + if (index < 0) { + if (yymback(&yy->yymmatch[-index], -match)) { + break; /* found an expression */ + } + } + yy->yymleng--; + (*yy->yymunput)(yy, (unsigned char) yy->yymtext[yy->yymleng]); + } + } + yy->yymtext[yy->yymleng] = '\0'; +#ifdef YYDEBUG + yymdmatch(yy, match); +#endif + yy->yymrejectflg = 0; + rejectleng = yy->yymleng; + + if (yy->yymleng > 0) { + yy->yymeol = (unsigned char) (yy->yymtext[yy->yymleng - 1] == '\n'); + } + else { + yy->yymeol = yy->yymoldeol; + } + + /* perform user action */ + token = (*yy->yymlexaction)(yy, match); + + if (yy->yymreturnflg) { + return token; + } + if (!yy->yymrejectflg) { + break; + } + if (rejectleng == yy->yymleng) { + rejectmatch = match; + } + } + else if (yy->yymleng > oldleng + 1) { + yy->yymleng--; + (*yy->yymunput)(yy, (unsigned char) yy->yymtext[yy->yymleng]); + } + else { + yy->yymeol = (unsigned char) (yy->yymtext[0] == '\n'); + (*yy->yymoutput)(yy, yy->yymtext[0]); /* non-matched character */ + break; + } + } + } + else { + int index; + int match; + yyassert(yy->yymleng == oldleng); + + /* handles <> rules */ + index = 0; + match = yy->yymstate[state].match; + if (match < 0) { + index = -match; + match = yy->yymmatch[index++]; + } + while (match > 0) { + int token; + yy->yymtext[yy->yymleng] = '\0'; +#ifdef YYDEBUG + yymdmatch(yy, match); +#endif + yy->yymrejectflg = 0; /* clear flag */ + + /* perform user action */ + token = (*yy->yymlexaction)(yy, match); + + if (yy->yymreturnflg) { + return token; + } + if (!yy->yymrejectflg) { + break; + } + + if (index == 0) { + break; + } + match = yy->yymmatch[index++]; + } + + if ((*yy->yymwrap)(yy)) { + yy->yymoldeol = 1; + yy->yymeol = 1; + yy->yymstart = 0; + return 0; /* eof reached */ + } + } + } +} diff --git a/Utils/Parser Generator/SOURCE/yymcpars.c b/Utils/Parser Generator/SOURCE/yymcpars.c new file mode 100644 index 000000000..38f04f792 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yymcpars.c @@ -0,0 +1,27 @@ +/************************************************************ +yymcpars.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "myacc.h" + +#ifdef YYPROTOTYPE +int YYCDECL yymcparse(yymparse_t YYFAR *yy) +#else +int YYCDECL yymcparse(yy) +yymparse_t YYFAR *yy; +#endif +{ + int n; + yyassert(yy != NULL); + yyassert(yymiscompactparser(yy)); /* make sure it's a compact parser */ + + n = yymsetup(yy); + if (n != 0) { + return n; + } + return yymcwork(yy); +} diff --git a/Utils/Parser Generator/SOURCE/yymcwipe.c b/Utils/Parser Generator/SOURCE/yymcwipe.c new file mode 100644 index 000000000..9fa0eb6e3 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yymcwipe.c @@ -0,0 +1,24 @@ +/************************************************************ +yymcwipe.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include "myacc.h" + +#ifdef YYPROTOTYPE +void YYCDECL yymcwipe(yymparse_t YYFAR *yy) +#else +void YYCDECL yymcwipe(yy) +yymparse_t YYFAR *yy; +#endif +{ + yyassert(yy != NULL); + yyassert(yymiscompactparser(yy)); /* make sure it's a compact parser */ + + yymdestructpop(yy, yy->yymtop + 1); + yymcdestructclearin(yy); +} diff --git a/Utils/Parser Generator/SOURCE/yymcwork.c b/Utils/Parser Generator/SOURCE/yymcwork.c new file mode 100644 index 000000000..2f4368f83 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yymcwork.c @@ -0,0 +1,293 @@ +/************************************************************ +yymcwork.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include "myacc.h" + +#ifdef YYPROTOTYPE +int YYCDECL yymcwork(yymparse_t YYFAR *yy) +#else +int YYCDECL yymcwork(yy) +yymparse_t YYFAR *yy; +#endif +{ + int errorpop = 0; + yyassert(yy != NULL); + yyassert(yymiscompactparser(yy)); /* make sure it's a compact parser */ + + while (1) { + unsigned char type; + short sr; + yystack_t state = yympeek(yy); /* get top state */ + + int index = yy->yymcstateaction[state]; + while (1) { + if (yy->yymctokenaction[index].token == YYTK_ALL) { + if (yy->yymctokenaction[index].type == YYAT_DEFAULT) { + state = yy->yymctokenaction[index].sr; + index = yy->yymcstateaction[state]; + continue; + } + break; + } + + if (!yy->yymlookahead) { + yy->yymlookahead = 1; + yy->yymchar = (*yy->yymgettoken)(yy); + if (yy->yymchar < 0) { + yy->yymchar = 0; + } +#ifdef YYDEBUG + yymdgettoken(yy, yy->yymchar); +#endif + } + if (yy->yymctokenaction[index].token == yy->yymchar) { + break; + } + index++; + } + type = yy->yymctokenaction[index].type; + sr = yy->yymctokenaction[index].sr; + + /* action */ + switch (type) { + case YYAT_SHIFT: +#ifdef YYDEBUG + yymdshift(yy, yy->yymchar); +#endif + if (yy->yymskip > 0) { + yymsetskip(yy, yy->yymskip - 1); + } + if (!yympush(yy, sr)) { +#ifdef YYDEBUG + yymdabort(yy); +#endif + if (yy->yymwipeflg) { + yymcwipe(yy); /* clean up */ + } + return 1; + } + memcpy(&((char YYFAR *) yy->yymattributestackptr)[yy->yymtop * + yy->yymattribute_size], yy->yymlvalptr, yy->yymattribute_size); + yy->yymlookahead = 0; + continue; /* go to top of while loop */ + case YYAT_REDUCE: +#ifdef YYDEBUG + yymdreduce(yy, sr); +#endif + yy->yymretireflg = 0; + if (yy->yymreduction[sr].action != -1) { + /* user actions in here */ + if (yy->yymreduction[sr].length > 0) { + memcpy(yy->yymvalptr, &((char YYFAR *) yy->yymattributestackptr) + [(yy->yymtop + 1 - yy->yymreduction[sr].length) * + yy->yymattribute_size], yy->yymattribute_size); + } + + yy->yymerrorflg = 0; + yy->yymexitflg = 0; + (*yy->yymparseaction)(yy, yy->yymreduction[sr].action); + + /* check for special user requected actions */ + if (yy->yymexitflg) { +#ifdef YYDEBUG + yymexit(yy, yy->yymexitcode); +#endif + return yy->yymexitcode; + } + if (yy->yymerrorflg) { + errorpop = yy->yymerrorpop; +#ifdef YYDEBUG + yymdthrowerror(yy, yy->yymerrorpop); +#endif + yy->yymerrorcount++; + break; /* go to error handler */ + } + } + + yympop(yy, yy->yymreduction[sr].length); + { + yystack_t state = yympeek(yy); /* get top state */ + short next; + + int nonterm = yy->yymreduction[sr].nonterm; + int index = yy->yymcstategoto[state]; + while (1) { + if (yy->yymcnontermgoto[index].nonterm == -1) { + if (yy->yymcnontermgoto[index].next != -1) { + state = yy->yymcnontermgoto[index].next; + index = yy->yymcstategoto[state]; + continue; + } + break; + } + if (yy->yymcnontermgoto[index].nonterm == nonterm) { + break; + } + index++; + } + next = yy->yymcnontermgoto[index].next; + yyassert(next != -1); + + if (!yympush(yy, next)) { +#ifdef YYDEBUG + yymdabort(yy); +#endif + if (yy->yymwipeflg) { + yymcwipe(yy); /* clean up */ + } + return 1; + } + } + if (yy->yymreduction[sr].action != -1) { + memcpy(&((char YYFAR *) yy->yymattributestackptr) + [yy->yymtop * yy->yymattribute_size], + yy->yymvalptr, yy->yymattribute_size); + } + if (yy->yymretireflg) { +#ifdef YYDEBUG + yymdretire(yy, yy->yymretirecode); +#endif + return yy->yymretirecode; + } + continue; /* go to top of while loop */ + case YYAT_ERROR: +#ifdef YYDEBUG + yymdsyntaxerror(yy); +#endif + if (yy->yymskip == 0) { + yy->yymerrorcount++; + (*yy->yymsyntaxerror)(yy); + } + break; /* go to error handler */ + default: + yyassert(type == YYAT_ACCEPT); +#ifdef YYDEBUG + yymdaccept(yy); +#endif + return 0; + } + + /* error handler */ + if (yy->yymskip < 3 || errorpop > 0) { +#ifdef YYDEBUG + yymdattemptrecovery(yy); +#endif + yy->yympopflg = 0; /* clear flag */ + while (1) { + state = yympeek(yy); /* get top state */ + index = yy->yymcstateaction[state]; + while (1) { + if (yy->yymctokenaction[index].token == YYTK_ALL) { + if (yy->yymctokenaction[index].type == YYAT_DEFAULT) { + state = yy->yymctokenaction[index].sr; + index = yy->yymcstateaction[state]; + continue; + } + break; + } + if (yy->yymctokenaction[index].token == YYTK_ERROR) { + break; + } + index++; + } + type = yy->yymctokenaction[index].type; + sr = yy->yymctokenaction[index].sr; + + if (type == YYAT_SHIFT) { + if (errorpop <= 0) { +#ifdef YYDEBUG + yymdshift(yy, YYTK_ERROR); +#endif + if (!yympush(yy, sr)) { +#ifdef YYDEBUG + yymdabort(yy); +#endif + if (yy->yymwipeflg) { + yymcwipe(yy); /* clean up */ + } + return 1; + } + yymsetskip(yy, 3); /* skip 3 erroneous characters */ + break; + } + errorpop--; + } + + yy->yympopflg = 1; + + /* clean up any symbol attributes */ + if (yy->yymdestructorptr != NULL) { + int action; + state = yympeek(yy); + action = yy->yymdestructorptr[state]; + if (action != -1) { + /* user actions in here */ + memcpy(yy->yymvalptr, &((char YYFAR *) yy->yymattributestackptr) + [yy->yymtop * yy->yymattribute_size], + yy->yymattribute_size); + + (*yy->yymparseaction)(yy, action); + + memcpy(&((char YYFAR *) yy->yymattributestackptr) + [yy->yymtop * yy->yymattribute_size], yy->yymvalptr, + yy->yymattribute_size); + } + } + yympop(yy, 1); + if (yy->yymtop < 0) { +#ifdef YYDEBUG + yymdabort(yy); +#endif + if (yy->yymwipeflg) { + yymcwipe(yy); /* clean up */ + } + return 1; + } + } + } + else { + if (yy->yymlookahead) { + if (yy->yymchar != 0) { +#ifdef YYDEBUG + yymddiscard(yy, yy->yymchar); +#endif + (*yy->yymdiscard)(yy, yy->yymchar); + + /* clean up any token attributes */ + if (yy->yymctokendestptr != NULL) { + YYCONST yyctokendest_t YYNEARFAR *tokendestptr = yy->yymctokendestptr; + while (tokendestptr->token != 0) { + if (tokendestptr->token == yy->yymchar) { + /* user actions in here */ + memcpy(yy->yymvalptr, yy->yymlvalptr, yy->yymattribute_size); + + (*yy->yymparseaction)(yy, tokendestptr->action); + + memcpy(yy->yymlvalptr, yy->yymvalptr, yy->yymattribute_size); + break; + } + tokendestptr++; + } + } + + yy->yymlookahead = 0; /* skip erroneous character */ + } + else { +#ifdef YYDEBUG + yymdabort(yy); +#endif + if (yy->yymwipeflg) { + yymcwipe(yy); /* clean up */ + } + return 1; + } + } + } + } +} diff --git a/Utils/Parser Generator/SOURCE/yymdeci.c b/Utils/Parser Generator/SOURCE/yymdeci.c new file mode 100644 index 000000000..a0795bcee --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yymdeci.c @@ -0,0 +1,40 @@ +/************************************************************ +yymdeci.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include "myacc.h" + +#ifdef YYPROTOTYPE +void YYCDECL yymdestructclearin(yymparse_t YYFAR *yy) +#else +void YYCDECL yymdestructclearin(yy) +yymparse_t YYFAR *yy; +#endif +{ + yyassert(yy != NULL); + yyassert(yymisfastparser(yy)); /* make sure it's a fast parser */ + + if (yy->yymlookahead) { + /* clean up any token attributes */ + if (yy->yymtokendestptr != NULL) { + int index = yy->yymtokendestbase + yy->yymchar; + if (index >= 0 && index < yy->yymtokendest_size) { + int action = yy->yymtokendestptr[index]; + if (action != -1) { + /* user actions in here */ + memcpy(yy->yymvalptr, yy->yymlvalptr, yy->yymattribute_size); + + (*yy->yymparseaction)(yy, action); + + memcpy(yy->yymlvalptr, yy->yymvalptr, yy->yymattribute_size); + } + } + } + yy->yymlookahead = 0; + } +} diff --git a/Utils/Parser Generator/SOURCE/yymdepop.c b/Utils/Parser Generator/SOURCE/yymdepop.c new file mode 100644 index 000000000..1bc0ab95c --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yymdepop.c @@ -0,0 +1,46 @@ +/************************************************************ +yymdepop.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include "myacc.h" + +#ifdef YYPROTOTYPE +void YYCDECL yymdestructpop(yymparse_t YYFAR *yy, int num) +#else +void YYCDECL yymdestructpop(yy, num) +yymparse_t YYFAR *yy; +int num; +#endif +{ + yyassert(yy != NULL); + yyassert(num >= 0); + yyassert(yy->yymtop - num >= -1); + + if (yy->yymdestructorptr != NULL) { + while (num > 0) { + yystack_t state = yympeek(yy); + int action = yy->yymdestructorptr[state]; + if (action != -1) { + /* user actions in here */ + memcpy(yy->yymvalptr, &((char YYFAR *) yy->yymattributestackptr) + [yy->yymtop * yy->yymattribute_size], yy->yymattribute_size); + + (*yy->yymparseaction)(yy, action); + + memcpy(&((char YYFAR *) yy->yymattributestackptr) + [yy->yymtop * yy->yymattribute_size], yy->yymvalptr, + yy->yymattribute_size); + } + yympop(yy, 1); + num--; + } + } + else { + yympop(yy, num); + } +} diff --git a/Utils/Parser Generator/SOURCE/yymdisc.c b/Utils/Parser Generator/SOURCE/yymdisc.c new file mode 100644 index 000000000..62677b9fa --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yymdisc.c @@ -0,0 +1,26 @@ +/************************************************************ +yymdisc.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "myacc.h" + +#ifdef __BORLANDC__ +#pragma argsused +#endif + +#ifdef YYPROTOTYPE +void YYCDECL yymdiscard(yymparse_t YYFAR *yy, int token) +#else +void YYCDECL yymdiscard(yy, token) +yymparse_t YYFAR *yy; +int token; +#endif +{ + yyassert(yy != NULL); + yyassert(token > 0); + /* do nothing */ +} diff --git a/Utils/Parser Generator/SOURCE/yymdoutp.c b/Utils/Parser Generator/SOURCE/yymdoutp.c new file mode 100644 index 000000000..65815c322 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yymdoutp.c @@ -0,0 +1,75 @@ +/************************************************************ +yymdoutp.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include +#include "mlex.h" + +#ifdef YYDEBUG +#ifdef YYPROTOTYPE +void YYCDECL yymdebugoutput(yymlex_t YYFAR *yy, int ch) +#else +void YYCDECL yymdebugoutput(yy, ch) +yymlex_t YYFAR *yy; +int ch; +#endif +{ + char string[32]; + yyassert(yy != NULL); + + switch (ch) { + case EOF: + strcpy(string, "EOF"); + break; + case '\n': + strcpy(string, "\\n"); + break; + case '\t': + strcpy(string, "\\t"); + break; + case '\v': + strcpy(string, "\\v"); + break; + case '\b': + strcpy(string, "\\b"); + break; + case '\r': + strcpy(string, "\\r"); + break; + case '\f': + strcpy(string, "\\f"); + break; + case '\a': + strcpy(string, "\\a"); + break; + case '\\': + strcpy(string, "\\"); + break; + case '\?': + strcpy(string, "\\\?"); + break; + case '\'': + strcpy(string, "\\\'"); + break; + case '\"': + strcpy(string, "\\\""); + break; + default: + if (isascii(ch) && isgraph(ch)) { + string[0] = (char) ch; + string[1] = '\0'; + } + else { + sprintf(string, "\\%03o", (unsigned int) (unsigned char) ch); + } + break; + } + yymlexdebugoutput(yy, string); +} + +#endif diff --git a/Utils/Parser Generator/SOURCE/yymecho.c b/Utils/Parser Generator/SOURCE/yymecho.c new file mode 100644 index 000000000..c97a97c08 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yymecho.c @@ -0,0 +1,25 @@ +/************************************************************ +yymecho.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include "mlex.h" + +#ifdef YYPROTOTYPE +void YYCDECL yymecho(yymlex_t YYFAR *yy) +#else +void YYCDECL yymecho(yy) +yymlex_t YYFAR *yy; +#endif +{ + int i; + yyassert(yy != NULL); + + for (i = 0; i < yy->yymleng; i++) { + (*yy->yymoutput)(yy, yy->yymtext[i]); + } +} diff --git a/Utils/Parser Generator/SOURCE/yymerror.c b/Utils/Parser Generator/SOURCE/yymerror.c new file mode 100644 index 000000000..7d7d2a5e7 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yymerror.c @@ -0,0 +1,27 @@ +/************************************************************ +yymerror.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include "myacc.h" + +#ifdef YYPROTOTYPE +void YYCDECL yymerror(yymparse_t YYFAR *yy, YYCONST char YYFAR *text) +#else +void YYCDECL yymerror(yy, text) +yymparse_t YYFAR *yy; +YYCONST char YYFAR *text; +#endif +{ + yyassert(yy != NULL); + yyassert(text != NULL); + yyassert(yy->yymerr != NULL); + while (*text != '\0') { + putc(*text++, yy->yymerr); + } + putc('\n', yy->yymerr); +} diff --git a/Utils/Parser Generator/SOURCE/yymgetch.c b/Utils/Parser Generator/SOURCE/yymgetch.c new file mode 100644 index 000000000..d37e923ec --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yymgetch.c @@ -0,0 +1,23 @@ +/************************************************************ +yymgetch.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include +#include "mlex.h" + +#ifdef YYPROTOTYPE +int YYCDECL yymgetchar(yymlex_t YYFAR *yy) +#else +int YYCDECL yymgetchar(yy) +yymlex_t YYFAR *yy; +#endif +{ + yyassert(yy != NULL); + yyassert(yy->yymin != NULL); + return getc(yy->yymin); +} diff --git a/Utils/Parser Generator/SOURCE/yymgtok.c b/Utils/Parser Generator/SOURCE/yymgtok.c new file mode 100644 index 000000000..073daded0 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yymgtok.c @@ -0,0 +1,25 @@ +/************************************************************ +yymgtok.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "myacc.h" +#include "mlex.h" + +#ifdef YYPROTOTYPE +int YYCDECL yymgettoken(yymparse_t YYFAR *yy) +#else +int YYCDECL yymgettoken(yy) +yymparse_t YYFAR *yy; +#endif +{ + yymlex_t YYFAR *p; + yyassert(yy != NULL); + + p = (yymlex_t YYFAR *) yy->yymdata; + yyassert(p != NULL); + return yymlex(p); +} diff --git a/Utils/Parser Generator/SOURCE/yyminput.c b/Utils/Parser Generator/SOURCE/yyminput.c new file mode 100644 index 000000000..f1f91464f --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yyminput.c @@ -0,0 +1,46 @@ +/************************************************************ +yyminput.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include +#include "mlex.h" + +#ifdef YYPROTOTYPE +int YYCDECL yyminput(yymlex_t YYFAR *yy) +#else +int YYCDECL yyminput(yy) +yymlex_t YYFAR *yy; +#endif +{ + int ch; + yyassert(yy != NULL); + + if (yy->yymunputindex > 0) { + ch = yy->yymunputbufptr[--yy->yymunputindex]; + } + else { + ch = yy->yymgetchar(yy); + } + if (ch == '\n') { + yy->yymlineno++; + } + + /* debugging */ +#ifdef YYDEBUG + if (yydebug || yy->yymdebug) { + char string[128]; + + sprintf(string, "%p: input: \'", (void *) yy); + yymlexdebugoutput(yy, string); + yymdebugoutput(yy, ch); + yymlexdebugoutput(yy, "\'\n"); + } +#endif + + return ch; +} diff --git a/Utils/Parser Generator/SOURCE/yymlcln.c b/Utils/Parser Generator/SOURCE/yymlcln.c new file mode 100644 index 000000000..bb5901490 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yymlcln.c @@ -0,0 +1,41 @@ +/************************************************************ +yymlcln.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include +#include "mlex.h" + +#ifdef YYPROTOTYPE +void YYCDECL yymlexcleanup(yymlex_t YYFAR *yy) +#else +void YYCDECL yymlexcleanup(yy) +yymlex_t YYFAR *yy; +#endif +{ + yyassert(yy != NULL); + if (yy->yymtext != yy->yymstext) { + free(yy->yymtext); + yy->yymtext = yy->yymstext; + } + if (yy->yymstatebuf != yy->yymsstatebuf) { + free(yy->yymstatebuf); + yy->yymstatebuf = yy->yymsstatebuf; + } + if (yy->yymunputbufptr != yy->yymsunputbufptr) { + free(yy->yymunputbufptr); + yy->yymunputbufptr = yy->yymsunputbufptr; + } + yy->yymtext_size = yy->yymstext_size; + yy->yymunput_size = yy->yymsunput_size; + + if (yy->yymtext != NULL) { + *yy->yymtext = '\0'; + } + yy->yymleng = 0; + yy->yymunputindex = 0; +} diff --git a/Utils/Parser Generator/SOURCE/yymlcrea.c b/Utils/Parser Generator/SOURCE/yymlcrea.c new file mode 100644 index 000000000..d7f78ef71 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yymlcrea.c @@ -0,0 +1,90 @@ +/************************************************************ +yymlcrea.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "mlex.h" +#include + +#ifdef YYPROTOTYPE +int YYCDECL yymcreatelex(yymlex_t YYFAR *yy, YYCONST yymlex_t YYFAR *src) +#else +int YYCDECL yymcreatelex(yy, src) +yymlex_t YYFAR *yy; +YYCONST yymlex_t YYFAR *src; +#endif +{ + size_t textcharsize; + size_t statebufcharsize; + size_t unputbufcharsize; + yyassert(yy != NULL); + yyassert(src != NULL); + + *yy = *src; + + /* get sizes first */ + textcharsize = yy->yymstext_size + 1; /* include the '\0' */ + if (textcharsize <= (size_t) yy->yymstext_size) { + return 0; /* integer overflow */ + } + if (yy->yymstext_size != 0) { + statebufcharsize = yy->yymstext_size * sizeof(int); + if ((int) (statebufcharsize / sizeof(int)) != yy->yymstext_size) { + return 0; /* integer overflow */ + } + } + else { + statebufcharsize = 0; + } + if (yy->yymsunput_size != 0) { + unputbufcharsize = yy->yymsunput_size * sizeof(int); + if ((int) (unputbufcharsize / sizeof(int)) != yy->yymsunput_size) { + return 0; /* integer overflow */ + } + } + else { + unputbufcharsize = 0; + } + + /* allocate the memory if necessary */ + yy->yymstext = (char YYFAR *) malloc(textcharsize); + if (yy->yymstext == NULL) { + return 0; + } + if (statebufcharsize != 0) { + yy->yymsstatebuf = (int YYFAR *) malloc(statebufcharsize); + if (yy->yymsstatebuf == NULL) { + free(yy->yymstext); + return 0; + } + } + else { + yy->yymsstatebuf = NULL; + } + if (unputbufcharsize != 0) { + yy->yymsunputbufptr = (int YYFAR *) malloc(unputbufcharsize); + if (yy->yymsunputbufptr == NULL) { + free(yy->yymstext); + free(yy->yymsstatebuf); + return 0; + } + } + else { + yy->yymsunputbufptr = NULL; + } + + /* assign any other variables */ + yy->yymtext_size = yy->yymstext_size; + yy->yymtext = yy->yymstext; + yy->yymstatebuf = yy->yymsstatebuf; + yy->yymunput_size = yy->yymsunput_size; + yy->yymunputbufptr = yy->yymsunputbufptr; + + /* make sure we are ready to go */ + yymreset(yy); + + return 1; +} diff --git a/Utils/Parser Generator/SOURCE/yymldbug.c b/Utils/Parser Generator/SOURCE/yymldbug.c new file mode 100644 index 000000000..3fa57f261 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yymldbug.c @@ -0,0 +1,72 @@ +/************************************************************ +yymldbug.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#ifdef _WIN32 +#include +#include +#endif +#include "mlex.h" + +#ifdef YYDEBUG + +#ifdef YYPROTOTYPE +void YYCDECL yymdmatch(yymlex_t YYFAR *yy, int expr) +#else +void YYCDECL yymdmatch(yy, expr) +yymlex_t YYFAR *yy; +int expr; +#endif +{ + yyassert(yy != NULL); + if (yydebug || yy->yymdebug) { + char string[128]; + int i; + + sprintf(string, "%p: match: \"", (void *) yy); + yymlexdebugoutput(yy, string); + for (i = 0; i < yy->yymleng; i++) { + yymdebugoutput(yy, yy->yymtext[i]); + } + sprintf(string, "\", %d\n", (int) expr); + yymlexdebugoutput(yy, string); + } +} + +#ifdef YYPROTOTYPE +void YYCDECL yymlexdebugoutput(yymlex_t YYFAR *yy, YYCONST char *string) +#else +void YYCDECL yymlexdebugoutput(yy, string) +yymlex_t YYFAR *yy; +YYCONST char *string; +#endif +{ + yyassert(yy != NULL); + yyassert(string != NULL); + +#ifdef _WIN32 + if (yy->yymdebugout != NULL) { +#else + yyassert(yy->yymdebugout != NULL); +#endif + while (*string != '\0') { + putc(*string++, yy->yymdebugout); + } + + if (yydebugflush || yy->yymdebugflush) { + fflush(yy->yymdebugout); + } +#ifdef _WIN32 + } + else { + OutputDebugString(string); + } +#endif +} + +#endif diff --git a/Utils/Parser Generator/SOURCE/yymldest.c b/Utils/Parser Generator/SOURCE/yymldest.c new file mode 100644 index 000000000..5a7c759f0 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yymldest.c @@ -0,0 +1,25 @@ +/************************************************************ +yymldest.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "mlex.h" +#include + +#ifdef YYPROTOTYPE +void YYCDECL yymdestroylex(yymlex_t YYFAR *yy) +#else +void YYCDECL yymdestroylex(yy) +yymlex_t YYFAR *yy; +#endif +{ + yyassert( yy != NULL); + + yymlexcleanup(yy); + free(yy->yymstext); + free(yy->yymsstatebuf); + free(yy->yymsunputbufptr); +} diff --git a/Utils/Parser Generator/SOURCE/yymless.c b/Utils/Parser Generator/SOURCE/yymless.c new file mode 100644 index 000000000..5b0202ed5 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yymless.c @@ -0,0 +1,30 @@ +/************************************************************ +yymless.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "mlex.h" + +#ifdef YYPROTOTYPE +void YYCDECL yymless(yymlex_t YYFAR *yy, int length) +#else +void YYCDECL yymless(yy, length) +yymlex_t YYFAR *yy; +int length; +#endif +{ + yyassert(yy != NULL); + yyassert(length >= 0 && length <= yy->yymleng); + while (yy->yymleng > length) { + (*yy->yymunput)(yy, (unsigned char) yy->yymtext[--yy->yymleng]); + } + if (yy->yymleng > 0) { + yy->yymeol = (unsigned char) (yy->yymtext[yy->yymleng - 1] == '\n'); + } + else { + yy->yymeol = yy->yymoldeol; + } +} diff --git a/Utils/Parser Generator/SOURCE/yymlex.c b/Utils/Parser Generator/SOURCE/yymlex.c new file mode 100644 index 000000000..965639322 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yymlex.c @@ -0,0 +1,231 @@ +/************************************************************ +yymlex.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include +#include +#include +#include "mlex.h" + +#ifdef YYPROTOTYPE +int YYCDECL yymlex(yymlex_t YYFAR *yy) +#else +int YYCDECL yymlex(yy) +yymlex_t YYFAR *yy; +#endif +{ + yyassert(yy != NULL); + yyassert(yymisfastlexer(yy)); /* make sure it's a fast lexical analyser */ + + while (1) { + int oldleng; + int state = 1 + yy->yymstart; + if (yy->yymeol) { + state++; + } + + /* yymore */ + if (yy->yymmoreflg) { + yy->yymmoreflg = 0; /* clear flag */ + } + else { + yy->yymleng = 0; + yy->yymoldeol = yy->yymeol; + } + oldleng = yy->yymleng; + + /* look for a string */ + do { + int ch; /* lookahead character */ + + /* get input character */ + ch = (*yy->yyminput)(yy); + yyassert(ch >= 0 && ch <= UCHAR_MAX || ch == EOF); + if (ch == EOF) { + break; + } + + /* check for possible overflow */ + if (yy->yymleng == yy->yymtext_size) { + do { + if (yy->yymtextgrow) { + if (yy->yymtext_size != 0) { + int size = yy->yymtext_size * 2; + if (size / 2 == yy->yymtext_size) { /* overflow check */ + if (yymsettextsize(yy, size)) { + break; + } + } + } + else { + if (yymsettextsize(yy, 100)) { + break; + } + } + } + (*yy->yymtextoverflow)(yy); + exit(EXIT_FAILURE); + } + while (0); + } + + /* handles eof condition automatically */ + while (state != 0) { + int index = yy->yymstate[state].base + ch; + if (index >= 0 && index < yy->yymtransitionmax) { + if (yy->yymtransition[index].check == state) { + state = yy->yymtransition[index].next; + break; /* found a transition */ + } + } + state = yy->yymstate[state].def; + if (state < 0) { + if (ch >= 0 && ch <= 0xff) { + state = -state; + } + else { + state = 0; + } + break; + } + } + + { + int leng = yy->yymleng; /* slightly more efficient */ + yy->yymtext[leng] = (char) ch; + yy->yymstatebuf[leng] = state; + leng++; + yy->yymleng = leng; + } + } + while (state != 0 && (yy->yymstate[state].def != 0 || yy->yymstate[state].base != 0)); + + /* now find a match */ + if (yy->yymleng > oldleng) { + int rejectmatch = 0; + while (1) { + int match = yy->yymstate[yy->yymstatebuf[yy->yymleng - 1]].match; + if (rejectmatch != 0) { + if (match < 0) { + int index = -match; + do { + match = yy->yymmatch[index++]; + } + while (match > 0 && match <= rejectmatch); + } + else { + if (match == rejectmatch) { + match = 0; + } + } + rejectmatch = 0; + } + else { + if (match < 0) { + match = yy->yymmatch[-match]; + } + } + if (match > 0) { + int rejectleng; + int token; + /* check for backup */ + if (yy->yymbackup[match]) { + while (yy->yymleng > oldleng) { + int index = yy->yymstate[yy->yymstatebuf[yy->yymleng - 1]].match; + if (index < 0) { + if (yymback(&yy->yymmatch[-index], -match)) { + break; /* found an expression */ + } + } + yy->yymleng--; + (*yy->yymunput)(yy, (unsigned char) yy->yymtext[yy->yymleng]); + } + } + yy->yymtext[yy->yymleng] = '\0'; +#ifdef YYDEBUG + yymdmatch(yy, match); +#endif + yy->yymrejectflg = 0; + rejectleng = yy->yymleng; + + if (yy->yymleng > 0) { + yy->yymeol = (unsigned char) (yy->yymtext[yy->yymleng - 1] == '\n'); + } + else { + yy->yymeol = yy->yymoldeol; + } + + /* perform user action */ + token = (*yy->yymlexaction)(yy, match); + + if (yy->yymreturnflg) { + return token; + } + if (!yy->yymrejectflg) { + break; + } + if (rejectleng == yy->yymleng) { + rejectmatch = match; + } + } + else if (yy->yymleng > oldleng + 1) { + yy->yymleng--; + (*yy->yymunput)(yy, (unsigned char) yy->yymtext[yy->yymleng]); + } + else { + yy->yymeol = (unsigned char) (yy->yymtext[0] == '\n'); + (*yy->yymoutput)(yy, yy->yymtext[0]); /* non-matched character */ + break; + } + } + } + else { + int index; + int match; + yyassert(yy->yymleng == oldleng); + + /* handles <> rules */ + index = 0; + match = yy->yymstate[state].match; + if (match < 0) { + index = -match; + match = yy->yymmatch[index++]; + } + while (match > 0) { + int token; + yy->yymtext[yy->yymleng] = '\0'; +#ifdef YYDEBUG + yymdmatch(yy, match); +#endif + yy->yymrejectflg = 0; /* clear flag */ + + /* perform user action */ + token = (*yy->yymlexaction)(yy, match); + + if (yy->yymreturnflg) { + return token; + } + if (!yy->yymrejectflg) { + break; + } + + if (index == 0) { + break; + } + match = yy->yymmatch[index++]; + } + + if ((*yy->yymwrap)(yy)) { + yy->yymoldeol = 1; + yy->yymeol = 1; + yy->yymstart = 0; + return 0; /* eof reached */ + } + } + } +} diff --git a/Utils/Parser Generator/SOURCE/yymlinit.c b/Utils/Parser Generator/SOURCE/yymlinit.c new file mode 100644 index 000000000..f4632ada4 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yymlinit.c @@ -0,0 +1,26 @@ +/************************************************************ +yymlinit.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "mlex.h" + +#ifdef YYPROTOTYPE +void YYCDECL yymlexinit(yymlex_t YYFAR *yy) +#else +void YYCDECL yymlexinit(yy) +yymlex_t YYFAR *yy; +#endif +{ + yyassert(yy != NULL); + + yy->yymin = stdin; + yy->yymout = stdout; + yy->yymerr = stderr; +#ifdef YYDEBUG + yy->yymdebugout = stdout; +#endif +} diff --git a/Utils/Parser Generator/SOURCE/yymoutpt.c b/Utils/Parser Generator/SOURCE/yymoutpt.c new file mode 100644 index 000000000..b3dccb750 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yymoutpt.c @@ -0,0 +1,42 @@ +/************************************************************ +yymoutpt.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include +#include "mlex.h" + +#ifdef YYPROTOTYPE +void YYCDECL yymoutput(yymlex_t YYFAR *yy, int ch) +#else +void YYCDECL yymoutput(yy, ch) +yymlex_t YYFAR *yy; +int ch; +#endif +{ + yyassert(yy != NULL); + + /* debugging */ +#ifdef YYDEBUG + if (yydebug || yy->yymdebug) { + char string[128]; + + sprintf(string, "%p: output: \'", (void *) yy); + yymlexdebugoutput(yy, string); + yymdebugoutput(yy, ch); + yymlexdebugoutput(yy, "\'\n"); + } +#endif + + yyassert(yy->yymout != NULL); + +#ifdef __BORLANDC__ + putc((char) ch, yy->yymout); +#else + putc(ch, yy->yymout); +#endif +} diff --git a/Utils/Parser Generator/SOURCE/yymparse.c b/Utils/Parser Generator/SOURCE/yymparse.c new file mode 100644 index 000000000..5824f54e0 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yymparse.c @@ -0,0 +1,28 @@ +/************************************************************ +yymparse.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include "myacc.h" + +#ifdef YYPROTOTYPE +int YYCDECL yymparse(yymparse_t YYFAR *yy) +#else +int YYCDECL yymparse(yy) +yymparse_t YYFAR *yy; +#endif +{ + int n; + yyassert(yy != NULL); + yyassert(yymisfastparser(yy)); /* make sure it's a fast parser */ + + n = yymsetup(yy); + if (n != 0) { + return n; + } + return yymwork(yy); +} diff --git a/Utils/Parser Generator/SOURCE/yympcln.c b/Utils/Parser Generator/SOURCE/yympcln.c new file mode 100644 index 000000000..0df937386 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yympcln.c @@ -0,0 +1,30 @@ +/************************************************************ +yympcln.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include "myacc.h" + +#ifdef YYPROTOTYPE +void YYCDECL yymparsecleanup(yymparse_t YYFAR *yy) +#else +void YYCDECL yymparsecleanup(yy) +yymparse_t YYFAR *yy; +#endif +{ + if (yy->yymstackptr != yy->yymsstackptr) { + free(yy->yymstackptr); + yy->yymstackptr = yy->yymsstackptr; + } + if (yy->yymattributestackptr != yy->yymsattributestackptr) { + free(yy->yymattributestackptr); + yy->yymattributestackptr = yy->yymsattributestackptr; + } + yy->yymstack_size = yy->yymsstack_size; + + yy->yymtop = -1; +} diff --git a/Utils/Parser Generator/SOURCE/yympcrea.c b/Utils/Parser Generator/SOURCE/yympcrea.c new file mode 100644 index 000000000..d90750c6e --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yympcrea.c @@ -0,0 +1,75 @@ +/************************************************************ +yympcrea.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "myacc.h" +#include + +#ifdef YYPROTOTYPE +int YYCDECL yymcreateparse(yymparse_t YYFAR *yy, YYCONST yymparse_t YYFAR *src) +#else +int YYCDECL yymcreateparse(yy, src) +yymparse_t YYFAR *yy; +YYCONST yymparse_t YYFAR *src; +#endif +{ + yyassert(yy != NULL); + yyassert(src != NULL); + + *yy = *src; + + /* stack */ + if (yy->yymsstack_size != 0) { + size_t stackcharsize; + size_t attributestackcharsize; + + stackcharsize = yy->yymsstack_size * sizeof(yystack_t); + if ((int) (stackcharsize / sizeof(yystack_t)) != yy->yymsstack_size) { + return 0; /* integer overflow */ + } + attributestackcharsize = yy->yymsstack_size * yy->yymattribute_size; + if ((int) (attributestackcharsize / yy->yymattribute_size) != yy->yymsstack_size) { + return 0; /* integer overflow */ + } + + yy->yymsstackptr = (yystack_t YYFAR *) malloc(stackcharsize); + if (yy->yymsstackptr == NULL) { + return 0; + } + yy->yymsattributestackptr = malloc(attributestackcharsize); + if (yy->yymsattributestackptr == NULL) { + free(yy->yymsstackptr); + return 0; + } + } + else { + yy->yymsstackptr = NULL; + yy->yymsattributestackptr = NULL; + } + yy->yymstack_size = yy->yymsstack_size; + yy->yymstackptr = yy->yymsstackptr; + yy->yymattributestackptr = yy->yymsattributestackptr; + + /* yylval */ + yy->yymlvalptr = malloc(yy->yymattribute_size); + if (yy->yymlvalptr == NULL) { + free(yy->yymsstackptr); + free(yy->yymsattributestackptr); + return 0; + } + + /* yyval ($$) */ + yy->yymvalptr = malloc(yy->yymattribute_size); + if (yy->yymvalptr == NULL) { + free(yy->yymsstackptr); + free(yy->yymsattributestackptr); + free(yy->yymlvalptr); + return 0; + } + + return 1; +} diff --git a/Utils/Parser Generator/SOURCE/yympdbug.c b/Utils/Parser Generator/SOURCE/yympdbug.c new file mode 100644 index 000000000..46fcdf842 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yympdbug.c @@ -0,0 +1,277 @@ +/************************************************************ +yympdbug.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#ifdef _WIN32 +#include +#include +#endif +#include "myacc.h" + +#ifdef YYDEBUG + +#ifdef YYPROTOTYPE +YYCONST char *YYCDECL yymtokenstring(yymparse_t YYFAR *yy, int token) +#else +YYCONST char *YYCDECL yymtokenstring(yy, token) +yymparse_t YYFAR *yy; +int token; +#endif +{ + YYCONST yysymbol_t YYNEARFAR *symbol; + yyassert(yy != NULL); + yyassert(token >= 0); + + symbol = yy->yymsymbol; + while (symbol->name != NULL) { + if (symbol->token == token) { + return symbol->name; + } + symbol++; + } + return "illegal-token"; +} + +#ifdef YYPROTOTYPE +void YYCDECL yymdgettoken(yymparse_t YYFAR *yy, int token) +#else +void YYCDECL yymdgettoken(yy, token) +yymparse_t YYFAR *yy; +int token; +#endif +{ + yyassert(yy != NULL); + yyassert(token >= 0); + if (yydebug || yy->yymdebug) { + char string[128]; + YYCONST char *tokenstring = yymtokenstring(yy, token); + yyassert(tokenstring != NULL); + + sprintf(string, "%p: get token ", (void *) yy); + yymparsedebugoutput(yy, string); + yymparsedebugoutput(yy, tokenstring); + sprintf(string, " (%d)\n", (int) token); + yymparsedebugoutput(yy, string); + } +} + +#ifdef YYPROTOTYPE +void YYCDECL yymdshift(yymparse_t YYFAR *yy, int token) +#else +void YYCDECL yymdshift(yy, token) +yymparse_t YYFAR *yy; +int token; +#endif +{ + yyassert(yy != NULL); + yyassert(token >= 0); + if (yydebug || yy->yymdebug) { + char string[128]; + YYCONST char *tokenstring = yymtokenstring(yy, token); + yyassert(tokenstring != NULL); + + sprintf(string, "%p: shift token ", (void *) yy); + yymparsedebugoutput(yy, string); + yymparsedebugoutput(yy, tokenstring); + sprintf(string, " (%d)\n", (int) token); + yymparsedebugoutput(yy, string); + } +} + +#ifdef YYPROTOTYPE +void YYCDECL yymdreduce(yymparse_t YYFAR *yy, int rule) +#else +void YYCDECL yymdreduce(yy, rule) +yymparse_t YYFAR *yy; +int rule; +#endif +{ + yyassert(yy != NULL); + yyassert(rule >= 0); + if (yydebug || yy->yymdebug) { + char string[128]; + + sprintf(string, "%p: reduce rule ", (void *) yy); + yymparsedebugoutput(yy, string); + yymparsedebugoutput(yy, yy->yymrule[rule]); + sprintf(string, " (%d)\n", (int) rule); + yymparsedebugoutput(yy, string); + } +} + +#ifdef YYPROTOTYPE +void YYCDECL yymdsyntaxerror(yymparse_t YYFAR *yy) +#else +void YYCDECL yymdsyntaxerror(yy) +yymparse_t YYFAR *yy; +#endif +{ + yyassert(yy != NULL); + if (yydebug || yy->yymdebug) { + char string[128]; + + sprintf(string, "%p: syntax error\n", (void *) yy); + yymparsedebugoutput(yy, string); + } +} + +#ifdef YYPROTOTYPE +void YYCDECL yymdaccept(yymparse_t YYFAR *yy) +#else +void YYCDECL yymdaccept(yy) +yymparse_t YYFAR *yy; +#endif +{ + yyassert(yy != NULL); + if (yydebug || yy->yymdebug) { + char string[128]; + + sprintf(string, "%p: accept\n", (void *) yy); + yymparsedebugoutput(yy, string); + } +} + +#ifdef YYPROTOTYPE +void YYCDECL yymdabort(yymparse_t YYFAR *yy) +#else +void YYCDECL yymdabort(yy) +yymparse_t YYFAR *yy; +#endif +{ + yyassert(yy != NULL); + if (yydebug || yy->yymdebug) { + char string[128]; + + sprintf(string, "%p: abort\n", (void *) yy); + yymparsedebugoutput(yy, string); + } +} + +#ifdef YYPROTOTYPE +void YYCDECL yymddiscard(yymparse_t YYFAR *yy, int token) +#else +void YYCDECL yymddiscard(yy, token) +yymparse_t YYFAR *yy; +int token; +#endif +{ + yyassert(yy != NULL); + yyassert(token >= 0); + if (yydebug || yy->yymdebug) { + char string[128]; + YYCONST char *tokenstring = yymtokenstring(yy, token); + yyassert(tokenstring != NULL); + + sprintf(string, "%p: discard token ", (void *) yy); + yymparsedebugoutput(yy, string); + yymparsedebugoutput(yy, tokenstring); + sprintf(string, " (%d)\n", (int) token); + yymparsedebugoutput(yy, string); + } +} + +#ifdef YYPROTOTYPE +void YYCDECL yymdexit(yymparse_t YYFAR *yy, int exitcode) +#else +void YYCDECL yymdexit(yy, exitcode) +yymparse_t YYFAR *yy; +int exitcode; +#endif +{ + yyassert(yy != NULL); + if (yydebug || yy->yymdebug) { + char string[128]; + + sprintf(string, "%p: exit with code %d\n", (void *) yy, (int) exitcode); + yymparsedebugoutput(yy, string); + } +} + +#ifdef YYPROTOTYPE +void YYCDECL yymdthrowerror(yymparse_t YYFAR *yy, int errorpop) +#else +void YYCDECL yymdthrowerror(yy, errorpop) +yymparse_t YYFAR *yy; +int errorpop; +#endif +{ + yyassert(yy != NULL); + if (yydebug || yy->yymdebug) { + char string[128]; + + sprintf(string, "%p: throw error and pop %d error handling state(s)\n", + (void *) yy, (int) errorpop); + yymparsedebugoutput(yy, string); + } +} + +#ifdef YYPROTOTYPE +void YYCDECL yymdretire(yymparse_t YYFAR *yy, int retirecode) +#else +void YYCDECL yymdretire(yy, retirecode) +yymparse_t YYFAR *yy; +int retirecode; +#endif +{ + yyassert(yy != NULL); + if (yydebug || yy->yymdebug) { + char string[128]; + + sprintf(string, "%p: retire with code %d\n", (void *) yy, (int) retirecode); + yymparsedebugoutput(yy, string); + } +} + +#ifdef YYPROTOTYPE +void YYCDECL yymdattemptrecovery(yymparse_t YYFAR *yy) +#else +void YYCDECL yymdattemptrecovery(yy) +yymparse_t YYFAR *yy; +#endif +{ + yyassert(yy != NULL); + if (yydebug || yy->yymdebug) { + char string[128]; + + sprintf(string, "%p: attempting error recovery\n", (void *) yy); + yymparsedebugoutput(yy, string); + } +} + +#ifdef YYPROTOTYPE +void YYCDECL yymparsedebugoutput(yymparse_t YYFAR *yy, YYCONST char *string) +#else +void YYCDECL yymparsedebugoutput(yy, string) +yymparse_t YYFAR *yy; +YYCONST char *string; +#endif +{ + yyassert(yy != NULL); + yyassert(string != NULL); + +#ifdef _WIN32 + if (yy->yymdebugout != NULL) { +#else + yyassert(yy->yymdebugout != NULL); +#endif + while (*string != '\0') { + putc(*string++, yy->yymdebugout); + } + + if (yydebugflush || yy->yymdebugflush) { + fflush(yy->yymdebugout); + } +#ifdef _WIN32 + } + else { + OutputDebugString(string); + } +#endif +} + +#endif diff --git a/Utils/Parser Generator/SOURCE/yympdest.c b/Utils/Parser Generator/SOURCE/yympdest.c new file mode 100644 index 000000000..2021f2b10 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yympdest.c @@ -0,0 +1,27 @@ +/************************************************************ +yympdest.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "myacc.h" +#include + +#ifdef YYPROTOTYPE +void YYCDECL yymdestroyparse(yymparse_t YYFAR *yy) +#else +void YYCDECL yymdestroyparse(yy) +yymparse_t YYFAR *yy; +#endif +{ + yyassert(yy != NULL); + + yymparsecleanup(yy); + free(yy->yymsstackptr); + free(yy->yymsattributestackptr); + + free(yy->yymlvalptr); + free(yy->yymvalptr); +} diff --git a/Utils/Parser Generator/SOURCE/yympinit.c b/Utils/Parser Generator/SOURCE/yympinit.c new file mode 100644 index 000000000..0b0e08d7b --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yympinit.c @@ -0,0 +1,24 @@ +/************************************************************ +yympinit.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "myacc.h" + +#ifdef YYPROTOTYPE +void YYCDECL yymparseinit(yymparse_t YYFAR *yy) +#else +void YYCDECL yymparseinit(yy) +yymparse_t YYFAR *yy; +#endif +{ + yyassert(yy != NULL); + + yy->yymerr = stderr; +#ifdef YYDEBUG + yy->yymdebugout = stdout; +#endif +} diff --git a/Utils/Parser Generator/SOURCE/yympop.c b/Utils/Parser Generator/SOURCE/yympop.c new file mode 100644 index 000000000..72aefa62e --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yympop.c @@ -0,0 +1,41 @@ +/************************************************************ +yympop.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "myacc.h" + +#ifdef YYDEBUG +#ifdef YYPROTOTYPE +void YYCDECL yympop(yymparse_t YYFAR *yy, int num) +#else +void YYCDECL yympop(yy, num) +yymparse_t YYFAR *yy; +int num; +#endif +{ + yyassert(yy != NULL); + yyassert(num >= 0); + yy->yymtop -= num; + yyassert(yy->yymtop >= -1); + + /* debugging */ + if (yydebug || yy->yymdebug) { + if (num > 0) { + char string[128]; + + sprintf(string, "%p: pop %d state(s)", (void *) yy, (int) num); + yymparsedebugoutput(yy, string); + if (yy->yymtop >= 0) { + sprintf(string, " uncovering state %d", + (int) yy->yymstackptr[yy->yymtop]); + yymparsedebugoutput(yy, string); + } + yymparsedebugoutput(yy, "\n"); + } + } +} +#endif diff --git a/Utils/Parser Generator/SOURCE/yympush.c b/Utils/Parser Generator/SOURCE/yympush.c new file mode 100644 index 000000000..d2a6c3dd9 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yympush.c @@ -0,0 +1,111 @@ +/************************************************************ +yympush.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include +#include "myacc.h" + +#ifdef YYPROTOTYPE +int YYCDECL yympush(yymparse_t YYFAR *yy, yystack_t state) +#else +int YYCDECL yympush(yy, state) +yymparse_t YYFAR *yy; +yystack_t state; +#endif +{ + yyassert(yy != NULL); + + yy->yymtop++; /* increment first */ + if (yy->yymtop == yy->yymstack_size) { + do { + if (yy->yymstackgrow) { + if (yy->yymstack_size != 0) { + int size = yy->yymstack_size * 2; + if (size / 2 == yy->yymstack_size) { /* overflow check */ + if (yymsetstacksize(yy, size)) { + break; + } + } + } + else { + if (yymsetstacksize(yy, 100)) { + break; + } + } + } + yy->yymtop--; + + /* debugging */ +#ifdef YYDEBUG + if (yydebug || yy->yymdebug) { + char string[128]; + + sprintf(string, "%p: stack overflow\n", (void *) yy); + yymparsedebugoutput(yy, string); + } +#endif + + (*yy->yymstackoverflow)(yy); + return 0; + } + while (0); + } + yy->yymstackptr[yy->yymtop] = state; + + /* debugging */ +#ifdef YYDEBUG + if (yydebug || yy->yymdebug) { + char string[128]; + + sprintf(string, "%p: push state %d", (void *) yy, (int) state); + yymparsedebugoutput(yy, string); + if (yy->yymtop > 0) { + sprintf(string, " covering state %d", + (int) yy->yymstackptr[yy->yymtop - 1]); + yymparsedebugoutput(yy, string); + } + yymparsedebugoutput(yy, "\n"); + + /* output stack contents */ + if (yydebugstack || yy->yymdebugstack) { + int rows; + int i; + int n; + + yymparsedebugoutput(yy, "\nstack"); + n = sprintf(string, "\n +"); + for (i = 0; i < 10; i++) { + n += sprintf(&string[n], " %5d", (int) i); + } + yymparsedebugoutput(yy, string); + + rows = 1; + if (yy->yymtop >= 0) { + rows += yy->yymtop / 10; + } + for (i = 0; i < rows; i++) { + int j; + n = sprintf(string, "\n %5d", (int) (10 * i)); + for (j = 0; j < 10; j++) { + int index = 10 * i + j; + if (index <= yy->yymtop) { + n += sprintf(&string[n], " %5d", (int) yy->yymstackptr[index]); + } + else { + n += sprintf(&string[n], " -"); + } + } + yymparsedebugoutput(yy, string); + } + yymparsedebugoutput(yy, "\n\n"); + } + } +#endif + + return 1; +} diff --git a/Utils/Parser Generator/SOURCE/yymreset.c b/Utils/Parser Generator/SOURCE/yymreset.c new file mode 100644 index 000000000..35c78f4ab --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yymreset.c @@ -0,0 +1,27 @@ +/************************************************************ +yymreset.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "mlex.h" + +#ifdef YYPROTOTYPE +void YYCDECL yymreset(yymlex_t YYFAR *yy) +#else +void YYCDECL yymreset(yy) +yymlex_t YYFAR *yy; +#endif +{ + yyassert(yy != NULL); + yy->yymleng = 0; + yy->yymlineno = 1; + yy->yymunputindex = 0; + yy->yymmoreflg = 0; + yy->yymrejectflg = 0; + yy->yymeol = 1; + yy->yymoldeol = 1; + yy->yymstart = 0; +} diff --git a/Utils/Parser Generator/SOURCE/yymsetin.c b/Utils/Parser Generator/SOURCE/yymsetin.c new file mode 100644 index 000000000..598babcf3 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yymsetin.c @@ -0,0 +1,25 @@ +/************************************************************ +yymsetin.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "myacc.h" + +#ifdef YYPROTOTYPE +void YYCDECL yymsetin(yymparse_t YYFAR *yy, int token) +#else +void YYCDECL yymsetin(yy, token) +yymparse_t YYFAR *yy; +int token; +#endif +{ + yyassert(yy != NULL); + if (token < 0) { + token = 0; + } + yy->yymchar = token; + yy->yymlookahead = 1; +} diff --git a/Utils/Parser Generator/SOURCE/yymsetup.c b/Utils/Parser Generator/SOURCE/yymsetup.c new file mode 100644 index 000000000..edf963cff --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yymsetup.c @@ -0,0 +1,36 @@ +/************************************************************ +yymsetup.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "myacc.h" + +#ifdef YYPROTOTYPE +int YYCDECL yymsetup(yymparse_t YYFAR *yy) +#else +int YYCDECL yymsetup(yy) +yymparse_t YYFAR *yy; +#endif +{ + yyassert(yy != NULL); + + /* initialise variables */ + yy->yymtop = -1; + yy->yymlookahead = 0; + yy->yymskip = 0; + yy->yymerrorcount = 0; + yy->yymchar = -1; + yy->yympopflg = 0; + + /* push initial state onto the stack */ + if (!yympush(yy, 0)) { +#ifdef YYDEBUG + yymdabort(yy); +#endif + return 1; + } + return 0; +} diff --git a/Utils/Parser Generator/SOURCE/yymsoflw.c b/Utils/Parser Generator/SOURCE/yymsoflw.c new file mode 100644 index 000000000..e19a19126 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yymsoflw.c @@ -0,0 +1,21 @@ +/************************************************************ +yymsoflw.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include "myacc.h" + +#ifdef YYPROTOTYPE +void YYCDECL yymstackoverflow(yymparse_t YYFAR *yy) +#else +void YYCDECL yymstackoverflow(yy) +yymparse_t YYFAR *yy; +#endif +{ + yyassert(yy != NULL); + (*yy->yymerror)(yy, "yacc stack overflow"); +} diff --git a/Utils/Parser Generator/SOURCE/yymsskip.c b/Utils/Parser Generator/SOURCE/yymsskip.c new file mode 100644 index 000000000..13e5b3a32 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yymsskip.c @@ -0,0 +1,46 @@ +/************************************************************ +yymsskip.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include "myacc.h" + +#ifdef YYDEBUG +#ifdef YYPROTOTYPE +void YYCDECL yymsetskip(yymparse_t YYFAR *yy, int skip) +#else +void YYCDECL yymsetskip(yy, skip) +yymparse_t YYFAR *yy; +int skip; +#endif +{ + yyassert(yy != NULL); + yyassert(skip >= 0); + + /* debugging */ + if (yydebug || yy->yymdebug) { + if (skip > 0) { + if (yy->yymskip == 0) { + char string[128]; + + sprintf(string, "%p: entering error recovery\n", (void *) yy); + yymparsedebugoutput(yy, string); + } + } + else { + if (yy->yymskip > 0) { + char string[128]; + + sprintf(string, "%p: leaving error recovery\n", (void *) yy); + yymparsedebugoutput(yy, string); + } + } + } + + yy->yymskip = skip; +} +#endif diff --git a/Utils/Parser Generator/SOURCE/yymsssiz.c b/Utils/Parser Generator/SOURCE/yymsssiz.c new file mode 100644 index 000000000..9d55f2726 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yymsssiz.c @@ -0,0 +1,88 @@ +/************************************************************ +yymsssiz.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include +#include "myacc.h" + +#ifdef YYPROTOTYPE +int YYCDECL yymsetstacksize(yymparse_t YYFAR *yy, int size) +#else +int YYCDECL yymsetstacksize(yy, size) +yymparse_t YYFAR *yy; +int size; +#endif +{ + yyassert(yy != NULL); + yyassert(size >= 0); + if (yy->yymstack_size != size) { + yystack_t YYFAR *stackptr; +#if defined(__STDC__) || defined(__cplusplus) + void YYFAR *attributestackptr; +#else + char YYFAR *attributestackptr; +#endif + size_t stackcharsize; + size_t attributestackcharsize; + + if (size <= yy->yymtop) { + return 0; + } + + stackcharsize = size * sizeof(yystack_t); + if ((int) (stackcharsize / sizeof(yystack_t)) != size) { + return 0; /* integer overflow */ + } + attributestackcharsize = size * yy->yymattribute_size; + if ((int) (attributestackcharsize / yy->yymattribute_size) != size) { + return 0; /* integer overflow */ + } + + /* allocate */ + if (size <= yy->yymsstack_size) { + stackptr = yy->yymsstackptr; + attributestackptr = yy->yymsattributestackptr; + } + else { + stackptr = (yystack_t YYFAR *) malloc(stackcharsize); + if (stackptr == NULL) { + return 0; + } + attributestackptr = malloc(attributestackcharsize); + if (attributestackptr == NULL) { + free(stackptr); /* clean up */ + return 0; + } + } + + /* copy */ + if (stackptr != yy->yymstackptr) { + size_t charsize = yy->yymstack_size * sizeof(yystack_t); + memcpy(stackptr, yy->yymstackptr, min(stackcharsize, charsize)); + } + if (attributestackptr != yy->yymattributestackptr) { + size_t charsize = yy->yymstack_size * yy->yymattribute_size; + memcpy(attributestackptr, yy->yymattributestackptr, min(attributestackcharsize, + charsize)); + } + + /* free */ + if (yy->yymstackptr != yy->yymsstackptr) { + free(yy->yymstackptr); + } + if (yy->yymattributestackptr != yy->yymsattributestackptr) { + free(yy->yymattributestackptr); + } + + /* assign */ + yy->yymstackptr = stackptr; + yy->yymattributestackptr = attributestackptr; + yy->yymstack_size = size; + } + return 1; +} diff --git a/Utils/Parser Generator/SOURCE/yymstsiz.c b/Utils/Parser Generator/SOURCE/yymstsiz.c new file mode 100644 index 000000000..85a3a84d2 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yymstsiz.c @@ -0,0 +1,84 @@ +/************************************************************ +yymstsiz.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include +#include "mlex.h" + +#ifdef YYPROTOTYPE +int YYCDECL yymsettextsize(yymlex_t YYFAR *yy, int size) +#else +int YYCDECL yymsettextsize(yy, size) +yymlex_t YYFAR *yy; +int size; +#endif +{ + yyassert(yy != NULL); + yyassert(size >= 0); + if (yy->yymtext_size != size) { + char YYFAR *text; + int YYFAR *statebuf; + + size_t textcharsize; + size_t statebufcharsize; + + if (size < yy->yymleng) { + return 0; + } + + textcharsize = size + 1; /* include the '\0' */ + if (textcharsize <= (size_t) size) { + return 0; /* integer overflow */ + } + statebufcharsize = size * sizeof(int); + if ((int) (statebufcharsize / sizeof(int)) != size) { + return 0; /* integer overflow */ + } + + /* allocate */ + if (size <= yy->yymstext_size) { + text = yy->yymstext; + statebuf = yy->yymsstatebuf; + } + else { + text = (char YYFAR *) malloc(textcharsize); + if (text == NULL) { + return 0; + } + statebuf = (int YYFAR *) malloc(statebufcharsize); + if (statebuf == NULL) { + free(text); /* clean up */ + return 0; + } + } + + /* copy */ + if (text != yy->yymtext) { + size_t charsize = yy->yymtext_size + 1; + memcpy(text, yy->yymtext, min(textcharsize, charsize)); + } + if (statebuf != yy->yymstatebuf) { + size_t charsize = yy->yymtext_size * sizeof(int); + memcpy(statebuf, yy->yymstatebuf, min(statebufcharsize, charsize)); + } + + /* free */ + if (yy->yymtext != yy->yymstext) { + free(yy->yymtext); + } + if (yy->yymstatebuf != yy->yymsstatebuf) { + free(yy->yymstatebuf); + } + + /* assign */ + yy->yymtext = text; + yy->yymstatebuf = statebuf; + yy->yymtext_size = size; + } + return 1; +} diff --git a/Utils/Parser Generator/SOURCE/yymsusiz.c b/Utils/Parser Generator/SOURCE/yymsusiz.c new file mode 100644 index 000000000..98e885dee --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yymsusiz.c @@ -0,0 +1,64 @@ +/************************************************************ +yymsusiz.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include +#include "mlex.h" + +#ifdef YYPROTOTYPE +int YYCDECL yymsetunputsize(yymlex_t YYFAR *yy, int size) +#else +int YYCDECL yymsetunputsize(yy, size) +yymlex_t YYFAR *yy; +int size; +#endif +{ + yyassert(yy != NULL); + yyassert(size >= 0); + if (yy->yymunput_size != size) { + int YYFAR *unputbufptr; + + size_t unputbufcharsize; + + if (size < yy->yymunputindex) { + return 0; + } + + unputbufcharsize = size * sizeof(int); + if ((int) (unputbufcharsize / sizeof(int)) != size) { + return 0; /* integer overflow */ + } + + /* allocate */ + if (size <= yy->yymsunput_size) { + unputbufptr = yy->yymsunputbufptr; + } + else { + unputbufptr = (int YYFAR *) malloc(unputbufcharsize); + if (unputbufptr == NULL) { + return 0; + } + } + + /* copy */ + if (unputbufptr != yy->yymunputbufptr) { + size_t charsize = yy->yymunput_size * sizeof(int); + memcpy(unputbufptr, yy->yymunputbufptr, min(unputbufcharsize, charsize)); + } + + /* free */ + if (yy->yymunputbufptr != yy->yymsunputbufptr) { + free(yy->yymunputbufptr); + } + + /* assign */ + yy->yymunputbufptr = unputbufptr; + yy->yymunput_size = size; + } + return 1; +} diff --git a/Utils/Parser Generator/SOURCE/yymsyner.c b/Utils/Parser Generator/SOURCE/yymsyner.c new file mode 100644 index 000000000..bfb4a9b4b --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yymsyner.c @@ -0,0 +1,21 @@ +/************************************************************ +yymsyner.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include "myacc.h" + +#ifdef YYPROTOTYPE +void YYCDECL yymsyntaxerror(yymparse_t YYFAR *yy) +#else +void YYCDECL yymsyntaxerror(yy) +yymparse_t YYFAR *yy; +#endif +{ + yyassert(yy != NULL); + (*yy->yymerror)(yy, "syntax error"); +} diff --git a/Utils/Parser Generator/SOURCE/yymtoflw.c b/Utils/Parser Generator/SOURCE/yymtoflw.c new file mode 100644 index 000000000..4598cc440 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yymtoflw.c @@ -0,0 +1,21 @@ +/************************************************************ +yymtoflw.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "mlex.h" + +#ifdef YYPROTOTYPE +void YYCDECL yymtextoverflow(yymlex_t YYFAR *yy) +#else +void YYCDECL yymtextoverflow(yy) +yymlex_t YYFAR *yy; +#endif +{ + yyassert(yy != NULL); + yyassert(yy->yymerr != NULL); + fprintf(yy->yymerr, "lex text buffer overflow (%d)\n", (int) yy->yymtext_size); +} diff --git a/Utils/Parser Generator/SOURCE/yymuncin.c b/Utils/Parser Generator/SOURCE/yymuncin.c new file mode 100644 index 000000000..aba3d7808 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yymuncin.c @@ -0,0 +1,24 @@ +/************************************************************ +yymuncin.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "myacc.h" + +#ifdef YYPROTOTYPE +int YYCDECL yymunclearin(yymparse_t YYFAR *yy) +#else +int YYCDECL yymunclearin(yy) +yymparse_t YYFAR *yy; +#endif +{ + yyassert(yy != NULL); + if (!yy->yymlookahead && yy->yymchar != -1) { + yy->yymlookahead = 1; + return 1; + } + return 0; +} diff --git a/Utils/Parser Generator/SOURCE/yymunput.c b/Utils/Parser Generator/SOURCE/yymunput.c new file mode 100644 index 000000000..0ff68e32a --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yymunput.c @@ -0,0 +1,69 @@ +/************************************************************ +yymunput.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include +#include +#include +#include "mlex.h" + +#ifdef YYPROTOTYPE +void YYCDECL yymunput(yymlex_t YYFAR *yy, int ch) +#else +void YYCDECL yymunput(yy, ch) +yymlex_t YYFAR *yy; +int ch; +#endif +{ + yyassert(yy != NULL); + yyassert(ch >= 0 && ch <= UCHAR_MAX || ch == EOF); + yyassert(yy->yymunputindex >= 0 && yy->yymunputindex <= yy->yymunput_size); + + /* check unput buffer size */ + if (yy->yymunputindex == yy->yymunput_size) { + do { + if (yy->yymunputgrow) { + if (yy->yymunput_size != 0) { + int size = yy->yymunput_size * 2; + if (size / 2 == yy->yymunput_size) { /* overflow check */ + if (yymsetunputsize(yy, size)) { + break; + } + } + } + else { + if (yymsetunputsize(yy, 100)) { + break; + } + } + } + (*yy->yymunputoverflow)(yy); + exit(EXIT_FAILURE); + } + while (0); + } + + yy->yymunputbufptr[yy->yymunputindex++] = ch; + + /* check line number */ + if (ch == '\n') { + yy->yymlineno--; + } + + /* debugging */ +#ifdef YYDEBUG + if (yydebug || yy->yymdebug) { + char string[128]; + + sprintf(string, "%p: unput: \'", (void *) yy); + yymlexdebugoutput(yy, string); + yymdebugoutput(yy, ch); + yymlexdebugoutput(yy, "\'\n"); + } +#endif +} diff --git a/Utils/Parser Generator/SOURCE/yymuoflw.c b/Utils/Parser Generator/SOURCE/yymuoflw.c new file mode 100644 index 000000000..c5587de01 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yymuoflw.c @@ -0,0 +1,21 @@ +/************************************************************ +yymuoflw.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "mlex.h" + +#ifdef YYPROTOTYPE +void YYCDECL yymunputoverflow(yymlex_t YYFAR *yy) +#else +void YYCDECL yymunputoverflow(yy) +yymlex_t YYFAR *yy; +#endif +{ + yyassert(yy != NULL); + yyassert(yy->yymerr != NULL); + fprintf(yy->yymerr, "lex unput buffer overflow (%d)\n", (int) yy->yymunput_size); +} diff --git a/Utils/Parser Generator/SOURCE/yymwipe.c b/Utils/Parser Generator/SOURCE/yymwipe.c new file mode 100644 index 000000000..abf5c0285 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yymwipe.c @@ -0,0 +1,24 @@ +/************************************************************ +yymwipe.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include "myacc.h" + +#ifdef YYPROTOTYPE +void YYCDECL yymwipe(yymparse_t YYFAR *yy) +#else +void YYCDECL yymwipe(yy) +yymparse_t YYFAR *yy; +#endif +{ + yyassert(yy != NULL); + yyassert(yymisfastparser(yy)); /* make sure it's a fast parser */ + + yymdestructpop(yy, yy->yymtop + 1); + yymdestructclearin(yy); +} diff --git a/Utils/Parser Generator/SOURCE/yymwork.c b/Utils/Parser Generator/SOURCE/yymwork.c new file mode 100644 index 000000000..01f8ecaaf --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yymwork.c @@ -0,0 +1,293 @@ +/************************************************************ +yymwork.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include "myacc.h" + +#ifdef YYPROTOTYPE +int YYCDECL yymwork(yymparse_t YYFAR *yy) +#else +int YYCDECL yymwork(yy) +yymparse_t YYFAR *yy; +#endif +{ + int errorpop = 0; + yyassert(yy != NULL); + yyassert(yymisfastparser(yy)); /* make sure it's a fast parser */ + + while (1) { + unsigned char type; + short sr; + yystack_t state = yympeek(yy); /* get top state */ + + while (1) { + if (yy->yymstateaction[state].lookahead) { + int index; + if (!yy->yymlookahead) { + yy->yymlookahead = 1; + yy->yymchar = (*yy->yymgettoken)(yy); + if (yy->yymchar < 0) { + yy->yymchar = 0; + } +#ifdef YYDEBUG + yymdgettoken(yy, yy->yymchar); +#endif + } + index = yy->yymstateaction[state].base + yy->yymchar; + if (index >= 0 && index < yy->yymtokenaction_size) { + if (yy->yymtokenaction[index].check == state) { + type = yy->yymtokenaction[index].type; + sr = yy->yymtokenaction[index].sr; + break; /* escape from loop */ + } + } + } + + type = yy->yymstateaction[state].type; + sr = yy->yymstateaction[state].sr; + if (type != YYAT_DEFAULT) { + break; /* escape from loop */ + } + state = sr; + } + + /* action */ + switch (type) { + case YYAT_SHIFT: +#ifdef YYDEBUG + yymdshift(yy, yy->yymchar); +#endif + if (yy->yymskip > 0) { + yymsetskip(yy, yy->yymskip - 1); + } + if (!yympush(yy, sr)) { +#ifdef YYDEBUG + yymdabort(yy); +#endif + if (yy->yymwipeflg) { + yymwipe(yy); /* clean up */ + } + return 1; + } + memcpy(&((char YYFAR *) yy->yymattributestackptr)[yy->yymtop * + yy->yymattribute_size], yy->yymlvalptr, yy->yymattribute_size); + yy->yymlookahead = 0; + continue; /* go to top of while loop */ + case YYAT_REDUCE: +#ifdef YYDEBUG + yymdreduce(yy, sr); +#endif + yy->yymretireflg = 0; + if (yy->yymreduction[sr].action != -1) { + /* user actions in here */ + if (yy->yymreduction[sr].length > 0) { + memcpy(yy->yymvalptr, &((char YYFAR *) yy->yymattributestackptr) + [(yy->yymtop + 1 - yy->yymreduction[sr].length) * + yy->yymattribute_size], yy->yymattribute_size); + } + + yy->yymerrorflg = 0; + yy->yymexitflg = 0; + (*yy->yymparseaction)(yy, yy->yymreduction[sr].action); + + /* check for special user requected actions */ + if (yy->yymexitflg) { +#ifdef YYDEBUG + yymdexit(yy, yy->yymexitcode); +#endif + return yy->yymexitcode; + } + if (yy->yymerrorflg) { + errorpop = yy->yymerrorpop; +#ifdef YYDEBUG + yymdthrowerror(yy, yy->yymerrorpop); +#endif + yy->yymerrorcount++; + break; /* go to error handler */ + } + } + + yympop(yy, yy->yymreduction[sr].length); + { + yystack_t state = yympeek(yy); /* get top state */ + short next; + + int nonterm = yy->yymreduction[sr].nonterm; + while (1) { + int index = yy->yymstategoto[state].base + nonterm; + if (index >= 0 && index < yy->yymnontermgoto_size) { + if (yy->yymnontermgoto[index].check == state) { + next = yy->yymnontermgoto[index].next; + break; + } + } + + next = yy->yymstategoto[state].def; + if (next == -1) { + break; + } + state = next; + } + yyassert(next != -1); + + if (!yympush(yy, next)) { +#ifdef YYDEBUG + yymdabort(yy); +#endif + if (yy->yymwipeflg) { + yymwipe(yy); /* clean up */ + } + return 1; + } + } + if (yy->yymreduction[sr].action != -1) { + memcpy(&((char YYFAR *) yy->yymattributestackptr) + [yy->yymtop * yy->yymattribute_size], + yy->yymvalptr, yy->yymattribute_size); + } + if (yy->yymretireflg) { +#ifdef YYDEBUG + yymdretire(yy, yy->yymretirecode); +#endif + return yy->yymretirecode; + } + continue; /* go to top of while loop */ + case YYAT_ERROR: +#ifdef YYDEBUG + yymdsyntaxerror(yy); +#endif + if (yy->yymskip == 0) { + yy->yymerrorcount++; + (*yy->yymsyntaxerror)(yy); + } + break; /* go to error handler */ + default: + yyassert(type == YYAT_ACCEPT); +#ifdef YYDEBUG + yymdaccept(yy); +#endif + return 0; + } + + /* error handler */ + if (yy->yymskip < 3 || errorpop > 0) { +#ifdef YYDEBUG + yymdattemptrecovery(yy); +#endif + yy->yympopflg = 0; /* clear flag */ + while (1) { + state = yympeek(yy); /* get top state */ + while (1) { + int index = yy->yymstateaction[state].base + YYTK_ERROR; + if (index >= 0 && index < yy->yymtokenaction_size) { + if (yy->yymtokenaction[index].check == state) { + type = yy->yymtokenaction[index].type; + sr = yy->yymtokenaction[index].sr; + break; /* escape from loop */ + } + } + + type = yy->yymstateaction[state].type; + sr = yy->yymstateaction[state].sr; + if (type != YYAT_DEFAULT) { + break; /* escape from loop */ + } + state = sr; + } + + if (type == YYAT_SHIFT) { + if (errorpop <= 0) { +#ifdef YYDEBUG + yymdshift(yy, YYTK_ERROR); +#endif + if (!yympush(yy, sr)) { +#ifdef YYDEBUG + yymdabort(yy); +#endif + if (yy->yymwipeflg) { + yymwipe(yy); /* clean up */ + } + return 1; + } + yymsetskip(yy, 3); /* skip 3 erroneous characters */ + break; + } + errorpop--; + } + + yy->yympopflg = 1; + + /* clean up any symbol attributes */ + if (yy->yymdestructorptr != NULL) { + int action; + state = yympeek(yy); + action = yy->yymdestructorptr[state]; + if (action != -1) { + /* user actions in here */ + memcpy(yy->yymvalptr, &((char YYFAR *) yy->yymattributestackptr) + [yy->yymtop * yy->yymattribute_size], + yy->yymattribute_size); + + (*yy->yymparseaction)(yy, action); + + memcpy(&((char YYFAR *) yy->yymattributestackptr) + [yy->yymtop * yy->yymattribute_size], yy->yymvalptr, + yy->yymattribute_size); + } + } + yympop(yy, 1); + if (yy->yymtop < 0) { +#ifdef YYDEBUG + yymdabort(yy); +#endif + if (yy->yymwipeflg) { + yymwipe(yy); /* clean up */ + } + return 1; + } + } + } + else { + if (yy->yymlookahead) { + if (yy->yymchar != 0) { +#ifdef YYDEBUG + yymddiscard(yy, yy->yymchar); +#endif + (*yy->yymdiscard)(yy, yy->yymchar); + + /* clean up any token attributes */ + if (yy->yymtokendestptr != NULL) { + int index = yy->yymtokendestbase + yy->yymchar; + if (index >= 0 && index < yy->yymtokendest_size) { + int action = yy->yymtokendestptr[index]; + if (action != -1) { + /* user actions in here */ + memcpy(yy->yymvalptr, yy->yymlvalptr, yy->yymattribute_size); + + (*yy->yymparseaction)(yy, action); + + memcpy(yy->yymlvalptr, yy->yymvalptr, yy->yymattribute_size); + } + } + } + + yy->yymlookahead = 0; /* skip erroneous character */ + } + else { +#ifdef YYDEBUG + yymdabort(yy); +#endif + if (yy->yymwipeflg) { + yymwipe(yy); /* clean up */ + } + return 1; + } + } + } + } +} diff --git a/Utils/Parser Generator/SOURCE/yymwrap.c b/Utils/Parser Generator/SOURCE/yymwrap.c new file mode 100644 index 000000000..dd55e5657 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yymwrap.c @@ -0,0 +1,24 @@ +/************************************************************ +yymwrap.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "mlex.h" + +#ifdef __BORLANDC__ +#pragma argsused +#endif + +#ifdef YYPROTOTYPE +int YYCDECL yymwrap(yymlex_t YYFAR *yy) +#else +int YYCDECL yymwrap(yy) +yymlex_t YYFAR *yy; +#endif +{ + yyassert(yy != NULL); + return 1; +} diff --git a/Utils/Parser Generator/SOURCE/yysback.c b/Utils/Parser Generator/SOURCE/yysback.c new file mode 100644 index 000000000..861530f6d --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yysback.c @@ -0,0 +1,27 @@ +/************************************************************ +yysback.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "lex.h" + +#ifdef YYPROTOTYPE +int YYCDECL yyback(YYCONST yymatch_t YYNEARFAR *p, int action) +#else +int YYCDECL yyback(p, action) +YYCONST yymatch_t YYNEARFAR *p; +int action; +#endif +{ + yyassert(p != NULL); + yyassert(action < 0); + while (*p != 0) { + if (*p++ == action) { + return 1; + } + } + return 0; +} diff --git a/Utils/Parser Generator/SOURCE/yyscdeci.c b/Utils/Parser Generator/SOURCE/yyscdeci.c new file mode 100644 index 000000000..78b83545a --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yyscdeci.c @@ -0,0 +1,37 @@ +/************************************************************ +yyscdeci.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include "yacc.h" + +#ifdef YYPROTOTYPE +void YYCDECL yycdestructclearin(void) +#else +void YYCDECL yycdestructclearin() +#endif +{ + if (yylookahead) { + /* clean up any token attributes */ + if (yyctokendestptr != NULL) { + YYCONST yyctokendest_t YYNEARFAR *tokendestptr = yyctokendestptr; + while (tokendestptr->token != 0) { + if (tokendestptr->token == yychar) { + /* user actions in here */ + memcpy(yyvalptr, yylvalptr, yyattribute_size); + + yyparseaction(tokendestptr->action); + + memcpy(yylvalptr, yyvalptr, yyattribute_size); + break; + } + tokendestptr++; + } + } + yylookahead = 0; + } +} diff --git a/Utils/Parser Generator/SOURCE/yysclex.c b/Utils/Parser Generator/SOURCE/yysclex.c new file mode 100644 index 000000000..aee1c4e4f --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yysclex.c @@ -0,0 +1,232 @@ +/************************************************************ +yysclex.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include +#include +#include +#include "lex.h" + +#ifdef YYPROTOTYPE +int YYCDECL yyclex(void) +#else +int YYCDECL yyclex() +#endif +{ + while (1) { + int oldleng; + int state = 1 + yystart; + if (yyeol) { + state++; + } + + /* yymore */ + if (yymoreflg) { + yymoreflg = 0; /* clear flag */ + } + else { + yyleng = 0; + yyoldeol = yyeol; + } + oldleng = yyleng; + + /* look for a string */ + do { + int index; + int ch; /* lookahead character */ + + /* get input character */ + ch = yyinput(); + yyassert(ch >= 0 && ch <= UCHAR_MAX || ch == EOF); + if (ch == EOF) { + break; + } + + /* check for possible overflow */ + if (yyleng == yytext_size) { + do { + if (yytextgrow) { + if (yytext_size != 0) { + int size = yytext_size * 2; + if (size / 2 == yytext_size) { /* overflow check */ + if (yysettextsize(size)) { + break; + } + } + } + else { + if (yysettextsize(100)) { + break; + } + } + } + yytextoverflow(); + exit(EXIT_FAILURE); + } + while (0); + } + + /* look for a transition */ + index = yystate[state].base; + while (1) { + if (yyctransition[index].next == 0) { + state = yystate[state].def; + if (state <= 0) { + if (state < 0) { + if (ch >= 0 && ch <= 0xff) { + state = -state; + } + else { + state = 0; + } + } + break; + } + } + if (ch >= yyctransition[index].first && + ch <= yyctransition[index].last) { + state = yyctransition[index].next; + break; + } + index++; + } + + { + int leng = yyleng; /* slightly more efficient */ + yytext[leng] = (char) ch; + yystatebuf[leng] = state; + leng++; + yyleng = leng; + } + } + while (state != 0 && (yystate[state].def != 0 || yystate[state].base != 0)); + + /* now find a match */ + if (yyleng > oldleng) { + int rejectmatch = 0; + while (1) { + int match = yystate[yystatebuf[yyleng - 1]].match; + if (rejectmatch != 0) { + if (match < 0) { + int index = -match; + do { + match = yymatch[index++]; + } + while (match > 0 && match <= rejectmatch); + } + else { + if (match == rejectmatch) { + match = 0; + } + } + rejectmatch = 0; + } + else { + if (match < 0) { + match = yymatch[-match]; + } + } + if (match > 0) { + int rejectleng; + int token; + /* check for backup */ + if (yybackup[match]) { + while (yyleng > oldleng) { + int index = yystate[yystatebuf[yyleng - 1]].match; + if (index < 0) { + if (yyback(&yymatch[-index], -match)) { + break; /* found an expression */ + } + } + yyleng--; + yyunput((unsigned char) yytext[yyleng]); + } + } + yytext[yyleng] = '\0'; +#ifdef YYDEBUG + yydmatch(match); +#endif + yyrejectflg = 0; /* clear flag */ + rejectleng = yyleng; + + if (yyleng > 0) { + yyeol = (unsigned char) (yytext[yyleng - 1] == '\n'); + } + else { + yyeol = yyoldeol; + } + + /* perform user action */ + token = yylexaction(match); + + if (yyreturnflg) { + return token; + } + if (!yyrejectflg) { + break; + } + if (rejectleng == yyleng) { + rejectmatch = match; + } + } + else if (yyleng > oldleng + 1) { + yyleng--; + yyunput((unsigned char) yytext[yyleng]); + } + else { + yyeol = (unsigned char) (yytext[0] == '\n'); + yyoutput(yytext[0]); /* non-matched character */ + break; + } + } + } + else { + int index; + int match; + yyassert(yyleng == oldleng); + + /* handles <> rules */ + index = 0; + match = yystate[state].match; + if (match < 0) { + index = -match; + match = yymatch[index++]; + } + while (match > 0) { + int token; + yytext[yyleng] = '\0'; +#ifdef YYDEBUG + yydmatch(match); +#endif + yyrejectflg = 0; /* clear flag */ + + /* perform user action */ + token = yylexaction(match); + + if (yyreturnflg) { + return token; + } + if (!yyrejectflg) { + break; + } + + if (index == 0) { + break; + } + match = yymatch[index++]; + } + + if (yywrap()) { + yyoldeol = 1; + yyeol = 1; + yystart = 0; + return 0; /* eof reached */ + } + } + } +} diff --git a/Utils/Parser Generator/SOURCE/yyscpars.c b/Utils/Parser Generator/SOURCE/yyscpars.c new file mode 100644 index 000000000..b40aa7cb3 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yyscpars.c @@ -0,0 +1,23 @@ +/************************************************************ +yyscpars.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include "yacc.h" + +#ifdef YYPROTOTYPE +int YYCDECL yycparse(void) +#else +int YYCDECL yycparse() +#endif +{ + int n = yysetup(); + if (n != 0) { + return n; + } + return yycwork(); +} diff --git a/Utils/Parser Generator/SOURCE/yyscwipe.c b/Utils/Parser Generator/SOURCE/yyscwipe.c new file mode 100644 index 000000000..41a1690f4 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yyscwipe.c @@ -0,0 +1,20 @@ +/************************************************************ +yyscwipe.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include "yacc.h" + +#ifdef YYPROTOTYPE +void YYCDECL yycwipe(void) +#else +void YYCDECL yycwipe() +#endif +{ + yydestructpop(yytop + 1); + yycdestructclearin(); +} diff --git a/Utils/Parser Generator/SOURCE/yyscwork.c b/Utils/Parser Generator/SOURCE/yyscwork.c new file mode 100644 index 000000000..ba97b90b3 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yyscwork.c @@ -0,0 +1,286 @@ +/************************************************************ +yyscwork.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include "yacc.h" + +#ifdef YYPROTOTYPE +int YYCDECL yycwork(void) +#else +int YYCDECL yycwork() +#endif +{ + int errorpop = 0; + while (1) { + unsigned char type; + short sr; + yystack_t state = yypeek(); /* get top state */ + + int index = yycstateaction[state]; + while (1) { + if (yyctokenaction[index].token == YYTK_ALL) { + if (yyctokenaction[index].type == YYAT_DEFAULT) { + state = yyctokenaction[index].sr; + index = yycstateaction[state]; + continue; + } + break; + } + + if (!yylookahead) { + yychar = yygettoken(); + if (yychar < 0) { + yychar = 0; + } + yylookahead = 1; +#ifdef YYDEBUG + yydgettoken(yychar); +#endif + } + if (yyctokenaction[index].token == yychar) { + break; + } + index++; + } + type = yyctokenaction[index].type; + sr = yyctokenaction[index].sr; + + /* action */ + switch (type) { + case YYAT_SHIFT: +#ifdef YYDEBUG + yydshift(yychar); +#endif + if (yyskip > 0) { + yysetskip(yyskip - 1); + } + if (!yypush(sr)) { +#ifdef YYDEBUG + yydabort(); +#endif + if (yywipeflg) { + yycwipe(); /* clean up */ + } + return 1; + } + memcpy(&((char YYFAR *) yyattributestackptr)[yytop * yyattribute_size], + yylvalptr, yyattribute_size); + yylookahead = 0; + continue; /* go to top of while loop */ + case YYAT_REDUCE: +#ifdef YYDEBUG + yydreduce(sr); +#endif + yyretireflg = 0; + if (yyreduction[sr].action != -1) { + /* user actions in here */ + if (yyreduction[sr].length > 0) { + memcpy(yyvalptr, &((char YYFAR *) yyattributestackptr) + [(yytop + 1 - yyreduction[sr].length) * yyattribute_size], + yyattribute_size); + } + + yyerrorflg = 0; + yyexitflg = 0; + yyparseaction(yyreduction[sr].action); + + /* check for special user requected actions */ + if (yyexitflg) { +#ifdef YYDEBUG + yydexit(yyexitcode); +#endif + return yyexitcode; + } + if (yyerrorflg) { + errorpop = yyerrorpop; +#ifdef YYDEBUG + yydthrowerror(errorpop); +#endif + yyerrorcount++; + break; /* go to error handler */ + } + } + + yypop(yyreduction[sr].length); + { + yystack_t state = yypeek(); /* get top state */ + short next; + + int nonterm = yyreduction[sr].nonterm; + int index = yycstategoto[state]; + while (1) { + if (yycnontermgoto[index].nonterm == -1) { + if (yycnontermgoto[index].next != -1) { + state = yycnontermgoto[index].next; + index = yycstategoto[state]; + continue; + } + break; + } + if (yycnontermgoto[index].nonterm == nonterm) { + break; + } + index++; + } + next = yycnontermgoto[index].next; + yyassert(next != -1); + + if (!yypush(next)) { +#ifdef YYDEBUG + yydabort(); +#endif + if (yywipeflg) { + yycwipe(); /* clean up */ + } + return 1; + } + } + if (yyreduction[sr].action != -1) { + memcpy(&((char YYFAR *) yyattributestackptr)[yytop * yyattribute_size], + yyvalptr, yyattribute_size); + } + if (yyretireflg) { +#ifdef YYDEBUG + yydretire(yyretirecode); +#endif + return yyretirecode; + } + continue; /* go to top of while loop */ + case YYAT_ERROR: +#ifdef YYDEBUG + yydsyntaxerror(); +#endif + if (yyskip == 0) { + yyerrorcount++; + yysyntaxerror(); + } + break; /* go to error handler */ + default: + yyassert(type == YYAT_ACCEPT); +#ifdef YYDEBUG + yydaccept(); +#endif + return 0; + } + + /* error handler */ + if (yyskip < 3 || yyerrorpop > 0) { +#ifdef YYDEBUG + yydattemptrecovery(); +#endif + yypopflg = 0; /* clear flag */ + while (yytop >= 0) { + state = yypeek(); /* get top state */ + index = yycstateaction[state]; + while (1) { + if (yyctokenaction[index].token == YYTK_ALL) { + if (yyctokenaction[index].type == YYAT_DEFAULT) { + state = yyctokenaction[index].sr; + index = yycstateaction[state]; + continue; + } + break; + } + if (yyctokenaction[index].token == YYTK_ERROR) { + break; + } + index++; + } + type = yyctokenaction[index].type; + sr = yyctokenaction[index].sr; + + if (type == YYAT_SHIFT) { + if (errorpop <= 0) { +#ifdef YYDEBUG + yydshift(YYTK_ERROR); +#endif + if (!yypush(sr)) { +#ifdef YYDEBUG + yydabort(); +#endif + if (yywipeflg) { + yycwipe(); /* clean up */ + } + return 1; + } + yysetskip(3); /* skip 3 erroneous characters */ + break; + } + errorpop--; + } + + yypopflg = 1; + + /* clean up any symbol attributes */ + if (yydestructorptr != NULL) { + int action; + state = yypeek(); + action = yydestructorptr[state]; + if (action != -1) { + /* user actions in here */ + memcpy(yyvalptr, &((char YYFAR *) yyattributestackptr) + [yytop * yyattribute_size], yyattribute_size); + + yyparseaction(action); + + memcpy(&((char YYFAR *) yyattributestackptr) + [yytop * yyattribute_size], yyvalptr, yyattribute_size); + } + } + yypop(1); + if (yytop < 0) { +#ifdef YYDEBUG + yydabort(); +#endif + if (yywipeflg) { + yycwipe(); /* clean up */ + } + return 1; + } + } + } + else { + if (yylookahead) { + if (yychar != 0) { +#ifdef YYDEBUG + yyddiscard(yychar); +#endif + yydiscard(yychar); + + /* clean up any token attributes */ + if (yyctokendestptr != NULL) { + YYCONST yyctokendest_t YYNEARFAR *tokendestptr = yyctokendestptr; + while (tokendestptr->token != 0) { + if (tokendestptr->token == yychar) { + /* user actions in here */ + memcpy(yyvalptr, yylvalptr, yyattribute_size); + + yyparseaction(tokendestptr->action); + + memcpy(yylvalptr, yyvalptr, yyattribute_size); + break; + } + tokendestptr++; + } + } + + yylookahead = 0; /* skip erroneous character */ + } + else { +#ifdef YYDEBUG + yydabort(); +#endif + if (yywipeflg) { + yycwipe(); /* clean up */ + } + return 1; + } + } + } + } +} diff --git a/Utils/Parser Generator/SOURCE/yysdeci.c b/Utils/Parser Generator/SOURCE/yysdeci.c new file mode 100644 index 000000000..6a7aa8b1a --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yysdeci.c @@ -0,0 +1,36 @@ +/************************************************************ +yysdeci.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include "yacc.h" + +#ifdef YYPROTOTYPE +void YYCDECL yydestructclearin(void) +#else +void YYCDECL yydestructclearin() +#endif +{ + if (yylookahead) { + /* clean up any token attributes */ + if (yytokendestptr != NULL) { + int index = yytokendestbase + yychar; + if (index >= 0 && index < yytokendest_size) { + int action = yytokendestptr[index]; + if (action != -1) { + /* user actions in here */ + memcpy(yyvalptr, yylvalptr, yyattribute_size); + + yyparseaction(action); + + memcpy(yylvalptr, yyvalptr, yyattribute_size); + } + } + } + yylookahead = 0; + } +} diff --git a/Utils/Parser Generator/SOURCE/yysdepop.c b/Utils/Parser Generator/SOURCE/yysdepop.c new file mode 100644 index 000000000..9da969a0e --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yysdepop.c @@ -0,0 +1,43 @@ +/************************************************************ +yysdepop.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include "yacc.h" + +#ifdef YYPROTOTYPE +void YYCDECL yydestructpop(int num) +#else +void YYCDECL yydestructpop(num) +int num; +#endif +{ + yyassert(num >= 0); + yyassert(yytop - num >= -1); + + if (yydestructorptr != NULL) { + while (num > 0) { + yystack_t state = yypeek(); + int action = yydestructorptr[state]; + if (action != -1) { + /* user actions in here */ + memcpy(yyvalptr, &((char YYFAR *) yyattributestackptr) + [yytop * yyattribute_size], yyattribute_size); + + yyparseaction(action); + + memcpy(&((char YYFAR *) yyattributestackptr) + [yytop * yyattribute_size], yyvalptr, yyattribute_size); + } + yypop(1); + num--; + } + } + else { + yypop(num); + } +} diff --git a/Utils/Parser Generator/SOURCE/yysdisc.c b/Utils/Parser Generator/SOURCE/yysdisc.c new file mode 100644 index 000000000..3353636a8 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yysdisc.c @@ -0,0 +1,25 @@ +/************************************************************ +yysdisc.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include "yacc.h" + +#ifdef __BORLANDC__ +#pragma argsused +#endif + +#ifdef YYPROTOTYPE +void YYCDECL yydiscard(int token) +#else +void YYCDECL yydiscard(token) +int token; +#endif +{ + yyassert(token > 0); + /* do nothing */ +} diff --git a/Utils/Parser Generator/SOURCE/yysdoutp.c b/Utils/Parser Generator/SOURCE/yysdoutp.c new file mode 100644 index 000000000..036fe70b8 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yysdoutp.c @@ -0,0 +1,72 @@ +/************************************************************ +yysdoutp.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include +#include "lex.h" + +#ifdef YYDEBUG +#ifdef YYPROTOTYPE +void YYCDECL yydebugoutput(int ch) +#else +void YYCDECL yydebugoutput(ch) +int ch; +#endif +{ + char string[32]; + switch (ch) { + case EOF: + strcpy(string, "EOF"); + break; + case '\n': + strcpy(string, "\\n"); + break; + case '\t': + strcpy(string, "\\t"); + break; + case '\v': + strcpy(string, "\\v"); + break; + case '\b': + strcpy(string, "\\b"); + break; + case '\r': + strcpy(string, "\\r"); + break; + case '\f': + strcpy(string, "\\f"); + break; + case '\a': + strcpy(string, "\\a"); + break; + case '\\': + strcpy(string, "\\"); + break; + case '\?': + strcpy(string, "\\\?"); + break; + case '\'': + strcpy(string, "\\\'"); + break; + case '\"': + strcpy(string, "\\\""); + break; + default: + if (isascii(ch) && isgraph(ch)) { + string[0] = (char) ch; + string[1] = '\0'; + } + else { + sprintf(string, "\\%03o", (unsigned int) (unsigned char) ch); + } + break; + } + yylexdebugoutput(string); +} + +#endif diff --git a/Utils/Parser Generator/SOURCE/yysecho.c b/Utils/Parser Generator/SOURCE/yysecho.c new file mode 100644 index 000000000..015d4fbdd --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yysecho.c @@ -0,0 +1,22 @@ +/************************************************************ +yysecho.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include "lex.h" + +#ifdef YYPROTOTYPE +void YYCDECL yyecho(void) +#else +void YYCDECL yyecho() +#endif +{ + int i; + for (i = 0; i < yyleng; i++) { + yyoutput(yytext[i]); + } +} diff --git a/Utils/Parser Generator/SOURCE/yyserror.c b/Utils/Parser Generator/SOURCE/yyserror.c new file mode 100644 index 000000000..5eefd3bf3 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yyserror.c @@ -0,0 +1,25 @@ +/************************************************************ +yyserror.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include "yacc.h" + +#ifdef YYPROTOTYPE +void YYCDECL yyerror(YYCONST char YYFAR *text) +#else +void YYCDECL yyerror(text) +YYCONST char YYFAR *text; +#endif +{ + yyassert(text != NULL); + yyassert(yyparseerr != NULL); + while (*text != '\0') { + putc(*text++, yyparseerr); + } + putc('\n', yyparseerr); +} diff --git a/Utils/Parser Generator/SOURCE/yysgetch.c b/Utils/Parser Generator/SOURCE/yysgetch.c new file mode 100644 index 000000000..2ab760761 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yysgetch.c @@ -0,0 +1,20 @@ +/************************************************************ +yysgetch.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include "lex.h" + +#ifdef YYPROTOTYPE +int YYCDECL yygetchar(void) +#else +int YYCDECL yygetchar() +#endif +{ + yyassert(yyin != NULL); + return getc(yyin); +} diff --git a/Utils/Parser Generator/SOURCE/yysgtok.c b/Utils/Parser Generator/SOURCE/yysgtok.c new file mode 100644 index 000000000..cc4aea4f4 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yysgtok.c @@ -0,0 +1,18 @@ +/************************************************************ +yysgtok.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "yacc.h" + +#ifdef YYPROTOTYPE +int YYCDECL yygettoken(void) +#else +int YYCDECL yygettoken() +#endif +{ + return yylex(); +} diff --git a/Utils/Parser Generator/SOURCE/yysinput.c b/Utils/Parser Generator/SOURCE/yysinput.c new file mode 100644 index 000000000..1ea2aa0b9 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yysinput.c @@ -0,0 +1,39 @@ +/************************************************************ +yysinput.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include +#include "lex.h" + +#ifdef YYPROTOTYPE +int YYCDECL yyinput(void) +#else +int YYCDECL yyinput() +#endif +{ + int ch; + if (yyunputindex > 0) { + ch = yyunputbufptr[--yyunputindex]; + } + else { + ch = yygetchar(); + } + if (ch == '\n') { + yylineno++; + } + +#ifdef YYDEBUG + if (yydebug || yylexdebug) { + yylexdebugoutput("input: \'"); + yydebugoutput(ch); + yylexdebugoutput("\'\n"); + } +#endif + + return ch; +} diff --git a/Utils/Parser Generator/SOURCE/yyslcln.c b/Utils/Parser Generator/SOURCE/yyslcln.c new file mode 100644 index 000000000..5e37efcf3 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yyslcln.c @@ -0,0 +1,39 @@ +/************************************************************ +yyslcln.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include +#include "lex.h" + +#ifdef YYPROTOTYPE +void YYCDECL yylexcleanup(void) +#else +void YYCDECL yylexcleanup() +#endif +{ + if (yytext != yystext) { + free(yytext); + yytext = yystext; + } + if (yystatebuf != yysstatebuf) { + free(yystatebuf); + yystatebuf = yysstatebuf; + } + if (yyunputbufptr != yysunputbufptr) { + free(yyunputbufptr); + yyunputbufptr = yysunputbufptr; + } + yytext_size = yystext_size; + yyunput_size = yysunput_size; + + if (yytext != NULL) { + *yytext = '\0'; + } + yyleng = 0; + yyunputindex = 0; +} diff --git a/Utils/Parser Generator/SOURCE/yysldbug.c b/Utils/Parser Generator/SOURCE/yysldbug.c new file mode 100644 index 000000000..75646b785 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yysldbug.c @@ -0,0 +1,75 @@ +/************************************************************ +yysldbug.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#ifdef _WIN32 +#include +#include +#endif +#include "lex.h" + +#ifdef YYDEBUG + +int YYNEAR YYDCDECL yylexdebug = 0; +int YYNEAR YYDCDECL yylexdebugflush = 0; +#ifndef YYNINITSTREAM +FILE YYFAR *YYNEAR YYDCDECL yylexdebugout = stdout; +#else +FILE YYFAR *YYNEAR YYDCDECL yylexdebugout = NULL; +#endif + +#ifdef YYPROTOTYPE +void YYCDECL yydmatch(int expr) +#else +void YYCDECL yydmatch(expr) +int expr; +#endif +{ + if (yydebug || yylexdebug) { + char string[128]; + int i; + + yylexdebugoutput("match: \""); + for (i = 0; i < yyleng; i++) { + yydebugoutput(yytext[i]); + } + sprintf(string, "\", %d\n", (int) expr); + yylexdebugoutput(string); + } +} + +#ifdef YYPROTOTYPE +void YYCDECL yylexdebugoutput(YYCONST char *string) +#else +void YYCDECL yylexdebugoutput(string) +YYCONST char *string; +#endif +{ + yyassert(string != NULL); + +#ifdef _WIN32 + if (yylexdebugout != NULL) { +#else + yyassert(yylexdebugout != NULL); +#endif + while (*string != '\0') { + putc(*string++, yylexdebugout); + } + + if (yydebugflush || yylexdebugflush) { + fflush(yylexdebugout); + } +#ifdef _WIN32 + } + else { + OutputDebugString(string); + } +#endif +} + +#endif diff --git a/Utils/Parser Generator/SOURCE/yysless.c b/Utils/Parser Generator/SOURCE/yysless.c new file mode 100644 index 000000000..bdaab4f03 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yysless.c @@ -0,0 +1,28 @@ +/************************************************************ +yysless.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "lex.h" + +#ifdef YYPROTOTYPE +void YYCDECL yyless(int length) +#else +void YYCDECL yyless(length) +int length; +#endif +{ + yyassert(length >= 0 && length <= yyleng); + while (yyleng > length) { + yyunput((unsigned char) yytext[--yyleng]); + } + if (yyleng > 0) { + yyeol = (unsigned char) (yytext[yyleng - 1] == '\n'); + } + else { + yyeol = yyoldeol; + } +} diff --git a/Utils/Parser Generator/SOURCE/yyslex.c b/Utils/Parser Generator/SOURCE/yyslex.c new file mode 100644 index 000000000..93435f10f --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yyslex.c @@ -0,0 +1,226 @@ +/************************************************************ +yyslex.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include +#include +#include +#include "lex.h" + +#ifdef YYPROTOTYPE +int YYCDECL yylex(void) +#else +int YYCDECL yylex() +#endif +{ + while (1) { + int oldleng; + int state = 1 + yystart; + if (yyeol) { + state++; + } + + /* yymore */ + if (yymoreflg) { + yymoreflg = 0; /* clear flag */ + } + else { + yyleng = 0; + yyoldeol = yyeol; + } + oldleng = yyleng; + + /* look for a string */ + do { + int ch; /* lookahead character */ + + /* get input character */ + ch = yyinput(); + yyassert(ch >= 0 && ch <= UCHAR_MAX || ch == EOF); + if (ch == EOF) { + break; + } + + /* check for possible overflow */ + if (yyleng == yytext_size) { + do { + if (yytextgrow) { + if (yytext_size != 0) { + int size = yytext_size * 2; + if (size / 2 == yytext_size) { /* overflow check */ + if (yysettextsize(size)) { + break; + } + } + } + else { + if (yysettextsize(100)) { + break; + } + } + } + yytextoverflow(); + exit(EXIT_FAILURE); + } + while (0); + } + + /* look for a transition */ + do { + int index = yystate[state].base + ch; + if (index >= 0 && index < yytransitionmax) { + if (yytransition[index].check == state) { + state = yytransition[index].next; + break; /* found a transition */ + } + } + state = yystate[state].def; + if (state < 0) { + if (ch >= 0 && ch <= 0xff) { + state = -state; + } + else { + state = 0; + } + break; /* default transition */ + } + } + while (state != 0); + + { + int leng = yyleng; /* slightly more efficient */ + yytext[leng] = (char) ch; + yystatebuf[leng] = state; + leng++; + yyleng = leng; + } + } + while (state != 0 && (yystate[state].def != 0 || yystate[state].base != 0)); + + /* now find a match */ + if (yyleng > oldleng) { + int rejectmatch = 0; + while (1) { + int match = yystate[yystatebuf[yyleng - 1]].match; + if (rejectmatch != 0) { + if (match < 0) { + int index = -match; + do { + match = yymatch[index++]; + } + while (match > 0 && match <= rejectmatch); + } + else { + match = 0; + } + rejectmatch = 0; + } + else { + if (match < 0) { + match = yymatch[-match]; + } + } + if (match > 0) { + int rejectleng; + int token; + /* check for backup */ + if (yybackup[match]) { + while (yyleng > oldleng) { + int index = yystate[yystatebuf[yyleng - 1]].match; + if (index < 0) { + if (yyback(&yymatch[-index], -match)) { + break; /* found an expression */ + } + } + yyleng--; + yyunput((unsigned char) yytext[yyleng]); + } + } + yytext[yyleng] = '\0'; +#ifdef YYDEBUG + yydmatch(match); +#endif + yyrejectflg = 0; /* clear flag */ + rejectleng = yyleng; + + if (yyleng > 0) { + yyeol = (unsigned char) (yytext[yyleng - 1] == '\n'); + } + else { + yyeol = yyoldeol; + } + + /* perform user action */ + token = yylexaction(match); + + if (yyreturnflg) { + return token; + } + if (!yyrejectflg) { + break; + } + if (rejectleng == yyleng) { + rejectmatch = match; + } + } + else if (yyleng > oldleng + 1) { + yyleng--; + yyunput((unsigned char) yytext[yyleng]); + } + else { + yyeol = (unsigned char) (yytext[0] == '\n'); + yyoutput(yytext[0]); /* non-matched character */ + break; + } + } + } + else { + int index; + int match; + yyassert(yyleng == oldleng); + + /* handles <> rules */ + index = 0; + match = yystate[state].match; + if (match < 0) { + index = -match; + match = yymatch[index++]; + } + while (match > 0) { + int token; + yytext[yyleng] = '\0'; +#ifdef YYDEBUG + yydmatch(match); +#endif + yyrejectflg = 0; /* clear flag */ + + /* perform user action */ + token = yylexaction(match); + + if (yyreturnflg) { + return token; + } + if (!yyrejectflg) { + break; + } + + if (index == 0) { + break; + } + match = yymatch[index++]; + } + + if (yywrap()) { + yyoldeol = 1; + yyeol = 1; + yystart = 0; + return 0; /* eof reached */ + } + } + } +} diff --git a/Utils/Parser Generator/SOURCE/yyslinit.c b/Utils/Parser Generator/SOURCE/yyslinit.c new file mode 100644 index 000000000..18393a22d --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yyslinit.c @@ -0,0 +1,23 @@ +/************************************************************ +yyslinit.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "lex.h" + +#ifdef YYPROTOTYPE +void YYCDECL yylexinit(void) +#else +void YYCDECL yylexinit() +#endif +{ + yyin = stdin; + yyout = stdout; + yylexerr = stderr; +#ifdef YYDEBUG + yylexdebugout = stdout; +#endif +} diff --git a/Utils/Parser Generator/SOURCE/yyslvars.c b/Utils/Parser Generator/SOURCE/yyslvars.c new file mode 100644 index 000000000..96c20223d --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yyslvars.c @@ -0,0 +1,31 @@ +/************************************************************ +yyslvars.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "lex.h" + +int YYNEAR YYDCDECL yyleng = 0; +int YYNEAR YYDCDECL yylineno = 1; +int YYNEAR YYDCDECL yyunputindex = 0; +unsigned char YYNEAR YYDCDECL yymoreflg = 0; +unsigned char YYNEAR YYDCDECL yyrejectflg; +unsigned char YYNEAR YYDCDECL yyreturnflg; +unsigned char YYNEAR YYDCDECL yytextgrow = 1; +unsigned char YYNEAR YYDCDECL yyunputgrow = 1; +unsigned char YYNEAR YYDCDECL yyeol = 1; +unsigned char YYNEAR YYDCDECL yyoldeol = 1; +int YYNEAR YYDCDECL yystart = 0; + +#ifndef YYNINITSTREAM +FILE YYFAR *YYNEAR YYDCDECL yyin = stdin; +FILE YYFAR *YYNEAR YYDCDECL yyout = stdout; +FILE YYFAR *YYNEAR YYDCDECL yylexerr = stderr; +#else +FILE YYFAR *YYNEAR YYDCDECL yyin = NULL; +FILE YYFAR *YYNEAR YYDCDECL yyout = NULL; +FILE YYFAR *YYNEAR YYDCDECL yylexerr = NULL; +#endif diff --git a/Utils/Parser Generator/SOURCE/yysoutpt.c b/Utils/Parser Generator/SOURCE/yysoutpt.c new file mode 100644 index 000000000..d6af666e5 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yysoutpt.c @@ -0,0 +1,36 @@ +/************************************************************ +yysoutpt.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include +#include "lex.h" + +#ifdef YYPROTOTYPE +void YYCDECL yyoutput(int ch) +#else +void YYCDECL yyoutput(ch) +int ch; +#endif +{ + /* debugging */ +#ifdef YYDEBUG + if (yydebug || yylexdebug) { + yylexdebugoutput("output: \'"); + yydebugoutput(ch); + yylexdebugoutput("\'\n"); + } +#endif + + yyassert(yyout != NULL); + +#ifdef __BORLANDC__ + putc((char) ch, yyout); +#else + putc(ch, yyout); +#endif +} diff --git a/Utils/Parser Generator/SOURCE/yysparse.c b/Utils/Parser Generator/SOURCE/yysparse.c new file mode 100644 index 000000000..7cc86a5d8 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yysparse.c @@ -0,0 +1,22 @@ +/************************************************************ +yysparse.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "yacc.h" + +#ifdef YYPROTOTYPE +int YYCDECL yyparse(void) +#else +int YYCDECL yyparse() +#endif +{ + int n = yysetup(); + if (n != 0) { + return n; + } + return yywork(); +} diff --git a/Utils/Parser Generator/SOURCE/yyspcln.c b/Utils/Parser Generator/SOURCE/yyspcln.c new file mode 100644 index 000000000..b566a8c07 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yyspcln.c @@ -0,0 +1,29 @@ +/************************************************************ +yyspcln.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include "yacc.h" + +#ifdef YYPROTOTYPE +void YYCDECL yyparsecleanup(void) +#else +void YYCDECL yyparsecleanup() +#endif +{ + if (yystackptr != yysstackptr) { + free(yystackptr); + yystackptr = yysstackptr; + } + if (yyattributestackptr != yysattributestackptr) { + free(yyattributestackptr); + yyattributestackptr = yysattributestackptr; + } + yystack_size = yysstack_size; + + yytop = -1; +} diff --git a/Utils/Parser Generator/SOURCE/yyspdbug.c b/Utils/Parser Generator/SOURCE/yyspdbug.c new file mode 100644 index 000000000..ce4c45954 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yyspdbug.c @@ -0,0 +1,244 @@ +/************************************************************ +yyspdbug.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#ifdef _WIN32 +#include +#include +#endif +#include "yacc.h" + +#ifdef YYDEBUG + +int YYNEAR YYDCDECL yyparsedebug = 0; +int YYNEAR YYDCDECL yyparsedebugstack = 0; +int YYNEAR YYDCDECL yyparsedebugflush = 0; +#ifndef YYNINITSTREAM +FILE YYFAR *YYNEAR YYDCDECL yyparsedebugout = stdout; +#else +FILE YYFAR *YYNEAR YYDCDECL yyparsedebugout = NULL; +#endif + +#ifdef YYPROTOTYPE +YYCONST char *YYCDECL yytokenstring(int token) +#else +YYCONST char *YYCDECL yytokenstring(token) +int token; +#endif +{ + YYCONST yysymbol_t YYNEARFAR *symbol; + yyassert(token >= 0); + + symbol = yysymbol; + while (symbol->name != NULL) { + if (symbol->token == token) { + return symbol->name; + } + symbol++; + } + return "illegal-token"; +} + +#ifdef YYPROTOTYPE +void YYCDECL yydgettoken(int token) +#else +void YYCDECL yydgettoken(token) +int token; +#endif +{ + yyassert(token >= 0); + if (yydebug || yyparsedebug) { + char string[128]; + YYCONST char *tokenstring = yytokenstring(token); + yyassert(tokenstring != NULL); + + yyparsedebugoutput("get token "); + yyparsedebugoutput(tokenstring); + sprintf(string, " (%d)\n", (int) token); + yyparsedebugoutput(string); + } +} + +#ifdef YYPROTOTYPE +void YYCDECL yydshift(int token) +#else +void YYCDECL yydshift(token) +int token; +#endif +{ + yyassert(token >= 0); + if (yydebug || yyparsedebug) { + char string[128]; + YYCONST char *tokenstring = yytokenstring(token); + yyassert(tokenstring != NULL); + + yyparsedebugoutput("shift token "); + yyparsedebugoutput(tokenstring); + sprintf(string, " (%d)\n", (int) token); + yyparsedebugoutput(string); + } +} + +#ifdef YYPROTOTYPE +void YYCDECL yydreduce(int rule) +#else +void YYCDECL yydreduce(rule) +int rule; +#endif +{ + yyassert(rule >= 0); + if (yydebug || yyparsedebug) { + char string[128]; + + yyparsedebugoutput("reduce rule "); + yyparsedebugoutput(yyrule[rule]); + sprintf(string, " (%d)\n", (int) rule); + yyparsedebugoutput(string); + } +} + +#ifdef YYPROTOTYPE +void YYCDECL yydsyntaxerror(void) +#else +void YYCDECL yydsyntaxerror() +#endif +{ + if (yydebug || yyparsedebug) { + yyparsedebugoutput("syntax error\n"); + } +} + +#ifdef YYPROTOTYPE +void YYCDECL yydaccept(void) +#else +void YYCDECL yydaccept() +#endif +{ + if (yydebug || yyparsedebug) { + yyparsedebugoutput("accept\n"); + } +} + +#ifdef YYPROTOTYPE +void YYCDECL yydabort(void) +#else +void YYCDECL yydabort() +#endif +{ + if (yydebug || yyparsedebug) { + yyparsedebugoutput("abort\n"); + } +} + +#ifdef YYPROTOTYPE +void YYCDECL yyddiscard(int token) +#else +void YYCDECL yyddiscard(token) +int token; +#endif +{ + yyassert(token >= 0); + if (yydebug || yyparsedebug) { + char string[128]; + YYCONST char *tokenstring = yytokenstring(token); + yyassert(tokenstring != NULL); + + yyparsedebugoutput("discard token "); + yyparsedebugoutput(tokenstring); + sprintf(string, " (%d)\n", (int) token); + yyparsedebugoutput(string); + } +} + +#ifdef YYPROTOTYPE +void YYCDECL yydexit(int exitcode) +#else +void YYCDECL yydexit(exitcode) +int exitcode; +#endif +{ + if (yydebug || yyparsedebug) { + char string[128]; + + sprintf(string, "exit with code %d\n", (int) exitcode); + yyparsedebugoutput(string); + } +} + +#ifdef YYPROTOTYPE +void YYCDECL yydthrowerror(int errorpop) +#else +void YYCDECL yydthrowerror(errorpop) +int errorpop; +#endif +{ + if (yydebug || yyparsedebug) { + char string[128]; + + sprintf(string, "throw error and pop %d error handling state(s)\n", + (int) errorpop); + yyparsedebugoutput(string); + } +} + +#ifdef YYPROTOTYPE +void YYCDECL yydretire(int retirecode) +#else +void YYCDECL yydretire(retirecode) +int retirecode; +#endif +{ + if (yydebug || yyparsedebug) { + char string[128]; + + sprintf(string, "retire with code %d\n", (int) retirecode); + yyparsedebugoutput(string); + } +} + +#ifdef YYPROTOTYPE +void YYCDECL yydattemptrecovery(void) +#else +void YYCDECL yydattemptrecovery() +#endif +{ + if (yydebug || yyparsedebug) { + yyparsedebugoutput("attempting error recovery\n"); + } +} + +#ifdef YYPROTOTYPE +void YYCDECL yyparsedebugoutput(YYCONST char *string) +#else +void YYCDECL yyparsedebugoutput(string) +YYCONST char *string; +#endif +{ + yyassert(string != NULL); + +#ifdef _WIN32 + if (yyparsedebugout != NULL) { +#else + yyassert(yyparsedebugout != NULL); +#endif + while (*string != '\0') { + putc(*string++, yyparsedebugout); + } + + if (yydebugflush || yyparsedebugflush) { + fflush(yyparsedebugout); + } +#ifdef _WIN32 + } + else { + OutputDebugString(string); + } +#endif +} + +#endif diff --git a/Utils/Parser Generator/SOURCE/yyspinit.c b/Utils/Parser Generator/SOURCE/yyspinit.c new file mode 100644 index 000000000..a90f40d66 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yyspinit.c @@ -0,0 +1,21 @@ +/************************************************************ +yyspinit.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "yacc.h" + +#ifdef YYPROTOTYPE +void YYCDECL yyparseinit(void) +#else +void YYCDECL yyparseinit() +#endif +{ + yyparseerr = stderr; +#ifdef YYDEBUG + yyparsedebugout = stdout; +#endif +} diff --git a/Utils/Parser Generator/SOURCE/yyspop.c b/Utils/Parser Generator/SOURCE/yyspop.c new file mode 100644 index 000000000..253f612a8 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yyspop.c @@ -0,0 +1,38 @@ +/************************************************************ +yyspop.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "yacc.h" + +#ifdef YYDEBUG +#ifdef YYPROTOTYPE +void YYCDECL yypop(int num) +#else +void YYCDECL yypop(num) +int num; +#endif +{ + yyassert(num >= 0); + yytop -= num; + yyassert(yytop >= -1); + + /* debugging */ + if (yydebug || yyparsedebug) { + if (num > 0) { + char string[128]; + + sprintf(string, "pop %d state(s)", (int) num); + yyparsedebugoutput(string); + if (yytop >= 0) { + sprintf(string, " uncovering state %d", (int) yystackptr[yytop]); + yyparsedebugoutput(string); + } + yyparsedebugoutput("\n"); + } + } +} +#endif diff --git a/Utils/Parser Generator/SOURCE/yyspush.c b/Utils/Parser Generator/SOURCE/yyspush.c new file mode 100644 index 000000000..c93846eaa --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yyspush.c @@ -0,0 +1,104 @@ +/************************************************************ +yyspush.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include +#include "yacc.h" + +#ifdef YYPROTOTYPE +int YYCDECL yypush(yystack_t state) +#else +int YYCDECL yypush(state) +yystack_t state; +#endif +{ + yytop++; /* increment first */ + if (yytop == yystack_size) { + do { + if (yystackgrow) { + if (yystack_size != 0) { + int size = yystack_size * 2; + if (size / 2 == yystack_size) { /* overflow check */ + if (yysetstacksize(size)) { + break; + } + } + } + else { + if (yysetstacksize(100)) { + break; + } + } + } + yytop--; + + /* debugging */ +#ifdef YYDEBUG + if (yydebug || yyparsedebug) { + yyparsedebugoutput("stack overflow\n"); + } +#endif + + yystackoverflow(); + return 0; + } + while (0); + } + yystackptr[yytop] = state; + + /* debugging */ +#ifdef YYDEBUG + if (yydebug || yyparsedebug) { + char string[128]; + + sprintf(string, "push state %d", (int) state); + yyparsedebugoutput(string); + if (yytop > 0) { + sprintf(string, " covering state %d", (int) yystackptr[yytop - 1]); + yyparsedebugoutput(string); + } + yyparsedebugoutput("\n"); + + /* output stack contents */ + if (yydebugstack || yyparsedebugstack) { + int rows; + int i; + int n; + + yyparsedebugoutput("\nstack"); + n = sprintf(string, "\n +"); + for (i = 0; i < 10; i++) { + n += sprintf(&string[n], " %5d", (int) i); + } + yyparsedebugoutput(string); + + rows = 1; + if (yytop >= 0) { + rows += yytop / 10; + } + for (i = 0; i < rows; i++) { + int j; + n = sprintf(string, "\n %5d", (int) (10 * i)); + for (j = 0; j < 10; j++) { + int index = 10 * i + j; + if (index <= yytop) { + n += sprintf(&string[n], " %5d", (int) yystackptr[index]); + } + else { + n += sprintf(&string[n], " -"); + } + } + yyparsedebugoutput(string); + } + yyparsedebugoutput("\n\n"); + } + } +#endif + + return 1; +} diff --git a/Utils/Parser Generator/SOURCE/yyspvars.c b/Utils/Parser Generator/SOURCE/yyspvars.c new file mode 100644 index 000000000..910b07b1d --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yyspvars.c @@ -0,0 +1,30 @@ +/************************************************************ +yyspvars.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "yacc.h" + +unsigned char YYNEAR YYDCDECL yylookahead = 0; /* whether we have lookahead token */ +unsigned char YYNEAR YYDCDECL yystackgrow = 1; /* do we allow stack to grow? */ +unsigned char YYNEAR YYDCDECL yyexitflg = 0; /* whether yyexit called */ +unsigned char YYNEAR YYDCDECL yyretireflg = 0; /* whether yyretire called */ +unsigned char YYNEAR YYDCDECL yyerrorflg = 0; /* whether yyforceerror called */ +unsigned char YYNEAR YYDCDECL yypopflg = 0; /* popping symbols during error recovery */ +unsigned char YYNEAR YYDCDECL yywipeflg = 1; /* whether to "wipe" stack on abort */ +int YYNEAR YYDCDECL yytop = -1; /* the current top of the stack */ +int YYNEAR YYDCDECL yychar = -1; /* lookahead token */ +int YYNEAR YYDCDECL yyskip = 0; /* skip erroneous characters */ +int YYNEAR YYDCDECL yyerrorcount = 0; /* syntax error count */ +int YYNEAR YYDCDECL yyexitcode; /* yyexit exit code */ +int YYNEAR YYDCDECL yyretirecode; /* yyretire exit code */ +int YYNEAR YYDCDECL yyerrorpop; /* how many error transitions to pop */ + +#ifndef YYNINITSTREAM +FILE YYFAR *YYNEAR YYDCDECL yyparseerr = stderr; +#else +FILE YYFAR *YYNEAR YYDCDECL yyparseerr = NULL; +#endif diff --git a/Utils/Parser Generator/SOURCE/yysreset.c b/Utils/Parser Generator/SOURCE/yysreset.c new file mode 100644 index 000000000..9ecec8dbf --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yysreset.c @@ -0,0 +1,25 @@ +/************************************************************ +yysreset.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "lex.h" + +#ifdef YYPROTOTYPE +void YYCDECL yyreset(void) +#else +void YYCDECL yyreset() +#endif +{ + yyleng = 0; + yylineno = 1; + yyunputindex = 0; + yymoreflg = 0; + yyrejectflg = 0; + yyeol = 1; + yyoldeol = 1; + yystart = 0; +} diff --git a/Utils/Parser Generator/SOURCE/yyssetin.c b/Utils/Parser Generator/SOURCE/yyssetin.c new file mode 100644 index 000000000..17cc650f5 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yyssetin.c @@ -0,0 +1,23 @@ +/************************************************************ +yyssetin.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "yacc.h" + +#ifdef YYPROTOTYPE +void YYCDECL yysetin(int token) +#else +void YYCDECL yysetin(token) +int token; +#endif +{ + if (token < 0) { + token = 0; + } + yychar = token; + yylookahead = 1; +} diff --git a/Utils/Parser Generator/SOURCE/yyssetup.c b/Utils/Parser Generator/SOURCE/yyssetup.c new file mode 100644 index 000000000..7cbe6851a --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yyssetup.c @@ -0,0 +1,33 @@ +/************************************************************ +yyssetup.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "yacc.h" + +#ifdef YYPROTOTYPE +int YYCDECL yysetup(void) +#else +int YYCDECL yysetup() +#endif +{ + /* initialise variables */ + yytop = -1; + yylookahead = 0; + yyskip = 0; + yyerrorcount = 0; + yychar = -1; + yypopflg = 0; + + /* push initial state onto the stack */ + if (!yypush(0)) { +#ifdef YYDEBUG + yydabort(); +#endif + return 1; + } + return 0; +} diff --git a/Utils/Parser Generator/SOURCE/yyssoflw.c b/Utils/Parser Generator/SOURCE/yyssoflw.c new file mode 100644 index 000000000..b4fdc2d28 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yyssoflw.c @@ -0,0 +1,19 @@ +/************************************************************ +yyssoflw.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include "yacc.h" + +#ifdef YYPROTOTYPE +void YYCDECL yystackoverflow(void) +#else +void YYCDECL yystackoverflow() +#endif +{ + yyerror("yacc stack overflow"); +} diff --git a/Utils/Parser Generator/SOURCE/yyssskip.c b/Utils/Parser Generator/SOURCE/yyssskip.c new file mode 100644 index 000000000..ab56cc14a --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yyssskip.c @@ -0,0 +1,38 @@ +/************************************************************ +yyssskip.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include "yacc.h" + +#ifdef YYDEBUG +#ifdef YYPROTOTYPE +void YYCDECL yysetskip(int skip) +#else +void YYCDECL yysetskip(skip) +int skip; +#endif +{ + yyassert(skip >= 0); + + /* debugging */ + if (yydebug || yyparsedebug) { + if (skip > 0) { + if (yyskip == 0) { + yyparsedebugoutput("entering error recovery\n"); + } + } + else { + if (yyskip > 0) { + yyparsedebugoutput("leaving error recovery\n"); + } + } + } + + yyskip = skip; +} +#endif diff --git a/Utils/Parser Generator/SOURCE/yyssssiz.c b/Utils/Parser Generator/SOURCE/yyssssiz.c new file mode 100644 index 000000000..625193627 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yyssssiz.c @@ -0,0 +1,86 @@ +/************************************************************ +yyssssiz.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include +#include "yacc.h" + +#ifdef YYPROTOTYPE +int YYCDECL yysetstacksize(int size) +#else +int YYCDECL yysetstacksize(size) +int size; +#endif +{ + yyassert(size >= 0); + if (yystack_size != size) { + yystack_t YYFAR *stackptr; +#if defined(__STDC__) || defined(__cplusplus) + void YYFAR *attributestackptr; +#else + char YYFAR *attributestackptr; +#endif + size_t stackcharsize; + size_t attributestackcharsize; + + if (size <= yytop) { + return 0; + } + + stackcharsize = size * sizeof(yystack_t); + if ((int) (stackcharsize / sizeof(yystack_t)) != size) { + return 0; /* integer overflow */ + } + attributestackcharsize = size * yyattribute_size; + if ((int) (attributestackcharsize / yyattribute_size) != size) { + return 0; /* integer overflow */ + } + + /* allocate */ + if (size <= yysstack_size) { + stackptr = yysstackptr; + attributestackptr = yysattributestackptr; + } + else { + stackptr = (yystack_t YYFAR *) malloc(stackcharsize); + if (stackptr == NULL) { + return 0; + } + attributestackptr = malloc(attributestackcharsize); + if (attributestackptr == NULL) { + free(stackptr); /* clean up */ + return 0; + } + } + + /* copy */ + if (stackptr != yystackptr) { + size_t charsize = yystack_size * sizeof(yystack_t); + memcpy(stackptr, yystackptr, min(stackcharsize, charsize)); + } + if (attributestackptr != yyattributestackptr) { + size_t charsize = yystack_size * yyattribute_size; + memcpy(attributestackptr, yyattributestackptr, min(attributestackcharsize, + charsize)); + } + + /* free */ + if (yystackptr != yysstackptr) { + free(yystackptr); + } + if (yyattributestackptr != yysattributestackptr) { + free(yyattributestackptr); + } + + /* assign */ + yystackptr = stackptr; + yyattributestackptr = attributestackptr; + yystack_size = size; + } + return 1; +} diff --git a/Utils/Parser Generator/SOURCE/yysstsiz.c b/Utils/Parser Generator/SOURCE/yysstsiz.c new file mode 100644 index 000000000..b5d6e79e1 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yysstsiz.c @@ -0,0 +1,82 @@ +/************************************************************ +yysstsiz.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include +#include "lex.h" + +#ifdef YYPROTOTYPE +int YYCDECL yysettextsize(int size) +#else +int YYCDECL yysettextsize(size) +int size; +#endif +{ + yyassert(size >= 0); + if (yytext_size != size) { + char YYFAR *text; + int YYFAR *statebuf; + + size_t textcharsize; + size_t statebufcharsize; + + if (size < yyleng) { + return 0; + } + + textcharsize = size + 1; /* include the '\0' */ + if (textcharsize <= (size_t) size) { + return 0; /* integer overflow */ + } + statebufcharsize = size * sizeof(int); + if ((int) (statebufcharsize / sizeof(int)) != size) { + return 0; /* integer overflow */ + } + + /* allocate */ + if (size <= yystext_size) { + text = yystext; + statebuf = yysstatebuf; + } + else { + text = (char YYFAR *) malloc(textcharsize); + if (text == NULL) { + return 0; + } + statebuf = (int YYFAR *) malloc(statebufcharsize); + if (statebuf == NULL) { + free(text); /* clean up */ + return 0; + } + } + + /* copy */ + if (text != yytext) { + size_t charsize = yytext_size + 1; + memcpy(text, yytext, min(textcharsize, charsize)); + } + if (statebuf != yystatebuf) { + size_t charsize = yytext_size * sizeof(int); + memcpy(statebuf, yystatebuf, min(statebufcharsize, charsize)); + } + + /* free */ + if (yytext != yystext) { + free(yytext); + } + if (yystatebuf != yysstatebuf) { + free(yystatebuf); + } + + /* assign */ + yytext = text; + yystatebuf = statebuf; + yytext_size = size; + } + return 1; +} diff --git a/Utils/Parser Generator/SOURCE/yyssusiz.c b/Utils/Parser Generator/SOURCE/yyssusiz.c new file mode 100644 index 000000000..e3b83abd4 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yyssusiz.c @@ -0,0 +1,62 @@ +/************************************************************ +yyssusiz.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include +#include "lex.h" + +#ifdef YYPROTOTYPE +int YYCDECL yysetunputsize(int size) +#else +int YYCDECL yysetunputsize(size) +int size; +#endif +{ + yyassert(size >= 0); + if (yyunput_size != size) { + int YYFAR *unputbufptr; + + size_t unputbufcharsize; + + if (size < yyunputindex) { + return 0; + } + + unputbufcharsize = size * sizeof(int); + if ((int) (unputbufcharsize / sizeof(int)) != size) { + return 0; /* integer overflow */ + } + + /* allocate */ + if (size <= yysunput_size) { + unputbufptr = yysunputbufptr; + } + else { + unputbufptr = (int YYFAR *) malloc(unputbufcharsize); + if (unputbufptr == NULL) { + return 0; + } + } + + /* copy */ + if (unputbufptr != yyunputbufptr) { + size_t charsize = yyunput_size * sizeof(int); + memcpy(unputbufptr, yyunputbufptr, min(unputbufcharsize, charsize)); + } + + /* free */ + if (yyunputbufptr != yysunputbufptr) { + free(yyunputbufptr); + } + + /* assign */ + yyunputbufptr = unputbufptr; + yyunput_size = size; + } + return 1; +} diff --git a/Utils/Parser Generator/SOURCE/yyssyner.c b/Utils/Parser Generator/SOURCE/yyssyner.c new file mode 100644 index 000000000..f2716ede3 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yyssyner.c @@ -0,0 +1,18 @@ +/************************************************************ +yyssyner.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "yacc.h" + +#ifdef YYPROTOTYPE +void YYCDECL yysyntaxerror(void) +#else +void YYCDECL yysyntaxerror() +#endif +{ + yyerror("syntax error"); +} diff --git a/Utils/Parser Generator/SOURCE/yystoflw.c b/Utils/Parser Generator/SOURCE/yystoflw.c new file mode 100644 index 000000000..9b46917d1 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yystoflw.c @@ -0,0 +1,19 @@ +/************************************************************ +yystoflw.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "lex.h" + +#ifdef YYPROTOTYPE +void YYCDECL yytextoverflow(void) +#else +void YYCDECL yytextoverflow() +#endif +{ + yyassert(yylexerr != NULL); + fprintf(yylexerr, "lex text buffer overflow (%d)\n", (int) yytext_size); +} diff --git a/Utils/Parser Generator/SOURCE/yysuncin.c b/Utils/Parser Generator/SOURCE/yysuncin.c new file mode 100644 index 000000000..068d2f17d --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yysuncin.c @@ -0,0 +1,22 @@ +/************************************************************ +yysuncin.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "yacc.h" + +#ifdef YYPROTOTYPE +int YYCDECL yyunclearin(void) +#else +int YYCDECL yyunclearin() +#endif +{ + if (!yylookahead && yychar != -1) { + yylookahead = 1; + return 1; + } + return 0; +} diff --git a/Utils/Parser Generator/SOURCE/yysunput.c b/Utils/Parser Generator/SOURCE/yysunput.c new file mode 100644 index 000000000..dff56d7fc --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yysunput.c @@ -0,0 +1,64 @@ +/************************************************************ +yysunput.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include +#include +#include +#include "lex.h" + +#ifdef YYPROTOTYPE +void YYCDECL yyunput(int ch) +#else +void YYCDECL yyunput(ch) +int ch; +#endif +{ + yyassert(ch >= 0 && ch <= UCHAR_MAX || ch == EOF); + yyassert(yyunputindex >= 0 && yyunputindex <= yyunput_size); + + /* check unput buffer size */ + if (yyunputindex == yyunput_size) { + do { + if (yyunputgrow) { + if (yyunput_size != 0) { + int size = yyunput_size * 2; + if (size / 2 == yyunput_size) { /* overflow check */ + if (yysetunputsize(size)) { + break; + } + } + } + else { + if (yysetunputsize(100)) { + break; + } + } + } + yyunputoverflow(); + exit(EXIT_FAILURE); + } + while (0); + } + + yyunputbufptr[yyunputindex++] = ch; + + /* check line number */ + if (ch == '\n') { + yylineno--; + } + + /* debugging */ +#ifdef YYDEBUG + if (yydebug || yylexdebug) { + yylexdebugoutput("unput: \'"); + yydebugoutput(ch); + yylexdebugoutput("\'\n"); + } +#endif +} diff --git a/Utils/Parser Generator/SOURCE/yysuoflw.c b/Utils/Parser Generator/SOURCE/yysuoflw.c new file mode 100644 index 000000000..554084e36 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yysuoflw.c @@ -0,0 +1,19 @@ +/************************************************************ +yysuoflw.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "lex.h" + +#ifdef YYPROTOTYPE +void YYCDECL yyunputoverflow(void) +#else +void YYCDECL yyunputoverflow() +#endif +{ + yyassert(yylexerr != NULL); + fprintf(yylexerr, "lex unput buffer overflow (%d)\n", (int) yyunput_size); +} diff --git a/Utils/Parser Generator/SOURCE/yyswipe.c b/Utils/Parser Generator/SOURCE/yyswipe.c new file mode 100644 index 000000000..f07c67a3a --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yyswipe.c @@ -0,0 +1,20 @@ +/************************************************************ +yyswipe.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include "yacc.h" + +#ifdef YYPROTOTYPE +void YYCDECL yywipe(void) +#else +void YYCDECL yywipe() +#endif +{ + yydestructpop(yytop + 1); + yydestructclearin(); +} diff --git a/Utils/Parser Generator/SOURCE/yyswork.c b/Utils/Parser Generator/SOURCE/yyswork.c new file mode 100644 index 000000000..834c00ad5 --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yyswork.c @@ -0,0 +1,287 @@ +/************************************************************ +yyswork.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include +#include "yacc.h" + +#ifdef YYPROTOTYPE +int YYCDECL yywork(void) +#else +int YYCDECL yywork() +#endif +{ + int errorpop = 0; + while (1) { + unsigned char type; + short sr; + yystack_t state = yypeek(); /* get top state */ + while (1) { + if (yystateaction[state].lookahead) { + int index; + if (!yylookahead) { + yychar = yygettoken(); + if (yychar < 0) { + yychar = 0; + } + yylookahead = 1; +#ifdef YYDEBUG + yydgettoken(yychar); +#endif + } + index = yystateaction[state].base + yychar; + if (index >= 0 && index < yytokenaction_size) { + if (yytokenaction[index].check == state) { + type = yytokenaction[index].type; + sr = yytokenaction[index].sr; + break; /* escape from loop */ + } + } + } + + type = yystateaction[state].type; + sr = yystateaction[state].sr; + if (type != YYAT_DEFAULT) { + break; /* escape from loop */ + } + state = sr; + } + + /* action */ + switch (type) { + case YYAT_SHIFT: +#ifdef YYDEBUG + yydshift(yychar); +#endif + if (yyskip > 0) { + yysetskip(yyskip - 1); + } + if (!yypush(sr)) { +#ifdef YYDEBUG + yydabort(); +#endif + if (yywipeflg) { + yywipe(); /* clean up */ + } + return 1; + } + memcpy(&((char YYFAR *) yyattributestackptr)[yytop * yyattribute_size], + yylvalptr, yyattribute_size); + yylookahead = 0; + continue; /* go to top of while loop */ + case YYAT_REDUCE: +#ifdef YYDEBUG + yydreduce(sr); +#endif + yyretireflg = 0; + if (yyreduction[sr].action != -1) { + /* user actions in here */ + if (yyreduction[sr].length > 0) { + memcpy(yyvalptr, &((char YYFAR *) yyattributestackptr) + [(yytop + 1 - yyreduction[sr].length) * yyattribute_size], + yyattribute_size); + } + + yyerrorflg = 0; + yyexitflg = 0; + yyparseaction(yyreduction[sr].action); + + /* check for special user requected actions */ + if (yyexitflg) { +#ifdef YYDEBUG + yydexit(yyexitcode); +#endif + return yyexitcode; + } + if (yyerrorflg) { + errorpop = yyerrorpop; +#ifdef YYDEBUG + yydthrowerror(yyerrorpop); +#endif + yyerrorcount++; + break; /* go to error handler */ + } + } + + yypop(yyreduction[sr].length); + { + yystack_t state = yypeek(); /* get top state */ + short next; + + int nonterm = yyreduction[sr].nonterm; + while (1) { + int index = yystategoto[state].base + nonterm; + if (index >= 0 && index < yynontermgoto_size) { + if (yynontermgoto[index].check == state) { + next = yynontermgoto[index].next; + break; + } + } + + next = yystategoto[state].def; + if (next == -1) { + break; + } + state = next; + } + yyassert(next != -1); + + if (!yypush(next)) { +#ifdef YYDEBUG + yydabort(); +#endif + if (yywipeflg) { + yywipe(); /* clean up */ + } + return 1; + } + } + if (yyreduction[sr].action != -1) { + memcpy(&((char YYFAR *) yyattributestackptr)[yytop * yyattribute_size], + yyvalptr, yyattribute_size); + } + if (yyretireflg) { +#ifdef YYDEBUG + yydretire(yyretirecode); +#endif + return yyretirecode; + } + continue; /* go to top of while loop */ + case YYAT_ERROR: +#ifdef YYDEBUG + yydsyntaxerror(); +#endif + if (yyskip == 0) { + yyerrorcount++; + yysyntaxerror(); + } + break; /* go to error handler */ + default: + yyassert(type == YYAT_ACCEPT); +#ifdef YYDEBUG + yydaccept(); +#endif + return 0; + } + + /* error handler */ + if (yyskip < 3 || errorpop > 0) { +#ifdef YYDEBUG + yydattemptrecovery(); +#endif + yypopflg = 0; /* clear flag */ + while (1) { + state = yypeek(); /* get top state */ + while (1) { + if (yystateaction[state].lookahead) { + int index = yystateaction[state].base + YYTK_ERROR; + if (index >= 0 && index < yytokenaction_size) { + if (yytokenaction[index].check == state) { + type = yytokenaction[index].type; + sr = yytokenaction[index].sr; + break; /* escape from loop */ + } + } + } + + type = yystateaction[state].type; + sr = yystateaction[state].sr; + if (type != YYAT_DEFAULT) { + break; /* escape from loop */ + } + state = sr; + } + + if (type == YYAT_SHIFT) { + if (errorpop <= 0) { +#ifdef YYDEBUG + yydshift(YYTK_ERROR); +#endif + if (!yypush(sr)) { +#ifdef YYDEBUG + yydabort(); +#endif + if (yywipeflg) { + yywipe(); /* clean up */ + } + return 1; + } + yysetskip(3); /* skip 3 erroneous characters */ + break; + } + errorpop--; + } + + yypopflg = 1; + + /* clean up any symbol attributes */ + if (yydestructorptr != NULL) { + int action; + state = yypeek(); + action = yydestructorptr[state]; + if (action != -1) { + /* user actions in here */ + memcpy(yyvalptr, &((char YYFAR *) yyattributestackptr) + [yytop * yyattribute_size], yyattribute_size); + + yyparseaction(action); + + memcpy(&((char YYFAR *) yyattributestackptr) + [yytop * yyattribute_size], yyvalptr, yyattribute_size); + } + } + yypop(1); + if (yytop < 0) { +#ifdef YYDEBUG + yydabort(); +#endif + if (yywipeflg) { + yywipe(); /* clean up */ + } + return 1; + } + } + } + else { + if (yylookahead) { + if (yychar != 0) { +#ifdef YYDEBUG + yyddiscard(yychar); +#endif + yydiscard(yychar); + + /* clean up any token attributes */ + if (yytokendestptr != NULL) { + int index = yytokendestbase + yychar; + if (index >= 0 && index < yytokendest_size) { + int action = yytokendestptr[index]; + if (action != -1) { + /* user actions in here */ + memcpy(yyvalptr, yylvalptr, yyattribute_size); + + yyparseaction(action); + + memcpy(yylvalptr, yyvalptr, yyattribute_size); + } + } + } + + yylookahead = 0; /* skip erroneous character */ + } + else { +#ifdef YYDEBUG + yydabort(); +#endif + if (yywipeflg) { + yywipe(); /* clean up */ + } + return 1; + } + } + } + } +} diff --git a/Utils/Parser Generator/SOURCE/yyswrap.c b/Utils/Parser Generator/SOURCE/yyswrap.c new file mode 100644 index 000000000..8393b3eab --- /dev/null +++ b/Utils/Parser Generator/SOURCE/yyswrap.c @@ -0,0 +1,18 @@ +/************************************************************ +yyswrap.c +This file can be freely modified for the generation of +custom code. + +Copyright (c) 1999 Bumble-Bee Software Ltd. +************************************************************/ + +#include "lex.h" + +#ifdef YYPROTOTYPE +int YYCDECL yywrap(void) +#else +int YYCDECL yywrap() +#endif +{ + return 1; +} diff --git a/Utils/Parser Generator/readme.txt b/Utils/Parser Generator/readme.txt new file mode 100644 index 000000000..5e748ca0a --- /dev/null +++ b/Utils/Parser Generator/readme.txt @@ -0,0 +1,40 @@ +Parser Generator Read Me File +Version 1.00 +Copyright (C) 1999 Bumble-Bee Software Ltd. + +Parser Generator is a Windows based YACC and Lex IDE. It is a Shareware +program and can be freely distributed providing it is done so in its +entirety. It includes two custom versions of YACC and Lex called AYACC +and ALex respectively. They have had a few modifications, some of which +are listed below. + +Features +Below are some of the features that are provided by Parser Generator: + +1) Project management facility. +2) Project rebuild mechanism, including Output window and error mapping +to source files. +3) Full editor including YACC and Lex syntax colouring. +4) YACC can generate LALR(1), CLR(1) and SLR(1) parsers. +5) C and C++ code generation. +6) Lex can deal successfully with the '\0' character. +7) A Library now holds most of the table driving code. +8) YACC and Lex can generate either fast or compact parsers/lexical +analysers. +9) YACC and Lex can generate multiple parsers/lexical analysers for +inclusion in a single executable. +10) Parsers can now perform clean up during error recovery. When a +symbol is popped off of the stack, or a lookahead token is discarded, an +action can be called. This is useful if, for instance, you are building +a node tree. + +Contacts +For any queries, requests or bug reports contact: + +phil@bumblebeesoftware.com + +The most up to date version of Parser Generator can be found at the web +site: + +http://www.bumblebeesoftware.com +