Bad region recovery, child region not considered
For the following file, region error recovery tries to recover the parse error at the end (marked with a comment). It looks at the previous sibling to see if it can be removed, but it may be too big. It seems like it’s then also not considering the child of this sibling, which would fix the error.
The complete input file:
module meta_amb_suggestionsimports
libstratego-lib
libstratego-sglr
libstratego-aterm
libstratego-xtc
stratego-contextsignature constructors
parse-table : Version * StartState * List(Label) * List(State) * List(Priority) -> parse-table
parse-tree : Tree * Version -> parse-treerules
main =
xtc-io-wrap(
id
,
with(
table := <import-term(include/Stratego-Java-15.tbl)>;
<register-prod(|“Stratego-Java-15”)> table
);
parse-xtc-file-pt-report-errors(|table, None());
rules(
LanguageContext := IN_STRATEGO
);
resolve-ambs-top
)rules // Parse table registration
register-table(|lang-name):
parse-table(version, startstate, labels, states, priorities) ->
with
lang-name
<+
rules(
IsRegisteredTable: lang-name
);
<alltd(register-prod(|lang-name))> labelsregister-prod(|lang-name):
prod(lhs, sort2, a*) ->
where
cons := <one(fetch-cons)> a*;
sort1 := <one(?sort() + ?parameterized-sort(, _))> lhs;
switch !cons
case “ToMetaExpr”:
rules(
ToMetaExpr: (lang-name, sort1, sort2) -> lhs
)
case “FromMetaExpr”:
rules(
FromMetaExpr: (lang-name, sort1, sort2) -> lhs
)
endrules // Ambiguity suggestions
resolve-ambs-top:
parse-tree(tree, version) -> (tree’, amb-error*, amb-warning*)
with
{| AmbErrors, AmbWarnings:
tree’ := tree;
amb-error* := ;
amb-warning* :=
|}resolve-ambs:
appl @ appl(prod @ prod(_, _, a*), arg*) -> appl(prod, arg’)
with
cons := a;
arg’* := <resolve-ambs-change-context(|cons)> arg*
<+
arg’* := <all(resolve-ambs)> arg*resolve-ambs:
amb @ amb(a*) -> amb’
with
if all( a*) then // TODO: or one()?
if LanguageContext => <IN_BUILD + IN_META_BUILD>;
amb then
if <all(is-to-meta-expr-branch)> a* then
// Fixing the amb in e.g. |[ class x ]| would be better for performance
rules(AmbWarnings :+= (amb, amb))
end;
amb’ := amb;
// TODO: amb’ := amb
// for now, I’m treating this just as any other error
rules(AmbErrors :+= (amb, amb))
else
rules(AmbErrors :+= (amb, amb));
amb’ := amb
end
else
// Not a meta-expr ambiguity
amb’ := amb
end/**
* Tests if an ambiguous branch is a ToMetaExpr/FromMetaExpr.
/
is-meta-expr-branch:
appl(prod(_, _, a), kid*) ->
where
a* => <“ToMetaExpr” + “FromMetaExpr”>
<+
one( kid*)/**
* Tests if an ambiguous branch is a ToMetaExpr.
/
is-to-meta-expr-branch:
appl(prod(_, _, a), kid*) ->
where
a* => “ToMetaExpr”
<+
one( kid*)is-decidable-build-amb:
amb(a*) ->
where
all-bodies := <collect-all(?appl(<fetch-cons => “ToMetaExpr”>, ))>;
map(?body);
// TODO: test if possible constructors of test do not collide with constructors of a*
(a*, a*)amb-suggestion:
amb(a*) ->
with
all-possible-quotations := <map()> a*amb-suggestion:
prod(_, sort()) // MISSING RHSrules // ERROR REPORTED HERE
fetch-cons = one(?term(cons()))
and the child of the previous region that should have been removed:
Submitted by Lennart Kats on 11 June 2010 at 13:18
amb-suggestion:
prod(_, sort()) // MISSING RHS
Issue Log
Seems like it may be caused by something else.
I also get a “bad” region recovery for the following:
rules // Ambiguity suggestionsamb-suggestion-parts-prod:
prod()rules // ERROR REPORTED HERE
This time, it will skip the region from “amb” to “rules”, instead of just skipping the last child. So it seems like a last-child problem?
old issue.
Log in to post comments