From 9acde4af4ddd627b96214c78b20216fb6504b223 Mon Sep 17 00:00:00 2001 From: Kraemerd <Dominic_Daniel.Kraemer@Student.Reutlingen-University.de> Date: Mon, 9 Jan 2023 19:20:52 +0100 Subject: [PATCH] added JavaDocs documentation to the Parser.java and Lexer.java --- src/main/Lexer.java | 25 +++++++++++++++++++++---- src/main/Parser.java | 8 ++++++++ 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/main/Lexer.java b/src/main/Lexer.java index 8b8b4ba..72e4173 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 4647716..c9498ce 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 { /** -- GitLab