36
index.typ
36
index.typ
@@ -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 "’"}.
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user