diff --git a/Aufgabe4/Parser.java b/Aufgabe4/Parser.java index 57c8728b9eb5caa7491730eb5b610a47755ea61e..c230d25d1e90bd397429597216d28cb9b98b0025 100644 --- a/Aufgabe4/Parser.java +++ b/Aufgabe4/Parser.java @@ -184,7 +184,7 @@ public class Parser { toReturn.astDigitAfterComma = parseNumber(new ArrayList<> (decimalTokens.subList(positionOfDecimalPoint + 1, decimalTokens.size()))); } - + diff --git a/Aufgabe4/main.java b/Aufgabe4/main.java index 935ae503a1c3d0896e2330eea377c7f87ea542d3..f46339291eb2aece0c9a9ad35e165a10c010f6bd 100644 --- a/Aufgabe4/main.java +++ b/Aufgabe4/main.java @@ -2,12 +2,12 @@ import java.util.Arrays; public class main { - public static void main(String[] args){ + public static void main(String[] args) { // values above integer space will produce errors - String ausdruck = "3.5 * 2.5 + 2.1"; + String ausdruck = "0032.00555 * 2.5 + 2.1"; Lexer lexer = new Lexer(); @@ -23,9 +23,7 @@ public class main { Parser p = new Parser(); - AstExpression result = p.parse(lexer.lex(ausdruck)); - - + AstExpression result = p.parse(lexer.lex(ausdruck)); do { @@ -41,7 +39,7 @@ public class main { System.out.println(result.astBinaryOp.astOperator.astOperator); - if(result.astBinaryOp.astExpression2.astValue != null) { + if (result.astBinaryOp.astExpression2.astValue != null) { try { System.out.println(result.astBinaryOp.astExpression2.astValue.astNumber.astDigitWoz.astDigitWozContent); @@ -62,45 +60,7 @@ public class main { } - - } while ( true ); - -/* - - System.out.println( ((AstValue) result.astBinaryOp.binaryOp[0]).astNumber.astDigitWoz.astDigitWozContent ); - - System.out.println( ((AstOperator) result.astBinaryOp.binaryOp[1]).astOperator ); - - - //------------------- - - AstExpression root = (AstExpression) result.astBinaryOp.binaryOp[2]; - - System.out.println( ((AstValue) root.astBinaryOp.binaryOp[0]).astNumber.astDigitWoz.astDigitWozContent ); - - System.out.println( ((AstOperator) root.astBinaryOp.binaryOp[1]).astOperator ); - - //--------------------- - - AstExpression root2 = (AstExpression) root.astBinaryOp.binaryOp[2]; - - System.out.println( ((AstValue) root2.astBinaryOp.binaryOp[0]).astNumber.astDigitWoz.astDigitWozContent ); - - System.out.println( ((AstOperator) root2.astBinaryOp.binaryOp[1]).astOperator ); - - System.out.println( ((AstValue) root2.astBinaryOp.binaryOp[2]).astNumber.astDigitWoz.astDigitWozContent ); - - - -*/ + } while (true); } - /* - void printAst (AstExpression astE) { - - if(astE.) - - } - - */ }