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
a52098c0
Commit
a52098c0
authored
2 years ago
by
Dominic Daniel Krämer
Browse files
Options
Downloads
Patches
Plain Diff
implemented better text output for the ParserExceptions
parent
49cea458
No related branches found
No related tags found
1 merge request
!6
Dominicsbranch
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Parser.java
+4
-4
4 additions, 4 deletions
src/Parser.java
with
4 additions
and
4 deletions
src/Parser.java
+
4
−
4
View file @
a52098c0
...
...
@@ -84,7 +84,7 @@ public class Parser {
//parses a list of tokens into a value
private
Optional
<
Expression
>
parseValue
(
List
<
Lexer
.
Token
>
ts
)
throws
ParserException
{
if
(
ts
.
isEmpty
())
{
throw
new
ParserException
(
"
SyntaxError: expected a number
"
);
throw
new
ParserException
(
"
RuntimeException: empty token list
"
);
}
if
(
ts
.
get
(
0
).
getType
()
!=
Lexer
.
TokenType
.
NUMBER
)
{
return
Optional
.
empty
();
...
...
@@ -114,13 +114,13 @@ public class Parser {
//parses a decimal of a list of tokens & a string
private
Expression
parseDecimal
(
List
<
Lexer
.
Token
>
ts
,
String
data
)
throws
ParserException
{
if
(
ts
.
size
()<
1
)
{
throw
new
ParserException
(
"
SyntaxError:
"
);
throw
new
ParserException
(
"
RuntimeException: empty token list
"
);
}
if
(
ts
.
get
(
0
).
getType
()
!=
Lexer
.
TokenType
.
SPECIAL
)
{
throw
new
ParserException
(
""
);
throw
new
ParserException
(
"
SyntaxException: expected a comma
"
);
}
if
(
ts
.
get
(
1
).
getType
()
!=
Lexer
.
TokenType
.
NUMBER
)
{
throw
new
ParserException
(
""
);
throw
new
ParserException
(
"
SyntaxException: expected a number after a comma
"
);
}
Number
beforeDot
=
(
Number
)
parseNumber
(
data
);
ts
.
remove
(
0
);
...
...
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