dialogos-project / dialogos

The DialogOS dialog system.
https://www.dialogos.app
GNU General Public License v3.0
21 stars 8 forks source link

oddities in Grammar.java #203

Closed timobaumann closed 4 years ago

timobaumann commented 5 years ago

there's a printPossibleTokens() which (supposedly) prints just that. However, using a left-recursive grammar, it produces:

Possible first terminal symbols for rule...
input : $input, $zahl, eight, five, four, nine, one, seven, six, three, two, zero
zahl : eight, five, four, nine, one, seven, six, three, two, zero

and for a right-recursive grammar:

Possible first terminal symbols for rule...
input : $zahl, eight, five, four, nine, one, seven, six, three, two, zero
zahl : eight, five, four, nine, one, seven, six, three, two, zero
inputNeg : $zahl, eight, five, four, nine, one, seven, six, three, two, zero

What's curious is that (a) in both cases $zahl is reported as a terminal symbol (which, of course, is wrong) and (b) only in the left-recursive case is the recurring symbol mentioned as part of the terminal symbols (note that $inputNeg is not mentioned for $input but $zahl is).

Really odd, I would be curious to know whether we need all this (at least partially broken) functionality or whether it could be removed.

Any thoughts?

timobaumann commented 5 years ago

never mind (b) -- of course the recursion is not a first possible token for right recursion.

timobaumann commented 4 years ago

I'll go ahead and remove printPossibleTokens().