Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
No it is not. The production rule for function call is given as
That says, that the arguments of the call are
expression
s.3 + 4
is an expression, so interpreting the inputf 2 3 + 4
as equivalent tof 2 (3 + 4)
is valid according to the grammar. That the grammar listsfunction-call
(only) as an option forfactor
does not change that. The grammar is simply ambiguous. In more ways than this.It is defined uniquely by the grammar; function calls have highest precedence.
I think I recall coming across this because I was failing some tests due to whichever order the tests expected. Maybe I just noticed it from the specification though. Unfortunately it was so long ago that I don't remember.
It's probably implementation-dependent, and there do not seem to be tests with it currently.
Did you finish the kata? Which precedence order was correct?
I haven't completed the kata, but I would take f 2 3 + 4 as (f 2 3) + 4, in the same manner that 23+5 is taken as (23)+5
love the kata.
There is so much in there to learn.
Grammar transformations, applying Visitor pattern, ...
There are some ambiguities such as order of evaluation, e.g. "4 / 2 * 3" is 6.0 according to the kata, but could be 2/3 also,
but these can be resolved through debug statements.
I do not believe the problem description uniquely specifies the result of the following:
This could either return 10 or 9, depending on whether it is evaluated as
(f 2 3) + 4
, orf 2 (3 + 4)
.Function calls should thus be added to the precedence table.
Full LR parser for learning purposes
Don't parse the output of ls: http://mywiki.wooledge.org/ParsingLs