You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
scala>classC(valinput:ParserInput) extendsParser{
|defid(r: Rule0) = r
|defMyRule= rule( "omg" )
|defMyRule2= rule( "wtf"~ id(MyRule) )
| }
defined classC
If we're going to dedicate paragraphs of text and code-snippets to say how illegal this code is, is there any way to make it not-compile? If we can't make it work properly maybe we can at least make it not compile
Note that a related parser does not compile, but probably for the wrong reasons
scala>classC(valinput:ParserInput) extendsParser{
|defid(r: Rule0) = r
|defMyRule= rule( "omg"~ id("wtf"~"bbq") )
| }
<console>:12:error: Calls to `~` must be inside `rule` macro
defMyRule= rule( "omg"~ id("wtf"~"bbq") )
^
<console>:12:error: Calls to `str` must be inside `rule` macro
defMyRule= rule( "omg"~ id("wtf"~"bbq") )
^
<console>:12:error: Calls to `str` must be inside `rule` macro
defMyRule= rule( "omg"~ id("wtf"~"bbq") )
The text was updated successfully, but these errors were encountered:
The question is how we can distinguish between the in principle legal (#116):
deffoo= rule(bar(baz))
defbar(r: =>Rule0) = r
defbaz= rule(...)
and the definitely illegal
deffoo= rule(bar(baz))
defbar(r: Rule0) = r
defbaz= rule(...)
On the type level there is no difference, so we'd have to catch it in one of the macro expansions.
In baz we can't, because that is a legal rule in itself.
So we have to catch it in the expansion of the foo rule macro by realizing that an expression evaluating to RuleX is passed as argument to a call where the respective parameter is not call-by-name. However, at the call site of bar there is no difference between passing a normal and passing a call-by-name argument.
We need to be able to look at the signature of bar at the call site for bar, which is (AFAIK) impossible with the current macro infrastructure and the per-rule macro approach we currently apply.
So, it appears to me that we won't be able to clear this ticket before having cleared #118.
If we're going to dedicate paragraphs of text and code-snippets to say how illegal this code is, is there any way to make it not-compile? If we can't make it work properly maybe we can at least make it not compile
Note that a related parser does not compile, but probably for the wrong reasons
The text was updated successfully, but these errors were encountered: