2018-01-07 19:46:10 +01:00
|
|
|
use super::*;
|
|
|
|
|
|
|
|
pub(super) fn literal(p: &mut Parser) -> bool {
|
2018-01-20 19:49:58 +01:00
|
|
|
match p.current() {
|
2018-01-28 00:31:23 +01:00
|
|
|
TRUE_KW | FALSE_KW | INT_NUMBER | FLOAT_NUMBER | BYTE | CHAR | STRING | RAW_STRING
|
|
|
|
| BYTE_STRING | RAW_BYTE_STRING => {
|
2018-01-20 21:25:34 +01:00
|
|
|
let lit = p.start();
|
2018-01-20 19:49:58 +01:00
|
|
|
p.bump();
|
2018-01-20 21:25:34 +01:00
|
|
|
lit.complete(p, LITERAL);
|
2018-01-20 19:49:58 +01:00
|
|
|
true
|
|
|
|
}
|
2018-01-28 00:31:23 +01:00
|
|
|
_ => false,
|
2018-01-20 19:49:58 +01:00
|
|
|
}
|
|
|
|
}
|
2018-01-28 20:59:18 +01:00
|
|
|
|
|
|
|
pub(super) fn expr(p: &mut Parser) {
|
2018-02-17 23:06:48 +01:00
|
|
|
if literal(p) {
|
|
|
|
return;
|
2018-01-28 20:59:18 +01:00
|
|
|
}
|
2018-02-17 23:06:48 +01:00
|
|
|
|
|
|
|
match p.current() {
|
|
|
|
L_PAREN => tuple_expr(p),
|
|
|
|
_ => p.error("expected expression"),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn tuple_expr(p: &mut Parser) {
|
|
|
|
assert!(p.at(L_PAREN));
|
|
|
|
let m = p.start();
|
|
|
|
p.expect(L_PAREN);
|
|
|
|
p.expect(R_PAREN);
|
|
|
|
m.complete(p, TUPLE_EXPR);
|
2018-01-28 20:59:18 +01:00
|
|
|
}
|