diff --git a/main/options/options.h b/main/options/options.h index a034df0b87b..d9277188683 100644 --- a/main/options/options.h +++ b/main/options/options.h @@ -121,13 +121,6 @@ const std::vector parser_options({ {"prism", Parser::PRISM}, }); -struct AutogenConstCacheConfig { - // A file which contains a cache that can be used to potentially skip autogen - std::string cacheFile; - // A list of files which have changed since the last autogen run. - std::vector changedFiles; -}; - namespace { #if !defined(EMSCRIPTEN) diff --git a/main/pipeline/pipeline.cc b/main/pipeline/pipeline.cc index 26769abc11a..7d4e699ec21 100644 --- a/main/pipeline/pipeline.cc +++ b/main/pipeline/pipeline.cc @@ -239,11 +239,14 @@ ast::ParsedFile indexOne(const options::Options &opts, core::GlobalState &lgs, c bool stopAfterParser = opts.stopAfterPhase == options::Phase::PARSER; - if (parser == options::Parser::SORBET) { - parseTree = runParser(lgs, file, print, opts.traceLexer, opts.traceParser); - } else if (parser == options::Parser::PRISM) { - parseTree = runPrismParser(lgs, file, stopAfterParser, print); - } // Any other option would have been handled in the options parser + switch (parser) { + case options::Parser::SORBET: + parseTree = runParser(lgs, file, print, opts.traceLexer, opts.traceParser); + break; + case options::Parser::PRISM: + parseTree = runPrismParser(lgs, file, stopAfterParser, print); + break; + } if (stopAfterParser) { return emptyParsedFile(file); diff --git a/parser/prism/Parser.cc b/parser/prism/Parser.cc index 9a18eab0cf4..ef6d0d8cb68 100644 --- a/parser/prism/Parser.cc +++ b/parser/prism/Parser.cc @@ -2,12 +2,12 @@ namespace sorbet::parser::Prism { -pm_parser_t *Parser::get_raw_parser_pointer() { +pm_parser_t *Parser::getRawParserPointer() { return &storage->parser; } Node Parser::parse_root() { - pm_node_t *root = pm_parse(get_raw_parser_pointer()); + pm_node_t *root = pm_parse(getRawParserPointer()); return Node{*this, root}; }; diff --git a/parser/prism/Parser.h b/parser/prism/Parser.h index dbf3c59106a..6c8a44f7845 100644 --- a/parser/prism/Parser.h +++ b/parser/prism/Parser.h @@ -72,7 +72,7 @@ class Parser final { void collectErrors(); private: - pm_parser_t *get_raw_parser_pointer(); + pm_parser_t *getRawParserPointer(); }; class Node final { @@ -80,7 +80,7 @@ class Node final { Parser parser; void operator()(pm_node_t *node) { - pm_node_destroy(parser.get_raw_parser_pointer(), node); + pm_node_destroy(parser.getRawParserPointer(), node); } }; @@ -95,7 +95,7 @@ class Node final { Node(const Node &) = delete; // Copy constructor Node &operator=(const Node &) = delete; // Copy assignment - pm_node_t *get_raw_node_pointer() const { + pm_node_t *getRawNodePointer() const { return node.get(); } }; diff --git a/parser/prism/Translator.cc b/parser/prism/Translator.cc index cd72fac7beb..c3befb3cea3 100644 --- a/parser/prism/Translator.cc +++ b/parser/prism/Translator.cc @@ -1366,7 +1366,7 @@ unique_ptr Translator::translate(pm_node_t *node) { } unique_ptr Translator::translate(const Node &node) { - return translate(node.get_raw_node_pointer()); + return translate(node.getRawNodePointer()); } core::LocOffsets Translator::translateLoc(pm_location_t loc) { diff --git a/parser/prism/Translator.h b/parser/prism/Translator.h index 30e9c9cb1ef..e2c2b3a3795 100644 --- a/parser/prism/Translator.h +++ b/parser/prism/Translator.h @@ -1,8 +1,8 @@ #ifndef SORBET_PARSER_PRISM_TRANSLATOR_H #define SORBET_PARSER_PRISM_TRANSLATOR_H -#include "../Node.h" // To clarify: these are Sorbet Parser nodes, not Prism ones. #include "core/errors/parser.h" +#include "parser/Node.h" // To clarify: these are Sorbet Parser nodes, not Prism ones. #include "parser/prism/Parser.h" #include diff --git a/test/pipeline_test_runner.cc b/test/pipeline_test_runner.cc index 67dc3aab416..4d2e79511fb 100644 --- a/test/pipeline_test_runner.cc +++ b/test/pipeline_test_runner.cc @@ -222,15 +222,19 @@ vector index(unique_ptr &gs, absl::Span nodes; - if (parser == realmain::options::Parser::SORBET) { - std::cout << "Parsing with sorbet" << std::endl; - core::UnfreezeNameTable nameTableAccess(*gs); // enters original strings + switch (parser) { + case realmain::options::Parser::SORBET: { + std::cout << "Parsing with sorbet" << std::endl; + core::UnfreezeNameTable nameTableAccess(*gs); // enters original strings - auto settings = parser::Parser::Settings{}; - nodes = parser::Parser::run(*gs, file, settings); - } else if (parser == realmain::options::Parser::PRISM) { - std::cout << "Parsing with prism" << std::endl; - nodes = realmain::pipeline::runPrismParser(*gs, file, false, {}); + auto settings = parser::Parser::Settings{}; + nodes = parser::Parser::run(*gs, file, settings); + break; + } + case realmain::options::Parser::PRISM: + std::cout << "Parsing with prism" << std::endl; + nodes = realmain::pipeline::runPrismParser(*gs, file, false, {}); + break; } handler.drainErrors(*gs);