Skip to content
Snippets Groups Projects
Commit 9acde4af authored by Dominic Daniel Krämer's avatar Dominic Daniel Krämer
Browse files

added JavaDocs documentation to the Parser.java and Lexer.java

parent 0a999534
No related branches found
No related tags found
1 merge request!14Dominicsbranch
......@@ -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");
......
......@@ -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 {
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment