Compare commits
No commits in common. "f203da328b5e1af80360dafa1b5439600aa0cbdc" and "26871aa9aed93b5e35a5824ab9eba9f1906e41e9" have entirely different histories.
f203da328b
...
26871aa9ae
3 changed files with 7 additions and 41 deletions
|
|
@ -422,9 +422,7 @@ fn statement_let(p: &mut CParser) {
|
||||||
p.expect(TokenKind::Identifier, "expected a name for the variable");
|
p.expect(TokenKind::Identifier, "expected a name for the variable");
|
||||||
p.expect(TokenKind::Equal, "expected a '=' after the variable name");
|
p.expect(TokenKind::Equal, "expected a '=' after the variable name");
|
||||||
expression(p);
|
expression(p);
|
||||||
if !p.at(TokenKind::RightBrace) {
|
|
||||||
p.expect(TokenKind::Semicolon, "expect ';' to end a let statement");
|
p.expect(TokenKind::Semicolon, "expect ';' to end a let statement");
|
||||||
}
|
|
||||||
|
|
||||||
p.end(m, TreeKind::LetStatement);
|
p.end(m, TreeKind::LetStatement);
|
||||||
}
|
}
|
||||||
|
|
@ -438,9 +436,7 @@ fn statement_return(p: &mut CParser) {
|
||||||
"expect 'return' to start a return statement",
|
"expect 'return' to start a return statement",
|
||||||
);
|
);
|
||||||
expression(p);
|
expression(p);
|
||||||
if !p.at(TokenKind::RightBrace) {
|
|
||||||
p.expect(TokenKind::Semicolon, "expect ';' to end a return statement");
|
p.expect(TokenKind::Semicolon, "expect ';' to end a return statement");
|
||||||
}
|
|
||||||
|
|
||||||
p.end(m, TreeKind::ReturnStatement);
|
p.end(m, TreeKind::ReturnStatement);
|
||||||
}
|
}
|
||||||
|
|
@ -449,12 +445,10 @@ fn statement_expression(p: &mut CParser) {
|
||||||
let m = p.start();
|
let m = p.start();
|
||||||
|
|
||||||
expression(p);
|
expression(p);
|
||||||
if !p.at(TokenKind::RightBrace) {
|
|
||||||
p.expect(
|
p.expect(
|
||||||
TokenKind::Semicolon,
|
TokenKind::Semicolon,
|
||||||
"expect ';' to end an expression statement",
|
"expect ';' to end an expression statement",
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
p.end(m, TreeKind::ExpressionStatement);
|
p.end(m, TreeKind::ExpressionStatement);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,13 @@ use fine::parser::concrete::Tree;
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
|
|
||||||
fn rebase_concrete(source_path: &str, dump: &str) {
|
fn rebase_concrete(source_path: &str, dump: &str) {
|
||||||
|
// RE-BASE
|
||||||
let contents = std::fs::read_to_string(source_path)
|
let contents = std::fs::read_to_string(source_path)
|
||||||
.expect(&format!("unable to read input file {}", source_path));
|
.expect(&format!("unable to read input file {}", source_path));
|
||||||
|
|
||||||
let mut result = String::new();
|
let mut result = String::new();
|
||||||
let mut lines = contents.lines();
|
let mut lines = contents.lines();
|
||||||
|
|
||||||
// Search for the "concrete:" section.
|
|
||||||
let mut found_concrete_section = false;
|
let mut found_concrete_section = false;
|
||||||
while let Some(line) = lines.next() {
|
while let Some(line) = lines.next() {
|
||||||
result.push_str(line);
|
result.push_str(line);
|
||||||
|
|
@ -26,8 +26,6 @@ fn rebase_concrete(source_path: &str, dump: &str) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We've found the section we care about, replace all the lines we care
|
|
||||||
// about with the actual lines.
|
|
||||||
let mut replaced_output = false;
|
let mut replaced_output = false;
|
||||||
while let Some(line) = lines.next() {
|
while let Some(line) = lines.next() {
|
||||||
if line.starts_with("// | ") {
|
if line.starts_with("// | ") {
|
||||||
|
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
// concrete:
|
|
||||||
// | File
|
|
||||||
// | IfStatement
|
|
||||||
// | ConditionalExpression
|
|
||||||
// | If:'"if"'
|
|
||||||
// | LiteralExpression
|
|
||||||
// | True:'"true"'
|
|
||||||
// | Block
|
|
||||||
// | LeftBrace:'"{"'
|
|
||||||
// | ExpressionStatement
|
|
||||||
// | LiteralExpression
|
|
||||||
// | String:'"\"discarded\""'
|
|
||||||
// | Semicolon:'";"'
|
|
||||||
// | ExpressionStatement
|
|
||||||
// | LiteralExpression
|
|
||||||
// | Number:'"23"'
|
|
||||||
// | RightBrace:'"}"'
|
|
||||||
// | Else:'"else"'
|
|
||||||
// | Block
|
|
||||||
// | LeftBrace:'"{"'
|
|
||||||
// | ExpressionStatement
|
|
||||||
// | LiteralExpression
|
|
||||||
// | Number:'"45"'
|
|
||||||
// | RightBrace:'"}"'
|
|
||||||
//
|
|
||||||
if true { "discarded"; 23 } else { 45 }
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue