From f02eee6fd65e352c3fdc16b51aa7f99c2c63482d Mon Sep 17 00:00:00 2001 From: Maƫl Gassmann Date: Fri, 11 Jun 2021 22:30:14 +0200 Subject: [+] Added basic structure for the javacc-calculator --- calculator-javacc/.gitignore | 4 ++++ calculator-javacc/Calculator.jj | 35 +++++++++++++++++++++++++++++++++++ calculator-javacc/compileRun.sh | 2 ++ 3 files changed, 41 insertions(+) create mode 100644 calculator-javacc/.gitignore create mode 100644 calculator-javacc/Calculator.jj create mode 100755 calculator-javacc/compileRun.sh (limited to 'calculator-javacc') diff --git a/calculator-javacc/.gitignore b/calculator-javacc/.gitignore new file mode 100644 index 0000000..0e5a09f --- /dev/null +++ b/calculator-javacc/.gitignore @@ -0,0 +1,4 @@ +calculator-javacc.iml +.idea/ +*.java +*.class 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 : { + | + | + | + ( ) + > +} + +void Start() : { +} +{ + ()* +} \ No newline at end of file diff --git a/calculator-javacc/compileRun.sh b/calculator-javacc/compileRun.sh new file mode 100755 index 0000000..555604e --- /dev/null +++ b/calculator-javacc/compileRun.sh @@ -0,0 +1,2 @@ +#/bin/sh +javacc Calculator.jj && javac *.java && clear && java Calculator -- cgit v1.2.3