Restore recursive reference to expr parser in atom parser
This commit is contained in:
@@ -2,5 +2,5 @@ import interpreter.Interpreter
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val interpreter = Interpreter()
|
||||
interpreter.run("2 + 2 * 2 / 2 ** 2")
|
||||
interpreter.run("2 * (2 + 2)")
|
||||
}
|
||||
@@ -2,11 +2,22 @@ package dsl.ast.parser
|
||||
|
||||
import dsl.ast.model.entity.ParserOutput
|
||||
import dsl.token.model.entity.TokenList
|
||||
import dsl.token.model.enumeration.TokenType
|
||||
|
||||
class AtomParser : Parser() {
|
||||
override fun tryToParse(input: TokenList): ParserOutput {
|
||||
val parenthesesParser = allOf(
|
||||
listOf(
|
||||
terminal(TokenType.OPEN_PAREN),
|
||||
ExpressionParser(),
|
||||
terminal(TokenType.CLOSE_PAREN)
|
||||
)
|
||||
) {
|
||||
it[1]
|
||||
}
|
||||
val literalParser = oneOf(
|
||||
listOf(
|
||||
parenthesesParser,
|
||||
BoolLiteralParser(),
|
||||
FloatLiteralParser(),
|
||||
IntegerLiteralParser(),
|
||||
|
||||
Reference in New Issue
Block a user