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_suggestions

imports
libstratego-lib
libstratego-sglr
libstratego-aterm
libstratego-xtc
stratego-context

signature constructors

parse-table : Version * StartState * List(Label) * List(State) * List(Priority) -> parse-table
parse-tree : Tree * Version -> parse-tree

rules

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))> labels

register-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
)
end

rules // 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 RHS

rules // ERROR REPORTED HERE

fetch-cons = one(?term(cons()))

and the child of the previous region that should have been removed:


amb-suggestion:
prod(_, sort()) // MISSING RHS

Submitted by Lennart Kats on 11 June 2010 at 13:18

On 11 June 2010 at 13:56 Lennart Kats commented:

Seems like it may be caused by something else.

I also get a “bad” region recovery for the following:


rules // Ambiguity suggestions

amb-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?


On 23 November 2011 at 13:12 Lennart Kats tagged 1.1

On 23 November 2011 at 13:12 Lennart Kats removed tag interesting

On 24 February 2012 at 18:25 Lennart Kats removed tag major

On 24 February 2012 at 18:25 Lennart Kats tagged pre-new-terms

On 17 October 2012 at 11:26 Maartje commented:

old issue.


On 17 October 2012 at 11:26 Maartje closed this issue.

Log in to post comments