resolved #1, #2, #3, #4

This commit is contained in:
2025-10-13 20:09:06 +02:00
parent 2fe8b52985
commit 30e60158b4
2 changed files with 28 additions and 8 deletions

BIN
index.pdf

Binary file not shown.

View File

@@ -30,11 +30,24 @@
]
```java
program MyProgram {
void main() {
x[~1]++;
}
}
x[~1]++;
```
The statement above contains the following tokens:
- "program" (literal, terminal)
- MyProgram (ident, terminal)
- "{" (literal, terminal)
- "void" (literal, terminal)
- main (ident, terminal)
- "(" (literal, terminal)
- ")" (literal, terminal)
- "{" (literal, terminal)
- x (iden, terminal)
- "\[" (literal, terminal)
- "~" (literall, terminal)
@@ -42,8 +55,10 @@ The statement above contains the following tokens:
- "\]" (literal, terminal)
- "++" (literal, terminal)
- ";" (literal, terminal)
- "}" (literal, terminal)
- "}" (literal, terminal)
To sum it up the statement has a `~` and has a terminal symbol count of 7.
To sum it up the statement has a `~` and has a terminal symbol count of 17.
=== Task b
@@ -129,15 +144,20 @@ We have the following Recursion:
==== First Sets
- MethodDecl: { void , Type }
- AsignOp: { "=" , "+=" , "-=" , "\*=" , "/=" , "%=" }
- CondTerm: { CondFact }
- MethodDecl: { "void", Type, "}" } = #text(weight: "bold")[{ "void", ident, "}" }]
- AsignOp: #text(weight: "bold")[{ "=" , "+=" , "-=" , "\*=" , "/=" , "%=" }]
- CondTerm: { CondFact } = { Expr } = { Term, '-' } \
\= { Factor, '-' } = { Designator, number, charConst, "new", "(", "-" } \
\= #text(weight: "bold")[{ iden, number, charConst, "new", "(", "-" }]
==== Follow Sets
- MethodDecl: { "}", "void", Follow(Type) } = { "}", "void", ident }
- AsignOp: { ";" }
- CondTerm: { "&&", Follow(CondTerm) } = { "&&", CondFact }
- MethodDecl: { "}", "void", Follow(Type) } = #text(weight: "bold")[{ "}", "void", ident }]
- AsignOp: { Expr } = { "-", Term } = { "-", Factor } \
\= { "-", Designator, number, charConst, "new", "(", "-" } \
\= { "-", ident, number, charConst, "new", "(", "-" } \
\= #text(weight: "bold")[{ "-", ident, number, charConst, "new", "(" }]
- CondTerm: { "||", Follow(Condition) } = #text(weight: "bold")[{ "||", ")" }]
== 02 Konstruktion einer Grammatik
@@ -198,7 +218,7 @@ Row = "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8".
=== Task 2
```ebnf
Props = ident ":" Value { "," ident ":" Value } ";".
Props = ident ":" Value { "," ident ":" Value }.
Value = (ε | "" text "") {"+" "" text ""}.
```