diff options
author | Ryo Nihei <nihei.dev@gmail.com> | 2021-09-07 01:02:22 +0900 |
---|---|---|
committer | Ryo Nihei <nihei.dev@gmail.com> | 2021-09-07 02:17:41 +0900 |
commit | 0cf26ed10f2563ea6721590ddbd5cccc7fa502b1 (patch) | |
tree | e6ef2c493a0b2573436a59a4e07d224d2c79497c | |
parent | Add the semantic action API 'TrapAndShiftError' instead of 'TrapError' and 'S... (diff) | |
download | urubu-0cf26ed10f2563ea6721590ddbd5cccc7fa502b1.tar.gz urubu-0cf26ed10f2563ea6721590ddbd5cccc7fa502b1.tar.xz |
Call the 'MissError' when input doesn't meet an error production
-rw-r--r-- | driver/parser.go | 4 | ||||
-rw-r--r-- | driver/semantic_action_test.go | 4 |
2 files changed, 7 insertions, 1 deletions
diff --git a/driver/parser.go b/driver/parser.go index 522362e..3099d73 100644 --- a/driver/parser.go +++ b/driver/parser.go @@ -136,6 +136,10 @@ ACTION_LOOP: return err } if tok.EOF { + if p.semAct != nil { + p.semAct.MissError() + } + return nil } diff --git a/driver/semantic_action_test.go b/driver/semantic_action_test.go index ef92d92..c3f8943 100644 --- a/driver/semantic_action_test.go +++ b/driver/semantic_action_test.go @@ -147,12 +147,14 @@ char: "[a-z]"; }, }, { - caption: "the driver doesn't call `Accept` when a syntax error is trapped, but the input doesn't meet the error production", + caption: "when the input doesn't meet the error production, the driver calls `MissError`.", specSrc: specSrcWithErrorProd, src: `a !`, actLog: []string{ "shift/char", "trap/1/shift/error", + + "miss", }, }, { |