diff options
author | Gabriel Dos Reis <gdr@axiomatics.org> | 2017-01-15 23:47:28 -0800 |
---|---|---|
committer | Gabriel Dos Reis <gdr@axiomatics.org> | 2017-01-15 23:47:28 -0800 |
commit | e82d62219c661a2594286e0f867354864514bd87 (patch) | |
tree | a65a20d9e14ffac1d73ed9b439077d9c5a820a63 /src/syntax | |
parent | 7fab46eaa3de8e530863269556676e9de810758a (diff) | |
download | open-axiom-e82d62219c661a2594286e0f867354864514bd87.tar.gz |
Use library parser for bemol.
Diffstat (limited to 'src/syntax')
-rw-r--r-- | src/syntax/Parser.cxx | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/syntax/Parser.cxx b/src/syntax/Parser.cxx index e8759d2b..d78d3157 100644 --- a/src/syntax/Parser.cxx +++ b/src/syntax/Parser.cxx @@ -49,6 +49,46 @@ namespace { using TokenSequence = TokenStream<Token>; + struct ParsingContext { + explicit ParsingContext(TokenSequence& ts) + : tokens{ ts }, position{ } + { } + + bool exhausted() const { + return position >= tokens.size(); + } + + const Token* current_token() const { + if (exhausted()) + return nullptr; + return &tokens[position]; + } + + void advance() { ++position; } + + private: + TokenSequence& tokens; + TokenSequence::size_type position; + }; + + const Token* next_token(ParsingContext& ctx) { + while (auto t = ctx.current_token()) { + switch (t->category) { + case TokenCategory::Whitespace: + break; + + case TokenCategory::Comment: + if (t->value == TokenValue::Wisecrack) + break; + + default: + return t; + } + ctx.advance(); + } + return nullptr; + } + // Simple wrapper around standard file streams, along with the pathname // to the file. template<typename T> @@ -75,6 +115,9 @@ namespace { // FIXME: This is just a stub to get a native parsing entry point // into the bootsys and interpsys images. void transpile_boot_to_lisp(InputFile& in, OutputFile& out) { + out.stream << "## Input: " << in.path << '\n' + << "## Output: " << out.path << '\n'; + SourceInput src { in.stream }; while (auto f = src.get()) { out.stream << "================================================\n"; |