Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Abgabe4Java
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dominic Daniel Krämer
Abgabe4Java
Commits
9acde4af
Commit
9acde4af
authored
2 years ago
by
Dominic Daniel Krämer
Browse files
Options
Downloads
Patches
Plain Diff
added JavaDocs documentation to the Parser.java and Lexer.java
parent
0a999534
No related branches found
No related tags found
1 merge request
!14
Dominicsbranch
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/Lexer.java
+21
-4
21 additions, 4 deletions
src/main/Lexer.java
src/main/Parser.java
+8
-0
8 additions, 0 deletions
src/main/Parser.java
with
29 additions
and
4 deletions
src/main/Lexer.java
+
21
−
4
View file @
9acde4af
...
...
@@ -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"
);
...
...
This diff is collapsed.
Click to expand it.
src/main/Parser.java
+
8
−
0
View file @
9acde4af
...
...
@@ -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
{
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment