Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scanner und Parser Hannah Buch S.165 Aufg 1
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Abitur 2025
scanner und Parser Hannah Buch S.165 Aufg 1
Commits
218ab510
Commit
218ab510
authored
6 months ago
by
hannah.blech
Browse files
Options
Downloads
Patches
Plain Diff
comitt files
parent
fdc17298
Branches
main
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/Parser.java
+22
-2
22 additions, 2 deletions
src/Parser.java
src/Scanner.java
+4
-1
4 additions, 1 deletion
src/Scanner.java
src/Token.java
+1
-0
1 addition, 0 deletions
src/Token.java
with
27 additions
and
3 deletions
src/Parser.java
+
22
−
2
View file @
218ab510
import
java.util.List
;
public
class
Parser
{
private
List
<
Token
>
tokenliste
;
private
Token
aktuellesToken
;
public
Parser
(
List
<
Token
>
pTokenliste
){
...
...
@@ -11,19 +13,37 @@ public class Parser {
}
public
boolean
parse
(){
if
(
tokenliste
.
hasAccess
()
&&
pruefeS
()){
return
true
;
}
else
{
return
false
;
}
}
public
boolean
pruefeS
(){
aktuellesToken
=
tokenliste
.
getFirst
();
if
(
tokenliste
.
hasAccess
()
&&
aktuellesToken
.
getTyp
()
==
"EGAL"
||
aktuellesToken
.
getTyp
()
==
"ENDE"
){
aktuellesToken
=
nextToken
();
return
pruefeA
();
}
else
{
return
false
;}
}
public
boolean
pruefeA
(){
if
(
tokenliste
.
hasAccess
()
&&
aktuellesToken
.
getTyp
()
==
"EGAL"
||
aktuellesToken
.
getTyp
()
==
"ENDE"
){
aktuellesToken
=
nextToken
();
return
pruefeB
();
}
else
{
return
false
;}
}
public
boolean
pruefeS
(){
public
boolean
pruefeB
(){
return
tokenliste
.
hasAccess
()
&&
aktuellesToken
.
getTyp
()
==
"ENDE"
;
}
}
This diff is collapsed.
Click to expand it.
src/Scanner.java
+
4
−
1
View file @
218ab510
import
java.util.List
;
public
class
Scanner
{
private
String
eingabe
;
...
...
@@ -20,6 +21,7 @@ public class Scanner {
while
(
eingabe
.
charAt
(
pos
)
!=
'#'
){
erster
=
eingabe
.
charAt
(
pos
);
zweiter
=
eingabe
.
charAt
(
pos
+
1
);
Token
aktuellesToken
;
if
(
erster
==
'l'
&&
zweiter
==
'a'
){
aktuellesToken
=
new
Token
(
"EGAL"
,
"la"
);
}
...
...
@@ -31,6 +33,7 @@ public class Scanner {
}
else
{
fehler
=
true
;
ausgabe
();
break
;
}
...
...
@@ -40,7 +43,7 @@ public class Scanner {
}
private
void
ausgabe
(
boolean
fehler
){
private
void
ausgabe
(){
if
(
fehler
){
System
.
out
.
println
(
"Eingabe war nicht entsprechend der Regeln der Sprache. Bitte veruche es erneut"
);
}
...
...
This diff is collapsed.
Click to expand it.
src/Token.java
+
1
−
0
View file @
218ab510
...
...
@@ -23,4 +23,5 @@ public class Token {
public
void
setTyp
(
String
typ
)
{
this
.
typ
=
typ
;
}
}
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