Skip to content

Commit cbe04b6

Browse files
committed
---
yaml --- r: 124926 b: refs/heads/auto c: f8fd32e h: refs/heads/master v: v3
1 parent 9fdee0b commit cbe04b6

File tree

4 files changed

+25
-5
lines changed

4 files changed

+25
-5
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: 9fc5cf902f9613f40ce4d4346d1ae98a0904e67a
16+
refs/heads/auto: f8fd32ef9dd48a216ae5ca44ca65ea8f2205f581
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/grammar/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
verify
2+
*.class
3+
*.java
4+
*.tokens

branches/auto/src/grammar/RustLexer.g4

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ SHR : '>>' ;
4444

4545
BINOP
4646
: PLUS
47+
| SLASH
4748
| MINUS
4849
| STAR
4950
| PERCENT
@@ -95,6 +96,10 @@ LIT_CHAR
9596
: '\'' ( '\\' CHAR_ESCAPE | ~[\\'\n\t\r] ) '\''
9697
;
9798

99+
LIT_BYTE
100+
: 'b\'' ( '\\' ( [xX] HEXIT HEXIT | [nrt\\'"0] ) | ~[\\'\n\t\r] ) '\''
101+
;
102+
98103
fragment INT_SUFFIX
99104
: 'i'
100105
| 'i8'
@@ -130,7 +135,7 @@ LIT_STR
130135
;
131136

132137
LIT_BINARY : 'b' LIT_STR ;
133-
LIT_BINARY_RAW : 'b' LIT_STR_RAW ;
138+
LIT_BINARY_RAW : 'rb' LIT_STR_RAW ;
134139

135140
/* this is a bit messy */
136141

@@ -159,7 +164,7 @@ OUTER_DOC_COMMENT : '//!' ~[\r\n]* -> type(DOC_COMMENT) ;
159164
LINE_COMMENT : '//' ~[\r\n]* -> type(COMMENT) ;
160165

161166
DOC_BLOCK_COMMENT
162-
: ('/**' | '/*!') (DOC_BLOCK_COMMENT | .)*? '*/' -> type(DOC_COMMENT)
167+
: ('/**' ~[*] | '/*!') (DOC_BLOCK_COMMENT | .)*? '*/' -> type(DOC_COMMENT)
163168
;
164169

165170
BLOCK_COMMENT : '/*' (BLOCK_COMMENT | .)*? '*/' -> type(COMMENT) ;

branches/auto/src/grammar/verify.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ fn parse_token_list(file: &str) -> HashMap<String, Token> {
7171
"IDENT" => id(),
7272
"PLUS" => BINOP(PLUS),
7373
"LIT_CHAR" => LIT_CHAR(Name(0)),
74+
"LIT_BYTE" => LIT_BYTE(Name(0)),
7475
"EQ" => EQ,
7576
"RBRACKET" => RBRACKET,
7677
"COMMENT" => COMMENT,
@@ -124,7 +125,7 @@ fn str_to_binop(s: &str) -> BinOp {
124125
}
125126
}
126127

127-
/// Assuming a raw string/binary literal, strip out the leading/trailing
128+
/// Assuming a string/binary literal, strip out the leading/trailing
128129
/// hashes and surrounding quotes/raw/binary prefix.
129130
fn fix(mut lit: &str) -> ast::Name {
130131
if lit.char_at(0) == 'r' {
@@ -143,6 +144,15 @@ fn fix(mut lit: &str) -> ast::Name {
143144
parse::token::intern(lit.slice(leading_hashes + 1, lit.len() - leading_hashes - 1))
144145
}
145146

147+
/// Assuming a char/byte literal, strip the 'b' prefix and the single quotes.
148+
fn fixchar(mut lit: &str) -> ast::Name {
149+
if lit.char_at(0) == 'b' {
150+
lit = lit.slice_from(1);
151+
}
152+
153+
parse::token::intern(lit.slice(1, lit.len() - 1))
154+
}
155+
146156
fn count(lit: &str) -> uint {
147157
lit.chars().take_while(|c| *c == '#').count()
148158
}
@@ -167,7 +177,8 @@ fn parse_antlr_token(s: &str, tokens: &HashMap<String, Token>) -> TokenAndSpan {
167177
BINOPEQ(..) => BINOPEQ(str_to_binop(content.slice_to(content.len() - 1))),
168178
LIT_STR(..) => LIT_STR(fix(content)),
169179
LIT_STR_RAW(..) => LIT_STR_RAW(fix(content), count(content)),
170-
LIT_CHAR(..) => LIT_CHAR(nm),
180+
LIT_CHAR(..) => LIT_CHAR(fixchar(content)),
181+
LIT_BYTE(..) => LIT_BYTE(fixchar(content)),
171182
DOC_COMMENT(..) => DOC_COMMENT(nm),
172183
LIT_INTEGER(..) => LIT_INTEGER(nm),
173184
LIT_FLOAT(..) => LIT_FLOAT(nm),

0 commit comments

Comments
 (0)