diff --git a/src/main/kotlin/SMNP.kt b/src/main/kotlin/SMNP.kt index a3b0ba8..62eaaad 100644 --- a/src/main/kotlin/SMNP.kt +++ b/src/main/kotlin/SMNP.kt @@ -2,5 +2,5 @@ import interpreter.Interpreter fun main(args: Array) { val interpreter = Interpreter() - interpreter.run("true ** 123 ** 4 -\"fsfsef\".13.15 @c:14 3.14") + interpreter.run("2 ** 2 * true ** 123 ** 4 -\"fsfsef\".13.15 @c:14 3.14") } \ No newline at end of file diff --git a/src/main/kotlin/dsl/ast/model/node/ProductOperatorNode.kt b/src/main/kotlin/dsl/ast/model/node/ProductOperatorNode.kt new file mode 100644 index 0000000..00506bf --- /dev/null +++ b/src/main/kotlin/dsl/ast/model/node/ProductOperatorNode.kt @@ -0,0 +1,3 @@ +package dsl.ast.model.node + +class ProductOperatorNode(lhs: Node, operator: Node, rhs: Node) : BinaryOperatorAbstractNode(lhs, operator, rhs) \ No newline at end of file diff --git a/src/main/kotlin/dsl/ast/parser/TermParser.kt b/src/main/kotlin/dsl/ast/parser/TermParser.kt new file mode 100644 index 0000000..afc8f77 --- /dev/null +++ b/src/main/kotlin/dsl/ast/parser/TermParser.kt @@ -0,0 +1,18 @@ +package dsl.ast.parser + +import dsl.ast.model.entity.ParserOutput +import dsl.ast.model.node.ProductOperatorNode +import dsl.token.model.entity.TokenList +import dsl.token.model.enumeration.TokenType + +class TermParser : Parser() { + override fun tryToParse(input: TokenList): ParserOutput { + return leftAssociativeOperator( + FactorParser(), + listOf(TokenType.ASTERISK, TokenType.SLASH), + FactorParser() + ) { + lhs, operator, rhs -> ProductOperatorNode(lhs, operator, rhs) + }.parse(input) + } +} \ No newline at end of file