aboutsummaryrefslogtreecommitdiff
path: root/calculator-javacc/Calculator.jj
diff options
context:
space:
mode:
Diffstat (limited to 'calculator-javacc/Calculator.jj')
-rw-r--r--calculator-javacc/Calculator.jj35
1 files changed, 35 insertions, 0 deletions
diff --git a/calculator-javacc/Calculator.jj b/calculator-javacc/Calculator.jj
new file mode 100644
index 0000000..6cc78f5
--- /dev/null
+++ b/calculator-javacc/Calculator.jj
@@ -0,0 +1,35 @@
+options{DEBUG_PARSER = true; DEBUG_TOKEN_MANAGER = true;}
+
+PARSER_BEGIN(Calculator)
+public class Calculator {
+ public static void main(String[] args) {
+ try{
+ Calculator parser = new Calculator(System.in);
+ parser.Start();
+ }catch (ParseException e){
+ System.out.println(e.getMessage());
+ }
+ }
+}
+PARSER_END(Calculator)
+
+/**
+* For now only using the Hello World grammar
+*/
+
+SKIP : {
+ " "|"\t"|"\n"|"\r"
+}
+
+TOKEN : {
+ <SPACE: " "|"\t">|
+ <HELLO: "hello">|
+ <WORLD: "world">|
+ <HELLOWORLD: <HELLO> ( <SPACE> ) + <WORLD>>
+}
+
+void Start() : {
+}
+{
+ (<HELLOWORLD>)* <EOF>
+} \ No newline at end of file