diff options
author | Ben Smith <binjimin@gmail.com> | 2017-08-15 14:36:20 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-15 14:36:20 -0700 |
commit | 3d3920f6d9388c46af6725dabb34d98752958d8d (patch) | |
tree | cf77acb6d4140b2fb791f91d4af38d59ad8f66a3 /src/wast-parser-lexer-shared.cc | |
parent | 68e8642fea319253466bb3bddece75306f808a69 (diff) | |
download | wabt-3d3920f6d9388c46af6725dabb34d98752958d8d.tar.gz wabt-3d3920f6d9388c46af6725dabb34d98752958d8d.tar.bz2 wabt-3d3920f6d9388c46af6725dabb34d98752958d8d.zip |
Rewrite parser as recursive descent (#591)
* Remove Bison dependency
* Remove pre-generated parser files
* Rename build config from no-re2c-bison to no-re2c
* Add a simple make_unique implementation
* Move handling of module bindings into ir.cc
* Simplify lexer
- Remove lookahead, the parser handles this now
- Unify Token/LexerToken, it only contains terminal values now
- Refactor setting token type and value into one function (e.g.
LITERAL, RETURN => RETURN_LITERAL)
* New Parser
- Uses two tokens of lookahead (use Peek(0) or Peek(1))
- Consume() consumes one token of any kind
- Match(t) consumes the current token if it matches
- PeekMatch(t) returns true iff the token matches, but doesn't consume
- Basic error synchronization; plenty of room for improvement here
Diffstat (limited to 'src/wast-parser-lexer-shared.cc')
-rw-r--r-- | src/wast-parser-lexer-shared.cc | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/src/wast-parser-lexer-shared.cc b/src/wast-parser-lexer-shared.cc index c9ad9b61..80a9b8bd 100644 --- a/src/wast-parser-lexer-shared.cc +++ b/src/wast-parser-lexer-shared.cc @@ -16,27 +16,14 @@ #include "wast-parser-lexer-shared.h" -#include <cstdarg> -#include <cstdio> -#include <cstring> -#include <string> +#include "common.h" +#include "error-handler.h" +#include "wast-lexer.h" namespace wabt { -void WastParserError(Location* loc, - WastLexer* lexer, - WastParser* parser, - const char* format, - ...) { - parser->errors++; - va_list args; - va_start(args, format); - WastFormatError(parser->error_handler, loc, lexer, format, args); - va_end(args); -} - void WastFormatError(ErrorHandler* error_handler, - const struct Location* loc, + const Location* loc, WastLexer* lexer, const char* format, va_list args) { |