[fine] test compilation, start removing print
This commit is contained in:
parent
d8db65af55
commit
d8988cb2cf
8 changed files with 239 additions and 81 deletions
|
|
@ -138,7 +138,6 @@ pub enum TreeKind {
|
|||
BinaryExpression,
|
||||
IfStatement,
|
||||
Identifier,
|
||||
PrintStatement,
|
||||
}
|
||||
|
||||
pub struct Tree<'a> {
|
||||
|
|
@ -556,32 +555,10 @@ fn statement(p: &mut CParser) {
|
|||
// require a semicolon at the end if it's all by itself.
|
||||
TokenKind::If => statement_if(p),
|
||||
|
||||
TokenKind::Print => statement_print(p),
|
||||
|
||||
_ => statement_expression(p),
|
||||
}
|
||||
}
|
||||
|
||||
fn statement_print(p: &mut CParser) {
|
||||
assert!(p.at(TokenKind::Print));
|
||||
let m = p.start();
|
||||
|
||||
p.expect(
|
||||
TokenKind::Print,
|
||||
"expect 'print' to start a print statement",
|
||||
);
|
||||
p.expect(TokenKind::LeftParen, "expect '(' to start a print");
|
||||
if !p.at(TokenKind::RightParen) {
|
||||
expression(p);
|
||||
}
|
||||
p.expect(TokenKind::RightParen, "expect ')' after a print statement");
|
||||
if !p.at(TokenKind::RightBrace) {
|
||||
p.expect(TokenKind::Semicolon, "expect ';' to end a print statement");
|
||||
}
|
||||
|
||||
p.end(m, TreeKind::PrintStatement);
|
||||
}
|
||||
|
||||
fn statement_if(p: &mut CParser) {
|
||||
assert!(p.at(TokenKind::If));
|
||||
let m = p.start();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue