Skip to content

Commit 4c942c5

Browse files
authored
manual: fix string escapes in example (#1091)
1 parent ffb61f1 commit 4c942c5

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

docs/md/example.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ section presents a part of the specification for the Java language.
1111

1212
The example does not describe the whole lexical structure of Java programs,
1313
but only a small and simplified part of it:
14+
1415
- some keywords,
1516
- some operators,
16-
- comments
17+
- comments
1718
- and only two kinds of literals.
1819

19-
It also shows how to interface with the LALR parser generator CUP [@CUP]
20+
It also shows how to interface with the LALR parser generator CUP [@CUP]
2021
and therefore uses a class `sym` (generated by CUP), where integer constants
21-
for the terminal tokens of the CUP grammar are declared.
22+
for the terminal tokens of the CUP grammar are declared.
2223

2324
You can find this example in `examples/cup-java-minijava`.
2425

@@ -29,7 +30,7 @@ interface with the JFlex scanner). Both specifications adhere to the Java
2930
Language Specification [@LangSpec].
3031

3132
In `examples/standalone`, you can find a small standalone scanner that
32-
doesn’t need other dependencies or tools like CUP to give you working code.
33+
doesn’t need other dependencies or tools like CUP to give you working code.
3334

3435

3536
```
@@ -85,9 +86,9 @@ doesn’t need other dependencies or tools like CUP to give you working code.
8586
<YYINITIAL> "break" { return symbol(sym.BREAK); }
8687
8788
<YYINITIAL> {
88-
/* identifiers */
89+
/* identifiers */
8990
{Identifier} { return symbol(sym.IDENTIFIER); }
90-
91+
9192
/* literals */
9293
{DecIntegerLiteral} { return symbol(sym.INTEGER_LITERAL); }
9394
\" { string.setLength(0); yybegin(STRING); }
@@ -99,22 +100,22 @@ doesn’t need other dependencies or tools like CUP to give you working code.
99100
100101
/* comments */
101102
{Comment} { /* ignore */ }
102-
103+
103104
/* whitespace */
104105
{WhiteSpace} { /* ignore */ }
105106
}
106107
107108
<STRING> {
108-
\" { yybegin(YYINITIAL);
109-
return symbol(sym.STRING_LITERAL,
109+
\" { yybegin(YYINITIAL);
110+
return symbol(sym.STRING_LITERAL,
110111
string.toString()); }
111112
[^\n\r\"\\]+ { string.append( yytext() ); }
112113
\\t { string.append('\t'); }
113114
\\n { string.append('\n'); }
114115
115116
\\r { string.append('\r'); }
116117
\\\" { string.append('\"'); }
117-
\\ { string.append('\\'); }
118+
\\\\ { string.append('\\'); }
118119
}
119120
120121
/* error fallback */

0 commit comments

Comments
 (0)