Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[fix] TRX: Evaluation of productions was sometimes too eager.

If a choice was rejected because of partiality (i.e. parsing was
non-partial and the rule matched but did not consume all input)
then its associated production was still evaluated. So for
instance:

do Parser.parse(
  parser "/" -> jlog("bli")
       | "/bla" -> jlog("bla"),
  "/bla")

would print both bli & bla (OPA-832). Fixed now.
  • Loading branch information...
commit cdf502e330f92561db55bb1d9925064a88fa566f 1 parent 3a671c5
@akoprow akoprow authored
Showing with 10 additions and 3 deletions.
  1. +2 −3 passes/surfaceAstTrx.ml
  2. +8 −0 stdlib/core/parser/parser_private.opa
View
5 passes/surfaceAstTrx.ml
@@ -181,11 +181,10 @@ and translate_seq ~nested ~res_needed org_input (seq, loc) =
else
C.E.void ()
in
- let return_val = success_exp input result in
if nested then
- return_val
+ success_exp input result
else
- call_runtime_fun "check_partial" [!partial_flag_name; return_val]
+ call_runtime_fun "check_partial_lazy" [!partial_flag_name; input; (C.E.lambda []result)]
| (x, loc)::xs ->
let item_name = x.item_name in
View
8 stdlib/core/parser/parser_private.opa
@@ -68,6 +68,14 @@ type Parser_private.range = { one : Unicode.character }
Parser_private =
{{
+ check_partial_lazy(partial, it, res) =
+ if partial then
+ some((it, res()))
+ else
+ match Itextrator.next(it) with
+ | {none} -> some((it, res()))
+ | {some=_} -> none
+
check_partial(partial, result) =
if partial then
result
Please sign in to comment.
Something went wrong with that request. Please try again.