手动调整 env/stack/semantic 值以实现错误恢复
Manually tweak env/stack/semantic value to achieve an error recovery
我正在尝试在 this version of the project 中实现错误恢复(make
后跟 ./parse e1.input
进行测试)。
给定 e1.input
中的 (1
,我希望解析器像解析 )
一样运行并构建 AST Paren (Int 1)
。因此,我尝试了
let (startp, endp) = positions in
let _ = feed (T T_RPAREN) startp () endp env in
然而,它返回了一个错误Invalid_argument("feed: outgoing transition does not exist")
hahahaha depth of env 2
hahahaha current_state_number 2
hahahaha startp 1:1
hahahaha endp 1:2
element number of state 2
element startp 1:1
element endp 1:2
element incoming_symbol an integer
element v toComplete
element item: an expression -> an integer.
element number of state 1
element startp 1:0
element endp 1:1
element incoming_symbol (
element v toComplete
element item: an expression -> ( .an expression )
Line 1, characters 2-2: Error (parsing)
Error while analyzing an expression.
Fatal error: exception Invalid_argument("feed: outgoing transition does not exist")
有谁知道为什么会出现这个错误?
在喂)
之前,我们应该先reduce,下面的代码有效:
let env_new = force_reduction (find_production 1) env in
let env_new_new = feed (T T_RPAREN) startp () endp env_new in
(lex, input_needed env_new_new)
例如(1+2
,我们应该在喂)
之前减少两次,下面的代码有效:
let env_new = force_reduction (find_production 1) env in
let env_new_new = force_reduction (find_production 3) env_new in
let env_new_new_new = feed (T T_RPAREN) startp () endp env_new_new in
(lex, input_needed env_new_new_new)
我正在尝试在 this version of the project 中实现错误恢复(make
后跟 ./parse e1.input
进行测试)。
给定 e1.input
中的 (1
,我希望解析器像解析 )
一样运行并构建 AST Paren (Int 1)
。因此,我尝试了
let (startp, endp) = positions in
let _ = feed (T T_RPAREN) startp () endp env in
然而,它返回了一个错误Invalid_argument("feed: outgoing transition does not exist")
hahahaha depth of env 2
hahahaha current_state_number 2
hahahaha startp 1:1
hahahaha endp 1:2
element number of state 2
element startp 1:1
element endp 1:2
element incoming_symbol an integer
element v toComplete
element item: an expression -> an integer.
element number of state 1
element startp 1:0
element endp 1:1
element incoming_symbol (
element v toComplete
element item: an expression -> ( .an expression )
Line 1, characters 2-2: Error (parsing)
Error while analyzing an expression.
Fatal error: exception Invalid_argument("feed: outgoing transition does not exist")
有谁知道为什么会出现这个错误?
在喂)
之前,我们应该先reduce,下面的代码有效:
let env_new = force_reduction (find_production 1) env in
let env_new_new = feed (T T_RPAREN) startp () endp env_new in
(lex, input_needed env_new_new)
例如(1+2
,我们应该在喂)
之前减少两次,下面的代码有效:
let env_new = force_reduction (find_production 1) env in
let env_new_new = force_reduction (find_production 3) env_new in
let env_new_new_new = feed (T T_RPAREN) startp () endp env_new_new in
(lex, input_needed env_new_new_new)