diff --git a/src/main/Lexer.java b/src/main/Lexer.java index 8b8b4ba2e2f51d1b53d776abf917c7d3550d2de9..72e417310a791cd2f57708324c4fa151a26eb45b 100644 --- a/src/main/Lexer.java +++ b/src/main/Lexer.java @@ -5,15 +5,27 @@ import Exceptions.LexerException; import java.util.LinkedList; import java.util.List; +/** + * <h1>The Lexer</h1> + * The Lexer class crates a List of Token objects out of a String + * + * @author Dominic Daniel Krämer + * @version 1.0 + * @since 09.01.2023 + */ public class Lexer { - //enum TokenType that can either be a number, variable or a special character (like * or / etc.) + /** + * enum TokenType that can either be a number, variable or a special character (like * or / etc.) + */ public static enum TokenType { NUMBER, VARIABLE, SPECIAL } - //tokens with a TokenType that represents their type and a String with the actual data - //has for both values a getter method and overrides toString with its fitting values + /** + * tokens with a TokenType that represents their type and a String with the actual data + * has for both values a getter method and overrides toString with its fitting values + */ public static class Token { protected TokenType type; protected String data; @@ -36,7 +48,12 @@ public class Lexer { } } - //creates a list of tokens from a given String + /** + * creates a list of tokens from a given String + * @param input The String with the input + * @return result The List of Token objects + * @throws LexerException If the String was empty, or it couldn't create any result out of it + */ public static List<Token> lex(String input) throws Exception{ if(input.isEmpty()) { throw new LexerException("SyntaxError: lexer received empty String"); diff --git a/src/main/Parser.java b/src/main/Parser.java index 4647716cbbb81916362255ba5bdbe49454166d79..c9498cef91455b7a90531718c7953f8edab8e18a 100644 --- a/src/main/Parser.java +++ b/src/main/Parser.java @@ -5,6 +5,14 @@ import Exceptions.ParserException; import java.util.LinkedList; import java.util.List; +/** + * <h1>The Parser</h1> + * The Parser class parses a list of Tokens into an Expression that represents an AST + * + * @author Dominic Daniel Krämer + * @version 1.0 + * @since 09.01.2023 + */ public class Parser { /**