From 8034e6b7e77675c4f3862d13852f583c72fb1590 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aurimas=20Fi=C5=A1eras?= Date: Sat, 26 Jan 2013 10:45:12 +0200 Subject: [PATCH 01/20] Update smbase/array.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes compilation with gcc 4.7 array.h: In instantiation of ‘void ArrayStack::push(const T&) [with T = BPBox*]’: array.h:372:32: required from ‘void ObjArrayStack::push(T*) [with T = BPBox]’ boxprint.cc:371:39: required from here array.h:261:7: error: ‘setIndexDoubler’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive] array.h:261:7: note: declarations in dependent base ‘GrowArray’ are not found by unqualified lookup array.h:261:7: note: use ‘this->setIndexDoubler’ instead --- smbase/array.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smbase/array.h b/smbase/array.h index 0d08869..c17a033 100644 --- a/smbase/array.h +++ b/smbase/array.h @@ -258,7 +258,7 @@ class ArrayStack : public GrowArray { T & operator[] (int i) { return GrowArray::operator[](i); } void push(T const &val) - { setIndexDoubler(len++, val); } + { this->setIndexDoubler(len++, val); } T pop() { return operator[](--len); } T const &top() const From a6c99f406234cb6396e2586b9dc80050ab27e848 Mon Sep 17 00:00:00 2001 From: xaizek Date: Mon, 30 Oct 2017 21:51:56 +0200 Subject: [PATCH 02/20] Update elkhound/grampar.y for modern bison Where "modern" is bison 3.* or so. --- elkhound/grampar.y | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/elkhound/grampar.y b/elkhound/grampar.y index 86b4981..7198526 100644 --- a/elkhound/grampar.y +++ b/elkhound/grampar.y @@ -18,15 +18,11 @@ #define YYDEBUG 1 #endif -// name of extra parameter to yylex -#define YYLEX_PARAM parseParam - // make it call my yylex #define yylex(lv, param) grampar_yylex(lv, param) -// Bison calls yyerror(msg) on error; we need the extra -// parameter too, so the macro shoehorns it in there -#define yyerror(msg) grampar_yyerror(msg, YYPARSE_PARAM) +// Bison calls yyerror(, msg) on error +#define yyerror(param, msg) grampar_yyerror(msg, param) // rename the externally-visible parsing routine to make it // specific to this instance, so multiple bison-generated @@ -59,7 +55,10 @@ AssocKind whichKind(LocString * /*owner*/ kind); /* ================== bison declarations =================== */ // don't use globals -%pure_parser +%define api.pure full + +// extra parameter to both parser and lexer +%param {void *parseParam} /* ===================== tokens ============================ */ From 5dd5a073678fcf4b96b65ddc680c079953eed2cc Mon Sep 17 00:00:00 2001 From: noa body Date: Mon, 14 May 2018 20:55:19 -0600 Subject: [PATCH 03/20] YY_CURRENT_BUFFER workaround amended and smbase placed in path --- ast/gramlex.cc | 8 ++++---- smbase/configure.pl | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ast/gramlex.cc b/ast/gramlex.cc index 17be528..3288659 100644 --- a/ast/gramlex.cc +++ b/ast/gramlex.cc @@ -9,9 +9,9 @@ #include // cout, ifstream -// workaround for flex-2.5.31 -#ifdef FLEX_STD // detect later versions of flex - // copied from flex's output +// workaround for flex-2.5.31 and later +#ifndef yy_current_buffer // FlexLexer.h changed function + // check for macro definition #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ : NULL) @@ -19,7 +19,7 @@ // the 'yy_current_buffer' field was replaced by the buffer stack // alluded to above #define yy_current_buffer YY_CURRENT_BUFFER -#endif // FLEX_STD +#endif // yy_current_buffer // ----------------- GrammarLexer::AltReportError --------------- diff --git a/smbase/configure.pl b/smbase/configure.pl index 06b9678..7173f92 100755 --- a/smbase/configure.pl +++ b/smbase/configure.pl @@ -2,6 +2,7 @@ # configure script for smbase use strict 'subs'; +use lib '.'; require sm_config; From 4d9111870dfd851cabcbd23732adb02e055486d7 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Mon, 21 Nov 2022 12:54:23 -0600 Subject: [PATCH 04/20] Initial cmake work --- .cmake-format.py | 25 ++++ .gitignore | 3 + CMakeLists.txt | 8 ++ smbase/CMakeLists.txt | 277 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 313 insertions(+) create mode 100644 .cmake-format.py create mode 100644 CMakeLists.txt create mode 100644 smbase/CMakeLists.txt diff --git a/.cmake-format.py b/.cmake-format.py new file mode 100644 index 0000000..bd63fc2 --- /dev/null +++ b/.cmake-format.py @@ -0,0 +1,25 @@ +# SPDX-FileCopyrightText: 2021-2022, Collabora, Ltd. +# SPDX-License-Identifier: CC0-1.0 + + + +with section("format"): + line_width = 100 + tab_size = 4 + use_tabchars = False + fractional_tab_policy = "use-space" + + max_prefix_chars = 4 + + dangle_parens = False + dangle_align = "prefix-indent" + max_pargs_hwrap = 4 + max_rows_cmdline = 1 + + keyword_case = "upper" + + +# Do not reflow comments + +with section("markup"): + enable_markup = False diff --git a/.gitignore b/.gitignore index 8818d05..6ecb9e9 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,6 @@ nohup.out local_malloc llvm + +build*/ +.cache/ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..b97806e --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,8 @@ +# Copyright 2022, Collabora, Ltd. +# SPDX-License-Identifier: BSL-1.0 +cmake_minimum_required(VERSION 3.10) +project(oink-stack) + +include(CTest) + +add_subdirectory(smbase) diff --git a/smbase/CMakeLists.txt b/smbase/CMakeLists.txt new file mode 100644 index 0000000..c4a4764 --- /dev/null +++ b/smbase/CMakeLists.txt @@ -0,0 +1,277 @@ +add_library( + smbase + autofile.cc + autofile.h + bflatten.cc + bflatten.h + bit2d.cc + bit2d.h + bitarray.cc + bitarray.h + boxprint.cc + boxprint.h + breaker.cpp + breaker.h + crc.cpp + crc.h + cycles.c + cycles.h + d2vector.c + d2vector.h + datablok.cpp + datablok.h + exc.cpp + exc.h + flatten.cc + flatten.h + gprintf.c + gprintf.h + growbuf.cc + growbuf.h + hashline.cc + hashline.h + hashtbl.cc + hashtbl.h + missing.cpp + missing.h + nonport.cpp + nonport.h + ofstreamts.cc + ofstreamts.h + point.cc + point.h + pprint.cc + pprint.h + srcloc.cc + srcloc.h + str.cpp + strdict.cc + strdict.h + str.h + strhash.cc + strhash.h + stringset.cc + stringset.h + strtable.cc + strtable.h + strtokp.cpp + strtokp.h + strutil.cc + strutil.h + svdict.cc + svdict.h + syserr.cpp + syserr.h + trace.cc + trace.h + trace.html + trdelete.cc + trdelete.h + unixutil.c + unixutil.h + vdtllist.cc + vdtllist.h + voidlist.cc + voidlist.h + vptrmap.cc + vptrmap.h + warn.cpp + warn.h) + +target_sources(smbase PRIVATE $,malloc.c,malloc_stub.c>) +target_compile_definitions(smbase PRIVATE $,DEBUG_HEAP DEBUG,>) + +# srcloc.test2.cc +# srcloc.test.cc +if(NOT MINGW) + target_sources( + smbase + PRIVATE + mypopen.c + mypopen.h + mysig.cc + mysig.h + smregexp.cc + smregexp.h) +endif() + +target_include_directories(smbase PRIVATE .) +# These are M4 inputs: +# xassert.h +# xobjlist.h +# xstrobjdict.h + +add_executable(nonport nonport.cpp nonport.h gprintf.c) +target_compile_definitions(nonport PRIVATE TEST_NONPORT) +add_test(NAME nonport COMMAND nonport) + +add_executable(voidlist voidlist.cc voidlist.h) +target_compile_definitions(voidlist PRIVATE TEST_VOIDLIST) +target_link_libraries(voidlist PRIVATE smbase) +add_test(NAME voidlist COMMAND voidlist) + +add_executable(vdtllist vdtllist.cc vdtllist.h) +target_compile_definitions(vdtllist PRIVATE TEST_VDTLLIST) +target_link_libraries(vdtllist PRIVATE smbase) +add_test(NAME vdtllist COMMAND vdtllist) + +add_executable(taillist_test taillist_test.cc taillist.h) +target_link_libraries(taillist_test PRIVATE smbase) +add_test(NAME taillist_test COMMAND taillist_test) + +add_executable(tobjlist tobjlist.cc objlist.h voidlist.cc voidlist.h) +target_link_libraries(tobjlist PRIVATE smbase) +add_test(NAME tobjlist COMMAND tobjlist) + +add_executable(tsobjlist tsobjlist.cc sobjlist.h voidlist.cc voidlist.h) +target_link_libraries(tsobjlist PRIVATE smbase) +add_test(NAME tsobjlist COMMAND tsobjlist) + +add_executable(bit2d bit2d.cc bit2d.h) +target_compile_definitions(bit2d PRIVATE TEST_BIT2D) +target_link_libraries(bit2d PRIVATE smbase) +add_test(NAME bit2d COMMAND bit2d) + +add_executable(growbuf growbuf.cc growbuf.h) +target_compile_definitions(growbuf PRIVATE TEST_GROWBUF) +target_link_libraries(growbuf PRIVATE smbase) +add_test(NAME growbuf COMMAND growbuf) + +add_executable(strdict strdict.cc strdict.h) +target_compile_definitions(strdict PRIVATE TEST_STRDICT) +target_link_libraries(strdict PRIVATE smbase) +add_test(NAME strdict COMMAND strdict) + +add_executable(svdict svdict.cc svdict.h) +target_compile_definitions(svdict PRIVATE TEST_SVDICT) +target_link_libraries(svdict PRIVATE smbase) +add_test(NAME svdict COMMAND svdict) + +add_executable(str str.cpp str.h) +target_compile_definitions(str PRIVATE TEST_STR) +target_link_libraries(str PRIVATE smbase) +add_test(NAME str COMMAND str) + +add_executable(strutil strutil.cc strutil.h) +target_compile_definitions(strutil PRIVATE TEST_STRUTIL) +target_link_libraries(strutil PRIVATE smbase) +add_test(NAME strutil COMMAND strutil) + +add_executable(strhash strhash.cc strhash.h) +target_compile_definitions(strhash PRIVATE TEST_STRHASH) +target_link_libraries(strhash PRIVATE smbase) +add_test(NAME strhash COMMAND strhash) + +add_executable(trdelete trdelete.cc trdelete.h) +target_compile_definitions(trdelete PRIVATE TEST_TRDELETE) +target_link_libraries(trdelete PRIVATE smbase) +add_test(NAME trdelete COMMAND trdelete) + +add_executable(bflatten bflatten.cc bflatten.h) +target_compile_definitions(bflatten PRIVATE TEST_BFLATTEN) +target_link_libraries(bflatten PRIVATE smbase) +add_test(NAME bflatten COMMAND bflatten) +if(NOT MINGW) + + add_executable(mysig mysig.cc mysig.h) + target_compile_definitions(mysig PRIVATE TEST_MYSIG) + target_link_libraries(mysig PRIVATE smbase) + + add_test(NAME mysig COMMAND mysig) +endif() + +add_executable(testmalloc testmalloc.cc) +target_compile_definitions(testmalloc PRIVATE TEST_TESTMALLOC) +target_link_libraries(testmalloc PRIVATE smbase) +add_test(NAME testmalloc COMMAND testmalloc) + +if(NOT MINGW) + + add_executable(mypopen mypopen.c mypopen.h) + target_compile_definitions(mypopen PRIVATE TEST_MYPOPEN) + + add_test(NAME mypopen COMMAND mypopen) +endif() +# # this test is only useful when malloc is compiled with DEBUG_HEAP + +# add_executable(tmalloc tmalloc.c) +# target_link_libraries(testmalloc PRIVATE tmalloc) + +# add_test(NAME tmalloc COMMAND tmalloc) +# TODO doesn't link + +# add_executable(tobjpool tobjpool.cc objpool.h) + +# add_test(NAME tobjpool COMMAND tobjpool) + +add_executable(cycles cycles.h cycles.c) +target_compile_definitions(cycles PRIVATE TEST_CYCLES) +add_test(NAME cycles COMMAND cycles) + +# add_executable(crc crc.cpp) +# add_test(NAME crc COMMAND crc) + +add_executable(srcloc srcloc.cc) +target_compile_definitions(srcloc PRIVATE TEST_SRCLOC) +target_link_libraries(srcloc PRIVATE smbase) +add_test( + NAME srcloc + COMMAND srcloc + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + +add_executable(hashline hashline.cc) +target_compile_definitions(hashline PRIVATE TEST_HASHLINE) +target_link_libraries(hashline PRIVATE smbase) +add_test(NAME hashline COMMAND hashline) + +add_executable(gprintf gprintf.c gprintf.h) +target_compile_definitions(gprintf PRIVATE TEST_GPRINTF) +add_test(NAME gprintf COMMAND gprintf) + +if(NOT MINGW) + add_executable(smregexp smregexp.cc) + target_compile_definitions(smregexp PRIVATE TEST_SMREGEXP) + target_link_libraries(smregexp PRIVATE smbase) + add_test(NAME smregexp COMMAND smregexp) +endif() + +add_executable(vptrmap vptrmap.cc) +target_compile_definitions(vptrmap PRIVATE TEST_VPTRMAP) +target_link_libraries(vptrmap PRIVATE smbase) +add_test(NAME vptrmap COMMAND vptrmap) + +add_executable(pprint pprint.cc) +target_compile_definitions(pprint PRIVATE TEST_PPRINT) +target_link_libraries(pprint PRIVATE smbase) +add_test(NAME pprint COMMAND pprint) + +add_executable(boxprint boxprint.cc) +target_compile_definitions(boxprint PRIVATE TEST_BOXPRINT) +target_link_libraries(boxprint PRIVATE smbase) +add_test(NAME boxprint COMMAND boxprint) + +add_executable(tarrayqueue tarrayqueue.cc) +target_link_libraries(tarrayqueue PRIVATE smbase) +add_test(NAME tarrayqueue COMMAND tarrayqueue) + +add_executable(testarray testarray.cc) +target_link_libraries(testarray PRIVATE smbase) +add_test(NAME testarray COMMAND testarray) + +add_executable(autofile autofile.cc) +target_compile_definitions(autofile PRIVATE TEST_AUTOFILE) +target_link_libraries(autofile PRIVATE smbase) +add_test( + NAME autofile + COMMAND autofile autofile.cc + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + +add_executable(bitarray bitarray.cc) +target_compile_definitions(bitarray PRIVATE TEST_BITARRAY) +target_link_libraries(bitarray PRIVATE smbase) +add_test(NAME bitarray COMMAND bitarray) + +add_executable(d2vector d2vector.c) +target_compile_definitions(d2vector PRIVATE TEST_D2VECTOR) +target_link_libraries(d2vector PRIVATE smbase) +add_test(NAME d2vector COMMAND d2vector) From b8186ffa7be2ffb9ff1ebd2143f7b40574e33d42 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Mon, 21 Nov 2022 13:00:42 -0600 Subject: [PATCH 05/20] wip --- CMakeLists.txt | 4 ++++ ast/CMakeLists.txt | 8 ++++++++ 2 files changed, 12 insertions(+) create mode 100644 ast/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index b97806e..ef2a86e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,4 +5,8 @@ project(oink-stack) include(CTest) +find_package(BISON REQUIRED) + +# find_package(M4) + add_subdirectory(smbase) diff --git a/ast/CMakeLists.txt b/ast/CMakeLists.txt new file mode 100644 index 0000000..1a33bd5 --- /dev/null +++ b/ast/CMakeLists.txt @@ -0,0 +1,8 @@ +# Copyright 2022, Collabora, Ltd. +# SPDX-License-Identifier: BSL-1.0 + +bison_target(agrampar agrampar.y agrampar) + +add_library( + ast ${CMAKE_CURRENT_BINARY_DIR}/agrampar.tab.h ${CMAKE_CURRENT_BINARY_DIR}/agrampar.tab.cc + ${CMAKE_CURRENT_BINARY_DIR}/agrampar.codes.h) From fa27a5d6f57fa0b20da2c1e5f81a48b0af5ce0d7 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Mon, 21 Nov 2022 13:06:55 -0600 Subject: [PATCH 06/20] Update yacc file --- ast/agrampar.y | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ast/agrampar.y b/ast/agrampar.y index 7c96415..347edb8 100644 --- a/ast/agrampar.y +++ b/ast/agrampar.y @@ -23,7 +23,7 @@ /* ================== bison declarations =================== */ // don't use globals -%pure_parser +%define api.pure /* ===================== tokens ============================ */ From 1518736bb68005fb9bf66dc0f6b0028ba4ae7998 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Mon, 21 Nov 2022 13:41:25 -0600 Subject: [PATCH 07/20] update for newer bison --- ast/agrampar.h | 6 ++---- ast/agrampar.y | 13 +++++++------ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/ast/agrampar.h b/ast/agrampar.h index 7cc03bd..5514161 100644 --- a/ast/agrampar.h +++ b/ast/agrampar.h @@ -13,7 +13,6 @@ class GrammarLexer; // name of extra parameter to yyparse (i.e. the context in // which the parser operates, instead of that being stored // in some collection of globals) -#define YYPARSE_PARAM parseParam // type of thing extra param points at struct ASTParseParams { @@ -30,8 +29,7 @@ struct ASTParseParams { // caller interface to Bison-generated parser; starts parsing // (whatever stream lexer is reading) and returns 0 for success and // 1 for error; the extra parameter is available to actions to use -#define YYPARSE_PARAM parseParam -int agrampar_yyparse(void *YYPARSE_PARAM); +int agrampar_yyparse(void *parseParam); // when this is set to true, bison parser emits info about // actions as it's taking them @@ -53,7 +51,7 @@ CtorArg *parseCtorArg(rostring str); // error routine void agrampar_yyerror(char const *msg, void *parseParam); -#define yyerror(m) agrampar_yyerror(m, YYPARSE_PARAM) +#define yyerror(param, m) agrampar_yyerror(m, param) // parser's view of the lexer int agrampar_yylex(union YYSTYPE *lvalp, void *parseParam); diff --git a/ast/agrampar.y b/ast/agrampar.y index 347edb8..56e7fd1 100644 --- a/ast/agrampar.y +++ b/ast/agrampar.y @@ -23,8 +23,9 @@ /* ================== bison declarations =================== */ // don't use globals -%define api.pure +%define api.pure full +%param {void *parseParam} /* ===================== tokens ============================ */ /* tokens that have many lexical spellings */ @@ -131,8 +132,8 @@ Input: /* empty */ { $$ = new ASTList; } /* a class is a nonterminal in the abstract grammar */ /* yields TF_class */ Class: NewOpt "class" TOK_NAME CtorArgsOpt BaseClassesOpt ClassBody - { ($$=$6)->super->name = unbox($3); - $$->super->args.steal($4); + { ($$=$6)->super->name = unbox($3); + $$->super->args.steal($4); $$->super->bases.steal($5); } | NewOpt "class" TOK_NAME CtorArgs CtorArgs BaseClassesOpt ClassBody { ($$=$7)->super->name = unbox($3); @@ -174,7 +175,7 @@ ClassMembersOpt { ($$=$1)->super->decls.append($2); } ; -/* empty ctor args can have parens or not, at user's discretion */ +/* empty ctor args can have parens or not, at user's discretion */ /* yields ASTList */ CtorArgsOpt : /* empty */ @@ -207,7 +208,7 @@ CtorArgList: Arg Arg: ArgWord { $$ = $1; } | Arg ArgWord - { $$ = appendStr($1, $2); } // dealloc's $1, $2 + { $$ = appendStr($1, $2); } // deallocs $1, $2 ; /* yields string */ @@ -297,7 +298,7 @@ Verbatim: "verbatim" Embedded Option: "option" TOK_NAME OptionArgs ";" { $$ = new TF_option(unbox($2), $3); } ; - + /* yields ASTList */ OptionArgs: /*empty*/ { $$ = new ASTList; } From c407339966627b7f19d41ff0091c690d83901ba6 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Mon, 21 Nov 2022 13:54:57 -0600 Subject: [PATCH 08/20] almost fix an example build --- ast/exampletest.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ast/exampletest.cc b/ast/exampletest.cc index 0ff25cb..cb1fc3f 100644 --- a/ast/exampletest.cc +++ b/ast/exampletest.cc @@ -5,6 +5,9 @@ #include "../smbase/astlist.h" #include "../smbase/objlist.h" #include "locstr.h" +#include "srcloc.h" + +using namespace std; int main() { // **** build the thing From cab982ad25f21e38893e8d1bf28adacad72c26f5 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Mon, 21 Nov 2022 13:55:07 -0600 Subject: [PATCH 09/20] more cmake --- CMakeLists.txt | 2 ++ ast/CMakeLists.txt | 75 +++++++++++++++++++++++++++++++++++++++++-- smbase/CMakeLists.txt | 5 ++- 3 files changed, 78 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ef2a86e..32d6afd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,9 @@ project(oink-stack) include(CTest) find_package(BISON REQUIRED) +find_package(FLEX REQUIRED) # find_package(M4) add_subdirectory(smbase) +add_subdirectory(ast) diff --git a/ast/CMakeLists.txt b/ast/CMakeLists.txt index 1a33bd5..dcea085 100644 --- a/ast/CMakeLists.txt +++ b/ast/CMakeLists.txt @@ -1,8 +1,77 @@ # Copyright 2022, Collabora, Ltd. # SPDX-License-Identifier: BSL-1.0 -bison_target(agrampar agrampar.y agrampar) +bison_target( + agrampar agrampar.y ${CMAKE_CURRENT_BINARY_DIR}/agrampar.tab.cc + COMPILE_FLAGS "--token-table" # -Dapi.prefix={agrampar}" + DEFINES_FILE ${CMAKE_CURRENT_BINARY_DIR}/agrampar.tab.h) + +flex_target(agramlex agramlex.lex ${CMAKE_CURRENT_BINARY_DIR}/agramlex.yy.cc) +add_flex_bison_dependency(agramlex agrampar) + +add_executable( + ccsstr + ccsstr.cc + ccsstr.h + reporterr.cc + reporterr.h + embedded.cc + embedded.h) +target_compile_definitions(ccsstr PRIVATE TEST_CCSSTR) +target_link_libraries(ccsstr PRIVATE smbase) +target_include_directories(ccsstr PUBLIC ${CMAKE_CURRENT_BINARY_DIR} . ../smbase) add_library( - ast ${CMAKE_CURRENT_BINARY_DIR}/agrampar.tab.h ${CMAKE_CURRENT_BINARY_DIR}/agrampar.tab.cc - ${CMAKE_CURRENT_BINARY_DIR}/agrampar.codes.h) + ast + asthelp.cc + asthelp.h + ccsstr.cc + ccsstr.h + embedded.cc + embedded.h + gramlex.cc + gramlex.h + reporterr.cc + reporterr.h + xmlhelp.cc + xmlhelp.h) + +target_include_directories(ast PUBLIC .) +target_link_libraries(ast PUBLIC smbase) + +add_executable( + astgen + agrampar.cc + # ast.ast.cc + ast.ast.h + ast.hand.cc + ast.hand.h + astgen.cc + ${BISON_agrampar_OUTPUTS} + ${FLEX_agramlex_OUTPUTS}) +target_include_directories(astgen PUBLIC ${CMAKE_CURRENT_BINARY_DIR} .) +target_link_libraries(astgen PRIVATE ast) + +if(FALSE) + # TODO refactor in progress, doesn't build + set(EXAMPLE_CC ${CMAKE_CURRENT_BINARY_DIR}/example.cc) + set(EXAMPLE_H ${CMAKE_CURRENT_BINARY_DIR}/example.h) + add_custom_command( + OUTPUT ${EXAMPLE_CC} ${EXAMPLE_H} + COMMAND + astgen -v -o${CMAKE_CURRENT_BINARY_DIR}/example ${CMAKE_CURRENT_SOURCE_DIR}/example.ast + DEPENDS example.ast + USES_TERMINAL VERBATIM) + # add_test(NAME astgen-example COMMAND astgen ${CMAKE_CURRENT_SOURCE_DIR}/example.ast) + + add_executable( + exampletest + exampletest.cc + asthelp.cc + asthelp.h + locstr.h + locstr.cc + ${EXAMPLE_CC}) + target_include_directories(exampletest PUBLIC ${CMAKE_CURRENT_BINARY_DIR} .) + target_link_libraries(exampletest PUBLIC smbase) +endif() diff --git a/smbase/CMakeLists.txt b/smbase/CMakeLists.txt index c4a4764..84cf510 100644 --- a/smbase/CMakeLists.txt +++ b/smbase/CMakeLists.txt @@ -95,7 +95,10 @@ if(NOT MINGW) smregexp.h) endif() -target_include_directories(smbase PRIVATE .) +target_include_directories(smbase PUBLIC .) +if(NOT MSVC) + target_compile_options(smbase PUBLIC -Wno-deprecated) +endif() # These are M4 inputs: # xassert.h # xobjlist.h From d0cb5e97bf73198d3a844efc70cca74ea049e3c6 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Mon, 21 Nov 2022 14:27:53 -0600 Subject: [PATCH 10/20] More progress --- CMakeLists.txt | 1 + ast/CMakeLists.txt | 2 + elkhound/CMakeLists.txt | 89 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+) create mode 100644 elkhound/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 32d6afd..6ee6189 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,3 +12,4 @@ find_package(FLEX REQUIRED) add_subdirectory(smbase) add_subdirectory(ast) +add_subdirectory(elkhound) diff --git a/ast/CMakeLists.txt b/ast/CMakeLists.txt index dcea085..a5fe720 100644 --- a/ast/CMakeLists.txt +++ b/ast/CMakeLists.txt @@ -29,6 +29,8 @@ add_library( ccsstr.h embedded.cc embedded.h + locstr.cc + locstr.h gramlex.cc gramlex.h reporterr.cc diff --git a/elkhound/CMakeLists.txt b/elkhound/CMakeLists.txt new file mode 100644 index 0000000..6684d4b --- /dev/null +++ b/elkhound/CMakeLists.txt @@ -0,0 +1,89 @@ +# Copyright 2022, Collabora, Ltd. +# SPDX-License-Identifier: BSL-1.0 + +if(NOT MSVC) + add_compile_options(-fno-strict-aliasing) +endif() +add_compile_definitions(USE_ENDSOURCELOC=1) +add_library(elkhound-grammar OBJECT asockind.cc grammar.cc) +target_link_libraries(elkhound-grammar PUBLIC ast) +target_include_directories(elkhound-grammar PUBLIC .) + +flex_target(gramlex gramlex.lex ${CMAKE_CURRENT_BINARY_DIR}/gramlex.yy.cc) +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/gramast.ast.gen.h + ${CMAKE_CURRENT_BINARY_DIR}/gramast.ast.gen.cc + COMMAND + ${CMAKE_COMMAND} -E rm -f ${CMAKE_CURRENT_BINARY_DIR}/gramast.ast.gen.h + ${CMAKE_CURRENT_BINARY_DIR}/gramast.ast.gen.cc + COMMAND + astgen -o${CMAKE_CURRENT_BINARY_DIR}/gramast.ast.gen ${CMAKE_CURRENT_SOURCE_DIR}/gramast.ast + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gramast.ast + VERBATIM) +add_library( + elkhound-grampar OBJECT + emitcode.cc + mlsstr.cc + genml.cc + grampar.cc + # gramast.gen.o + ${CMAKE_CURRENT_BINARY_DIR}/gramast.ast.gen.h + ${CMAKE_CURRENT_BINARY_DIR}/gramast.ast.gen.cc + # gramlex.yy.cc + ${FLEX_gramlex_OUTPUTS}) +target_link_libraries(elkhound-grampar PUBLIC smbase ast) +target_include_directories(elkhound-grampar PUBLIC .) + +add_library(elkhound-glr OBJECT cyctimer.cc glr.cc parsetables.cc useract.cc) +target_link_libraries(elkhound-glr PUBLIC smbase) + +add_library(elkhound-util OBJECT ptreenode.cc ptreeact.cc) +target_link_libraries(elkhound-util PUBLIC smbase) + +add_library( + elkhound-support OBJECT + c/cc_lang.cc + c/parssppt.cc + c/lexer1.cc + c/lexer1yy.cc + c/lexer2.cc) +target_link_libraries(elkhound-support PUBLIC smbase ast) +target_include_directories(elkhound-support PUBLIC .) + +add_library(elkhound-lib $ $) +target_link_libraries(elkhound-lib PUBLIC smbase ast) + +add_executable( + elkhound + gramanl.cc + gramexpl.cc + $ + $ + grampar.tab.cc + parsetables.cc) +target_compile_definitions(elkhound PRIVATE GRAMANL_MAIN) +target_link_libraries(elkhound PUBLIC smbase ast) + +if(FALSE) + # can't find c.tok + file(READ cc2/cc2.gr ORIG_GR) + string(REGEX REPLACE "cc2[.]gr[.]gen[.]h" "cc2t/gr.gen.h" CC2_GR ${ORIG_GR}) + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/cc2/cc2t.gr ${CC2_GR}) + + set(TRGRAMANL ,lrtable) + add_custom_command( + OUTPUT + ${CMAKE_CURRENT_BINARY_DIR}/cc2/cc2t.gr.gen.cc + ${CMAKE_CURRENT_BINARY_DIR}/cc2/cc2t.gr.gen.h + ${CMAKE_CURRENT_BINARY_DIR}/cc2/cc2t.gr.gen.y + COMMAND ${CMAKE_COMMAND} -E rm -f ${CMAKE_CURRENT_BINARY_DIR}/cc2/cc2t.gr.* + COMMAND + elkhound -v -tr treebuild${TRGRAMANL} -o ${CMAKE_CURRENT_BINARY_DIR}/cc2/cc2t.gr.gen + cc2/cc2.gr + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/cc2/cc2t.gr) + + add_executable(cc2t cc2/cc2main.cc ${CMAKE_CURRENT_BINARY_DIR}/cc2/cc2t.gr.gen.cc + ${CMAKE_CURRENT_BINARY_DIR}/cc2/cc2t.gr.gen.h) + target_link_libraries(cc2t PUBLIC elkhound-lib) +endif() From 452245564518be6a323ea445e43a94ad58c6e1d4 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Mon, 21 Nov 2022 15:22:13 -0600 Subject: [PATCH 11/20] wip --- CMakeLists.txt | 1 + elkhound/CMakeLists.txt | 1 + elsa/CMakeLists.txt | 162 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 164 insertions(+) create mode 100644 elsa/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ee6189..b145038 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,3 +13,4 @@ find_package(FLEX REQUIRED) add_subdirectory(smbase) add_subdirectory(ast) add_subdirectory(elkhound) +add_subdirectory(elsa) diff --git a/elkhound/CMakeLists.txt b/elkhound/CMakeLists.txt index 6684d4b..92e2ef2 100644 --- a/elkhound/CMakeLists.txt +++ b/elkhound/CMakeLists.txt @@ -51,6 +51,7 @@ target_link_libraries(elkhound-support PUBLIC smbase ast) target_include_directories(elkhound-support PUBLIC .) add_library(elkhound-lib $ $) +target_include_directories(elkhound-lib PUBLIC .) target_link_libraries(elkhound-lib PUBLIC smbase ast) add_executable( diff --git a/elsa/CMakeLists.txt b/elsa/CMakeLists.txt new file mode 100644 index 0000000..97c4485 --- /dev/null +++ b/elsa/CMakeLists.txt @@ -0,0 +1,162 @@ +# Copyright 2022, Collabora, Ltd. +# SPDX-License-Identifier: BSL-1.0 +find_package(Perl REQUIRED) +set(TOK_MODS ${CMAKE_CURRENT_SOURCE_DIR}/cc_tokens.tok ${CMAKE_CURRENT_SOURCE_DIR}/gnu_ext.tok) +set(LEXER_MODS ${CMAKE_CURRENT_SOURCE_DIR}/cc.lex ${CMAKE_CURRENT_SOURCE_DIR}/gnu.lex) +set(CC_AST_MODS + ${CMAKE_CURRENT_SOURCE_DIR}/cc.ast + ${CMAKE_CURRENT_SOURCE_DIR}/cc_tcheck.ast + ${CMAKE_CURRENT_SOURCE_DIR}/cc_print.ast + ${CMAKE_CURRENT_SOURCE_DIR}/cfg.ast + ${CMAKE_CURRENT_SOURCE_DIR}/cc_elaborate.ast + ${CMAKE_CURRENT_SOURCE_DIR}/bpprint.ast + ${CMAKE_CURRENT_SOURCE_DIR}/cc2c.ast + ${CMAKE_CURRENT_SOURCE_DIR}/gnu.ast + ${CMAKE_CURRENT_SOURCE_DIR}/kandr.ast) +set(CC_GR_MODS ${CMAKE_CURRENT_SOURCE_DIR}/cc.gr ${CMAKE_CURRENT_SOURCE_DIR}/gnu.gr + ${CMAKE_CURRENT_SOURCE_DIR}/kandr.gr) + +# XML +set(XML_TYPE_LEXER + ${CMAKE_CURRENT_BINARY_DIR}/xml_enum_1.gen.h ${CMAKE_CURRENT_BINARY_DIR}/xml_lex_1.gen.lex + ${CMAKE_CURRENT_BINARY_DIR}/xml_name_1.gen.cc) +set(XML_TOKENS_FILES + ${CMAKE_CURRENT_SOURCE_DIR}/xml_basic.tokens ${CMAKE_CURRENT_SOURCE_DIR}/xml_file.tokens + ${CMAKE_CURRENT_SOURCE_DIR}/xml_type.tokens ${CMAKE_CURRENT_SOURCE_DIR}/xml_ast.gen.tokens) +add_custom_command( + OUTPUT ${XML_TYPE_LEXER} + DEPENDS ${XML_TOKENS_FILES} token.pl + COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/token.pl ${XML_TOKENS_FILES} + COMMENT "Generating basic, file, and typesystem xml lexer files by token.pl" + VERBATIM) + +set(XML_ASTGEN + ${CMAKE_CURRENT_BINARY_DIR}/xml_ast.gen.tokens + ${CMAKE_CURRENT_BINARY_DIR}/xml_ast_reader_0decl.gen.h + ${CMAKE_CURRENT_BINARY_DIR}/xml_ast_reader_1defn.gen.cc + ${CMAKE_CURRENT_BINARY_DIR}/xml_ast_reader_2ctrc.gen.cc) + +add_custom_command( + OUTPUT ${XML_ASTGEN} + # COMMAND ${CMAKE_COMMAND} -E rm -f ${XML_ASTGEN} + COMMAND astgen -tr no_ast.gen,xmlParser -v -o${CMAKE_CURRENT_BINARY_DIR}/xml_ast ${CC_AST_MODS} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + DEPENDS ${CC_AST_MODS} + USES_TERMINAL VERBATIM) + +add_custom_target(elsa_xml_generated_files DEPENDS ${XML_TYPE_LEXER} ${XML_ASTGEN}) + +set(LEX_INPUT + ${CMAKE_CURRENT_SOURCE_DIR}/xml_lex_0top.lex ${CMAKE_CURRENT_BINARY_DIR}/xml_lex_1.gen.lex + ${CMAKE_CURRENT_SOURCE_DIR}/xml_lex_2bot.lex) +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/xml_lex.gen.lex + COMMAND ${CMAKE_COMMAND} -E cat ${LEX_INPUT} > ${CMAKE_CURRENT_BINARY_DIR}/xml_lex.gen.lex + DEPENDS ${LEX_INPUT} + VERBATIM) + +flex_target(xml_lex ${CMAKE_CURRENT_BINARY_DIR}/xml_lex.gen.lex + ${CMAKE_CURRENT_BINARY_DIR}/xml_lex.gen.yy.cc) + +add_library( + elsa_xml_objs OBJECT + xml_lexer.cc + xml_reader.cc + xml_writer.cc + xml_file_reader.cc + xml_file_writer.cc + xml_type_reader.cc + xml_type_writer.cc + xml_ast_reader.cc + id_obj_dict.cc + xml_do_read.cc + # ${XML_ASTGEN} + # ${XML_TYPE_LEXER} + ${FLEX_xml_lex_OUTPUTS}) +target_link_libraries(elsa_xml_objs PUBLIC smbase elkhound-lib ast) +target_include_directories(elsa_xml_objs PUBLIC .) +# the cc files in here are included from within another cc, so hard to make a clean dep +add_dependencies(elsa_xml_objs elsa_xml_generated_files) + +set(TOK_FILES ${CMAKE_CURRENT_BINARY_DIR}/cc_tokens.h ${CMAKE_CURRENT_BINARY_DIR}/cc_tokens.cc + ${CMAKE_CURRENT_BINARY_DIR}/cc_tokens.ids) +add_custom_command( + OUTPUT ${TOK_FILES} + COMMAND ${CMAKE_COMMAND} -E rm -f ${TOK_FILES} + COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/make-token-files ${TOK_MODS} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/make-token-files ${TOK_MODS} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lexer.lex + COMMAND + ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/merge-lexer-exts.pl ${LEXER_MODS} > + ${CMAKE_CURRENT_BINARY_DIR}/lexer.lex + DEPENDS ${LEXER_MODS} merge-lexer-exts.pl) +flex_target(lexer ${CMAKE_CURRENT_BINARY_DIR}/lexer.lex ${CMAKE_CURRENT_BINARY_DIR}/lexer.yy.cc) + +set(CC_AST_CC ${CMAKE_CURRENT_BINARY_DIR}/cc.ast.gen.cc) +set(CC_AST_H ${CMAKE_CURRENT_BINARY_DIR}/cc.ast.gen.h) + +add_custom_command( + OUTPUT ${CC_AST_CC} ${CC_AST_H} + COMMAND astgen -v -o${CMAKE_CURRENT_BINARY_DIR}/cc.ast.gen ${CC_AST_MODS} + DEPENDS ${CC_AST_MODS} + USES_TERMINAL VERBATIM) + +set(CC_GR_MODS cc.gr gnu.gr kandr.gr) + +set(GR_GEN_OUTPUTS ${CMAKE_CURRENT_BINARY_DIR}/cc.gr.gen.cc ${CMAKE_CURRENT_BINARY_DIR}/cc.gr.gen.h + ${CMAKE_CURRENT_BINARY_DIR}/cc.gr.gen.y) +add_custom_command( + OUTPUT ${GR_GEN_OUTPUTS} ${CMAKE_CURRENT_BINARY_DIR}/cc.gr.gen.out + COMMAND ${CMAKE_COMMAND} -E rm -f ${GR_GEN_OUTPUTS} + COMMAND elkhound -v -tr lrtable -o ${CMAKE_CURRENT_BINARY_DIR}/cc.gr.gen ${CC_GR_MODS} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + DEPENDS ${CC_GR_MODS} cc_tokens.ids) +add_executable( + ccparse + bpprint.cc + ia64mangle.cc + mtype.cc + integrity.cc + astvisit.cc + template.cc + notopt.cc + cc_env.cc + cc_tcheck.cc + const_eval.cc + implint.cc + serialno.cc + cc_scope.cc + cc_elaborate.cc + ast_build.cc + $ + # $(LEXER_OBJS) + # $(XML_OBJS) + # $(EXT_OBJS) + builtinops.cc + cfg.cc + sprint.cc + mangle.cc + cc_err.cc + cc_type.cc + stdconv.cc + implconv.cc + overload.cc + typelistiter.cc + ${CC_AST_CC} + ${CC_AST_H} + # cc.ast.gen.cc + # cc.gr.gen.cc + ${GR_GEN_OUTPUTS} + parssppt.cc + cc_flags.cc + cc_print.cc + cc_ast_aux.cc + variable.cc + lookupset.cc + ccparse.cc + cc2c.cc) +target_link_libraries(ccparse PRIVATE smbase ast elkhound-lib) +target_include_directories(ccparse PRIVATE .) From 75ff1d3f62a364616233a3308efef8ed878fd6d8 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Mon, 21 Nov 2022 15:22:33 -0600 Subject: [PATCH 12/20] fix builds --- elkhound/glr.cc | 3 +++ elkhound/gramanl.cc | 2 ++ 2 files changed, 5 insertions(+) diff --git a/elkhound/glr.cc b/elkhound/glr.cc index 7074e0d..e351426 100644 --- a/elkhound/glr.cc +++ b/elkhound/glr.cc @@ -116,9 +116,12 @@ #include "sobjlist.h" // SObjList #include "owner.h" // Owner +#include #include // FILE #include // getenv +using std::ostream; + // ACTION(..) is code to execute for action trace diagnostics, i.e. "-tr action" #ifndef ACTION_TRACE #define ACTION_TRACE 0 diff --git a/elkhound/gramanl.cc b/elkhound/gramanl.cc index 1a0d478..3721ea2 100644 --- a/elkhound/gramanl.cc +++ b/elkhound/gramanl.cc @@ -23,6 +23,8 @@ #include // printf #include // uintptr_t +using std::cout; + // for ParseTables::emitConstructionCode: // linkdepend: parsetables.cc From b5c0cfaf1b4e6b0bc40af4f2dbc75b42dbe9e76b Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Mon, 21 Nov 2022 16:16:15 -0600 Subject: [PATCH 13/20] Fix include guard sanitization --- elsa/make-token-files | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elsa/make-token-files b/elsa/make-token-files index ff3193a..0983dd8 100755 --- a/elsa/make-token-files +++ b/elsa/make-token-files @@ -55,7 +55,7 @@ open(IDS, ">$baseName.ids") or die("cannot open $baseName.ids: $!\n"); # write the preambles $latch = "$baseName.h"; -$latch =~ tr|a-z./|A-Z__|; +$latch =~ tr|a-z./-|A-Z___|; print H (<<"EOF"); // $baseName.h // do not edit; this file automatically generated by From 5a1bed4631c972568845e7ccb63034ab592dd565 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Mon, 21 Nov 2022 16:16:47 -0600 Subject: [PATCH 14/20] More work on building --- CMakeLists.txt | 1 + elkhound/CMakeLists.txt | 37 +++++++-- elsa/CMakeLists.txt | 177 ++++++++++++++++++++++++++++++---------- 3 files changed, 163 insertions(+), 52 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b145038..9777bda 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,7 @@ cmake_minimum_required(VERSION 3.10) project(oink-stack) include(CTest) +set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) find_package(BISON REQUIRED) find_package(FLEX REQUIRED) diff --git a/elkhound/CMakeLists.txt b/elkhound/CMakeLists.txt index 92e2ef2..621a485 100644 --- a/elkhound/CMakeLists.txt +++ b/elkhound/CMakeLists.txt @@ -4,6 +4,15 @@ if(NOT MSVC) add_compile_options(-fno-strict-aliasing) endif() + +# Configure header +set(GLR_SOURCELOC 1) +set(eef 0) +set(gcs 0) +set(gcsc 0) +set(crs 0) +configure_file(glrconfig.h.in ${CMAKE_CURRENT_BINARY_DIR}/glrconfig.h @ONLY) + add_compile_definitions(USE_ENDSOURCELOC=1) add_library(elkhound-grammar OBJECT asockind.cc grammar.cc) target_link_libraries(elkhound-grammar PUBLIC ast) @@ -32,13 +41,15 @@ add_library( # gramlex.yy.cc ${FLEX_gramlex_OUTPUTS}) target_link_libraries(elkhound-grampar PUBLIC smbase ast) -target_include_directories(elkhound-grampar PUBLIC .) +target_include_directories(elkhound-grampar PUBLIC . ${CMAKE_CURRENT_BINARY_DIR}) -add_library(elkhound-glr OBJECT cyctimer.cc glr.cc parsetables.cc useract.cc) -target_link_libraries(elkhound-glr PUBLIC smbase) +# add_library(elkhound-glr OBJECT ) +# target_link_libraries(elkhound-glr PUBLIC smbase) +# target_include_directories(elkhound-glr PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) -add_library(elkhound-util OBJECT ptreenode.cc ptreeact.cc) -target_link_libraries(elkhound-util PUBLIC smbase) +# add_library(elkhound-util OBJECT ) +# target_link_libraries(elkhound-util PUBLIC smbase) +# target_include_directories(elkhound-util PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) add_library( elkhound-support OBJECT @@ -48,10 +59,19 @@ add_library( c/lexer1yy.cc c/lexer2.cc) target_link_libraries(elkhound-support PUBLIC smbase ast) -target_include_directories(elkhound-support PUBLIC .) +target_include_directories(elkhound-support PUBLIC . ${CMAKE_CURRENT_BINARY_DIR}) -add_library(elkhound-lib $ $) -target_include_directories(elkhound-lib PUBLIC .) +add_library( + elkhound-lib + # glr-set + cyctimer.cc + glr.cc + parsetables.cc + useract.cc + # util-set + ptreenode.cc + ptreeact.cc) +target_include_directories(elkhound-lib PUBLIC . ${CMAKE_CURRENT_BINARY_DIR}) target_link_libraries(elkhound-lib PUBLIC smbase ast) add_executable( @@ -64,6 +84,7 @@ add_executable( parsetables.cc) target_compile_definitions(elkhound PRIVATE GRAMANL_MAIN) target_link_libraries(elkhound PUBLIC smbase ast) +target_include_directories(elkhound PUBLIC . ${CMAKE_CURRENT_BINARY_DIR}) if(FALSE) # can't find c.tok diff --git a/elsa/CMakeLists.txt b/elsa/CMakeLists.txt index 97c4485..c7b8d22 100644 --- a/elsa/CMakeLists.txt +++ b/elsa/CMakeLists.txt @@ -1,8 +1,12 @@ # Copyright 2022, Collabora, Ltd. # SPDX-License-Identifier: BSL-1.0 find_package(Perl REQUIRED) -set(TOK_MODS ${CMAKE_CURRENT_SOURCE_DIR}/cc_tokens.tok ${CMAKE_CURRENT_SOURCE_DIR}/gnu_ext.tok) -set(LEXER_MODS ${CMAKE_CURRENT_SOURCE_DIR}/cc.lex ${CMAKE_CURRENT_SOURCE_DIR}/gnu.lex) + +set(USE_GNU TRUE) +set(USE_KANDR TRUE) + +set(TOK_MODS ${CMAKE_CURRENT_SOURCE_DIR}/cc_tokens.tok) +set(LEXER_MODS ${CMAKE_CURRENT_SOURCE_DIR}/cc.lex) set(CC_AST_MODS ${CMAKE_CURRENT_SOURCE_DIR}/cc.ast ${CMAKE_CURRENT_SOURCE_DIR}/cc_tcheck.ast @@ -10,26 +14,26 @@ set(CC_AST_MODS ${CMAKE_CURRENT_SOURCE_DIR}/cfg.ast ${CMAKE_CURRENT_SOURCE_DIR}/cc_elaborate.ast ${CMAKE_CURRENT_SOURCE_DIR}/bpprint.ast - ${CMAKE_CURRENT_SOURCE_DIR}/cc2c.ast - ${CMAKE_CURRENT_SOURCE_DIR}/gnu.ast - ${CMAKE_CURRENT_SOURCE_DIR}/kandr.ast) -set(CC_GR_MODS ${CMAKE_CURRENT_SOURCE_DIR}/cc.gr ${CMAKE_CURRENT_SOURCE_DIR}/gnu.gr - ${CMAKE_CURRENT_SOURCE_DIR}/kandr.gr) + ${CMAKE_CURRENT_SOURCE_DIR}/cc2c.ast) +set(CC_GR_MODS ${CMAKE_CURRENT_SOURCE_DIR}/cc.gr) +if(USE_GNU) + list(APPEND TOK_MODS ${CMAKE_CURRENT_SOURCE_DIR}/gnu_ext.tok) + list(APPEND LEXER_MODS ${CMAKE_CURRENT_SOURCE_DIR}/gnu.lex) + list(APPEND CC_AST_MODS ${CMAKE_CURRENT_SOURCE_DIR}/gnu.ast) + list(APPEND CC_GR_MODS ${CMAKE_CURRENT_SOURCE_DIR}/gnu.gr) +endif() +if(USE_KANDR) + list(APPEND CC_AST_MODS ${CMAKE_CURRENT_SOURCE_DIR}/kandr.ast) + list(APPEND CC_GR_MODS ${CMAKE_CURRENT_SOURCE_DIR}/kandr.gr) + +endif() + +set(CC_AST_CC ${CMAKE_CURRENT_BINARY_DIR}/cc.ast.gen.cc) +set(CC_AST_H ${CMAKE_CURRENT_BINARY_DIR}/cc.ast.gen.h) # XML -set(XML_TYPE_LEXER - ${CMAKE_CURRENT_BINARY_DIR}/xml_enum_1.gen.h ${CMAKE_CURRENT_BINARY_DIR}/xml_lex_1.gen.lex - ${CMAKE_CURRENT_BINARY_DIR}/xml_name_1.gen.cc) -set(XML_TOKENS_FILES - ${CMAKE_CURRENT_SOURCE_DIR}/xml_basic.tokens ${CMAKE_CURRENT_SOURCE_DIR}/xml_file.tokens - ${CMAKE_CURRENT_SOURCE_DIR}/xml_type.tokens ${CMAKE_CURRENT_SOURCE_DIR}/xml_ast.gen.tokens) -add_custom_command( - OUTPUT ${XML_TYPE_LEXER} - DEPENDS ${XML_TOKENS_FILES} token.pl - COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/token.pl ${XML_TOKENS_FILES} - COMMENT "Generating basic, file, and typesystem xml lexer files by token.pl" - VERBATIM) +# ast xml lexer/parser files generated by astgen set(XML_ASTGEN ${CMAKE_CURRENT_BINARY_DIR}/xml_ast.gen.tokens ${CMAKE_CURRENT_BINARY_DIR}/xml_ast_reader_0decl.gen.h @@ -42,10 +46,28 @@ add_custom_command( COMMAND astgen -tr no_ast.gen,xmlParser -v -o${CMAKE_CURRENT_BINARY_DIR}/xml_ast ${CC_AST_MODS} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} DEPENDS ${CC_AST_MODS} - USES_TERMINAL VERBATIM) + VERBATIM) + +#### single-source of lexing token definitions: + +# basic, file, and typesystem xml lexer files generated by token.pl; +# the ast tokens are generated by astgen elsewhere +set(XML_TYPE_LEXER + ${CMAKE_CURRENT_BINARY_DIR}/xml_enum_1.gen.h ${CMAKE_CURRENT_BINARY_DIR}/xml_lex_1.gen.lex + ${CMAKE_CURRENT_BINARY_DIR}/xml_name_1.gen.cc) +set(XML_TOKENS_FILES + ${CMAKE_CURRENT_SOURCE_DIR}/xml_basic.tokens ${CMAKE_CURRENT_SOURCE_DIR}/xml_file.tokens + ${CMAKE_CURRENT_SOURCE_DIR}/xml_type.tokens ${CMAKE_CURRENT_BINARY_DIR}/xml_ast.gen.tokens) +add_custom_command( + OUTPUT ${XML_TYPE_LEXER} + DEPENDS ${XML_TOKENS_FILES} token.pl + COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/token.pl ${XML_TOKENS_FILES} + COMMENT "Generating basic, file, and typesystem xml lexer files by token.pl" + VERBATIM) add_custom_target(elsa_xml_generated_files DEPENDS ${XML_TYPE_LEXER} ${XML_ASTGEN}) +# generate .lex file set(LEX_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/xml_lex_0top.lex ${CMAKE_CURRENT_BINARY_DIR}/xml_lex_1.gen.lex ${CMAKE_CURRENT_SOURCE_DIR}/xml_lex_2bot.lex) @@ -55,9 +77,25 @@ add_custom_command( DEPENDS ${LEX_INPUT} VERBATIM) -flex_target(xml_lex ${CMAKE_CURRENT_BINARY_DIR}/xml_lex.gen.lex - ${CMAKE_CURRENT_BINARY_DIR}/xml_lex.gen.yy.cc) +# run flex on the lexer description for ast xml parser +# flex_target(xml_lex ${CMAKE_CURRENT_BINARY_DIR}/xml_lex.gen.lex +# ${CMAKE_CURRENT_BINARY_DIR}/xml_lex.gen.yy.cc COMPILE_FLAGS "-v") +set(RUN_FLEX ${CMAKE_CURRENT_SOURCE_DIR}/../smbase/run-flex.pl) +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/xml_lex.gen.yy.cc + COMMAND + ${PERL_EXECUTABLE} ${RUN_FLEX} -nobackup -copies + -o${CMAKE_CURRENT_BINARY_DIR}/xml_lex.gen.yy.cc ${CMAKE_CURRENT_BINARY_DIR}/xml_lex.gen.lex + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/xml_lex.gen.lex ${RUN_FLEX} + COMMENT "Running run-flex.pl wrapper to generate xml_lex.gen.yy.cc" + VERBATIM) + +# add_library(elsa_xml_flex OBJECT ) +# target_include_directories(elsa_xml_flex PRIVATE . ${CMAKE_CURRENT_BINARY_DIR}) +# target_link_libraries(elsa_xml_flex PUBLIC smbase elkhound-lib) +# the cc files in here are included from within another cc, so hard to make a clean dep +# add_dependencies(elsa_xml_flex elsa_xml_generated_files) add_library( elsa_xml_objs OBJECT xml_lexer.cc @@ -70,41 +108,67 @@ add_library( xml_ast_reader.cc id_obj_dict.cc xml_do_read.cc - # ${XML_ASTGEN} - # ${XML_TYPE_LEXER} - ${FLEX_xml_lex_OUTPUTS}) + ${CMAKE_CURRENT_BINARY_DIR}/xml_lex.gen.yy.cc + ${CC_AST_H}) +# when building the ast xml lexer, delete the methods that would +# otherwise conflict with methods in lexer.yy.cc; they have identical +# implementations +target_compile_definitions(elsa_xml_objs PRIVATE NO_YYFLEXLEXER_METHODS) target_link_libraries(elsa_xml_objs PUBLIC smbase elkhound-lib ast) -target_include_directories(elsa_xml_objs PUBLIC .) -# the cc files in here are included from within another cc, so hard to make a clean dep -add_dependencies(elsa_xml_objs elsa_xml_generated_files) +target_include_directories(elsa_xml_objs PUBLIC . ${CMAKE_CURRENT_BINARY_DIR}) +# generate token lists set(TOK_FILES ${CMAKE_CURRENT_BINARY_DIR}/cc_tokens.h ${CMAKE_CURRENT_BINARY_DIR}/cc_tokens.cc ${CMAKE_CURRENT_BINARY_DIR}/cc_tokens.ids) add_custom_command( OUTPUT ${TOK_FILES} COMMAND ${CMAKE_COMMAND} -E rm -f ${TOK_FILES} - COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/make-token-files ${TOK_MODS} + COMMAND + ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/make-token-files -o + ${CMAKE_CURRENT_BINARY_DIR}/cc_tokens ${TOK_MODS} DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/make-token-files ${TOK_MODS} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "Running make-token-files" + VERBATIM) +# combine base lexer description and extensions add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lexer.lex COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/merge-lexer-exts.pl ${LEXER_MODS} > ${CMAKE_CURRENT_BINARY_DIR}/lexer.lex - DEPENDS ${LEXER_MODS} merge-lexer-exts.pl) -flex_target(lexer ${CMAKE_CURRENT_BINARY_DIR}/lexer.lex ${CMAKE_CURRENT_BINARY_DIR}/lexer.yy.cc) + DEPENDS ${LEXER_MODS} merge-lexer-exts.pl + VERBATIM) -set(CC_AST_CC ${CMAKE_CURRENT_BINARY_DIR}/cc.ast.gen.cc) -set(CC_AST_H ${CMAKE_CURRENT_BINARY_DIR}/cc.ast.gen.h) +# run flex on the lexer description +# flex_target(lexer ${CMAKE_CURRENT_BINARY_DIR}/lexer.lex ${CMAKE_CURRENT_BINARY_DIR}/lexer.yy.cc) +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lexer.yy.cc + COMMAND + ${PERL_EXECUTABLE} ${RUN_FLEX} -nobackup -copies -o${CMAKE_CURRENT_BINARY_DIR}/lexer.yy.cc + ${CMAKE_CURRENT_BINARY_DIR}/lexer.lex + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/lexer.lex ${RUN_FLEX} + COMMENT "Running run-flex.pl wrapper to generate lexer.yy.cc" + VERBATIM) +# run astgen to generate the AST implementation add_custom_command( OUTPUT ${CC_AST_CC} ${CC_AST_H} COMMAND astgen -v -o${CMAKE_CURRENT_BINARY_DIR}/cc.ast.gen ${CC_AST_MODS} DEPENDS ${CC_AST_MODS} - USES_TERMINAL VERBATIM) + VERBATIM) -set(CC_GR_MODS cc.gr gnu.gr kandr.gr) +add_library( + elsa_lexer_objs OBJECT + cppundolog.cc + baselexer.cc + lexer.cc + ${CMAKE_CURRENT_BINARY_DIR}/cc_tokens.cc + # ${FLEX_lexer_OUTPUTS} + ${CMAKE_CURRENT_BINARY_DIR}/lexer.yy.cc + cc_lang.cc) +target_link_libraries(elsa_lexer_objs PUBLIC smbase elkhound-lib ast) +target_include_directories(elsa_lexer_objs PUBLIC . ${CMAKE_CURRENT_BINARY_DIR}) set(GR_GEN_OUTPUTS ${CMAKE_CURRENT_BINARY_DIR}/cc.gr.gen.cc ${CMAKE_CURRENT_BINARY_DIR}/cc.gr.gen.h ${CMAKE_CURRENT_BINARY_DIR}/cc.gr.gen.y) @@ -112,10 +176,11 @@ add_custom_command( OUTPUT ${GR_GEN_OUTPUTS} ${CMAKE_CURRENT_BINARY_DIR}/cc.gr.gen.out COMMAND ${CMAKE_COMMAND} -E rm -f ${GR_GEN_OUTPUTS} COMMAND elkhound -v -tr lrtable -o ${CMAKE_CURRENT_BINARY_DIR}/cc.gr.gen ${CC_GR_MODS} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - DEPENDS ${CC_GR_MODS} cc_tokens.ids) -add_executable( - ccparse + DEPENDS ${CC_GR_MODS} ${CMAKE_CURRENT_BINARY_DIR}/cc_tokens.ids + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "Running elkhound to generate ${GR_GEN_OUTPUTS}" + USES_TERMINAL VERBATIM) +add_library(ccparse_objs STATIC bpprint.cc ia64mangle.cc mtype.cc @@ -131,7 +196,10 @@ add_executable( cc_scope.cc cc_elaborate.cc ast_build.cc + ${CC_AST_H} $ + # $ + $ # $(LEXER_OBJS) # $(XML_OBJS) # $(EXT_OBJS) @@ -147,8 +215,6 @@ add_executable( typelistiter.cc ${CC_AST_CC} ${CC_AST_H} - # cc.ast.gen.cc - # cc.gr.gen.cc ${GR_GEN_OUTPUTS} parssppt.cc cc_flags.cc @@ -158,5 +224,28 @@ add_executable( lookupset.cc ccparse.cc cc2c.cc) -target_link_libraries(ccparse PRIVATE smbase ast elkhound-lib) -target_include_directories(ccparse PRIVATE .) +target_link_libraries(ccparse_objs PUBLIC smbase ast elkhound-lib) +target_include_directories(ccparse_objs PUBLIC . ${CMAKE_CURRENT_BINARY_DIR}) +if(USE_GNU) + target_sources(ccparse_objs PRIVATE gnu.cc) +endif() +if(USE_KANDR) + target_sources(ccparse_objs PRIVATE kandr.cc) +endif() + +add_executable( + ccparse + main.cc) +target_link_libraries(ccparse PRIVATE ccparse_objs) + + +add_executable( + semgrep + semgrep.cc) +target_link_libraries(semgrep PRIVATE ccparse_objs) + +# TODO needs a flex invocation +# add_executable( +# iptparse +# iptparse.cc iptree.cc) +# target_link_libraries(iptparse PRIVATE ccparse_objs) From 910d2e53745627b9a024af321164a997bf04bd76 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Mon, 21 Nov 2022 16:21:45 -0600 Subject: [PATCH 15/20] start cleanup --- CMakeLists.txt | 20 ++++++++++++++++++++ elsa/CMakeLists.txt | 19 ++++++++++--------- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9777bda..3b8d0ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,11 +6,31 @@ project(oink-stack) include(CTest) set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) +find_package(Perl REQUIRED) find_package(BISON REQUIRED) find_package(FLEX REQUIRED) # find_package(M4) +set(RUN_FLEX + ${CMAKE_CURRENT_SOURCE_DIR}/smbase/run-flex.pl + CACHE INTERNAL "" FORCE) + +function(add_wrapped_flex NAME INPUT OUTPUT) + if(NOT IS_ABSOLUTE ${INPUT}) + set(INPUT ${CMAKE_CURRENT_SOURCE_DIR}/${INPUT}) + endif() + if(NOT IS_ABSOLUTE ${OUTPUT}) + set(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT}) + endif() + add_custom_command( + OUTPUT ${OUTPUT} + COMMAND ${PERL_EXECUTABLE} ${RUN_FLEX} -nobackup -copies -o${OUTPUT} ${INPUT} + DEPENDS ${INPUT} ${RUN_FLEX} + COMMENT "Running run-flex.pl wrapper to generate ${OUTPUT}" + VERBATIM) +endfunction() + add_subdirectory(smbase) add_subdirectory(ast) add_subdirectory(elkhound) diff --git a/elsa/CMakeLists.txt b/elsa/CMakeLists.txt index c7b8d22..09caa8d 100644 --- a/elsa/CMakeLists.txt +++ b/elsa/CMakeLists.txt @@ -80,15 +80,16 @@ add_custom_command( # run flex on the lexer description for ast xml parser # flex_target(xml_lex ${CMAKE_CURRENT_BINARY_DIR}/xml_lex.gen.lex # ${CMAKE_CURRENT_BINARY_DIR}/xml_lex.gen.yy.cc COMPILE_FLAGS "-v") -set(RUN_FLEX ${CMAKE_CURRENT_SOURCE_DIR}/../smbase/run-flex.pl) -add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/xml_lex.gen.yy.cc - COMMAND - ${PERL_EXECUTABLE} ${RUN_FLEX} -nobackup -copies - -o${CMAKE_CURRENT_BINARY_DIR}/xml_lex.gen.yy.cc ${CMAKE_CURRENT_BINARY_DIR}/xml_lex.gen.lex - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/xml_lex.gen.lex ${RUN_FLEX} - COMMENT "Running run-flex.pl wrapper to generate xml_lex.gen.yy.cc" - VERBATIM) +add_wrapped_flex(xml_lex ${CMAKE_CURRENT_BINARY_DIR}/xml_lex.gen.lex xml_lex.gen.yy.cc) +# set(RUN_FLEX ${CMAKE_CURRENT_SOURCE_DIR}/../smbase/run-flex.pl) +# add_custom_command( +# OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/xml_lex.gen.yy.cc +# COMMAND +# ${PERL_EXECUTABLE} ${RUN_FLEX} -nobackup -copies +# -o${CMAKE_CURRENT_BINARY_DIR}/xml_lex.gen.yy.cc ${CMAKE_CURRENT_BINARY_DIR}/xml_lex.gen.lex +# DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/xml_lex.gen.lex ${RUN_FLEX} +# COMMENT "Running run-flex.pl wrapper to generate xml_lex.gen.yy.cc" +# VERBATIM) # add_library(elsa_xml_flex OBJECT ) # target_include_directories(elsa_xml_flex PRIVATE . ${CMAKE_CURRENT_BINARY_DIR}) From badf0515ca1f80812ec66e7d85d0b476130d49fd Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Mon, 21 Nov 2022 17:00:01 -0600 Subject: [PATCH 16/20] Be able to generate everything --- CMakeLists.txt | 66 +++++++++++++++++++++++++ ast/CMakeLists.txt | 17 ++++--- elkhound/CMakeLists.txt | 68 +++++++++++++------------- elsa/CMakeLists.txt | 104 ++++++++++++++++------------------------ 4 files changed, 149 insertions(+), 106 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3b8d0ae..d11bbcc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,8 @@ cmake_minimum_required(VERSION 3.10) project(oink-stack) include(CTest) +include(GNUInstallDirs) + set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) find_package(Perl REQUIRED) @@ -16,6 +18,7 @@ set(RUN_FLEX ${CMAKE_CURRENT_SOURCE_DIR}/smbase/run-flex.pl CACHE INTERNAL "" FORCE) +# Prefer normal flex_target if possible, but if it's not... function(add_wrapped_flex NAME INPUT OUTPUT) if(NOT IS_ABSOLUTE ${INPUT}) set(INPUT ${CMAKE_CURRENT_SOURCE_DIR}/${INPUT}) @@ -31,6 +34,69 @@ function(add_wrapped_flex NAME INPUT OUTPUT) VERBATIM) endfunction() +# Wrap adding a custom command for running astgen +function(add_astgen_command) + set(options) + set(oneValueArgs OUTPUT_PREFIX) + set(multiValueArgs INPUTS OUTPUTS TRANSLATE_OPTIONS) + cmake_parse_arguments( + _AST + "${options}" + "${oneValueArgs}" + "${multiValueArgs}" + ${ARGN}) + if(_AST_TRANSLATE_OPTIONS) + string(REPLACE ";" "," _AST_TRANSLATE_OPTIONS "${_AST_TRANSLATE_OPTIONS}") + set(_AST_TRANSLATE_OPTIONS -tr ${_AST_TRANSLATE_OPTIONS}) + endif() + add_custom_command( + OUTPUT ${_AST_OUTPUTS} + COMMAND ${CMAKE_COMMAND} -E rm -f ${_AST_OUTPUTS} + COMMAND astgen ${_AST_TRANSLATE_OPTIONS} -o${_AST_OUTPUT_PREFIX} ${_AST_INPUTS} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + DEPENDS astgen ${_AST_INPUTS} + COMMENT + "Running astgen on ${_AST_INPUTS} to generate outputs prefixed by ${_AST_OUTPUT_PREFIX}" + VERBATIM) +endfunction() + +# Wrap adding a custom command for running elkhound +function(add_elkhound_command) + set(options) + set(oneValueArgs OUTPUT_PREFIX CC_OUTPUT_VAR WORKING_DIRECTORY) + set(multiValueArgs INPUTS TRANSLATE_OPTIONS EXTRA_DEPENDS) + cmake_parse_arguments( + _ELK + "${options}" + "${oneValueArgs}" + "${multiValueArgs}" + ${ARGN}) + if(_ELK_TRANSLATE_OPTIONS) + string(REPLACE ";" "," _ELK_TRANSLATE_OPTIONS "${_ELK_TRANSLATE_OPTIONS}") + set(_ELK_TRANSLATE_OPTIONS -tr ${_ELK_TRANSLATE_OPTIONS}) + endif() + if(NOT _ELK_WORKING_DIRECTORY) + set(_ELK_WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + endif() + set(CC_OUTPUTS "${_ELK_OUTPUT_PREFIX}.cc" "${_ELK_OUTPUT_PREFIX}.h") + set(Y_OUTPUTS "${_ELK_OUTPUT_PREFIX}.y") + set(LOG_OUTPUTS "${_ELK_OUTPUT_PREFIX}.out") + add_custom_command( + OUTPUT ${CC_OUTPUTS} ${Y_OUTPUTS} ${LOG_OUTPUTS} + COMMAND ${CMAKE_COMMAND} -E rm -f ${CC_OUTPUTS} ${Y_OUTPUTS} ${LOG_OUTPUTS} + COMMAND elkhound ${_ELK_TRANSLATE_OPTIONS} -o ${_ELK_OUTPUT_PREFIX} ${_ELK_INPUTS} + WORKING_DIRECTORY ${_ELK_WORKING_DIRECTORY} + DEPENDS elkhound ${_ELK_INPUTS} ${_ELK_EXTRA_DEPENDS} + COMMENT + "Running elkhound on ${_ELK_INPUTS} to generate outputs prefixed by ${_ELK_OUTPUT_PREFIX}" + VERBATIM) + if(_ELK_CC_OUTPUT_VAR) + set(${_ELK_CC_OUTPUT_VAR} + ${CC_OUTPUTS} + PARENT_SCOPE) + endif() +endfunction() + add_subdirectory(smbase) add_subdirectory(ast) add_subdirectory(elkhound) diff --git a/ast/CMakeLists.txt b/ast/CMakeLists.txt index a5fe720..82af335 100644 --- a/ast/CMakeLists.txt +++ b/ast/CMakeLists.txt @@ -54,17 +54,20 @@ add_executable( target_include_directories(astgen PUBLIC ${CMAKE_CURRENT_BINARY_DIR} .) target_link_libraries(astgen PRIVATE ast) +install(TARGETS astgen RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + if(FALSE) # TODO refactor in progress, doesn't build set(EXAMPLE_CC ${CMAKE_CURRENT_BINARY_DIR}/example.cc) set(EXAMPLE_H ${CMAKE_CURRENT_BINARY_DIR}/example.h) - add_custom_command( - OUTPUT ${EXAMPLE_CC} ${EXAMPLE_H} - COMMAND - astgen -v -o${CMAKE_CURRENT_BINARY_DIR}/example ${CMAKE_CURRENT_SOURCE_DIR}/example.ast - DEPENDS example.ast - USES_TERMINAL VERBATIM) - # add_test(NAME astgen-example COMMAND astgen ${CMAKE_CURRENT_SOURCE_DIR}/example.ast) + add_astgen_command( + INPUTS + ${CMAKE_CURRENT_SOURCE_DIR}/example.ast + OUTPUT_PREFIX + ${CMAKE_CURRENT_BINARY_DIR}/example + OUTPUTS + ${EXAMPLE_CC} + ${EXAMPLE_H}) add_executable( exampletest diff --git a/elkhound/CMakeLists.txt b/elkhound/CMakeLists.txt index 621a485..36bf8d2 100644 --- a/elkhound/CMakeLists.txt +++ b/elkhound/CMakeLists.txt @@ -19,38 +19,32 @@ target_link_libraries(elkhound-grammar PUBLIC ast) target_include_directories(elkhound-grammar PUBLIC .) flex_target(gramlex gramlex.lex ${CMAKE_CURRENT_BINARY_DIR}/gramlex.yy.cc) -add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/gramast.ast.gen.h - ${CMAKE_CURRENT_BINARY_DIR}/gramast.ast.gen.cc - COMMAND - ${CMAKE_COMMAND} -E rm -f ${CMAKE_CURRENT_BINARY_DIR}/gramast.ast.gen.h - ${CMAKE_CURRENT_BINARY_DIR}/gramast.ast.gen.cc - COMMAND - astgen -o${CMAKE_CURRENT_BINARY_DIR}/gramast.ast.gen ${CMAKE_CURRENT_SOURCE_DIR}/gramast.ast - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gramast.ast - VERBATIM) + +bison_target(grampar grampar.y ${CMAKE_CURRENT_BINARY_DIR}/grampar.tab.cc + DEFINES_FILE ${CMAKE_CURRENT_BINARY_DIR}/grampar.tab.h) +add_flex_bison_dependency(gramlex grampar) + +add_astgen_command( + INPUTS + ${CMAKE_CURRENT_SOURCE_DIR}/gramast.ast + OUTPUTS + ${CMAKE_CURRENT_BINARY_DIR}/gramast.ast.gen.h + ${CMAKE_CURRENT_BINARY_DIR}/gramast.ast.gen.cc + OUTPUT_PREFIX + ${CMAKE_CURRENT_BINARY_DIR}/gramast.ast.gen) + add_library( elkhound-grampar OBJECT emitcode.cc mlsstr.cc genml.cc grampar.cc - # gramast.gen.o ${CMAKE_CURRENT_BINARY_DIR}/gramast.ast.gen.h ${CMAKE_CURRENT_BINARY_DIR}/gramast.ast.gen.cc - # gramlex.yy.cc ${FLEX_gramlex_OUTPUTS}) target_link_libraries(elkhound-grampar PUBLIC smbase ast) target_include_directories(elkhound-grampar PUBLIC . ${CMAKE_CURRENT_BINARY_DIR}) -# add_library(elkhound-glr OBJECT ) -# target_link_libraries(elkhound-glr PUBLIC smbase) -# target_include_directories(elkhound-glr PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) - -# add_library(elkhound-util OBJECT ) -# target_link_libraries(elkhound-util PUBLIC smbase) -# target_include_directories(elkhound-util PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) - add_library( elkhound-support OBJECT c/cc_lang.cc @@ -74,38 +68,40 @@ add_library( target_include_directories(elkhound-lib PUBLIC . ${CMAKE_CURRENT_BINARY_DIR}) target_link_libraries(elkhound-lib PUBLIC smbase ast) + add_executable( elkhound gramanl.cc gramexpl.cc $ $ - grampar.tab.cc + ${BISON_grampar_OUTPUTS} parsetables.cc) target_compile_definitions(elkhound PRIVATE GRAMANL_MAIN) target_link_libraries(elkhound PUBLIC smbase ast) target_include_directories(elkhound PUBLIC . ${CMAKE_CURRENT_BINARY_DIR}) +install(TARGETS elkhound RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + if(FALSE) - # can't find c.tok + # needs c.tok from nested c directory file(READ cc2/cc2.gr ORIG_GR) string(REGEX REPLACE "cc2[.]gr[.]gen[.]h" "cc2t/gr.gen.h" CC2_GR ${ORIG_GR}) file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/cc2/cc2t.gr ${CC2_GR}) - set(TRGRAMANL ,lrtable) - add_custom_command( - OUTPUT - ${CMAKE_CURRENT_BINARY_DIR}/cc2/cc2t.gr.gen.cc - ${CMAKE_CURRENT_BINARY_DIR}/cc2/cc2t.gr.gen.h - ${CMAKE_CURRENT_BINARY_DIR}/cc2/cc2t.gr.gen.y - COMMAND ${CMAKE_COMMAND} -E rm -f ${CMAKE_CURRENT_BINARY_DIR}/cc2/cc2t.gr.* - COMMAND - elkhound -v -tr treebuild${TRGRAMANL} -o ${CMAKE_CURRENT_BINARY_DIR}/cc2/cc2t.gr.gen - cc2/cc2.gr - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/cc2/cc2t.gr) + add_elkhound_command( + INPUTS + cc2/cc2.gr + OUTPUT_PREFIX + ${CMAKE_CURRENT_BINARY_DIR}/cc2/cc2t.gr.gen + CC_OUTPUT_VAR + CC2T_GEN_OUTPUTS + WORKING_DIRECTORY + ${CMAKE_CURRENT_SOURCE_DIR} + TRANSLATE_OPTIONS + treebuild + lrtable) - add_executable(cc2t cc2/cc2main.cc ${CMAKE_CURRENT_BINARY_DIR}/cc2/cc2t.gr.gen.cc - ${CMAKE_CURRENT_BINARY_DIR}/cc2/cc2t.gr.gen.h) + add_executable(cc2t cc2/cc2main.cc ${CC2T_GEN_OUTPUTS}) target_link_libraries(cc2t PUBLIC elkhound-lib) endif() diff --git a/elsa/CMakeLists.txt b/elsa/CMakeLists.txt index 09caa8d..af3b71f 100644 --- a/elsa/CMakeLists.txt +++ b/elsa/CMakeLists.txt @@ -5,6 +5,8 @@ find_package(Perl REQUIRED) set(USE_GNU TRUE) set(USE_KANDR TRUE) +add_compile_definitions($,USE_SERIAL_NUMBERS=1,>) + set(TOK_MODS ${CMAKE_CURRENT_SOURCE_DIR}/cc_tokens.tok) set(LEXER_MODS ${CMAKE_CURRENT_SOURCE_DIR}/cc.lex) set(CC_AST_MODS @@ -40,13 +42,16 @@ set(XML_ASTGEN ${CMAKE_CURRENT_BINARY_DIR}/xml_ast_reader_1defn.gen.cc ${CMAKE_CURRENT_BINARY_DIR}/xml_ast_reader_2ctrc.gen.cc) -add_custom_command( - OUTPUT ${XML_ASTGEN} - # COMMAND ${CMAKE_COMMAND} -E rm -f ${XML_ASTGEN} - COMMAND astgen -tr no_ast.gen,xmlParser -v -o${CMAKE_CURRENT_BINARY_DIR}/xml_ast ${CC_AST_MODS} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - DEPENDS ${CC_AST_MODS} - VERBATIM) +add_astgen_command( + INPUTS + ${CC_AST_MODS} + OUTPUTS + ${XML_ASTGEN} + OUTPUT_PREFIX + ${CMAKE_CURRENT_BINARY_DIR}/xml_ast + TRANSLATE_OPTIONS + no_ast.get + xmlParser) #### single-source of lexing token definitions: @@ -78,25 +83,8 @@ add_custom_command( VERBATIM) # run flex on the lexer description for ast xml parser -# flex_target(xml_lex ${CMAKE_CURRENT_BINARY_DIR}/xml_lex.gen.lex -# ${CMAKE_CURRENT_BINARY_DIR}/xml_lex.gen.yy.cc COMPILE_FLAGS "-v") add_wrapped_flex(xml_lex ${CMAKE_CURRENT_BINARY_DIR}/xml_lex.gen.lex xml_lex.gen.yy.cc) -# set(RUN_FLEX ${CMAKE_CURRENT_SOURCE_DIR}/../smbase/run-flex.pl) -# add_custom_command( -# OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/xml_lex.gen.yy.cc -# COMMAND -# ${PERL_EXECUTABLE} ${RUN_FLEX} -nobackup -copies -# -o${CMAKE_CURRENT_BINARY_DIR}/xml_lex.gen.yy.cc ${CMAKE_CURRENT_BINARY_DIR}/xml_lex.gen.lex -# DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/xml_lex.gen.lex ${RUN_FLEX} -# COMMENT "Running run-flex.pl wrapper to generate xml_lex.gen.yy.cc" -# VERBATIM) - -# add_library(elsa_xml_flex OBJECT ) -# target_include_directories(elsa_xml_flex PRIVATE . ${CMAKE_CURRENT_BINARY_DIR}) -# target_link_libraries(elsa_xml_flex PUBLIC smbase elkhound-lib) - -# the cc files in here are included from within another cc, so hard to make a clean dep -# add_dependencies(elsa_xml_flex elsa_xml_generated_files) + add_library( elsa_xml_objs OBJECT xml_lexer.cc @@ -142,22 +130,19 @@ add_custom_command( VERBATIM) # run flex on the lexer description -# flex_target(lexer ${CMAKE_CURRENT_BINARY_DIR}/lexer.lex ${CMAKE_CURRENT_BINARY_DIR}/lexer.yy.cc) -add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lexer.yy.cc - COMMAND - ${PERL_EXECUTABLE} ${RUN_FLEX} -nobackup -copies -o${CMAKE_CURRENT_BINARY_DIR}/lexer.yy.cc - ${CMAKE_CURRENT_BINARY_DIR}/lexer.lex - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/lexer.lex ${RUN_FLEX} - COMMENT "Running run-flex.pl wrapper to generate lexer.yy.cc" - VERBATIM) + +add_wrapped_flex(lexer ${CMAKE_CURRENT_BINARY_DIR}/lexer.lex + ${CMAKE_CURRENT_BINARY_DIR}/lexer.yy.cc) # run astgen to generate the AST implementation -add_custom_command( - OUTPUT ${CC_AST_CC} ${CC_AST_H} - COMMAND astgen -v -o${CMAKE_CURRENT_BINARY_DIR}/cc.ast.gen ${CC_AST_MODS} - DEPENDS ${CC_AST_MODS} - VERBATIM) +add_astgen_command( + INPUTS + ${CC_AST_MODS} + OUTPUTS + ${CC_AST_CC} + ${CC_AST_H} + OUTPUT_PREFIX + ${CMAKE_CURRENT_BINARY_DIR}/cc.ast.gen) add_library( elsa_lexer_objs OBJECT @@ -165,23 +150,23 @@ add_library( baselexer.cc lexer.cc ${CMAKE_CURRENT_BINARY_DIR}/cc_tokens.cc - # ${FLEX_lexer_OUTPUTS} ${CMAKE_CURRENT_BINARY_DIR}/lexer.yy.cc cc_lang.cc) target_link_libraries(elsa_lexer_objs PUBLIC smbase elkhound-lib ast) target_include_directories(elsa_lexer_objs PUBLIC . ${CMAKE_CURRENT_BINARY_DIR}) -set(GR_GEN_OUTPUTS ${CMAKE_CURRENT_BINARY_DIR}/cc.gr.gen.cc ${CMAKE_CURRENT_BINARY_DIR}/cc.gr.gen.h - ${CMAKE_CURRENT_BINARY_DIR}/cc.gr.gen.y) -add_custom_command( - OUTPUT ${GR_GEN_OUTPUTS} ${CMAKE_CURRENT_BINARY_DIR}/cc.gr.gen.out - COMMAND ${CMAKE_COMMAND} -E rm -f ${GR_GEN_OUTPUTS} - COMMAND elkhound -v -tr lrtable -o ${CMAKE_CURRENT_BINARY_DIR}/cc.gr.gen ${CC_GR_MODS} - DEPENDS ${CC_GR_MODS} ${CMAKE_CURRENT_BINARY_DIR}/cc_tokens.ids - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMENT "Running elkhound to generate ${GR_GEN_OUTPUTS}" - USES_TERMINAL VERBATIM) -add_library(ccparse_objs STATIC +add_elkhound_command( + INPUTS + ${CC_GR_MODS} + OUTPUT_PREFIX + ${CMAKE_CURRENT_BINARY_DIR}/cc.gr.gen + CC_OUTPUT_VAR + CC_GR_GEN_OUTPUTS + EXTRA_DEPENDS + ${CMAKE_CURRENT_BINARY_DIR}/cc_tokens.ids) + +add_library( + ccparse_objs STATIC bpprint.cc ia64mangle.cc mtype.cc @@ -199,11 +184,7 @@ add_library(ccparse_objs STATIC ast_build.cc ${CC_AST_H} $ - # $ $ - # $(LEXER_OBJS) - # $(XML_OBJS) - # $(EXT_OBJS) builtinops.cc cfg.cc sprint.cc @@ -216,7 +197,7 @@ add_library(ccparse_objs STATIC typelistiter.cc ${CC_AST_CC} ${CC_AST_H} - ${GR_GEN_OUTPUTS} + ${CC_GR_GEN_OUTPUTS} parssppt.cc cc_flags.cc cc_print.cc @@ -234,17 +215,14 @@ if(USE_KANDR) target_sources(ccparse_objs PRIVATE kandr.cc) endif() -add_executable( - ccparse - main.cc) +add_executable(ccparse main.cc) target_link_libraries(ccparse PRIVATE ccparse_objs) - -add_executable( - semgrep - semgrep.cc) +add_executable(semgrep semgrep.cc) target_link_libraries(semgrep PRIVATE ccparse_objs) +install(TARGETS ccparse semgrep RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + # TODO needs a flex invocation # add_executable( # iptparse From fdb1f3f371e3c588e9ab2784566d1a31b6560653 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Mon, 21 Nov 2022 17:00:11 -0600 Subject: [PATCH 17/20] Remove more things we can generate --- ast/agrampar.codes.h | 34 - ast/agrampar.tab.cc | 2103 -------------------------------------- ast/agrampar.tab.h | 141 --- elkhound/grampar.codes.h | 30 - elkhound/grampar.tab.cc | 2056 ------------------------------------- elkhound/grampar.tab.h | 136 --- 6 files changed, 4500 deletions(-) delete mode 100644 ast/agrampar.codes.h delete mode 100644 ast/agrampar.tab.cc delete mode 100644 ast/agrampar.tab.h delete mode 100644 elkhound/grampar.codes.h delete mode 100644 elkhound/grampar.tab.cc delete mode 100644 elkhound/grampar.tab.h diff --git a/ast/agrampar.codes.h b/ast/agrampar.codes.h deleted file mode 100644 index d8f5456..0000000 --- a/ast/agrampar.codes.h +++ /dev/null @@ -1,34 +0,0 @@ -# define YYTOKENTYPE -#define TOK_NAME 258 -#define TOK_INTLIT 259 -#define TOK_EMBEDDED_CODE 260 -#define TOK_LBRACE 261 -#define TOK_RBRACE 262 -#define TOK_SEMICOLON 263 -#define TOK_ARROW 264 -#define TOK_LPAREN 265 -#define TOK_RPAREN 266 -#define TOK_LANGLE 267 -#define TOK_RANGLE 268 -#define TOK_STAR 269 -#define TOK_AMPERSAND 270 -#define TOK_COMMA 271 -#define TOK_EQUALS 272 -#define TOK_COLON 273 -#define TOK_CLASS 274 -#define TOK_PUBLIC 275 -#define TOK_PRIVATE 276 -#define TOK_PROTECTED 277 -#define TOK_VERBATIM 278 -#define TOK_IMPL_VERBATIM 279 -#define TOK_XML_VERBATIM 280 -#define TOK_CTOR 281 -#define TOK_DTOR 282 -#define TOK_PURE_VIRTUAL 283 -#define TOK_CUSTOM 284 -#define TOK_OPTION 285 -#define TOK_NEW 286 -#define TOK_ENUM 287 -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 diff --git a/ast/agrampar.tab.cc b/ast/agrampar.tab.cc deleted file mode 100644 index 1c48736..0000000 --- a/ast/agrampar.tab.cc +++ /dev/null @@ -1,2103 +0,0 @@ -/* A Bison parser, made by GNU Bison 2.3. */ - -/* Skeleton implementation for Bison's Yacc-like parsers in C - - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 - Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ - -/* As a special exception, you may create a larger work that contains - part or all of the Bison parser skeleton and distribute that work - under terms of your choice, so long as that work isn't itself a - parser generator using the skeleton or a modified version thereof - as a parser skeleton. Alternatively, if you modify or redistribute - the parser skeleton itself, you may (at your option) remove this - special exception, which will cause the skeleton and the resulting - Bison output files to be licensed under the GNU General Public - License without this special exception. - - This special exception was added by the Free Software Foundation in - version 2.2 of Bison. */ - -/* C LALR(1) parser skeleton written by Richard Stallman, by - simplifying the original so-called "semantic" parser. */ - -/* All symbols defined below should begin with yy or YY, to avoid - infringing on user name space. This should be done even for local - variables, as they might otherwise be expanded by user macros. - There are some unavoidable exceptions within include files to - define necessary library symbols; they are noted "INFRINGES ON - USER NAME SPACE" below. */ - -/* Identify Bison output. */ -#define YYBISON 1 - -/* Bison version. */ -#define YYBISON_VERSION "2.3" - -/* Skeleton name. */ -#define YYSKELETON_NAME "yacc.c" - -/* Pure parsers. */ -#define YYPURE 1 - -/* Using locations. */ -#define YYLSP_NEEDED 0 - - - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - TOK_NAME = 258, - TOK_INTLIT = 259, - TOK_EMBEDDED_CODE = 260, - TOK_LBRACE = 261, - TOK_RBRACE = 262, - TOK_SEMICOLON = 263, - TOK_ARROW = 264, - TOK_LPAREN = 265, - TOK_RPAREN = 266, - TOK_LANGLE = 267, - TOK_RANGLE = 268, - TOK_STAR = 269, - TOK_AMPERSAND = 270, - TOK_COMMA = 271, - TOK_EQUALS = 272, - TOK_COLON = 273, - TOK_CLASS = 274, - TOK_PUBLIC = 275, - TOK_PRIVATE = 276, - TOK_PROTECTED = 277, - TOK_VERBATIM = 278, - TOK_IMPL_VERBATIM = 279, - TOK_XML_VERBATIM = 280, - TOK_CTOR = 281, - TOK_DTOR = 282, - TOK_PURE_VIRTUAL = 283, - TOK_CUSTOM = 284, - TOK_OPTION = 285, - TOK_NEW = 286, - TOK_ENUM = 287 - }; -#endif -/* Tokens. */ -#define TOK_NAME 258 -#define TOK_INTLIT 259 -#define TOK_EMBEDDED_CODE 260 -#define TOK_LBRACE 261 -#define TOK_RBRACE 262 -#define TOK_SEMICOLON 263 -#define TOK_ARROW 264 -#define TOK_LPAREN 265 -#define TOK_RPAREN 266 -#define TOK_LANGLE 267 -#define TOK_RANGLE 268 -#define TOK_STAR 269 -#define TOK_AMPERSAND 270 -#define TOK_COMMA 271 -#define TOK_EQUALS 272 -#define TOK_COLON 273 -#define TOK_CLASS 274 -#define TOK_PUBLIC 275 -#define TOK_PRIVATE 276 -#define TOK_PROTECTED 277 -#define TOK_VERBATIM 278 -#define TOK_IMPL_VERBATIM 279 -#define TOK_XML_VERBATIM 280 -#define TOK_CTOR 281 -#define TOK_DTOR 282 -#define TOK_PURE_VIRTUAL 283 -#define TOK_CUSTOM 284 -#define TOK_OPTION 285 -#define TOK_NEW 286 -#define TOK_ENUM 287 - - - - -/* Copy the first part of user declarations. */ -#line 6 "agrampar.y" - - -#include "agrampar.h" // agrampar_yylex, etc. - -#include // malloc, free -#include // cout - -// enable debugging the parser -#ifndef NDEBUG - #define YYDEBUG 1 -#endif - -// permit having other parser's codes in the same program -#define yyparse agrampar_yyparse - - - -/* Enabling traces. */ -#ifndef YYDEBUG -# define YYDEBUG 0 -#endif - -/* Enabling verbose error messages. */ -#ifdef YYERROR_VERBOSE -# undef YYERROR_VERBOSE -# define YYERROR_VERBOSE 1 -#else -# define YYERROR_VERBOSE 0 -#endif - -/* Enabling the token table. */ -#ifndef YYTOKEN_TABLE -# define YYTOKEN_TABLE 0 -#endif - -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -typedef union YYSTYPE -#line 69 "agrampar.y" -{ - ASTSpecFile *file; - ASTList *formList; - TF_class *tfClass; - ASTList *ctorArgList; - ASTList *userDeclList; - string *str; - enum AccessCtl accessCtl; - AccessMod *accessMod; - ToplevelForm *verbatim; - Annotation *annotation; - TF_option *tfOption; - ASTList *stringList; - TF_enum *tfEnum; - ASTList *enumeratorList; - string *enumerator; - ASTList *baseClassList; - BaseClass *baseClass; - CustomCode *customCode; -} -/* Line 193 of yacc.c. */ -#line 198 "agrampar.tab.c" - YYSTYPE; -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 -#endif - - - -/* Copy the second part of user declarations. */ - - -/* Line 216 of yacc.c. */ -#line 211 "agrampar.tab.c" - -#ifdef short -# undef short -#endif - -#ifdef YYTYPE_UINT8 -typedef YYTYPE_UINT8 yytype_uint8; -#else -typedef unsigned char yytype_uint8; -#endif - -#ifdef YYTYPE_INT8 -typedef YYTYPE_INT8 yytype_int8; -#elif (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -typedef signed char yytype_int8; -#else -typedef short int yytype_int8; -#endif - -#ifdef YYTYPE_UINT16 -typedef YYTYPE_UINT16 yytype_uint16; -#else -typedef unsigned short int yytype_uint16; -#endif - -#ifdef YYTYPE_INT16 -typedef YYTYPE_INT16 yytype_int16; -#else -typedef short int yytype_int16; -#endif - -#ifndef YYSIZE_T -# ifdef __SIZE_TYPE__ -# define YYSIZE_T __SIZE_TYPE__ -# elif defined size_t -# define YYSIZE_T size_t -# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -# include /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# else -# define YYSIZE_T unsigned int -# endif -#endif - -#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) - -#ifndef YY_ -# if defined YYENABLE_NLS && YYENABLE_NLS -# if ENABLE_NLS -# include /* INFRINGES ON USER NAME SPACE */ -# define YY_(msgid) dgettext ("bison-runtime", msgid) -# endif -# endif -# ifndef YY_ -# define YY_(msgid) msgid -# endif -#endif - -/* Suppress unused-variable warnings by "using" E. */ -#if ! defined lint || defined __GNUC__ -# define YYUSE(e) ((void) (e)) -#else -# define YYUSE(e) /* empty */ -#endif - -/* Identity function, used to suppress warnings about constant conditions. */ -#ifndef lint -# define YYID(n) (n) -#else -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static int -YYID (int i) -#else -static int -YYID (i) - int i; -#endif -{ - return i; -} -#endif - -#if ! defined yyoverflow || YYERROR_VERBOSE - -/* The parser invokes alloca or malloc; define the necessary symbols. */ - -# ifdef YYSTACK_USE_ALLOCA -# if YYSTACK_USE_ALLOCA -# ifdef __GNUC__ -# define YYSTACK_ALLOC __builtin_alloca -# elif defined __BUILTIN_VA_ARG_INCR -# include /* INFRINGES ON USER NAME SPACE */ -# elif defined _AIX -# define YYSTACK_ALLOC __alloca -# elif defined _MSC_VER -# include /* INFRINGES ON USER NAME SPACE */ -# define alloca _alloca -# else -# define YYSTACK_ALLOC alloca -# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -# include /* INFRINGES ON USER NAME SPACE */ -# ifndef _STDLIB_H -# define _STDLIB_H 1 -# endif -# endif -# endif -# endif -# endif - -# ifdef YYSTACK_ALLOC - /* Pacify GCC's `empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) -# ifndef YYSTACK_ALLOC_MAXIMUM - /* The OS might guarantee only one guard page at the bottom of the stack, - and a page size can be as small as 4096 bytes. So we cannot safely - invoke alloca (N) if N exceeds 4096. Use a slightly smaller number - to allow for a few compiler-allocated temporary stack slots. */ -# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ -# endif -# else -# define YYSTACK_ALLOC YYMALLOC -# define YYSTACK_FREE YYFREE -# ifndef YYSTACK_ALLOC_MAXIMUM -# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM -# endif -# if (defined __cplusplus && ! defined _STDLIB_H \ - && ! ((defined YYMALLOC || defined malloc) \ - && (defined YYFREE || defined free))) -# include /* INFRINGES ON USER NAME SPACE */ -# ifndef _STDLIB_H -# define _STDLIB_H 1 -# endif -# endif -# ifndef YYMALLOC -# define YYMALLOC malloc -# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ -# endif -# endif -# ifndef YYFREE -# define YYFREE free -# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -void free (void *); /* INFRINGES ON USER NAME SPACE */ -# endif -# endif -# endif -#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ - - -#if (! defined yyoverflow \ - && (! defined __cplusplus \ - || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) - -/* A type that is properly aligned for any stack member. */ -union yyalloc -{ - yytype_int16 yyss; - YYSTYPE yyvs; - }; - -/* The size of the maximum gap between one aligned stack and the next. */ -# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) - -/* The size of an array large to enough to hold all stacks, each with - N elements. */ -# define YYSTACK_BYTES(N) \ - ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ - + YYSTACK_GAP_MAXIMUM) - -/* Copy COUNT objects from FROM to TO. The source and destination do - not overlap. */ -# ifndef YYCOPY -# if defined __GNUC__ && 1 < __GNUC__ -# define YYCOPY(To, From, Count) \ - __builtin_memcpy (To, From, (Count) * sizeof (*(From))) -# else -# define YYCOPY(To, From, Count) \ - do \ - { \ - YYSIZE_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (To)[yyi] = (From)[yyi]; \ - } \ - while (YYID (0)) -# endif -# endif - -/* Relocate STACK from its old location to the new one. The - local variables YYSIZE and YYSTACKSIZE give the old and new number of - elements in the stack, and YYPTR gives the new location of the - stack. Advance YYPTR to a properly aligned location for the next - stack. */ -# define YYSTACK_RELOCATE(Stack) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack, Stack, yysize); \ - Stack = &yyptr->Stack; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ - } \ - while (YYID (0)) - -#endif - -/* YYFINAL -- State number of the termination state. */ -#define YYFINAL 3 -/* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 114 - -/* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 33 -/* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 30 -/* YYNRULES -- Number of rules. */ -#define YYNRULES 73 -/* YYNRULES -- Number of states. */ -#define YYNSTATES 116 - -/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ -#define YYUNDEFTOK 2 -#define YYMAXUTOK 287 - -#define YYTRANSLATE(YYX) \ - ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) - -/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ -static const yytype_uint8 yytranslate[] = -{ - 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, - 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32 -}; - -#if YYDEBUG -/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in - YYRHS. */ -static const yytype_uint8 yyprhs[] = -{ - 0, 0, 3, 5, 6, 9, 12, 15, 18, 21, - 24, 31, 39, 40, 42, 46, 48, 49, 56, 65, - 68, 69, 71, 74, 78, 80, 84, 86, 89, 91, - 93, 97, 99, 101, 103, 105, 107, 111, 112, 115, - 118, 124, 126, 130, 133, 137, 139, 141, 143, 145, - 147, 149, 151, 156, 158, 162, 165, 168, 171, 176, - 177, 180, 186, 193, 195, 199, 201, 202, 205, 207, - 211, 213, 215, 217 -}; - -/* YYRHS -- A `-1'-separated list of the rules' RHS. */ -static const yytype_int8 yyrhs[] = -{ - 34, 0, -1, 35, -1, -1, 35, 36, -1, 35, - 53, -1, 35, 54, -1, 35, 56, -1, 35, 48, - -1, 35, 8, -1, 37, 19, 3, 40, 59, 38, - -1, 37, 19, 3, 41, 41, 59, 38, -1, -1, - 31, -1, 6, 39, 7, -1, 8, -1, -1, 39, - 9, 3, 40, 59, 8, -1, 39, 9, 3, 40, - 59, 6, 46, 7, -1, 39, 47, -1, -1, 41, - -1, 10, 11, -1, 10, 42, 11, -1, 43, -1, - 42, 16, 43, -1, 44, -1, 43, 44, -1, 3, - -1, 4, -1, 12, 45, 13, -1, 14, -1, 15, - -1, 17, -1, 19, -1, 43, -1, 43, 16, 45, - -1, -1, 46, 47, -1, 51, 49, -1, 51, 5, - 17, 5, 8, -1, 48, -1, 29, 3, 49, -1, - 5, 8, -1, 6, 5, 7, -1, 20, -1, 21, - -1, 22, -1, 26, -1, 27, -1, 28, -1, 50, - -1, 50, 10, 52, 11, -1, 3, -1, 52, 16, - 3, -1, 23, 49, -1, 24, 49, -1, 25, 49, - -1, 30, 3, 55, 8, -1, -1, 55, 3, -1, - 32, 3, 6, 57, 7, -1, 32, 3, 6, 57, - 16, 7, -1, 58, -1, 57, 16, 58, -1, 3, - -1, -1, 18, 60, -1, 62, -1, 60, 16, 62, - -1, 20, -1, 21, -1, 22, -1, 61, 3, -1 -}; - -/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ -static const yytype_uint16 yyrline[] = -{ - 0, 116, 116, 122, 123, 124, 125, 126, 127, 128, - 133, 137, 145, 146, 158, 160, 168, 169, 171, 173, - 181, 182, 188, 190, 195, 202, 207, 209, 215, 216, - 217, 218, 219, 220, 221, 225, 227, 234, 235, 241, - 243, 245, 251, 257, 259, 265, 266, 267, 268, 269, - 270, 274, 276, 281, 283, 288, 290, 292, 297, 303, - 304, 309, 311, 316, 318, 323, 329, 330, 335, 337, - 343, 344, 345, 349 -}; -#endif - -#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE -/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. - First, the terminals, then, starting at YYNTOKENS, nonterminals. */ -static const char *const yytname[] = -{ - "$end", "error", "$undefined", "TOK_NAME", "TOK_INTLIT", - "TOK_EMBEDDED_CODE", "\"{\"", "\"}\"", "\";\"", "\"->\"", "\"(\"", - "\")\"", "\"<\"", "\">\"", "\"*\"", "\"&\"", "\",\"", "\"=\"", "\":\"", - "\"class\"", "\"public\"", "\"private\"", "\"protected\"", - "\"verbatim\"", "\"impl_verbatim\"", "\"xml_verbatim\"", "\"ctor\"", - "\"dtor\"", "\"pure_virtual\"", "\"custom\"", "\"option\"", "\"new\"", - "\"enum\"", "$accept", "StartSymbol", "Input", "Class", "NewOpt", - "ClassBody", "ClassMembersOpt", "CtorArgsOpt", "CtorArgs", "CtorArgList", - "Arg", "ArgWord", "ArgList", "CtorMembersOpt", "Annotation", - "CustomCode", "Embedded", "Public", "AccessMod", "StringList", - "Verbatim", "Option", "OptionArgs", "Enum", "EnumeratorSeq", - "Enumerator", "BaseClassesOpt", "BaseClassSeq", "BaseAccess", - "BaseClass", 0 -}; -#endif - -# ifdef YYPRINT -/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to - token YYLEX-NUM. */ -static const yytype_uint16 yytoknum[] = -{ - 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, - 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, - 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, - 285, 286, 287 -}; -# endif - -/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const yytype_uint8 yyr1[] = -{ - 0, 33, 34, 35, 35, 35, 35, 35, 35, 35, - 36, 36, 37, 37, 38, 38, 39, 39, 39, 39, - 40, 40, 41, 41, 42, 42, 43, 43, 44, 44, - 44, 44, 44, 44, 44, 45, 45, 46, 46, 47, - 47, 47, 48, 49, 49, 50, 50, 50, 50, 50, - 50, 51, 51, 52, 52, 53, 53, 53, 54, 55, - 55, 56, 56, 57, 57, 58, 59, 59, 60, 60, - 61, 61, 61, 62 -}; - -/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ -static const yytype_uint8 yyr2[] = -{ - 0, 2, 1, 0, 2, 2, 2, 2, 2, 2, - 6, 7, 0, 1, 3, 1, 0, 6, 8, 2, - 0, 1, 2, 3, 1, 3, 1, 2, 1, 1, - 3, 1, 1, 1, 1, 1, 3, 0, 2, 2, - 5, 1, 3, 2, 3, 1, 1, 1, 1, 1, - 1, 1, 4, 1, 3, 2, 2, 2, 4, 0, - 2, 5, 6, 1, 3, 1, 0, 2, 1, 3, - 1, 1, 1, 2 -}; - -/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state - STATE-NUM when YYTABLE doesn't specify something else to do. Zero - means the default is an error. */ -static const yytype_uint8 yydefact[] = -{ - 3, 0, 2, 1, 9, 0, 0, 0, 0, 0, - 13, 0, 4, 0, 8, 5, 6, 7, 0, 0, - 55, 56, 57, 0, 59, 0, 0, 43, 0, 42, - 0, 0, 20, 44, 60, 58, 65, 0, 63, 0, - 66, 21, 61, 0, 28, 29, 22, 0, 31, 32, - 33, 34, 0, 24, 26, 0, 0, 66, 62, 64, - 35, 0, 23, 0, 27, 70, 71, 72, 67, 0, - 68, 16, 15, 10, 0, 0, 30, 25, 0, 73, - 0, 11, 36, 69, 14, 0, 45, 46, 47, 48, - 49, 50, 19, 41, 51, 0, 20, 0, 0, 39, - 66, 21, 53, 0, 0, 0, 52, 0, 0, 37, - 17, 54, 40, 0, 18, 38 -}; - -/* YYDEFGOTO[NTERM-NUM]. */ -static const yytype_int8 yydefgoto[] = -{ - -1, 1, 2, 12, 13, 73, 80, 40, 41, 52, - 60, 54, 61, 113, 92, 93, 20, 94, 95, 103, - 15, 16, 30, 17, 37, 38, 56, 68, 69, 70 -}; - -/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ -#define YYPACT_NINF -55 -static const yytype_int8 yypact[] = -{ - -55, 11, -4, -55, -55, 26, 26, 26, 20, 36, - -55, 70, -55, 33, -55, -55, -55, -55, 52, 72, - -55, -55, -55, 26, -55, 69, 79, -55, 83, -55, - 5, 88, 76, -55, -55, -55, -55, 0, -55, 47, - 74, 76, -55, 7, -55, -55, -55, 81, -55, -55, - -55, -55, 22, 81, -55, 49, 57, 74, -55, -55, - 64, 84, -55, 81, -55, -55, -55, -55, 78, 96, - -55, -55, -55, -55, 57, 81, -55, 81, 49, -55, - 15, -55, -55, -55, -55, 98, -55, -55, -55, -55, - -55, -55, -55, -55, 92, 82, 76, 100, 1, -55, - 74, -55, -55, 29, 99, 66, -55, 102, 101, -55, - -55, -55, -55, 27, -55, -55 -}; - -/* YYPGOTO[NTERM-NUM]. */ -static const yytype_int8 yypgoto[] = -{ - -55, -55, -55, -55, -55, 32, -55, 12, -39, -55, - -33, -48, 35, -55, -2, 105, -6, -55, -55, -55, - -55, -55, -55, -55, -55, 71, -54, -55, -55, 34 -}; - -/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If - positive, shift that token. If negative, reduce the rule which - number is the opposite. If zero, do what YYDEFACT says. - If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -13 -static const yytype_int8 yytable[] = -{ - 21, 22, 57, 74, 4, 64, 53, 42, 34, 27, - 36, 3, 64, 35, 58, -12, 43, 29, 104, 5, - 6, 7, 84, 23, 85, 8, 9, 10, 11, 64, - 77, 18, 19, 62, 114, 86, 87, 88, 63, 24, - 106, 89, 90, 91, 8, 107, 105, 86, 87, 88, - 44, 45, 26, 89, 90, 91, 8, 101, 46, 47, - 27, 48, 49, 71, 50, 72, 51, 44, 45, 65, - 66, 67, 109, 25, 110, 31, 47, 28, 48, 49, - 75, 50, 32, 51, 44, 45, 39, 98, 19, 99, - 33, 36, 55, 47, 78, 48, 49, 76, 50, 79, - 51, 96, 97, 102, 108, 111, 81, 14, 100, 112, - 82, 115, 83, 0, 59 -}; - -static const yytype_int8 yycheck[] = -{ - 6, 7, 41, 57, 8, 53, 39, 7, 3, 8, - 3, 0, 60, 8, 7, 19, 16, 23, 17, 23, - 24, 25, 7, 3, 9, 29, 30, 31, 32, 77, - 63, 5, 6, 11, 7, 20, 21, 22, 16, 3, - 11, 26, 27, 28, 29, 16, 100, 20, 21, 22, - 3, 4, 19, 26, 27, 28, 29, 96, 11, 12, - 8, 14, 15, 6, 17, 8, 19, 3, 4, 20, - 21, 22, 6, 3, 8, 6, 12, 5, 14, 15, - 16, 17, 3, 19, 3, 4, 10, 5, 6, 95, - 7, 3, 18, 12, 16, 14, 15, 13, 17, 3, - 19, 3, 10, 3, 5, 3, 74, 2, 96, 8, - 75, 113, 78, -1, 43 -}; - -/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing - symbol of state STATE-NUM. */ -static const yytype_uint8 yystos[] = -{ - 0, 34, 35, 0, 8, 23, 24, 25, 29, 30, - 31, 32, 36, 37, 48, 53, 54, 56, 5, 6, - 49, 49, 49, 3, 3, 3, 19, 8, 5, 49, - 55, 6, 3, 7, 3, 8, 3, 57, 58, 10, - 40, 41, 7, 16, 3, 4, 11, 12, 14, 15, - 17, 19, 42, 43, 44, 18, 59, 41, 7, 58, - 43, 45, 11, 16, 44, 20, 21, 22, 60, 61, - 62, 6, 8, 38, 59, 16, 13, 43, 16, 3, - 39, 38, 45, 62, 7, 9, 20, 21, 22, 26, - 27, 28, 47, 48, 50, 51, 3, 10, 5, 49, - 40, 41, 3, 52, 17, 59, 11, 16, 5, 6, - 8, 3, 8, 46, 7, 47 -}; - -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 - -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrorlab - - -/* Like YYERROR except do call yyerror. This remains here temporarily - to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. */ - -#define YYFAIL goto yyerrlab - -#define YYRECOVERING() (!!yyerrstatus) - -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY && yylen == 1) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - yytoken = YYTRANSLATE (yychar); \ - YYPOPSTACK (1); \ - goto yybackup; \ - } \ - else \ - { \ - yyerror (YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ -while (YYID (0)) - - -#define YYTERROR 1 -#define YYERRCODE 256 - - -/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. - If N is 0, then set CURRENT to the empty location which ends - the previous symbol: RHS[0] (always defined). */ - -#define YYRHSLOC(Rhs, K) ((Rhs)[K]) -#ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - do \ - if (YYID (N)) \ - { \ - (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ - (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ - (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ - (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ - } \ - else \ - { \ - (Current).first_line = (Current).last_line = \ - YYRHSLOC (Rhs, 0).last_line; \ - (Current).first_column = (Current).last_column = \ - YYRHSLOC (Rhs, 0).last_column; \ - } \ - while (YYID (0)) -#endif - - -/* YY_LOCATION_PRINT -- Print the location on the stream. - This macro was not mandated originally: define only if we know - we won't break user code: when these are the locations we know. */ - -#ifndef YY_LOCATION_PRINT -# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL -# define YY_LOCATION_PRINT(File, Loc) \ - fprintf (File, "%d.%d-%d.%d", \ - (Loc).first_line, (Loc).first_column, \ - (Loc).last_line, (Loc).last_column) -# else -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) -# endif -#endif - - -/* YYLEX -- calling `yylex' with the right arguments. */ - -#ifdef YYLEX_PARAM -# define YYLEX yylex (&yylval, YYLEX_PARAM) -#else -# define YYLEX yylex (&yylval) -#endif - -/* Enable debugging if requested. */ -#if YYDEBUG - -# ifndef YYFPRINTF -# include /* INFRINGES ON USER NAME SPACE */ -# define YYFPRINTF fprintf -# endif - -# define YYDPRINTF(Args) \ -do { \ - if (yydebug) \ - YYFPRINTF Args; \ -} while (YYID (0)) - -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yy_symbol_print (stderr, \ - Type, Value); \ - YYFPRINTF (stderr, "\n"); \ - } \ -} while (YYID (0)) - - -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ - -/*ARGSUSED*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) -#else -static void -yy_symbol_value_print (yyoutput, yytype, yyvaluep) - FILE *yyoutput; - int yytype; - YYSTYPE const * const yyvaluep; -#endif -{ - if (!yyvaluep) - return; -# ifdef YYPRINT - if (yytype < YYNTOKENS) - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); -# else - YYUSE (yyoutput); -# endif - switch (yytype) - { - default: - break; - } -} - - -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ - -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) -#else -static void -yy_symbol_print (yyoutput, yytype, yyvaluep) - FILE *yyoutput; - int yytype; - YYSTYPE const * const yyvaluep; -#endif -{ - if (yytype < YYNTOKENS) - YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); - else - YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); - - yy_symbol_value_print (yyoutput, yytype, yyvaluep); - YYFPRINTF (yyoutput, ")"); -} - -/*------------------------------------------------------------------. -| yy_stack_print -- Print the state stack from its BOTTOM up to its | -| TOP (included). | -`------------------------------------------------------------------*/ - -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) -#else -static void -yy_stack_print (bottom, top) - yytype_int16 *bottom; - yytype_int16 *top; -#endif -{ - YYFPRINTF (stderr, "Stack now"); - for (; bottom <= top; ++bottom) - YYFPRINTF (stderr, " %d", *bottom); - YYFPRINTF (stderr, "\n"); -} - -# define YY_STACK_PRINT(Bottom, Top) \ -do { \ - if (yydebug) \ - yy_stack_print ((Bottom), (Top)); \ -} while (YYID (0)) - - -/*------------------------------------------------. -| Report that the YYRULE is going to be reduced. | -`------------------------------------------------*/ - -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yy_reduce_print (YYSTYPE *yyvsp, int yyrule) -#else -static void -yy_reduce_print (yyvsp, yyrule) - YYSTYPE *yyvsp; - int yyrule; -#endif -{ - int yynrhs = yyr2[yyrule]; - int yyi; - unsigned long int yylno = yyrline[yyrule]; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", - yyrule - 1, yylno); - /* The symbols being reduced. */ - for (yyi = 0; yyi < yynrhs; yyi++) - { - fprintf (stderr, " $%d = ", yyi + 1); - yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], - &(yyvsp[(yyi + 1) - (yynrhs)]) - ); - fprintf (stderr, "\n"); - } -} - -# define YY_REDUCE_PRINT(Rule) \ -do { \ - if (yydebug) \ - yy_reduce_print (yyvsp, Rule); \ -} while (YYID (0)) - -/* Nonzero means print parse trace. It is left uninitialized so that - multiple parsers can coexist. */ -int yydebug; -#else /* !YYDEBUG */ -# define YYDPRINTF(Args) -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) -# define YY_STACK_PRINT(Bottom, Top) -# define YY_REDUCE_PRINT(Rule) -#endif /* !YYDEBUG */ - - -/* YYINITDEPTH -- initial size of the parser's stacks. */ -#ifndef YYINITDEPTH -# define YYINITDEPTH 200 -#endif - -/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only - if the built-in stack extension method is used). - - Do not make this value too large; the results are undefined if - YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) - evaluated with infinite-precision integer arithmetic. */ - -#ifndef YYMAXDEPTH -# define YYMAXDEPTH 10000 -#endif - - - -#if YYERROR_VERBOSE - -# ifndef yystrlen -# if defined __GLIBC__ && defined _STRING_H -# define yystrlen strlen -# else -/* Return the length of YYSTR. */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static YYSIZE_T -yystrlen (const char *yystr) -#else -static YYSIZE_T -yystrlen (yystr) - const char *yystr; -#endif -{ - YYSIZE_T yylen; - for (yylen = 0; yystr[yylen]; yylen++) - continue; - return yylen; -} -# endif -# endif - -# ifndef yystpcpy -# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE -# define yystpcpy stpcpy -# else -/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in - YYDEST. */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static char * -yystpcpy (char *yydest, const char *yysrc) -#else -static char * -yystpcpy (yydest, yysrc) - char *yydest; - const char *yysrc; -#endif -{ - char *yyd = yydest; - const char *yys = yysrc; - - while ((*yyd++ = *yys++) != '\0') - continue; - - return yyd - 1; -} -# endif -# endif - -# ifndef yytnamerr -/* Copy to YYRES the contents of YYSTR after stripping away unnecessary - quotes and backslashes, so that it's suitable for yyerror. The - heuristic is that double-quoting is unnecessary unless the string - contains an apostrophe, a comma, or backslash (other than - backslash-backslash). YYSTR is taken from yytname. If YYRES is - null, do not copy; instead, return the length of what the result - would have been. */ -static YYSIZE_T -yytnamerr (char *yyres, const char *yystr) -{ - if (*yystr == '"') - { - YYSIZE_T yyn = 0; - char const *yyp = yystr; - - for (;;) - switch (*++yyp) - { - case '\'': - case ',': - goto do_not_strip_quotes; - - case '\\': - if (*++yyp != '\\') - goto do_not_strip_quotes; - /* Fall through. */ - default: - if (yyres) - yyres[yyn] = *yyp; - yyn++; - break; - - case '"': - if (yyres) - yyres[yyn] = '\0'; - return yyn; - } - do_not_strip_quotes: ; - } - - if (! yyres) - return yystrlen (yystr); - - return yystpcpy (yyres, yystr) - yyres; -} -# endif - -/* Copy into YYRESULT an error message about the unexpected token - YYCHAR while in state YYSTATE. Return the number of bytes copied, - including the terminating null byte. If YYRESULT is null, do not - copy anything; just return the number of bytes that would be - copied. As a special case, return 0 if an ordinary "syntax error" - message will do. Return YYSIZE_MAXIMUM if overflow occurs during - size calculation. */ -static YYSIZE_T -yysyntax_error (char *yyresult, int yystate, int yychar) -{ - int yyn = yypact[yystate]; - - if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) - return 0; - else - { - int yytype = YYTRANSLATE (yychar); - YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); - YYSIZE_T yysize = yysize0; - YYSIZE_T yysize1; - int yysize_overflow = 0; - enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - int yyx; - -# if 0 - /* This is so xgettext sees the translatable formats that are - constructed on the fly. */ - YY_("syntax error, unexpected %s"); - YY_("syntax error, unexpected %s, expecting %s"); - YY_("syntax error, unexpected %s, expecting %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); -# endif - char *yyfmt; - char const *yyf; - static char const yyunexpected[] = "syntax error, unexpected %s"; - static char const yyexpecting[] = ", expecting %s"; - static char const yyor[] = " or %s"; - char yyformat[sizeof yyunexpected - + sizeof yyexpecting - 1 - + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) - * (sizeof yyor - 1))]; - char const *yyprefix = yyexpecting; - - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn + 1; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yycount = 1; - - yyarg[0] = yytname[yytype]; - yyfmt = yystpcpy (yyformat, yyunexpected); - - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) - { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - yysize = yysize0; - yyformat[sizeof yyunexpected - 1] = '\0'; - break; - } - yyarg[yycount++] = yytname[yyx]; - yysize1 = yysize + yytnamerr (0, yytname[yyx]); - yysize_overflow |= (yysize1 < yysize); - yysize = yysize1; - yyfmt = yystpcpy (yyfmt, yyprefix); - yyprefix = yyor; - } - - yyf = YY_(yyformat); - yysize1 = yysize + yystrlen (yyf); - yysize_overflow |= (yysize1 < yysize); - yysize = yysize1; - - if (yysize_overflow) - return YYSIZE_MAXIMUM; - - if (yyresult) - { - /* Avoid sprintf, as that infringes on the user's name space. - Don't have undefined behavior even if the translation - produced a string with the wrong number of "%s"s. */ - char *yyp = yyresult; - int yyi = 0; - while ((*yyp = *yyf) != '\0') - { - if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) - { - yyp += yytnamerr (yyp, yyarg[yyi++]); - yyf += 2; - } - else - { - yyp++; - yyf++; - } - } - } - return yysize; - } -} -#endif /* YYERROR_VERBOSE */ - - -/*-----------------------------------------------. -| Release the memory associated to this symbol. | -`-----------------------------------------------*/ - -/*ARGSUSED*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) -#else -static void -yydestruct (yymsg, yytype, yyvaluep) - const char *yymsg; - int yytype; - YYSTYPE *yyvaluep; -#endif -{ - YYUSE (yyvaluep); - - if (!yymsg) - yymsg = "Deleting"; - YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); - - switch (yytype) - { - - default: - break; - } -} - - -/* Prevent warnings from -Wmissing-prototypes. */ - -#ifdef YYPARSE_PARAM -#if defined __STDC__ || defined __cplusplus -int yyparse (void *YYPARSE_PARAM); -#else -int yyparse (); -#endif -#else /* ! YYPARSE_PARAM */ -#if defined __STDC__ || defined __cplusplus -int yyparse (void); -#else -int yyparse (); -#endif -#endif /* ! YYPARSE_PARAM */ - - - - - - -/*----------. -| yyparse. | -`----------*/ - -#ifdef YYPARSE_PARAM -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -int -yyparse (void *YYPARSE_PARAM) -#else -int -yyparse (YYPARSE_PARAM) - void *YYPARSE_PARAM; -#endif -#else /* ! YYPARSE_PARAM */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -int -yyparse (void) -#else -int -yyparse () - -#endif -#endif -{ - /* The look-ahead symbol. */ -int yychar; - -/* The semantic value of the look-ahead symbol. */ -YYSTYPE yylval; - -/* Number of syntax errors so far. */ -int yynerrs; - - int yystate; - int yyn; - int yyresult; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - /* Look-ahead token as an internal (translated) token number. */ - int yytoken = 0; -#if YYERROR_VERBOSE - /* Buffer for error messages, and its allocated size. */ - char yymsgbuf[128]; - char *yymsg = yymsgbuf; - YYSIZE_T yymsg_alloc = sizeof yymsgbuf; -#endif - - /* Three stacks and their tools: - `yyss': related to states, - `yyvs': related to semantic values, - `yyls': related to locations. - - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - - /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss = yyssa; - yytype_int16 *yyssp; - - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs = yyvsa; - YYSTYPE *yyvsp; - - - -#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) - - YYSIZE_T yystacksize = YYINITDEPTH; - - /* The variables used to return semantic value and location from the - action routines. */ - YYSTYPE yyval; - - - /* The number of symbols on the RHS of the reduced rule. - Keep to zero when no symbol should be popped. */ - int yylen = 0; - - YYDPRINTF ((stderr, "Starting parse\n")); - - yystate = 0; - yyerrstatus = 0; - yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ - - /* Initialize stack pointers. - Waste one element of value and location stack - so that they stay on the same level as the state stack. - The wasted elements are never initialized. */ - - yyssp = yyss; - yyvsp = yyvs; - - goto yysetstate; - -/*------------------------------------------------------------. -| yynewstate -- Push a new state, which is found in yystate. | -`------------------------------------------------------------*/ - yynewstate: - /* In all cases, when you get here, the value and location stacks - have just been pushed. So pushing a state here evens the stacks. */ - yyssp++; - - yysetstate: - *yyssp = yystate; - - if (yyss + yystacksize - 1 <= yyssp) - { - /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = yyssp - yyss + 1; - -#ifdef yyoverflow - { - /* Give user a chance to reallocate the stack. Use copies of - these so that the &'s don't force the real ones into - memory. */ - YYSTYPE *yyvs1 = yyvs; - yytype_int16 *yyss1 = yyss; - - - /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. This used to be a - conditional around just the two extra args, but that might - be undefined if yyoverflow is a macro. */ - yyoverflow (YY_("memory exhausted"), - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), - - &yystacksize); - - yyss = yyss1; - yyvs = yyvs1; - } -#else /* no yyoverflow */ -# ifndef YYSTACK_RELOCATE - goto yyexhaustedlab; -# else - /* Extend the stack our own way. */ - if (YYMAXDEPTH <= yystacksize) - goto yyexhaustedlab; - yystacksize *= 2; - if (YYMAXDEPTH < yystacksize) - yystacksize = YYMAXDEPTH; - - { - yytype_int16 *yyss1 = yyss; - union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); - if (! yyptr) - goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss); - YYSTACK_RELOCATE (yyvs); - -# undef YYSTACK_RELOCATE - if (yyss1 != yyssa) - YYSTACK_FREE (yyss1); - } -# endif -#endif /* no yyoverflow */ - - yyssp = yyss + yysize - 1; - yyvsp = yyvs + yysize - 1; - - - YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); - - if (yyss + yystacksize - 1 <= yyssp) - YYABORT; - } - - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); - - goto yybackup; - -/*-----------. -| yybackup. | -`-----------*/ -yybackup: - - /* Do appropriate processing given the current state. Read a - look-ahead token if we need one and don't already have one. */ - - /* First try to decide what to do without reference to look-ahead token. */ - yyn = yypact[yystate]; - if (yyn == YYPACT_NINF) - goto yydefault; - - /* Not known => get a look-ahead token if don't already have one. */ - - /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ - if (yychar == YYEMPTY) - { - YYDPRINTF ((stderr, "Reading a token: ")); - yychar = YYLEX; - } - - if (yychar <= YYEOF) - { - yychar = yytoken = YYEOF; - YYDPRINTF ((stderr, "Now at end of input.\n")); - } - else - { - yytoken = YYTRANSLATE (yychar); - YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); - } - - /* If the proper action on seeing token YYTOKEN is to reduce or to - detect an error, take that action. */ - yyn += yytoken; - if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) - goto yydefault; - yyn = yytable[yyn]; - if (yyn <= 0) - { - if (yyn == 0 || yyn == YYTABLE_NINF) - goto yyerrlab; - yyn = -yyn; - goto yyreduce; - } - - if (yyn == YYFINAL) - YYACCEPT; - - /* Count tokens shifted since error; after three, turn off error - status. */ - if (yyerrstatus) - yyerrstatus--; - - /* Shift the look-ahead token. */ - YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - - /* Discard the shifted token unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; - - yystate = yyn; - *++yyvsp = yylval; - - goto yynewstate; - - -/*-----------------------------------------------------------. -| yydefault -- do the default action for the current state. | -`-----------------------------------------------------------*/ -yydefault: - yyn = yydefact[yystate]; - if (yyn == 0) - goto yyerrlab; - goto yyreduce; - - -/*-----------------------------. -| yyreduce -- Do a reduction. | -`-----------------------------*/ -yyreduce: - /* yyn is the number of a rule to reduce with. */ - yylen = yyr2[yyn]; - - /* If YYLEN is nonzero, implement the default value of the action: - `$$ = $1'. - - Otherwise, the following line sets YYVAL to garbage. - This behavior is undocumented and Bison - users should not rely upon it. Assigning to YYVAL - unconditionally makes the parser a bit smaller, and it avoids a - GCC warning that YYVAL may be used uninitialized. */ - yyval = yyvsp[1-yylen]; - - - YY_REDUCE_PRINT (yyn); - switch (yyn) - { - case 2: -#line 117 "agrampar.y" - { (yyval.file) = *((ASTSpecFile**)parseParam) = new ASTSpecFile((yyvsp[(1) - (1)].formList)); ;} - break; - - case 3: -#line 122 "agrampar.y" - { (yyval.formList) = new ASTList; ;} - break; - - case 4: -#line 123 "agrampar.y" - { ((yyval.formList)=(yyvsp[(1) - (2)].formList))->append((yyvsp[(2) - (2)].tfClass)); ;} - break; - - case 5: -#line 124 "agrampar.y" - { ((yyval.formList)=(yyvsp[(1) - (2)].formList))->append((yyvsp[(2) - (2)].verbatim)); ;} - break; - - case 6: -#line 125 "agrampar.y" - { ((yyval.formList)=(yyvsp[(1) - (2)].formList))->append((yyvsp[(2) - (2)].tfOption)); ;} - break; - - case 7: -#line 126 "agrampar.y" - { ((yyval.formList)=(yyvsp[(1) - (2)].formList))->append((yyvsp[(2) - (2)].tfEnum)); ;} - break; - - case 8: -#line 127 "agrampar.y" - { ((yyval.formList)=(yyvsp[(1) - (2)].formList))->append(new TF_custom((yyvsp[(2) - (2)].customCode))); ;} - break; - - case 9: -#line 128 "agrampar.y" - { (yyval.formList)=(yyvsp[(1) - (2)].formList); ;} - break; - - case 10: -#line 134 "agrampar.y" - { ((yyval.tfClass)=(yyvsp[(6) - (6)].tfClass))->super->name = unbox((yyvsp[(3) - (6)].str)); - (yyval.tfClass)->super->args.steal((yyvsp[(4) - (6)].ctorArgList)); - (yyval.tfClass)->super->bases.steal((yyvsp[(5) - (6)].baseClassList)); ;} - break; - - case 11: -#line 138 "agrampar.y" - { ((yyval.tfClass)=(yyvsp[(7) - (7)].tfClass))->super->name = unbox((yyvsp[(3) - (7)].str)); - (yyval.tfClass)->super->args.steal((yyvsp[(4) - (7)].ctorArgList)); - (yyval.tfClass)->super->lastArgs.steal((yyvsp[(5) - (7)].ctorArgList)); - (yyval.tfClass)->super->bases.steal((yyvsp[(6) - (7)].baseClassList)); ;} - break; - - case 12: -#line 145 "agrampar.y" - {;} - break; - - case 13: -#line 146 "agrampar.y" - {;} - break; - - case 14: -#line 159 "agrampar.y" - { (yyval.tfClass)=(yyvsp[(2) - (3)].tfClass); ;} - break; - - case 15: -#line 161 "agrampar.y" - { (yyval.tfClass) = new TF_class(new ASTClass("(placeholder)", NULL, NULL, NULL, NULL), NULL); ;} - break; - - case 16: -#line 168 "agrampar.y" - { (yyval.tfClass) = new TF_class(new ASTClass("(placeholder)", NULL, NULL, NULL, NULL), NULL); ;} - break; - - case 17: -#line 170 "agrampar.y" - { ((yyval.tfClass)=(yyvsp[(1) - (6)].tfClass))->ctors.append(new ASTClass(unbox((yyvsp[(3) - (6)].str)), (yyvsp[(4) - (6)].ctorArgList), NULL, (yyvsp[(5) - (6)].baseClassList), NULL)); ;} - break; - - case 18: -#line 172 "agrampar.y" - { ((yyval.tfClass)=(yyvsp[(1) - (8)].tfClass))->ctors.append(new ASTClass(unbox((yyvsp[(3) - (8)].str)), (yyvsp[(4) - (8)].ctorArgList), NULL, (yyvsp[(5) - (8)].baseClassList), (yyvsp[(7) - (8)].userDeclList))); ;} - break; - - case 19: -#line 174 "agrampar.y" - { ((yyval.tfClass)=(yyvsp[(1) - (2)].tfClass))->super->decls.append((yyvsp[(2) - (2)].annotation)); ;} - break; - - case 20: -#line 181 "agrampar.y" - { (yyval.ctorArgList) = new ASTList; ;} - break; - - case 21: -#line 183 "agrampar.y" - { (yyval.ctorArgList) = (yyvsp[(1) - (1)].ctorArgList); ;} - break; - - case 22: -#line 189 "agrampar.y" - { (yyval.ctorArgList) = new ASTList; ;} - break; - - case 23: -#line 191 "agrampar.y" - { (yyval.ctorArgList) = (yyvsp[(2) - (3)].ctorArgList); ;} - break; - - case 24: -#line 196 "agrampar.y" - { (yyval.ctorArgList) = new ASTList; - { - string tmp = unbox((yyvsp[(1) - (1)].str)); - (yyval.ctorArgList)->append(parseCtorArg(tmp)); - } - ;} - break; - - case 25: -#line 203 "agrampar.y" - { ((yyval.ctorArgList)=(yyvsp[(1) - (3)].ctorArgList))->append(parseCtorArg(unbox((yyvsp[(3) - (3)].str)))); ;} - break; - - case 26: -#line 208 "agrampar.y" - { (yyval.str) = (yyvsp[(1) - (1)].str); ;} - break; - - case 27: -#line 210 "agrampar.y" - { (yyval.str) = appendStr((yyvsp[(1) - (2)].str), (yyvsp[(2) - (2)].str)); ;} - break; - - case 28: -#line 215 "agrampar.y" - { (yyval.str) = appendStr((yyvsp[(1) - (1)].str), box(" ")); ;} - break; - - case 29: -#line 216 "agrampar.y" - { (yyval.str) = appendStr((yyvsp[(1) - (1)].str), box(" ")); ;} - break; - - case 30: -#line 217 "agrampar.y" - { (yyval.str) = appendStr(box("<"), appendStr((yyvsp[(2) - (3)].str), box(">"))); ;} - break; - - case 31: -#line 218 "agrampar.y" - { (yyval.str) = box("*"); ;} - break; - - case 32: -#line 219 "agrampar.y" - { (yyval.str) = box("&"); ;} - break; - - case 33: -#line 220 "agrampar.y" - { (yyval.str) = box("="); ;} - break; - - case 34: -#line 221 "agrampar.y" - { (yyval.str) = box("class "); ;} - break; - - case 35: -#line 226 "agrampar.y" - { (yyval.str) = (yyvsp[(1) - (1)].str); ;} - break; - - case 36: -#line 228 "agrampar.y" - { (yyval.str) = appendStr((yyvsp[(1) - (3)].str), appendStr(box(","), (yyvsp[(3) - (3)].str))); ;} - break; - - case 37: -#line 234 "agrampar.y" - { (yyval.userDeclList) = new ASTList; ;} - break; - - case 38: -#line 236 "agrampar.y" - { ((yyval.userDeclList)=(yyvsp[(1) - (2)].userDeclList))->append((yyvsp[(2) - (2)].annotation)); ;} - break; - - case 39: -#line 242 "agrampar.y" - { (yyval.annotation) = new UserDecl((yyvsp[(1) - (2)].accessMod), unbox((yyvsp[(2) - (2)].str)), ""); ;} - break; - - case 40: -#line 244 "agrampar.y" - { (yyval.annotation) = new UserDecl((yyvsp[(1) - (5)].accessMod), unbox((yyvsp[(2) - (5)].str)), unbox((yyvsp[(4) - (5)].str))); ;} - break; - - case 41: -#line 246 "agrampar.y" - { (yyval.annotation) = (yyvsp[(1) - (1)].customCode); ;} - break; - - case 42: -#line 252 "agrampar.y" - { (yyval.customCode) = new CustomCode(unbox((yyvsp[(2) - (3)].str)), unbox((yyvsp[(3) - (3)].str))); ;} - break; - - case 43: -#line 258 "agrampar.y" - { (yyval.str) = (yyvsp[(1) - (2)].str); ;} - break; - - case 44: -#line 260 "agrampar.y" - { (yyval.str) = (yyvsp[(2) - (3)].str); ;} - break; - - case 45: -#line 265 "agrampar.y" - { (yyval.accessCtl) = AC_PUBLIC; ;} - break; - - case 46: -#line 266 "agrampar.y" - { (yyval.accessCtl) = AC_PRIVATE; ;} - break; - - case 47: -#line 267 "agrampar.y" - { (yyval.accessCtl) = AC_PROTECTED; ;} - break; - - case 48: -#line 268 "agrampar.y" - { (yyval.accessCtl) = AC_CTOR; ;} - break; - - case 49: -#line 269 "agrampar.y" - { (yyval.accessCtl) = AC_DTOR; ;} - break; - - case 50: -#line 270 "agrampar.y" - { (yyval.accessCtl) = AC_PUREVIRT; ;} - break; - - case 51: -#line 275 "agrampar.y" - { (yyval.accessMod) = new AccessMod((yyvsp[(1) - (1)].accessCtl), NULL); ;} - break; - - case 52: -#line 277 "agrampar.y" - { (yyval.accessMod) = new AccessMod((yyvsp[(1) - (4)].accessCtl), (yyvsp[(3) - (4)].stringList)); ;} - break; - - case 53: -#line 282 "agrampar.y" - { (yyval.stringList) = new ASTList((yyvsp[(1) - (1)].str)); ;} - break; - - case 54: -#line 284 "agrampar.y" - { ((yyval.stringList)=(yyvsp[(1) - (3)].stringList))->append((yyvsp[(3) - (3)].str)); ;} - break; - - case 55: -#line 289 "agrampar.y" - { (yyval.verbatim) = new TF_verbatim(unbox((yyvsp[(2) - (2)].str))); ;} - break; - - case 56: -#line 291 "agrampar.y" - { (yyval.verbatim) = new TF_impl_verbatim(unbox((yyvsp[(2) - (2)].str))); ;} - break; - - case 57: -#line 293 "agrampar.y" - { (yyval.verbatim) = new TF_xml_verbatim(unbox((yyvsp[(2) - (2)].str))); ;} - break; - - case 58: -#line 298 "agrampar.y" - { (yyval.tfOption) = new TF_option(unbox((yyvsp[(2) - (4)].str)), (yyvsp[(3) - (4)].stringList)); ;} - break; - - case 59: -#line 303 "agrampar.y" - { (yyval.stringList) = new ASTList; ;} - break; - - case 60: -#line 305 "agrampar.y" - { ((yyval.stringList)=(yyvsp[(1) - (2)].stringList))->append((yyvsp[(2) - (2)].str)); ;} - break; - - case 61: -#line 310 "agrampar.y" - { (yyval.tfEnum) = new TF_enum(unbox((yyvsp[(2) - (5)].str)), (yyvsp[(4) - (5)].enumeratorList)); ;} - break; - - case 62: -#line 312 "agrampar.y" - { (yyval.tfEnum) = new TF_enum(unbox((yyvsp[(2) - (6)].str)), (yyvsp[(4) - (6)].enumeratorList)); ;} - break; - - case 63: -#line 317 "agrampar.y" - { (yyval.enumeratorList) = new ASTList((yyvsp[(1) - (1)].enumerator)); ;} - break; - - case 64: -#line 319 "agrampar.y" - { ((yyval.enumeratorList)=(yyvsp[(1) - (3)].enumeratorList))->append((yyvsp[(3) - (3)].enumerator)); ;} - break; - - case 65: -#line 324 "agrampar.y" - { (yyval.enumerator) = (yyvsp[(1) - (1)].str); ;} - break; - - case 66: -#line 329 "agrampar.y" - { (yyval.baseClassList) = new ASTList; ;} - break; - - case 67: -#line 331 "agrampar.y" - { (yyval.baseClassList) = (yyvsp[(2) - (2)].baseClassList); ;} - break; - - case 68: -#line 336 "agrampar.y" - { (yyval.baseClassList) = new ASTList((yyvsp[(1) - (1)].baseClass)); ;} - break; - - case 69: -#line 338 "agrampar.y" - { ((yyval.baseClassList)=(yyvsp[(1) - (3)].baseClassList))->append((yyvsp[(3) - (3)].baseClass)); ;} - break; - - case 70: -#line 343 "agrampar.y" - { (yyval.accessCtl) = AC_PUBLIC; ;} - break; - - case 71: -#line 344 "agrampar.y" - { (yyval.accessCtl) = AC_PRIVATE; ;} - break; - - case 72: -#line 345 "agrampar.y" - { (yyval.accessCtl) = AC_PROTECTED; ;} - break; - - case 73: -#line 350 "agrampar.y" - { (yyval.baseClass) = new BaseClass((yyvsp[(1) - (2)].accessCtl), unbox((yyvsp[(2) - (2)].str))); ;} - break; - - -/* Line 1267 of yacc.c. */ -#line 1885 "agrampar.tab.c" - default: break; - } - YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); - - YYPOPSTACK (yylen); - yylen = 0; - YY_STACK_PRINT (yyss, yyssp); - - *++yyvsp = yyval; - - - /* Now `shift' the result of the reduction. Determine what state - that goes to, based on the state we popped back to and the rule - number reduced by. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; - if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTOKENS]; - - goto yynewstate; - - -/*------------------------------------. -| yyerrlab -- here on detecting error | -`------------------------------------*/ -yyerrlab: - /* If not already recovering from an error, report this error. */ - if (!yyerrstatus) - { - ++yynerrs; -#if ! YYERROR_VERBOSE - yyerror (YY_("syntax error")); -#else - { - YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); - if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) - { - YYSIZE_T yyalloc = 2 * yysize; - if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) - yyalloc = YYSTACK_ALLOC_MAXIMUM; - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); - yymsg = (char *) YYSTACK_ALLOC (yyalloc); - if (yymsg) - yymsg_alloc = yyalloc; - else - { - yymsg = yymsgbuf; - yymsg_alloc = sizeof yymsgbuf; - } - } - - if (0 < yysize && yysize <= yymsg_alloc) - { - (void) yysyntax_error (yymsg, yystate, yychar); - yyerror (yymsg); - } - else - { - yyerror (YY_("syntax error")); - if (yysize != 0) - goto yyexhaustedlab; - } - } -#endif - } - - - - if (yyerrstatus == 3) - { - /* If just tried and failed to reuse look-ahead token after an - error, discard it. */ - - if (yychar <= YYEOF) - { - /* Return failure if at end of input. */ - if (yychar == YYEOF) - YYABORT; - } - else - { - yydestruct ("Error: discarding", - yytoken, &yylval); - yychar = YYEMPTY; - } - } - - /* Else will try to reuse look-ahead token after shifting the error - token. */ - goto yyerrlab1; - - -/*---------------------------------------------------. -| yyerrorlab -- error raised explicitly by YYERROR. | -`---------------------------------------------------*/ -yyerrorlab: - - /* Pacify compilers like GCC when the user code never invokes - YYERROR and the label yyerrorlab therefore never appears in user - code. */ - if (/*CONSTCOND*/ 0) - goto yyerrorlab; - - /* Do not reclaim the symbols of the rule which action triggered - this YYERROR. */ - YYPOPSTACK (yylen); - yylen = 0; - YY_STACK_PRINT (yyss, yyssp); - yystate = *yyssp; - goto yyerrlab1; - - -/*-------------------------------------------------------------. -| yyerrlab1 -- common code for both syntax error and YYERROR. | -`-------------------------------------------------------------*/ -yyerrlab1: - yyerrstatus = 3; /* Each real token shifted decrements this. */ - - for (;;) - { - yyn = yypact[yystate]; - if (yyn != YYPACT_NINF) - { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) - { - yyn = yytable[yyn]; - if (0 < yyn) - break; - } - } - - /* Pop the current state because it cannot handle the error token. */ - if (yyssp == yyss) - YYABORT; - - - yydestruct ("Error: popping", - yystos[yystate], yyvsp); - YYPOPSTACK (1); - yystate = *yyssp; - YY_STACK_PRINT (yyss, yyssp); - } - - if (yyn == YYFINAL) - YYACCEPT; - - *++yyvsp = yylval; - - - /* Shift the error token. */ - YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); - - yystate = yyn; - goto yynewstate; - - -/*-------------------------------------. -| yyacceptlab -- YYACCEPT comes here. | -`-------------------------------------*/ -yyacceptlab: - yyresult = 0; - goto yyreturn; - -/*-----------------------------------. -| yyabortlab -- YYABORT comes here. | -`-----------------------------------*/ -yyabortlab: - yyresult = 1; - goto yyreturn; - -#ifndef yyoverflow -/*-------------------------------------------------. -| yyexhaustedlab -- memory exhaustion comes here. | -`-------------------------------------------------*/ -yyexhaustedlab: - yyerror (YY_("memory exhausted")); - yyresult = 2; - /* Fall through. */ -#endif - -yyreturn: - if (yychar != YYEOF && yychar != YYEMPTY) - yydestruct ("Cleanup: discarding lookahead", - yytoken, &yylval); - /* Do not reclaim the symbols of the rule which action triggered - this YYABORT or YYACCEPT. */ - YYPOPSTACK (yylen); - YY_STACK_PRINT (yyss, yyssp); - while (yyssp != yyss) - { - yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp); - YYPOPSTACK (1); - } -#ifndef yyoverflow - if (yyss != yyssa) - YYSTACK_FREE (yyss); -#endif -#if YYERROR_VERBOSE - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); -#endif - /* Make sure YYID is used. */ - return YYID (yyresult); -} - - -#line 353 "agrampar.y" - - -/* ----------------- extra C code ------------------- */ - - diff --git a/ast/agrampar.tab.h b/ast/agrampar.tab.h deleted file mode 100644 index 9215e87..0000000 --- a/ast/agrampar.tab.h +++ /dev/null @@ -1,141 +0,0 @@ -/* A Bison parser, made by GNU Bison 2.3. */ - -/* Skeleton interface for Bison's Yacc-like parsers in C - - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 - Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ - -/* As a special exception, you may create a larger work that contains - part or all of the Bison parser skeleton and distribute that work - under terms of your choice, so long as that work isn't itself a - parser generator using the skeleton or a modified version thereof - as a parser skeleton. Alternatively, if you modify or redistribute - the parser skeleton itself, you may (at your option) remove this - special exception, which will cause the skeleton and the resulting - Bison output files to be licensed under the GNU General Public - License without this special exception. - - This special exception was added by the Free Software Foundation in - version 2.2 of Bison. */ - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - TOK_NAME = 258, - TOK_INTLIT = 259, - TOK_EMBEDDED_CODE = 260, - TOK_LBRACE = 261, - TOK_RBRACE = 262, - TOK_SEMICOLON = 263, - TOK_ARROW = 264, - TOK_LPAREN = 265, - TOK_RPAREN = 266, - TOK_LANGLE = 267, - TOK_RANGLE = 268, - TOK_STAR = 269, - TOK_AMPERSAND = 270, - TOK_COMMA = 271, - TOK_EQUALS = 272, - TOK_COLON = 273, - TOK_CLASS = 274, - TOK_PUBLIC = 275, - TOK_PRIVATE = 276, - TOK_PROTECTED = 277, - TOK_VERBATIM = 278, - TOK_IMPL_VERBATIM = 279, - TOK_XML_VERBATIM = 280, - TOK_CTOR = 281, - TOK_DTOR = 282, - TOK_PURE_VIRTUAL = 283, - TOK_CUSTOM = 284, - TOK_OPTION = 285, - TOK_NEW = 286, - TOK_ENUM = 287 - }; -#endif -/* Tokens. */ -#define TOK_NAME 258 -#define TOK_INTLIT 259 -#define TOK_EMBEDDED_CODE 260 -#define TOK_LBRACE 261 -#define TOK_RBRACE 262 -#define TOK_SEMICOLON 263 -#define TOK_ARROW 264 -#define TOK_LPAREN 265 -#define TOK_RPAREN 266 -#define TOK_LANGLE 267 -#define TOK_RANGLE 268 -#define TOK_STAR 269 -#define TOK_AMPERSAND 270 -#define TOK_COMMA 271 -#define TOK_EQUALS 272 -#define TOK_COLON 273 -#define TOK_CLASS 274 -#define TOK_PUBLIC 275 -#define TOK_PRIVATE 276 -#define TOK_PROTECTED 277 -#define TOK_VERBATIM 278 -#define TOK_IMPL_VERBATIM 279 -#define TOK_XML_VERBATIM 280 -#define TOK_CTOR 281 -#define TOK_DTOR 282 -#define TOK_PURE_VIRTUAL 283 -#define TOK_CUSTOM 284 -#define TOK_OPTION 285 -#define TOK_NEW 286 -#define TOK_ENUM 287 - - - - -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -typedef union YYSTYPE -#line 69 "agrampar.y" -{ - ASTSpecFile *file; - ASTList *formList; - TF_class *tfClass; - ASTList *ctorArgList; - ASTList *userDeclList; - string *str; - enum AccessCtl accessCtl; - AccessMod *accessMod; - ToplevelForm *verbatim; - Annotation *annotation; - TF_option *tfOption; - ASTList *stringList; - TF_enum *tfEnum; - ASTList *enumeratorList; - string *enumerator; - ASTList *baseClassList; - BaseClass *baseClass; - CustomCode *customCode; -} -/* Line 1529 of yacc.c. */ -#line 134 "agrampar.tab.h" - YYSTYPE; -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 -#endif - - - diff --git a/elkhound/grampar.codes.h b/elkhound/grampar.codes.h deleted file mode 100644 index 4d60bea..0000000 --- a/elkhound/grampar.codes.h +++ /dev/null @@ -1,30 +0,0 @@ -# define YYTOKENTYPE -#define TOK_INTEGER 258 -#define TOK_NAME 259 -#define TOK_STRING 260 -#define TOK_LIT_CODE 261 -#define TOK_LBRACE 262 -#define TOK_RBRACE 263 -#define TOK_COLON 264 -#define TOK_SEMICOLON 265 -#define TOK_ARROW 266 -#define TOK_LPAREN 267 -#define TOK_RPAREN 268 -#define TOK_COMMA 269 -#define TOK_TERMINALS 270 -#define TOK_TOKEN 271 -#define TOK_NONTERM 272 -#define TOK_FUN 273 -#define TOK_VERBATIM 274 -#define TOK_IMPL_VERBATIM 275 -#define TOK_PRECEDENCE 276 -#define TOK_OPTION 277 -#define TOK_EXPECT 278 -#define TOK_CONTEXT_CLASS 279 -#define TOK_SUBSETS 280 -#define TOK_DELETE 281 -#define TOK_REPLACE 282 -#define TOK_FORBID_NEXT 283 -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 diff --git a/elkhound/grampar.tab.cc b/elkhound/grampar.tab.cc deleted file mode 100644 index 7642289..0000000 --- a/elkhound/grampar.tab.cc +++ /dev/null @@ -1,2056 +0,0 @@ -/* A Bison parser, made by GNU Bison 2.3. */ - -/* Skeleton implementation for Bison's Yacc-like parsers in C - - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 - Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ - -/* As a special exception, you may create a larger work that contains - part or all of the Bison parser skeleton and distribute that work - under terms of your choice, so long as that work isn't itself a - parser generator using the skeleton or a modified version thereof - as a parser skeleton. Alternatively, if you modify or redistribute - the parser skeleton itself, you may (at your option) remove this - special exception, which will cause the skeleton and the resulting - Bison output files to be licensed under the GNU General Public - License without this special exception. - - This special exception was added by the Free Software Foundation in - version 2.2 of Bison. */ - -/* C LALR(1) parser skeleton written by Richard Stallman, by - simplifying the original so-called "semantic" parser. */ - -/* All symbols defined below should begin with yy or YY, to avoid - infringing on user name space. This should be done even for local - variables, as they might otherwise be expanded by user macros. - There are some unavoidable exceptions within include files to - define necessary library symbols; they are noted "INFRINGES ON - USER NAME SPACE" below. */ - -/* Identify Bison output. */ -#define YYBISON 1 - -/* Bison version. */ -#define YYBISON_VERSION "2.3" - -/* Skeleton name. */ -#define YYSKELETON_NAME "yacc.c" - -/* Pure parsers. */ -#define YYPURE 1 - -/* Using locations. */ -#define YYLSP_NEEDED 0 - - - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - TOK_INTEGER = 258, - TOK_NAME = 259, - TOK_STRING = 260, - TOK_LIT_CODE = 261, - TOK_LBRACE = 262, - TOK_RBRACE = 263, - TOK_COLON = 264, - TOK_SEMICOLON = 265, - TOK_ARROW = 266, - TOK_LPAREN = 267, - TOK_RPAREN = 268, - TOK_COMMA = 269, - TOK_TERMINALS = 270, - TOK_TOKEN = 271, - TOK_NONTERM = 272, - TOK_FUN = 273, - TOK_VERBATIM = 274, - TOK_IMPL_VERBATIM = 275, - TOK_PRECEDENCE = 276, - TOK_OPTION = 277, - TOK_EXPECT = 278, - TOK_CONTEXT_CLASS = 279, - TOK_SUBSETS = 280, - TOK_DELETE = 281, - TOK_REPLACE = 282, - TOK_FORBID_NEXT = 283 - }; -#endif -/* Tokens. */ -#define TOK_INTEGER 258 -#define TOK_NAME 259 -#define TOK_STRING 260 -#define TOK_LIT_CODE 261 -#define TOK_LBRACE 262 -#define TOK_RBRACE 263 -#define TOK_COLON 264 -#define TOK_SEMICOLON 265 -#define TOK_ARROW 266 -#define TOK_LPAREN 267 -#define TOK_RPAREN 268 -#define TOK_COMMA 269 -#define TOK_TERMINALS 270 -#define TOK_TOKEN 271 -#define TOK_NONTERM 272 -#define TOK_FUN 273 -#define TOK_VERBATIM 274 -#define TOK_IMPL_VERBATIM 275 -#define TOK_PRECEDENCE 276 -#define TOK_OPTION 277 -#define TOK_EXPECT 278 -#define TOK_CONTEXT_CLASS 279 -#define TOK_SUBSETS 280 -#define TOK_DELETE 281 -#define TOK_REPLACE 282 -#define TOK_FORBID_NEXT 283 - - - - -/* Copy the first part of user declarations. */ -#line 6 "grampar.y" - - -#include "grampar.h" // yylex, etc. -#include "gramast.ast.gen.h"// grammar syntax AST definition -#include "gramlex.h" // GrammarLexer -#include "owner.h" // Owner - -#include // malloc, free -#include // cout - -// enable debugging the parser -#ifndef NDEBUG - #define YYDEBUG 1 -#endif - -// name of extra parameter to yylex -#define YYLEX_PARAM parseParam - -// make it call my yylex -#define yylex(lv, param) grampar_yylex(lv, param) - -// Bison calls yyerror(msg) on error; we need the extra -// parameter too, so the macro shoehorns it in there -#define yyerror(msg) grampar_yyerror(msg, YYPARSE_PARAM) - -// rename the externally-visible parsing routine to make it -// specific to this instance, so multiple bison-generated -// parsers can coexist -#define yyparse grampar_yyparse - - -// grab the parameter -#define PARAM ((ParseParams*)parseParam) - -// return a locstring for 'str' with no location information -#define noloc(str) \ - new LocString(SL_UNKNOWN, /* unknown location */ \ - PARAM->lexer.strtable.add(str)) - -// locstring for NULL, with no location -#define nolocNULL() \ - new LocString(SL_UNKNOWN, NULL) - -// return a locstring with same location info as something else -// (passed as a pointer to a SourceLocation) -#define sameloc(otherLoc, str) \ - new LocString(otherLoc->loc, PARAM->lexer.strtable.add(str)) - -// interpret the word into an associativity kind specification -AssocKind whichKind(LocString * /*owner*/ kind); - - - -/* Enabling traces. */ -#ifndef YYDEBUG -# define YYDEBUG 0 -#endif - -/* Enabling verbose error messages. */ -#ifdef YYERROR_VERBOSE -# undef YYERROR_VERBOSE -# define YYERROR_VERBOSE 1 -#else -# define YYERROR_VERBOSE 0 -#endif - -/* Enabling the token table. */ -#ifndef YYTOKEN_TABLE -# define YYTOKEN_TABLE 0 -#endif - -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -typedef union YYSTYPE -#line 105 "grampar.y" -{ - int num; - LocString *str; - SourceLoc loc; - - ASTList *topFormList; - TopForm *topForm; - - ASTList *termDecls; - TermDecl *termDecl; - ASTList *termTypes; - TermType *termType; - ASTList *precSpecs; - - ASTList *specFuncs; - SpecFunc *specFunc; - ASTList *stringList; - - ASTList *prodDecls; - ProdDecl *prodDecl; - ASTList *rhsList; - RHSElt *rhsElt; -} -/* Line 193 of yacc.c. */ -#line 229 "grampar.tab.c" - YYSTYPE; -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 -#endif - - - -/* Copy the second part of user declarations. */ - - -/* Line 216 of yacc.c. */ -#line 242 "grampar.tab.c" - -#ifdef short -# undef short -#endif - -#ifdef YYTYPE_UINT8 -typedef YYTYPE_UINT8 yytype_uint8; -#else -typedef unsigned char yytype_uint8; -#endif - -#ifdef YYTYPE_INT8 -typedef YYTYPE_INT8 yytype_int8; -#elif (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -typedef signed char yytype_int8; -#else -typedef short int yytype_int8; -#endif - -#ifdef YYTYPE_UINT16 -typedef YYTYPE_UINT16 yytype_uint16; -#else -typedef unsigned short int yytype_uint16; -#endif - -#ifdef YYTYPE_INT16 -typedef YYTYPE_INT16 yytype_int16; -#else -typedef short int yytype_int16; -#endif - -#ifndef YYSIZE_T -# ifdef __SIZE_TYPE__ -# define YYSIZE_T __SIZE_TYPE__ -# elif defined size_t -# define YYSIZE_T size_t -# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -# include /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# else -# define YYSIZE_T unsigned int -# endif -#endif - -#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) - -#ifndef YY_ -# if defined YYENABLE_NLS && YYENABLE_NLS -# if ENABLE_NLS -# include /* INFRINGES ON USER NAME SPACE */ -# define YY_(msgid) dgettext ("bison-runtime", msgid) -# endif -# endif -# ifndef YY_ -# define YY_(msgid) msgid -# endif -#endif - -/* Suppress unused-variable warnings by "using" E. */ -#if ! defined lint || defined __GNUC__ -# define YYUSE(e) ((void) (e)) -#else -# define YYUSE(e) /* empty */ -#endif - -/* Identity function, used to suppress warnings about constant conditions. */ -#ifndef lint -# define YYID(n) (n) -#else -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static int -YYID (int i) -#else -static int -YYID (i) - int i; -#endif -{ - return i; -} -#endif - -#if ! defined yyoverflow || YYERROR_VERBOSE - -/* The parser invokes alloca or malloc; define the necessary symbols. */ - -# ifdef YYSTACK_USE_ALLOCA -# if YYSTACK_USE_ALLOCA -# ifdef __GNUC__ -# define YYSTACK_ALLOC __builtin_alloca -# elif defined __BUILTIN_VA_ARG_INCR -# include /* INFRINGES ON USER NAME SPACE */ -# elif defined _AIX -# define YYSTACK_ALLOC __alloca -# elif defined _MSC_VER -# include /* INFRINGES ON USER NAME SPACE */ -# define alloca _alloca -# else -# define YYSTACK_ALLOC alloca -# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -# include /* INFRINGES ON USER NAME SPACE */ -# ifndef _STDLIB_H -# define _STDLIB_H 1 -# endif -# endif -# endif -# endif -# endif - -# ifdef YYSTACK_ALLOC - /* Pacify GCC's `empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) -# ifndef YYSTACK_ALLOC_MAXIMUM - /* The OS might guarantee only one guard page at the bottom of the stack, - and a page size can be as small as 4096 bytes. So we cannot safely - invoke alloca (N) if N exceeds 4096. Use a slightly smaller number - to allow for a few compiler-allocated temporary stack slots. */ -# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ -# endif -# else -# define YYSTACK_ALLOC YYMALLOC -# define YYSTACK_FREE YYFREE -# ifndef YYSTACK_ALLOC_MAXIMUM -# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM -# endif -# if (defined __cplusplus && ! defined _STDLIB_H \ - && ! ((defined YYMALLOC || defined malloc) \ - && (defined YYFREE || defined free))) -# include /* INFRINGES ON USER NAME SPACE */ -# ifndef _STDLIB_H -# define _STDLIB_H 1 -# endif -# endif -# ifndef YYMALLOC -# define YYMALLOC malloc -# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ -# endif -# endif -# ifndef YYFREE -# define YYFREE free -# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -void free (void *); /* INFRINGES ON USER NAME SPACE */ -# endif -# endif -# endif -#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ - - -#if (! defined yyoverflow \ - && (! defined __cplusplus \ - || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) - -/* A type that is properly aligned for any stack member. */ -union yyalloc -{ - yytype_int16 yyss; - YYSTYPE yyvs; - }; - -/* The size of the maximum gap between one aligned stack and the next. */ -# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) - -/* The size of an array large to enough to hold all stacks, each with - N elements. */ -# define YYSTACK_BYTES(N) \ - ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ - + YYSTACK_GAP_MAXIMUM) - -/* Copy COUNT objects from FROM to TO. The source and destination do - not overlap. */ -# ifndef YYCOPY -# if defined __GNUC__ && 1 < __GNUC__ -# define YYCOPY(To, From, Count) \ - __builtin_memcpy (To, From, (Count) * sizeof (*(From))) -# else -# define YYCOPY(To, From, Count) \ - do \ - { \ - YYSIZE_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (To)[yyi] = (From)[yyi]; \ - } \ - while (YYID (0)) -# endif -# endif - -/* Relocate STACK from its old location to the new one. The - local variables YYSIZE and YYSTACKSIZE give the old and new number of - elements in the stack, and YYPTR gives the new location of the - stack. Advance YYPTR to a properly aligned location for the next - stack. */ -# define YYSTACK_RELOCATE(Stack) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack, Stack, yysize); \ - Stack = &yyptr->Stack; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ - } \ - while (YYID (0)) - -#endif - -/* YYFINAL -- State number of the termination state. */ -#define YYFINAL 3 -/* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 112 - -/* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 29 -/* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 28 -/* YYNRULES -- Number of rules. */ -#define YYNRULES 59 -/* YYNRULES -- Number of states. */ -#define YYNSTATES 106 - -/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ -#define YYUNDEFTOK 2 -#define YYMAXUTOK 283 - -#define YYTRANSLATE(YYX) \ - ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) - -/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ -static const yytype_uint8 yytranslate[] = -{ - 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, - 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28 -}; - -#if YYDEBUG -/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in - YYRHS. */ -static const yytype_uint8 yyprhs[] = -{ - 0, 0, 3, 5, 6, 9, 11, 13, 15, 17, - 19, 23, 26, 29, 33, 38, 45, 46, 49, 54, - 60, 62, 63, 64, 67, 72, 79, 80, 85, 86, - 92, 93, 96, 98, 100, 101, 104, 111, 112, 114, - 116, 120, 125, 134, 135, 138, 142, 147, 152, 154, - 156, 157, 160, 162, 166, 168, 172, 177, 182, 183 -}; - -/* YYRHS -- A `-1'-separated list of the rules' RHS. */ -static const yytype_int8 yyrhs[] = -{ - 30, 0, -1, 31, -1, -1, 31, 32, -1, 33, - -1, 34, -1, 35, -1, 36, -1, 50, -1, 24, - 6, 10, -1, 19, 6, -1, 20, 6, -1, 22, - 4, 10, -1, 22, 4, 3, 10, -1, 15, 7, - 37, 40, 42, 8, -1, -1, 37, 38, -1, 3, - 9, 4, 10, -1, 3, 9, 4, 5, 10, -1, - 6, -1, -1, -1, 40, 41, -1, 16, 39, 4, - 10, -1, 16, 39, 4, 7, 46, 8, -1, -1, - 21, 7, 43, 8, -1, -1, 43, 4, 3, 44, - 10, -1, -1, 44, 45, -1, 4, -1, 5, -1, - -1, 46, 47, -1, 18, 4, 12, 48, 13, 6, - -1, -1, 49, -1, 4, -1, 49, 14, 4, -1, - 17, 39, 4, 52, -1, 17, 39, 4, 7, 46, - 51, 56, 8, -1, -1, 51, 52, -1, 11, 54, - 53, -1, 27, 11, 54, 53, -1, 26, 11, 54, - 10, -1, 6, -1, 10, -1, -1, 54, 55, -1, - 4, -1, 4, 9, 4, -1, 5, -1, 4, 9, - 5, -1, 21, 12, 45, 13, -1, 28, 12, 45, - 13, -1, -1, 25, 49, 10, -1 -}; - -/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ -static const yytype_uint16 yyrline[] = -{ - 0, 162, 162, 167, 168, 172, 173, 174, 175, 176, - 180, 185, 186, 191, 192, 203, 208, 209, 217, 219, - 224, 225, 229, 230, 234, 236, 241, 242, 247, 248, - 253, 254, 258, 259, 265, 266, 270, 275, 276, 280, - 281, 292, 295, 300, 301, 305, 306, 307, 311, 312, - 316, 317, 326, 327, 328, 329, 330, 331, 335, 336 -}; -#endif - -#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE -/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. - First, the terminals, then, starting at YYNTOKENS, nonterminals. */ -static const char *const yytname[] = -{ - "$end", "error", "$undefined", "TOK_INTEGER", "TOK_NAME", "TOK_STRING", - "TOK_LIT_CODE", "\"{\"", "\"}\"", "\":\"", "\";\"", "\"->\"", "\"(\"", - "\")\"", "\",\"", "\"terminals\"", "\"token\"", "\"nonterm\"", "\"fun\"", - "\"verbatim\"", "\"impl_verbatim\"", "\"precedence\"", "\"option\"", - "\"expect\"", "\"context_class\"", "\"subsets\"", "\"delete\"", - "\"replace\"", "\"forbid_next\"", "$accept", "StartSymbol", - "TopFormList", "TopForm", "ContextClass", "Verbatim", "Option", - "Terminals", "TermDecls", "TerminalDecl", "Type", "TermTypes", - "TermType", "Precedence", "PrecSpecs", "NameOrStringList", - "NameOrString", "SpecFuncs", "SpecFunc", "FormalsOpt", "Formals", - "Nonterminal", "Productions", "Production", "Action", "RHS", "RHSElt", - "Subsets", 0 -}; -#endif - -# ifdef YYPRINT -/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to - token YYLEX-NUM. */ -static const yytype_uint16 yytoknum[] = -{ - 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, - 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, - 275, 276, 277, 278, 279, 280, 281, 282, 283 -}; -# endif - -/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const yytype_uint8 yyr1[] = -{ - 0, 29, 30, 31, 31, 32, 32, 32, 32, 32, - 33, 34, 34, 35, 35, 36, 37, 37, 38, 38, - 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, - 44, 44, 45, 45, 46, 46, 47, 48, 48, 49, - 49, 50, 50, 51, 51, 52, 52, 52, 53, 53, - 54, 54, 55, 55, 55, 55, 55, 55, 56, 56 -}; - -/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ -static const yytype_uint8 yyr2[] = -{ - 0, 2, 1, 0, 2, 1, 1, 1, 1, 1, - 3, 2, 2, 3, 4, 6, 0, 2, 4, 5, - 1, 0, 0, 2, 4, 6, 0, 4, 0, 5, - 0, 2, 1, 1, 0, 2, 6, 0, 1, 1, - 3, 4, 8, 0, 2, 3, 4, 4, 1, 1, - 0, 2, 1, 3, 1, 3, 4, 4, 0, 3 -}; - -/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state - STATE-NUM when YYTABLE doesn't specify something else to do. Zero - means the default is an error. */ -static const yytype_uint8 yydefact[] = -{ - 3, 0, 2, 1, 0, 21, 0, 0, 0, 0, - 4, 5, 6, 7, 8, 9, 16, 20, 0, 11, - 12, 0, 0, 22, 0, 0, 13, 10, 0, 17, - 26, 34, 50, 0, 0, 41, 14, 0, 21, 0, - 23, 0, 43, 0, 50, 50, 0, 0, 28, 15, - 0, 35, 58, 52, 54, 48, 49, 0, 0, 45, - 51, 0, 0, 0, 18, 0, 0, 0, 0, 44, - 0, 0, 0, 0, 47, 46, 19, 34, 24, 0, - 27, 37, 39, 0, 42, 53, 55, 32, 33, 0, - 0, 0, 30, 0, 38, 59, 0, 56, 57, 25, - 0, 0, 40, 29, 31, 36 -}; - -/* YYDEFGOTO[NTERM-NUM]. */ -static const yytype_int8 yydefgoto[] = -{ - -1, 1, 2, 10, 11, 12, 13, 14, 23, 29, - 18, 30, 40, 41, 66, 100, 89, 42, 51, 93, - 83, 15, 52, 35, 59, 43, 60, 70 -}; - -/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ -#define YYPACT_NINF -74 -static const yytype_int8 yypact[] = -{ - -74, 39, 21, -74, 1, 26, 31, 49, 48, 50, - -74, -74, -74, -74, -74, -74, -74, -74, 53, -74, - -74, 10, 51, 55, 4, 52, -74, -74, 54, -74, - -7, -74, -74, 56, 57, -74, -74, 60, 26, 58, - -74, 61, 41, -3, -74, -74, 7, 62, -74, -74, - 66, -74, 8, 63, -74, -74, -74, 59, 64, -74, - -74, 0, -3, 65, -74, 37, 18, 67, 69, -74, - 70, 44, 46, 46, -74, -74, -74, -74, -74, 71, - -74, 69, -74, 32, -74, -74, -74, -74, -74, 47, - 68, -2, -74, 72, 73, -74, 76, -74, -74, -74, - 19, 77, -74, -74, -74, -74 -}; - -/* YYPGOTO[NTERM-NUM]. */ -static const yytype_int8 yypgoto[] = -{ - -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, - 74, -74, -74, -74, -74, -74, -73, 5, -74, -74, - -4, -74, -74, 34, 22, 9, -74, -74 -}; - -/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If - positive, shift that token. If negative, reduce the rule which - number is the opposite. If zero, do what YYDEFACT says. - If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -1 -static const yytype_uint8 yytable[] = -{ - 90, 53, 54, 55, 53, 54, 99, 56, 16, 38, - 74, 31, 63, 25, 39, 32, 50, 64, 57, 32, - 26, 57, 79, 87, 88, 58, 80, 104, 58, 103, - 33, 34, 17, 68, 33, 34, 4, 19, 5, 3, - 6, 7, 95, 8, 77, 9, 96, 78, 85, 86, - 87, 88, 21, 61, 62, 20, 22, 24, 28, 50, - 97, 27, 36, 37, 46, 48, 65, 44, 45, 49, - 67, 72, 71, 82, 92, 76, 73, 94, 84, 81, - 102, 98, 91, 105, 75, 101, 69, 96, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 47 -}; - -static const yytype_int8 yycheck[] = -{ - 73, 4, 5, 6, 4, 5, 8, 10, 7, 16, - 10, 7, 5, 3, 21, 11, 18, 10, 21, 11, - 10, 21, 4, 4, 5, 28, 8, 100, 28, 10, - 26, 27, 6, 25, 26, 27, 15, 6, 17, 0, - 19, 20, 10, 22, 7, 24, 14, 10, 4, 5, - 4, 5, 4, 44, 45, 6, 6, 4, 3, 18, - 13, 10, 10, 9, 4, 7, 4, 11, 11, 8, - 4, 12, 9, 4, 3, 10, 12, 81, 8, 12, - 4, 13, 77, 6, 62, 13, 52, 14, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 38 -}; - -/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing - symbol of state STATE-NUM. */ -static const yytype_uint8 yystos[] = -{ - 0, 30, 31, 0, 15, 17, 19, 20, 22, 24, - 32, 33, 34, 35, 36, 50, 7, 6, 39, 6, - 6, 4, 6, 37, 4, 3, 10, 10, 3, 38, - 40, 7, 11, 26, 27, 52, 10, 9, 16, 21, - 41, 42, 46, 54, 11, 11, 4, 39, 7, 8, - 18, 47, 51, 4, 5, 6, 10, 21, 28, 53, - 55, 54, 54, 5, 10, 4, 43, 4, 25, 52, - 56, 9, 12, 12, 10, 53, 10, 7, 10, 4, - 8, 12, 4, 49, 8, 4, 5, 4, 5, 45, - 45, 46, 3, 48, 49, 10, 14, 13, 13, 8, - 44, 13, 4, 10, 45, 6 -}; - -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 - -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrorlab - - -/* Like YYERROR except do call yyerror. This remains here temporarily - to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. */ - -#define YYFAIL goto yyerrlab - -#define YYRECOVERING() (!!yyerrstatus) - -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY && yylen == 1) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - yytoken = YYTRANSLATE (yychar); \ - YYPOPSTACK (1); \ - goto yybackup; \ - } \ - else \ - { \ - yyerror (YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ -while (YYID (0)) - - -#define YYTERROR 1 -#define YYERRCODE 256 - - -/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. - If N is 0, then set CURRENT to the empty location which ends - the previous symbol: RHS[0] (always defined). */ - -#define YYRHSLOC(Rhs, K) ((Rhs)[K]) -#ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - do \ - if (YYID (N)) \ - { \ - (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ - (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ - (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ - (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ - } \ - else \ - { \ - (Current).first_line = (Current).last_line = \ - YYRHSLOC (Rhs, 0).last_line; \ - (Current).first_column = (Current).last_column = \ - YYRHSLOC (Rhs, 0).last_column; \ - } \ - while (YYID (0)) -#endif - - -/* YY_LOCATION_PRINT -- Print the location on the stream. - This macro was not mandated originally: define only if we know - we won't break user code: when these are the locations we know. */ - -#ifndef YY_LOCATION_PRINT -# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL -# define YY_LOCATION_PRINT(File, Loc) \ - fprintf (File, "%d.%d-%d.%d", \ - (Loc).first_line, (Loc).first_column, \ - (Loc).last_line, (Loc).last_column) -# else -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) -# endif -#endif - - -/* YYLEX -- calling `yylex' with the right arguments. */ - -#ifdef YYLEX_PARAM -# define YYLEX yylex (&yylval, YYLEX_PARAM) -#else -# define YYLEX yylex (&yylval) -#endif - -/* Enable debugging if requested. */ -#if YYDEBUG - -# ifndef YYFPRINTF -# include /* INFRINGES ON USER NAME SPACE */ -# define YYFPRINTF fprintf -# endif - -# define YYDPRINTF(Args) \ -do { \ - if (yydebug) \ - YYFPRINTF Args; \ -} while (YYID (0)) - -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yy_symbol_print (stderr, \ - Type, Value); \ - YYFPRINTF (stderr, "\n"); \ - } \ -} while (YYID (0)) - - -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ - -/*ARGSUSED*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) -#else -static void -yy_symbol_value_print (yyoutput, yytype, yyvaluep) - FILE *yyoutput; - int yytype; - YYSTYPE const * const yyvaluep; -#endif -{ - if (!yyvaluep) - return; -# ifdef YYPRINT - if (yytype < YYNTOKENS) - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); -# else - YYUSE (yyoutput); -# endif - switch (yytype) - { - default: - break; - } -} - - -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ - -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) -#else -static void -yy_symbol_print (yyoutput, yytype, yyvaluep) - FILE *yyoutput; - int yytype; - YYSTYPE const * const yyvaluep; -#endif -{ - if (yytype < YYNTOKENS) - YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); - else - YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); - - yy_symbol_value_print (yyoutput, yytype, yyvaluep); - YYFPRINTF (yyoutput, ")"); -} - -/*------------------------------------------------------------------. -| yy_stack_print -- Print the state stack from its BOTTOM up to its | -| TOP (included). | -`------------------------------------------------------------------*/ - -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) -#else -static void -yy_stack_print (bottom, top) - yytype_int16 *bottom; - yytype_int16 *top; -#endif -{ - YYFPRINTF (stderr, "Stack now"); - for (; bottom <= top; ++bottom) - YYFPRINTF (stderr, " %d", *bottom); - YYFPRINTF (stderr, "\n"); -} - -# define YY_STACK_PRINT(Bottom, Top) \ -do { \ - if (yydebug) \ - yy_stack_print ((Bottom), (Top)); \ -} while (YYID (0)) - - -/*------------------------------------------------. -| Report that the YYRULE is going to be reduced. | -`------------------------------------------------*/ - -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yy_reduce_print (YYSTYPE *yyvsp, int yyrule) -#else -static void -yy_reduce_print (yyvsp, yyrule) - YYSTYPE *yyvsp; - int yyrule; -#endif -{ - int yynrhs = yyr2[yyrule]; - int yyi; - unsigned long int yylno = yyrline[yyrule]; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", - yyrule - 1, yylno); - /* The symbols being reduced. */ - for (yyi = 0; yyi < yynrhs; yyi++) - { - fprintf (stderr, " $%d = ", yyi + 1); - yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], - &(yyvsp[(yyi + 1) - (yynrhs)]) - ); - fprintf (stderr, "\n"); - } -} - -# define YY_REDUCE_PRINT(Rule) \ -do { \ - if (yydebug) \ - yy_reduce_print (yyvsp, Rule); \ -} while (YYID (0)) - -/* Nonzero means print parse trace. It is left uninitialized so that - multiple parsers can coexist. */ -int yydebug; -#else /* !YYDEBUG */ -# define YYDPRINTF(Args) -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) -# define YY_STACK_PRINT(Bottom, Top) -# define YY_REDUCE_PRINT(Rule) -#endif /* !YYDEBUG */ - - -/* YYINITDEPTH -- initial size of the parser's stacks. */ -#ifndef YYINITDEPTH -# define YYINITDEPTH 200 -#endif - -/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only - if the built-in stack extension method is used). - - Do not make this value too large; the results are undefined if - YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) - evaluated with infinite-precision integer arithmetic. */ - -#ifndef YYMAXDEPTH -# define YYMAXDEPTH 10000 -#endif - - - -#if YYERROR_VERBOSE - -# ifndef yystrlen -# if defined __GLIBC__ && defined _STRING_H -# define yystrlen strlen -# else -/* Return the length of YYSTR. */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static YYSIZE_T -yystrlen (const char *yystr) -#else -static YYSIZE_T -yystrlen (yystr) - const char *yystr; -#endif -{ - YYSIZE_T yylen; - for (yylen = 0; yystr[yylen]; yylen++) - continue; - return yylen; -} -# endif -# endif - -# ifndef yystpcpy -# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE -# define yystpcpy stpcpy -# else -/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in - YYDEST. */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static char * -yystpcpy (char *yydest, const char *yysrc) -#else -static char * -yystpcpy (yydest, yysrc) - char *yydest; - const char *yysrc; -#endif -{ - char *yyd = yydest; - const char *yys = yysrc; - - while ((*yyd++ = *yys++) != '\0') - continue; - - return yyd - 1; -} -# endif -# endif - -# ifndef yytnamerr -/* Copy to YYRES the contents of YYSTR after stripping away unnecessary - quotes and backslashes, so that it's suitable for yyerror. The - heuristic is that double-quoting is unnecessary unless the string - contains an apostrophe, a comma, or backslash (other than - backslash-backslash). YYSTR is taken from yytname. If YYRES is - null, do not copy; instead, return the length of what the result - would have been. */ -static YYSIZE_T -yytnamerr (char *yyres, const char *yystr) -{ - if (*yystr == '"') - { - YYSIZE_T yyn = 0; - char const *yyp = yystr; - - for (;;) - switch (*++yyp) - { - case '\'': - case ',': - goto do_not_strip_quotes; - - case '\\': - if (*++yyp != '\\') - goto do_not_strip_quotes; - /* Fall through. */ - default: - if (yyres) - yyres[yyn] = *yyp; - yyn++; - break; - - case '"': - if (yyres) - yyres[yyn] = '\0'; - return yyn; - } - do_not_strip_quotes: ; - } - - if (! yyres) - return yystrlen (yystr); - - return yystpcpy (yyres, yystr) - yyres; -} -# endif - -/* Copy into YYRESULT an error message about the unexpected token - YYCHAR while in state YYSTATE. Return the number of bytes copied, - including the terminating null byte. If YYRESULT is null, do not - copy anything; just return the number of bytes that would be - copied. As a special case, return 0 if an ordinary "syntax error" - message will do. Return YYSIZE_MAXIMUM if overflow occurs during - size calculation. */ -static YYSIZE_T -yysyntax_error (char *yyresult, int yystate, int yychar) -{ - int yyn = yypact[yystate]; - - if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) - return 0; - else - { - int yytype = YYTRANSLATE (yychar); - YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); - YYSIZE_T yysize = yysize0; - YYSIZE_T yysize1; - int yysize_overflow = 0; - enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - int yyx; - -# if 0 - /* This is so xgettext sees the translatable formats that are - constructed on the fly. */ - YY_("syntax error, unexpected %s"); - YY_("syntax error, unexpected %s, expecting %s"); - YY_("syntax error, unexpected %s, expecting %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); -# endif - char *yyfmt; - char const *yyf; - static char const yyunexpected[] = "syntax error, unexpected %s"; - static char const yyexpecting[] = ", expecting %s"; - static char const yyor[] = " or %s"; - char yyformat[sizeof yyunexpected - + sizeof yyexpecting - 1 - + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) - * (sizeof yyor - 1))]; - char const *yyprefix = yyexpecting; - - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn + 1; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yycount = 1; - - yyarg[0] = yytname[yytype]; - yyfmt = yystpcpy (yyformat, yyunexpected); - - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) - { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - yysize = yysize0; - yyformat[sizeof yyunexpected - 1] = '\0'; - break; - } - yyarg[yycount++] = yytname[yyx]; - yysize1 = yysize + yytnamerr (0, yytname[yyx]); - yysize_overflow |= (yysize1 < yysize); - yysize = yysize1; - yyfmt = yystpcpy (yyfmt, yyprefix); - yyprefix = yyor; - } - - yyf = YY_(yyformat); - yysize1 = yysize + yystrlen (yyf); - yysize_overflow |= (yysize1 < yysize); - yysize = yysize1; - - if (yysize_overflow) - return YYSIZE_MAXIMUM; - - if (yyresult) - { - /* Avoid sprintf, as that infringes on the user's name space. - Don't have undefined behavior even if the translation - produced a string with the wrong number of "%s"s. */ - char *yyp = yyresult; - int yyi = 0; - while ((*yyp = *yyf) != '\0') - { - if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) - { - yyp += yytnamerr (yyp, yyarg[yyi++]); - yyf += 2; - } - else - { - yyp++; - yyf++; - } - } - } - return yysize; - } -} -#endif /* YYERROR_VERBOSE */ - - -/*-----------------------------------------------. -| Release the memory associated to this symbol. | -`-----------------------------------------------*/ - -/*ARGSUSED*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) -#else -static void -yydestruct (yymsg, yytype, yyvaluep) - const char *yymsg; - int yytype; - YYSTYPE *yyvaluep; -#endif -{ - YYUSE (yyvaluep); - - if (!yymsg) - yymsg = "Deleting"; - YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); - - switch (yytype) - { - - default: - break; - } -} - - -/* Prevent warnings from -Wmissing-prototypes. */ - -#ifdef YYPARSE_PARAM -#if defined __STDC__ || defined __cplusplus -int yyparse (void *YYPARSE_PARAM); -#else -int yyparse (); -#endif -#else /* ! YYPARSE_PARAM */ -#if defined __STDC__ || defined __cplusplus -int yyparse (void); -#else -int yyparse (); -#endif -#endif /* ! YYPARSE_PARAM */ - - - - - - -/*----------. -| yyparse. | -`----------*/ - -#ifdef YYPARSE_PARAM -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -int -yyparse (void *YYPARSE_PARAM) -#else -int -yyparse (YYPARSE_PARAM) - void *YYPARSE_PARAM; -#endif -#else /* ! YYPARSE_PARAM */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -int -yyparse (void) -#else -int -yyparse () - -#endif -#endif -{ - /* The look-ahead symbol. */ -int yychar; - -/* The semantic value of the look-ahead symbol. */ -YYSTYPE yylval; - -/* Number of syntax errors so far. */ -int yynerrs; - - int yystate; - int yyn; - int yyresult; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - /* Look-ahead token as an internal (translated) token number. */ - int yytoken = 0; -#if YYERROR_VERBOSE - /* Buffer for error messages, and its allocated size. */ - char yymsgbuf[128]; - char *yymsg = yymsgbuf; - YYSIZE_T yymsg_alloc = sizeof yymsgbuf; -#endif - - /* Three stacks and their tools: - `yyss': related to states, - `yyvs': related to semantic values, - `yyls': related to locations. - - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - - /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss = yyssa; - yytype_int16 *yyssp; - - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs = yyvsa; - YYSTYPE *yyvsp; - - - -#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) - - YYSIZE_T yystacksize = YYINITDEPTH; - - /* The variables used to return semantic value and location from the - action routines. */ - YYSTYPE yyval; - - - /* The number of symbols on the RHS of the reduced rule. - Keep to zero when no symbol should be popped. */ - int yylen = 0; - - YYDPRINTF ((stderr, "Starting parse\n")); - - yystate = 0; - yyerrstatus = 0; - yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ - - /* Initialize stack pointers. - Waste one element of value and location stack - so that they stay on the same level as the state stack. - The wasted elements are never initialized. */ - - yyssp = yyss; - yyvsp = yyvs; - - goto yysetstate; - -/*------------------------------------------------------------. -| yynewstate -- Push a new state, which is found in yystate. | -`------------------------------------------------------------*/ - yynewstate: - /* In all cases, when you get here, the value and location stacks - have just been pushed. So pushing a state here evens the stacks. */ - yyssp++; - - yysetstate: - *yyssp = yystate; - - if (yyss + yystacksize - 1 <= yyssp) - { - /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = yyssp - yyss + 1; - -#ifdef yyoverflow - { - /* Give user a chance to reallocate the stack. Use copies of - these so that the &'s don't force the real ones into - memory. */ - YYSTYPE *yyvs1 = yyvs; - yytype_int16 *yyss1 = yyss; - - - /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. This used to be a - conditional around just the two extra args, but that might - be undefined if yyoverflow is a macro. */ - yyoverflow (YY_("memory exhausted"), - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), - - &yystacksize); - - yyss = yyss1; - yyvs = yyvs1; - } -#else /* no yyoverflow */ -# ifndef YYSTACK_RELOCATE - goto yyexhaustedlab; -# else - /* Extend the stack our own way. */ - if (YYMAXDEPTH <= yystacksize) - goto yyexhaustedlab; - yystacksize *= 2; - if (YYMAXDEPTH < yystacksize) - yystacksize = YYMAXDEPTH; - - { - yytype_int16 *yyss1 = yyss; - union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); - if (! yyptr) - goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss); - YYSTACK_RELOCATE (yyvs); - -# undef YYSTACK_RELOCATE - if (yyss1 != yyssa) - YYSTACK_FREE (yyss1); - } -# endif -#endif /* no yyoverflow */ - - yyssp = yyss + yysize - 1; - yyvsp = yyvs + yysize - 1; - - - YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); - - if (yyss + yystacksize - 1 <= yyssp) - YYABORT; - } - - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); - - goto yybackup; - -/*-----------. -| yybackup. | -`-----------*/ -yybackup: - - /* Do appropriate processing given the current state. Read a - look-ahead token if we need one and don't already have one. */ - - /* First try to decide what to do without reference to look-ahead token. */ - yyn = yypact[yystate]; - if (yyn == YYPACT_NINF) - goto yydefault; - - /* Not known => get a look-ahead token if don't already have one. */ - - /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ - if (yychar == YYEMPTY) - { - YYDPRINTF ((stderr, "Reading a token: ")); - yychar = YYLEX; - } - - if (yychar <= YYEOF) - { - yychar = yytoken = YYEOF; - YYDPRINTF ((stderr, "Now at end of input.\n")); - } - else - { - yytoken = YYTRANSLATE (yychar); - YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); - } - - /* If the proper action on seeing token YYTOKEN is to reduce or to - detect an error, take that action. */ - yyn += yytoken; - if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) - goto yydefault; - yyn = yytable[yyn]; - if (yyn <= 0) - { - if (yyn == 0 || yyn == YYTABLE_NINF) - goto yyerrlab; - yyn = -yyn; - goto yyreduce; - } - - if (yyn == YYFINAL) - YYACCEPT; - - /* Count tokens shifted since error; after three, turn off error - status. */ - if (yyerrstatus) - yyerrstatus--; - - /* Shift the look-ahead token. */ - YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - - /* Discard the shifted token unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; - - yystate = yyn; - *++yyvsp = yylval; - - goto yynewstate; - - -/*-----------------------------------------------------------. -| yydefault -- do the default action for the current state. | -`-----------------------------------------------------------*/ -yydefault: - yyn = yydefact[yystate]; - if (yyn == 0) - goto yyerrlab; - goto yyreduce; - - -/*-----------------------------. -| yyreduce -- Do a reduction. | -`-----------------------------*/ -yyreduce: - /* yyn is the number of a rule to reduce with. */ - yylen = yyr2[yyn]; - - /* If YYLEN is nonzero, implement the default value of the action: - `$$ = $1'. - - Otherwise, the following line sets YYVAL to garbage. - This behavior is undocumented and Bison - users should not rely upon it. Assigning to YYVAL - unconditionally makes the parser a bit smaller, and it avoids a - GCC warning that YYVAL may be used uninitialized. */ - yyval = yyvsp[1-yylen]; - - - YY_REDUCE_PRINT (yyn); - switch (yyn) - { - case 2: -#line 163 "grampar.y" - { ((ParseParams*)parseParam)->treeTop = new GrammarAST((yyvsp[(1) - (1)].topFormList)); (yyval.num)=0; ;} - break; - - case 3: -#line 167 "grampar.y" - { (yyval.topFormList) = new ASTList; ;} - break; - - case 4: -#line 168 "grampar.y" - { ((yyval.topFormList)=(yyvsp[(1) - (2)].topFormList))->append((yyvsp[(2) - (2)].topForm)); ;} - break; - - case 5: -#line 172 "grampar.y" - { (yyval.topForm) = (yyvsp[(1) - (1)].topForm); ;} - break; - - case 6: -#line 173 "grampar.y" - { (yyval.topForm) = (yyvsp[(1) - (1)].topForm); ;} - break; - - case 7: -#line 174 "grampar.y" - { (yyval.topForm) = (yyvsp[(1) - (1)].topForm); ;} - break; - - case 8: -#line 175 "grampar.y" - { (yyval.topForm) = (yyvsp[(1) - (1)].topForm); ;} - break; - - case 9: -#line 176 "grampar.y" - { (yyval.topForm) = (yyvsp[(1) - (1)].topForm); ;} - break; - - case 10: -#line 181 "grampar.y" - { (yyval.topForm) = new TF_context((yyvsp[(2) - (3)].str)); ;} - break; - - case 11: -#line 185 "grampar.y" - { (yyval.topForm) = new TF_verbatim(false, (yyvsp[(2) - (2)].str)); ;} - break; - - case 12: -#line 186 "grampar.y" - { (yyval.topForm) = new TF_verbatim(true, (yyvsp[(2) - (2)].str)); ;} - break; - - case 13: -#line 191 "grampar.y" - { (yyval.topForm) = new TF_option((yyvsp[(2) - (3)].str), 1); ;} - break; - - case 14: -#line 192 "grampar.y" - { (yyval.topForm) = new TF_option((yyvsp[(2) - (4)].str), (yyvsp[(3) - (4)].num)); ;} - break; - - case 15: -#line 204 "grampar.y" - { (yyval.topForm) = new TF_terminals((yyvsp[(3) - (6)].termDecls), (yyvsp[(4) - (6)].termTypes), (yyvsp[(5) - (6)].precSpecs)); ;} - break; - - case 16: -#line 208 "grampar.y" - { (yyval.termDecls) = new ASTList; ;} - break; - - case 17: -#line 209 "grampar.y" - { ((yyval.termDecls)=(yyvsp[(1) - (2)].termDecls))->append((yyvsp[(2) - (2)].termDecl)); ;} - break; - - case 18: -#line 218 "grampar.y" - { (yyval.termDecl) = new TermDecl((yyvsp[(1) - (4)].num), (yyvsp[(3) - (4)].str), sameloc((yyvsp[(3) - (4)].str), "")); ;} - break; - - case 19: -#line 220 "grampar.y" - { (yyval.termDecl) = new TermDecl((yyvsp[(1) - (5)].num), (yyvsp[(3) - (5)].str), (yyvsp[(4) - (5)].str)); ;} - break; - - case 20: -#line 224 "grampar.y" - { (yyval.str) = (yyvsp[(1) - (1)].str); ;} - break; - - case 21: -#line 225 "grampar.y" - { (yyval.str) = nolocNULL(); ;} - break; - - case 22: -#line 229 "grampar.y" - { (yyval.termTypes) = new ASTList; ;} - break; - - case 23: -#line 230 "grampar.y" - { ((yyval.termTypes)=(yyvsp[(1) - (2)].termTypes))->append((yyvsp[(2) - (2)].termType)); ;} - break; - - case 24: -#line 235 "grampar.y" - { (yyval.termType) = new TermType((yyvsp[(3) - (4)].str), (yyvsp[(2) - (4)].str), new ASTList); ;} - break; - - case 25: -#line 237 "grampar.y" - { (yyval.termType) = new TermType((yyvsp[(3) - (6)].str), (yyvsp[(2) - (6)].str), (yyvsp[(5) - (6)].specFuncs)); ;} - break; - - case 26: -#line 241 "grampar.y" - { (yyval.precSpecs) = new ASTList; ;} - break; - - case 27: -#line 242 "grampar.y" - { (yyval.precSpecs) = (yyvsp[(3) - (4)].precSpecs); ;} - break; - - case 28: -#line 247 "grampar.y" - { (yyval.precSpecs) = new ASTList; ;} - break; - - case 29: -#line 249 "grampar.y" - { ((yyval.precSpecs)=(yyvsp[(1) - (5)].precSpecs))->append(new PrecSpec(whichKind((yyvsp[(2) - (5)].str)), (yyvsp[(3) - (5)].num), (yyvsp[(4) - (5)].stringList))); ;} - break; - - case 30: -#line 253 "grampar.y" - { (yyval.stringList) = new ASTList; ;} - break; - - case 31: -#line 254 "grampar.y" - { ((yyval.stringList)=(yyvsp[(1) - (2)].stringList))->append((yyvsp[(2) - (2)].str)); ;} - break; - - case 32: -#line 258 "grampar.y" - { (yyval.str) = (yyvsp[(1) - (1)].str); ;} - break; - - case 33: -#line 259 "grampar.y" - { (yyval.str) = (yyvsp[(1) - (1)].str); ;} - break; - - case 34: -#line 265 "grampar.y" - { (yyval.specFuncs) = new ASTList; ;} - break; - - case 35: -#line 266 "grampar.y" - { ((yyval.specFuncs)=(yyvsp[(1) - (2)].specFuncs))->append((yyvsp[(2) - (2)].specFunc)); ;} - break; - - case 36: -#line 271 "grampar.y" - { (yyval.specFunc) = new SpecFunc((yyvsp[(2) - (6)].str), (yyvsp[(4) - (6)].stringList), (yyvsp[(6) - (6)].str)); ;} - break; - - case 37: -#line 275 "grampar.y" - { (yyval.stringList) = new ASTList; ;} - break; - - case 38: -#line 276 "grampar.y" - { (yyval.stringList) = (yyvsp[(1) - (1)].stringList); ;} - break; - - case 39: -#line 280 "grampar.y" - { (yyval.stringList) = new ASTList((yyvsp[(1) - (1)].str)); ;} - break; - - case 40: -#line 281 "grampar.y" - { ((yyval.stringList)=(yyvsp[(1) - (3)].stringList))->append((yyvsp[(3) - (3)].str)); ;} - break; - - case 41: -#line 293 "grampar.y" - { (yyval.topForm) = new TF_nonterm((yyvsp[(3) - (4)].str), (yyvsp[(2) - (4)].str), new ASTList, - new ASTList((yyvsp[(4) - (4)].prodDecl)), NULL); ;} - break; - - case 42: -#line 296 "grampar.y" - { (yyval.topForm) = new TF_nonterm((yyvsp[(3) - (8)].str), (yyvsp[(2) - (8)].str), (yyvsp[(5) - (8)].specFuncs), (yyvsp[(6) - (8)].prodDecls), (yyvsp[(7) - (8)].stringList)); ;} - break; - - case 43: -#line 300 "grampar.y" - { (yyval.prodDecls) = new ASTList; ;} - break; - - case 44: -#line 301 "grampar.y" - { ((yyval.prodDecls)=(yyvsp[(1) - (2)].prodDecls))->append((yyvsp[(2) - (2)].prodDecl)); ;} - break; - - case 45: -#line 305 "grampar.y" - { (yyval.prodDecl) = new ProdDecl((yyvsp[(1) - (3)].loc), PDK_NEW, (yyvsp[(2) - (3)].rhsList), (yyvsp[(3) - (3)].str)); ;} - break; - - case 46: -#line 306 "grampar.y" - { (yyval.prodDecl) = new ProdDecl((yyvsp[(2) - (4)].loc), PDK_REPLACE,(yyvsp[(3) - (4)].rhsList), (yyvsp[(4) - (4)].str)); ;} - break; - - case 47: -#line 307 "grampar.y" - { (yyval.prodDecl) = new ProdDecl((yyvsp[(2) - (4)].loc), PDK_DELETE, (yyvsp[(3) - (4)].rhsList), nolocNULL()); ;} - break; - - case 48: -#line 311 "grampar.y" - { (yyval.str) = (yyvsp[(1) - (1)].str); ;} - break; - - case 49: -#line 312 "grampar.y" - { (yyval.str) = nolocNULL(); ;} - break; - - case 50: -#line 316 "grampar.y" - { (yyval.rhsList) = new ASTList; ;} - break; - - case 51: -#line 317 "grampar.y" - { ((yyval.rhsList)=(yyvsp[(1) - (2)].rhsList))->append((yyvsp[(2) - (2)].rhsElt)); ;} - break; - - case 52: -#line 326 "grampar.y" - { (yyval.rhsElt) = new RH_name(sameloc((yyvsp[(1) - (1)].str), ""), (yyvsp[(1) - (1)].str)); ;} - break; - - case 53: -#line 327 "grampar.y" - { (yyval.rhsElt) = new RH_name((yyvsp[(1) - (3)].str), (yyvsp[(3) - (3)].str)); ;} - break; - - case 54: -#line 328 "grampar.y" - { (yyval.rhsElt) = new RH_string(sameloc((yyvsp[(1) - (1)].str), ""), (yyvsp[(1) - (1)].str)); ;} - break; - - case 55: -#line 329 "grampar.y" - { (yyval.rhsElt) = new RH_string((yyvsp[(1) - (3)].str), (yyvsp[(3) - (3)].str)); ;} - break; - - case 56: -#line 330 "grampar.y" - { (yyval.rhsElt) = new RH_prec((yyvsp[(3) - (4)].str)); ;} - break; - - case 57: -#line 331 "grampar.y" - { (yyval.rhsElt) = new RH_forbid((yyvsp[(3) - (4)].str)); ;} - break; - - case 58: -#line 335 "grampar.y" - { (yyval.stringList) = NULL; ;} - break; - - case 59: -#line 336 "grampar.y" - { (yyval.stringList) = (yyvsp[(2) - (3)].stringList); ;} - break; - - -/* Line 1267 of yacc.c. */ -#line 1821 "grampar.tab.c" - default: break; - } - YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); - - YYPOPSTACK (yylen); - yylen = 0; - YY_STACK_PRINT (yyss, yyssp); - - *++yyvsp = yyval; - - - /* Now `shift' the result of the reduction. Determine what state - that goes to, based on the state we popped back to and the rule - number reduced by. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; - if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTOKENS]; - - goto yynewstate; - - -/*------------------------------------. -| yyerrlab -- here on detecting error | -`------------------------------------*/ -yyerrlab: - /* If not already recovering from an error, report this error. */ - if (!yyerrstatus) - { - ++yynerrs; -#if ! YYERROR_VERBOSE - yyerror (YY_("syntax error")); -#else - { - YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); - if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) - { - YYSIZE_T yyalloc = 2 * yysize; - if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) - yyalloc = YYSTACK_ALLOC_MAXIMUM; - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); - yymsg = (char *) YYSTACK_ALLOC (yyalloc); - if (yymsg) - yymsg_alloc = yyalloc; - else - { - yymsg = yymsgbuf; - yymsg_alloc = sizeof yymsgbuf; - } - } - - if (0 < yysize && yysize <= yymsg_alloc) - { - (void) yysyntax_error (yymsg, yystate, yychar); - yyerror (yymsg); - } - else - { - yyerror (YY_("syntax error")); - if (yysize != 0) - goto yyexhaustedlab; - } - } -#endif - } - - - - if (yyerrstatus == 3) - { - /* If just tried and failed to reuse look-ahead token after an - error, discard it. */ - - if (yychar <= YYEOF) - { - /* Return failure if at end of input. */ - if (yychar == YYEOF) - YYABORT; - } - else - { - yydestruct ("Error: discarding", - yytoken, &yylval); - yychar = YYEMPTY; - } - } - - /* Else will try to reuse look-ahead token after shifting the error - token. */ - goto yyerrlab1; - - -/*---------------------------------------------------. -| yyerrorlab -- error raised explicitly by YYERROR. | -`---------------------------------------------------*/ -yyerrorlab: - - /* Pacify compilers like GCC when the user code never invokes - YYERROR and the label yyerrorlab therefore never appears in user - code. */ - if (/*CONSTCOND*/ 0) - goto yyerrorlab; - - /* Do not reclaim the symbols of the rule which action triggered - this YYERROR. */ - YYPOPSTACK (yylen); - yylen = 0; - YY_STACK_PRINT (yyss, yyssp); - yystate = *yyssp; - goto yyerrlab1; - - -/*-------------------------------------------------------------. -| yyerrlab1 -- common code for both syntax error and YYERROR. | -`-------------------------------------------------------------*/ -yyerrlab1: - yyerrstatus = 3; /* Each real token shifted decrements this. */ - - for (;;) - { - yyn = yypact[yystate]; - if (yyn != YYPACT_NINF) - { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) - { - yyn = yytable[yyn]; - if (0 < yyn) - break; - } - } - - /* Pop the current state because it cannot handle the error token. */ - if (yyssp == yyss) - YYABORT; - - - yydestruct ("Error: popping", - yystos[yystate], yyvsp); - YYPOPSTACK (1); - yystate = *yyssp; - YY_STACK_PRINT (yyss, yyssp); - } - - if (yyn == YYFINAL) - YYACCEPT; - - *++yyvsp = yylval; - - - /* Shift the error token. */ - YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); - - yystate = yyn; - goto yynewstate; - - -/*-------------------------------------. -| yyacceptlab -- YYACCEPT comes here. | -`-------------------------------------*/ -yyacceptlab: - yyresult = 0; - goto yyreturn; - -/*-----------------------------------. -| yyabortlab -- YYABORT comes here. | -`-----------------------------------*/ -yyabortlab: - yyresult = 1; - goto yyreturn; - -#ifndef yyoverflow -/*-------------------------------------------------. -| yyexhaustedlab -- memory exhaustion comes here. | -`-------------------------------------------------*/ -yyexhaustedlab: - yyerror (YY_("memory exhausted")); - yyresult = 2; - /* Fall through. */ -#endif - -yyreturn: - if (yychar != YYEOF && yychar != YYEMPTY) - yydestruct ("Cleanup: discarding lookahead", - yytoken, &yylval); - /* Do not reclaim the symbols of the rule which action triggered - this YYABORT or YYACCEPT. */ - YYPOPSTACK (yylen); - YY_STACK_PRINT (yyss, yyssp); - while (yyssp != yyss) - { - yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp); - YYPOPSTACK (1); - } -#ifndef yyoverflow - if (yyss != yyssa) - YYSTACK_FREE (yyss); -#endif -#if YYERROR_VERBOSE - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); -#endif - /* Make sure YYID is used. */ - return YYID (yyresult); -} - - -#line 340 "grampar.y" - -/* ------------------ extra C code ------------------ */ -AssocKind whichKind(LocString * /*owner*/ kind) -{ - // delete 'kind' however we exit - Owner killer(kind); - - #define CHECK(syntax, value) \ - if (kind->equals(syntax)) { \ - return value; \ - } - CHECK("left", AK_LEFT); - CHECK("right", AK_RIGHT); - CHECK("nonassoc", AK_NONASSOC); - CHECK("prec", AK_NEVERASSOC); - CHECK("assoc_split", AK_SPLIT); - #undef CHECK - - xbase(stringc << kind->locString() - << ": invalid associativity kind: " << *kind); -} - diff --git a/elkhound/grampar.tab.h b/elkhound/grampar.tab.h deleted file mode 100644 index 954b8a6..0000000 --- a/elkhound/grampar.tab.h +++ /dev/null @@ -1,136 +0,0 @@ -/* A Bison parser, made by GNU Bison 2.3. */ - -/* Skeleton interface for Bison's Yacc-like parsers in C - - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 - Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ - -/* As a special exception, you may create a larger work that contains - part or all of the Bison parser skeleton and distribute that work - under terms of your choice, so long as that work isn't itself a - parser generator using the skeleton or a modified version thereof - as a parser skeleton. Alternatively, if you modify or redistribute - the parser skeleton itself, you may (at your option) remove this - special exception, which will cause the skeleton and the resulting - Bison output files to be licensed under the GNU General Public - License without this special exception. - - This special exception was added by the Free Software Foundation in - version 2.2 of Bison. */ - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - TOK_INTEGER = 258, - TOK_NAME = 259, - TOK_STRING = 260, - TOK_LIT_CODE = 261, - TOK_LBRACE = 262, - TOK_RBRACE = 263, - TOK_COLON = 264, - TOK_SEMICOLON = 265, - TOK_ARROW = 266, - TOK_LPAREN = 267, - TOK_RPAREN = 268, - TOK_COMMA = 269, - TOK_TERMINALS = 270, - TOK_TOKEN = 271, - TOK_NONTERM = 272, - TOK_FUN = 273, - TOK_VERBATIM = 274, - TOK_IMPL_VERBATIM = 275, - TOK_PRECEDENCE = 276, - TOK_OPTION = 277, - TOK_EXPECT = 278, - TOK_CONTEXT_CLASS = 279, - TOK_SUBSETS = 280, - TOK_DELETE = 281, - TOK_REPLACE = 282, - TOK_FORBID_NEXT = 283 - }; -#endif -/* Tokens. */ -#define TOK_INTEGER 258 -#define TOK_NAME 259 -#define TOK_STRING 260 -#define TOK_LIT_CODE 261 -#define TOK_LBRACE 262 -#define TOK_RBRACE 263 -#define TOK_COLON 264 -#define TOK_SEMICOLON 265 -#define TOK_ARROW 266 -#define TOK_LPAREN 267 -#define TOK_RPAREN 268 -#define TOK_COMMA 269 -#define TOK_TERMINALS 270 -#define TOK_TOKEN 271 -#define TOK_NONTERM 272 -#define TOK_FUN 273 -#define TOK_VERBATIM 274 -#define TOK_IMPL_VERBATIM 275 -#define TOK_PRECEDENCE 276 -#define TOK_OPTION 277 -#define TOK_EXPECT 278 -#define TOK_CONTEXT_CLASS 279 -#define TOK_SUBSETS 280 -#define TOK_DELETE 281 -#define TOK_REPLACE 282 -#define TOK_FORBID_NEXT 283 - - - - -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -typedef union YYSTYPE -#line 105 "grampar.y" -{ - int num; - LocString *str; - SourceLoc loc; - - ASTList *topFormList; - TopForm *topForm; - - ASTList *termDecls; - TermDecl *termDecl; - ASTList *termTypes; - TermType *termType; - ASTList *precSpecs; - - ASTList *specFuncs; - SpecFunc *specFunc; - ASTList *stringList; - - ASTList *prodDecls; - ProdDecl *prodDecl; - ASTList *rhsList; - RHSElt *rhsElt; -} -/* Line 1529 of yacc.c. */ -#line 129 "grampar.tab.h" - YYSTYPE; -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 -#endif - - - From be4742fbe727142490ea8524179a2dcadf976c84 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Mon, 21 Nov 2022 17:02:22 -0600 Subject: [PATCH 18/20] Small cleanup --- ast/CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ast/CMakeLists.txt b/ast/CMakeLists.txt index 82af335..b540ac3 100644 --- a/ast/CMakeLists.txt +++ b/ast/CMakeLists.txt @@ -3,7 +3,7 @@ bison_target( agrampar agrampar.y ${CMAKE_CURRENT_BINARY_DIR}/agrampar.tab.cc - COMPILE_FLAGS "--token-table" # -Dapi.prefix={agrampar}" + COMPILE_FLAGS "--token-table" DEFINES_FILE ${CMAKE_CURRENT_BINARY_DIR}/agrampar.tab.h) flex_target(agramlex agramlex.lex ${CMAKE_CURRENT_BINARY_DIR}/agramlex.yy.cc) @@ -44,7 +44,6 @@ target_link_libraries(ast PUBLIC smbase) add_executable( astgen agrampar.cc - # ast.ast.cc ast.ast.h ast.hand.cc ast.hand.h From d6888657010b566cabc88f49c53332f4dbf1c7a7 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Mon, 21 Nov 2022 17:21:10 -0600 Subject: [PATCH 19/20] Rename elkhound-lib --- elkhound/CMakeLists.txt | 10 ++++++---- elsa/CMakeLists.txt | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/elkhound/CMakeLists.txt b/elkhound/CMakeLists.txt index 36bf8d2..7f84845 100644 --- a/elkhound/CMakeLists.txt +++ b/elkhound/CMakeLists.txt @@ -56,7 +56,7 @@ target_link_libraries(elkhound-support PUBLIC smbase ast) target_include_directories(elkhound-support PUBLIC . ${CMAKE_CURRENT_BINARY_DIR}) add_library( - elkhound-lib + libelkhound # glr-set cyctimer.cc glr.cc @@ -65,9 +65,11 @@ add_library( # util-set ptreenode.cc ptreeact.cc) -target_include_directories(elkhound-lib PUBLIC . ${CMAKE_CURRENT_BINARY_DIR}) -target_link_libraries(elkhound-lib PUBLIC smbase ast) +target_include_directories(libelkhound PUBLIC . ${CMAKE_CURRENT_BINARY_DIR}) +target_link_libraries(libelkhound PUBLIC smbase ast) +# since we manually put "lib" on the fron +set_target_properties(libelkhound PROPERTIES PREFIX "") add_executable( elkhound @@ -103,5 +105,5 @@ if(FALSE) lrtable) add_executable(cc2t cc2/cc2main.cc ${CC2T_GEN_OUTPUTS}) - target_link_libraries(cc2t PUBLIC elkhound-lib) + target_link_libraries(cc2t PUBLIC libelkhound) endif() diff --git a/elsa/CMakeLists.txt b/elsa/CMakeLists.txt index af3b71f..db6d4ec 100644 --- a/elsa/CMakeLists.txt +++ b/elsa/CMakeLists.txt @@ -103,7 +103,7 @@ add_library( # otherwise conflict with methods in lexer.yy.cc; they have identical # implementations target_compile_definitions(elsa_xml_objs PRIVATE NO_YYFLEXLEXER_METHODS) -target_link_libraries(elsa_xml_objs PUBLIC smbase elkhound-lib ast) +target_link_libraries(elsa_xml_objs PUBLIC smbase libelkhound ast) target_include_directories(elsa_xml_objs PUBLIC . ${CMAKE_CURRENT_BINARY_DIR}) # generate token lists @@ -152,7 +152,7 @@ add_library( ${CMAKE_CURRENT_BINARY_DIR}/cc_tokens.cc ${CMAKE_CURRENT_BINARY_DIR}/lexer.yy.cc cc_lang.cc) -target_link_libraries(elsa_lexer_objs PUBLIC smbase elkhound-lib ast) +target_link_libraries(elsa_lexer_objs PUBLIC smbase libelkhound ast) target_include_directories(elsa_lexer_objs PUBLIC . ${CMAKE_CURRENT_BINARY_DIR}) add_elkhound_command( @@ -206,7 +206,7 @@ add_library( lookupset.cc ccparse.cc cc2c.cc) -target_link_libraries(ccparse_objs PUBLIC smbase ast elkhound-lib) +target_link_libraries(ccparse_objs PUBLIC smbase ast libelkhound) target_include_directories(ccparse_objs PUBLIC . ${CMAKE_CURRENT_BINARY_DIR}) if(USE_GNU) target_sources(ccparse_objs PRIVATE gnu.cc) From fe057c85a9eb738652dc854ca7e9135a0b37da45 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Mon, 21 Nov 2022 17:23:24 -0600 Subject: [PATCH 20/20] Stop using ofstreamTS --- ast/astgen.cc | 15 +++++++-------- elkhound/emitcode.h | 4 ++-- elkhound/gramanl.cc | 5 ++--- smbase/CMakeLists.txt | 4 ++-- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/ast/astgen.cc b/ast/astgen.cc index 4d96a25..675c738 100644 --- a/ast/astgen.cc +++ b/ast/astgen.cc @@ -13,10 +13,9 @@ #include "strtokp.h" // StrtokParse #include "exc.h" // xfatal #include "strdict.h" // StringDict -#include "ofstreamts.h" // ofstreamTS #include // strncmp -#include // ofstream +#include // std::ofstream #include // isalnum // propertly a member of ListClass below, but I don't like nested @@ -106,7 +105,7 @@ class Gen { string srcFname; // name of source file ObjList const &modules; // extension modules string destFname; // name of output file - ofstreamTS out; // output stream + std::ofstream out; // output stream ASTSpecFile const &file; // AST specification public: // funcs @@ -982,11 +981,11 @@ class CGen : public Gen { class XmlParserGen { StringSet attributeNames; // names of attributes of AST nodes - ofstreamTS tokensOut; - ofstreamTS parser0_decls; - ofstreamTS parser1_defs; - ofstreamTS parser2_ctorCalls; - ofstreamTS parser3_registerCalls; + std::ofstream tokensOut; + std::ofstream parser0_decls; + std::ofstream parser1_defs; + std::ofstream parser2_ctorCalls; + std::ofstream parser3_registerCalls; public: XmlParserGen(string &xmlParserName) diff --git a/elkhound/emitcode.h b/elkhound/emitcode.h index 5a71b27..b0ba862 100644 --- a/elkhound/emitcode.h +++ b/elkhound/emitcode.h @@ -6,11 +6,11 @@ #include "str.h" // stringBuffer #include "srcloc.h" // SourceLoc -#include "ofstreamts.h" // ofstreamTS +#include class EmitCode : public stringBuilder { private: // data - ofstreamTS os; // stream to write to + std::ofstream os; // stream to write to string fname; // filename for emitting #line int line; // current line number diff --git a/elkhound/gramanl.cc b/elkhound/gramanl.cc index 3721ea2..f765442 100644 --- a/elkhound/gramanl.cc +++ b/elkhound/gramanl.cc @@ -16,7 +16,6 @@ #include "strutil.h" // replace #include "ckheap.h" // numMallocCalls #include "genml.h" // emitMLActionCode -#include "ofstreamts.h" // ofstreamTS #include // ofstream #include // getenv @@ -2530,7 +2529,7 @@ void GrammarAnalysis::constructLRItemSets() if (tracingSys("itemset-graph")) { // write this info to a graph applet file - ofstreamTS out("lrsets.g"); + std::ofstream out("lrsets.g"); if (!out) { xsyserror("ofstream open"); } @@ -5050,7 +5049,7 @@ int inner_entry(int argc, char **argv) if (tracingSys("bison")) { string bisonFname = stringc << prefix << ".y"; traceProgress() << "writing bison-compatible grammar to " << bisonFname << std::endl; - ofstreamTS out(bisonFname.c_str()); + std::ofstream out(bisonFname.c_str()); g.printAsBison(out); } diff --git a/smbase/CMakeLists.txt b/smbase/CMakeLists.txt index 84cf510..1c03c86 100644 --- a/smbase/CMakeLists.txt +++ b/smbase/CMakeLists.txt @@ -36,8 +36,8 @@ add_library( missing.h nonport.cpp nonport.h - ofstreamts.cc - ofstreamts.h + # ofstreamts.cc + # ofstreamts.h point.cc point.h pprint.cc