From 88e8cab7f91924a217c09b52ddd92935a1f9f186 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 1 Sep 2016 16:34:44 -0700 Subject: [PATCH] Remove all mention of the ERROR rule type --- README.md | 12 +++--------- doc/grammar-schema.json | 15 --------------- src/compiler/parse_grammar.cc | 11 ----------- 3 files changed, 3 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 6bd5c3f7..d4f4b9b8 100644 --- a/README.md +++ b/README.md @@ -74,14 +74,7 @@ int main() { "type": "SEQ", "members": [ {"type": "STRING", "value": "("}, - - // Error recovery is controlled by wrapping rule subtrees - // in an 'ERROR' rule. - { - "type": "ERROR", - "content": {"type": "SYMBOL", "name": "expression"} - }, - + {"type": "SYMBOL", "name": "expression"}, {"type": "STRING", "value": ")"} ] } @@ -225,6 +218,7 @@ clang \ ### References - [Context Aware Scanning for Parsing Extensible Languages](http://www.umsec.umn.edu/publications/Context-Aware-Scanning-Parsing-Extensible) -- [LR(1) Parser Generation System](http://arxiv.org/pdf/1010.1234.pdf) (Error recovery scheme) - [Efficient and Flexible Incremental Parsing](http://harmonia.cs.berkeley.edu/papers/twagner-parsing.ps.gz) - [Incremental Analysis of Real Programming Languages](http://harmonia.cs.berkeley.edu/papers/twagner-glr.pdf) +- [Error Detection and Recovery in LR Parsers](http://what-when-how.com/compiler-writing/bottom-up-parsing-compiler-writing-part-13) +- [Error Recovery for LR Parsers](http://www.dtic.mil/dtic/tr/fulltext/u2/a043470.pdf) diff --git a/doc/grammar-schema.json b/doc/grammar-schema.json index 9fc50189..5f43b279 100644 --- a/doc/grammar-schema.json +++ b/doc/grammar-schema.json @@ -170,20 +170,6 @@ "required": ["type", "content"] }, - "error-rule": { - "type": "object", - "properties": { - "type": { - "type": "string", - "pattern": "^ERROR$" - }, - "content": { - "$ref": "#/definitions/rule" - } - }, - "required": ["type", "content"] - }, - "prec-rule": { "type": "object", "properties": { @@ -246,7 +232,6 @@ { "$ref": "#/definitions/repeat1-rule" }, { "$ref": "#/definitions/repeat-rule" }, { "$ref": "#/definitions/token-rule" }, - { "$ref": "#/definitions/error-rule" }, { "$ref": "#/definitions/prec-rule" }, { "$ref": "#/definitions/prec-left-rule" }, { "$ref": "#/definitions/prec-right-rule" } diff --git a/src/compiler/parse_grammar.cc b/src/compiler/parse_grammar.cc index 5c1c3200..185d919b 100644 --- a/src/compiler/parse_grammar.cc +++ b/src/compiler/parse_grammar.cc @@ -86,17 +86,6 @@ ParseRuleResult parse_rule(json_value *rule_json) { return { seq(members), "" }; } - if (type == "ERROR") { - json_value content_json = rule_json->operator[]("content"); - ParseRuleResult content = parse_rule(&content_json); - if (content.rule.get()) { - return { content.rule, "" }; - } else { - error_message = "Invalid error content: " + content.error_message; - goto error; - } - } - if (type == "REPEAT") { json_value content_json = rule_json->operator[]("content"); ParseRuleResult content = parse_rule(&content_json);