syntactic ambiguity if binding rule ends with "imports"
Foo: imports Sort from m Foo(_) : scopes Sort
yields
Submitted by Sebastian Erdweg on 8 May 2014 at 11:05amb( [ [ BindingRule( Var("Foo") , [] , [ ImportClause( [ WildcardImport( [Restricted([], NamespaceRef("Sort"))] , [] , RefScope(VarRef("m")) , Current() , [] ) ] ) ] ) , BindingRule( NoAnnoList(Op("Foo", [Wld()])) , [] , [ScopeClause([NamespaceRef("Sort")])] ) ] , [ BindingRule( Var("Foo") , [] , [ ImportClause( [ WildcardImport( [Restricted([], NamespaceRef("Sort"))] , [] , Context(All(), NamespaceRef("m"), VarRef("Foo"), [], Current()) , Current() , [] ) ] ) ] ) , BindingRule( NoAnnoList(Tuple([Wld()])) , [] , [ScopeClause([NamespaceRef("Sort")])] ) ] ] )
Issue Log
On 8 May 2014 at 13:15 Guido Wachsmuth commented:
The second alternative parses it as
Foo: imports Sort from m Foo (_): scopes Sort
This is a typical ambiguity for terms with optional parentheses for nullary constructors and tuples.
Possible fixes:
- Make parentheses mandatory.
- Introduce a keyword in the
imports ... from t
clause, e.g.imports ... from term t
.- Introduce an end-of-rule marker.
On 8 May 2014 at 13:17 Guido Wachsmuth tagged syntax
On 24 June 2014 at 17:19 D. Pelsmaeker commented:
I’m also encountering this issue. The following NaBL snippet gives me an ambiguity error:
binding rules Entity(name, super, _): imports Property from super EntityNoSuper(name, _): defines Entity name
The AST is ambiguous between this:
[BindingRule(Op("Entity", [Var("name"),Var("super"),Wld]),NoWhere, [ImportClause([WildcardImport([Restricted([],NamespaceRef(CurrentLanguage,"Property"))], [],Context(All,NamespaceRef(CurrentLanguage,"super"),VarRef("EntityNoSuper"), [],Current),Current,NoWhere)])]),BindingRule(Tuple([Var("name"),Wld]),NoWhere, [DefClause(Explicit,Unique,NamespaceRef(CurrentLanguage,"Entity"),VarRef("name"), [],Current,NoWhere)])]
And this:
[BindingRule(Op("Entity",[Var("name"),Var("super"),Wld]),NoWhere, [ImportClause([WildcardImport([Restricted([],NamespaceRef(CurrentLanguage,"Property"))], [],RefScope(VarRef("super")),Current,NoWhere)])]),BindingRule(Op("EntityNoSuper", [Var("name"),Wld]),NoWhere, [DefClause(Explicit,Unique,NamespaceRef(CurrentLanguage,"Entity"),VarRef("name"), [],Current,NoWhere)])]
A possible solution is to require
into
. In this caseinto current scope
can already be used.binding rules Entity(name, super, _): imports Property from super into current scope EntityNoSuper(name, _): defines Entity name
On 24 June 2014 at 18:56 Guido Wachsmuth commented:
For now, you can circumvent this by introducing another
binding rules
phrase after the import rule.
Log in to post comments