diff options
| author | GeonoTRON2000 <geono@thegt.org> | 2014-04-29 07:13:20 -0700 |
|---|---|---|
| committer | GeonoTRON2000 <geono@thegt.org> | 2014-04-29 07:13:20 -0700 |
| commit | eb05c2dd956b7e991f52eb5c7f03a0f11b7f1f33 (patch) | |
| tree | b3c7315063dae47af9ccf0efb40c4c2b1376e499 /Shenanigans/src/org/archphantom/shenanigans/parser/ShenaniganParser.scala | |
| parent | b115ae93a10962dd61c18d563be17ad9ef56d47a (diff) | |
| download | shenanigans-eb05c2dd956b7e991f52eb5c7f03a0f11b7f1f33.tar.gz | |
Pushed existing work
Diffstat (limited to 'Shenanigans/src/org/archphantom/shenanigans/parser/ShenaniganParser.scala')
| -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 |
