diff options
Diffstat (limited to 'Shenanigans/src/org/archphantom/shenanigans/parser')
| -rw-r--r-- | Shenanigans/src/org/archphantom/shenanigans/parser/ShenaniganParser.scala | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/Shenanigans/src/org/archphantom/shenanigans/parser/ShenaniganParser.scala b/Shenanigans/src/org/archphantom/shenanigans/parser/ShenaniganParser.scala new file mode 100644 index 0000000..e413a03 --- /dev/null +++ b/Shenanigans/src/org/archphantom/shenanigans/parser/ShenaniganParser.scala @@ -0,0 +1,50 @@ +package org.archphantom.shenanigans.parser +/* +import org.archphantom.shenanigans.elements.expressions._ +import org.archphantom.shenanigans.elements.expressions.statements._ +import org.archphantom.shenanigans.elements.values._ +import scala.util.parsing.combinator._ +import scala.util.parsing.combinator.lexical.StdLexical +import scala.util.parsing.combinator.syntactical.StandardTokenParsers +import org.archphantom.shenanigans.elements.expressions.operations._ + +object ShenaniganParser extends StandardTokenParsers { + override val lexical = new ShenaniLexer + + def parse (input : String) { + + } + + def boolean : Parser[BoolValue] = ("true" | "false") ^^ { + s => new BoolValue(s.toBoolean) + } + + def string : Parser[Array] = stringLit ^^ { + s => new Array(s) + } + + def double : Parser[DecimalValue] = numericLit ^^ { + s => new DecimalValue(s) + } + + def int : Parser[IntValue] = """\-?[0-9]+""".r ^^ { + s => new IntValue(s) + } + + def parens : Parser[Expression] = "(" ~> expr <~ ")" + + def unaryMinus:Parser[Subtraction] = "-" ~> expr ^^ { new Subtraction(new IntValue(0), expr) } + + def literal : Parser[Value] = boolean | string | double | int + + def variable : Parser[Variable] = """[a-zA-Z_]([\w\.]*\w)?""".r ^^ { + s => new Variable(s) + } + + def expr = literal | variable + +} + +class ShenaniLexer extends StdLexical { + +}*/
\ No newline at end of file |
