rust-analyzer/src/parser/grammar/expressions.rs
2018-02-09 22:44:50 +03:00

20 lines
478 B
Rust

use super::*;
pub(super) fn literal(p: &mut Parser) -> bool {
match p.current() {
TRUE_KW | FALSE_KW | INT_NUMBER | FLOAT_NUMBER | BYTE | CHAR | STRING | RAW_STRING
| BYTE_STRING | RAW_BYTE_STRING => {
let lit = p.start();
p.bump();
lit.complete(p, LITERAL);
true
}
_ => false,
}
}
pub(super) fn expr(p: &mut Parser) {
if !literal(p) {
p.error("expected expression");
}
}