Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions crates/lean_compiler/src/a_simplify_lang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1268,12 +1268,7 @@ fn simplify_lines(
res.push(SimpleLine::Panic);
}
Line::LocationReport { location } => {
res.push(SimpleLine::LocationReport {
location: SourceLocation {
line_number: *location,
file_id,
},
});
res.push(SimpleLine::LocationReport { location: *location });
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/lean_compiler/src/lang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ pub enum Line {
},
// noop, debug purpose only
LocationReport {
location: SourceLineNumber,
location: SourceLocation,
},
CustomHint(CustomHint, Vec<Expression>),
}
Expand Down
11 changes: 8 additions & 3 deletions crates/lean_compiler/src/parser/parsers/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use super::statement::StatementParser;
use super::{Parse, ParseContext, next_inner_pair};
use crate::{
SourceLineNumber,
lang::{AssignmentTarget, Expression, Function, Line, SimpleExpr},
lang::{AssignmentTarget, Expression, Function, Line, SimpleExpr, SourceLocation},
parser::{
error::{ParseResult, SemanticError},
grammar::{ParsePair, Rule},
Expand Down Expand Up @@ -71,10 +71,15 @@ impl FunctionParser {
pair: ParsePair<'_>,
ctx: &mut ParseContext,
) -> ParseResult<()> {
let location = pair.line_col().0;
let line_number = pair.line_col().0;
let line = StatementParser.parse(pair, ctx)?;

lines.push(Line::LocationReport { location });
lines.push(Line::LocationReport {
location: SourceLocation {
file_id: ctx.current_file_id,
line_number,
},
});
lines.push(line);

Ok(())
Expand Down
29 changes: 22 additions & 7 deletions crates/lean_compiler/src/parser/parsers/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use super::{Parse, ParseContext, next_inner_pair};
use crate::{
SourceLineNumber,
ir::HighLevelOperation,
lang::{AssumeBoolean, Condition, Expression, Line},
lang::{AssumeBoolean, Condition, Expression, Line, SourceLocation},
parser::{
error::{ParseResult, SemanticError},
grammar::{ParsePair, Rule},
Expand Down Expand Up @@ -158,10 +158,15 @@ impl IfStatementParser {
pair: ParsePair<'_>,
ctx: &mut ParseContext,
) -> ParseResult<()> {
let location = pair.line_col().0;
let line_number = pair.line_col().0;
let line = StatementParser.parse(pair, ctx)?;

lines.push(Line::LocationReport { location });
lines.push(Line::LocationReport {
location: SourceLocation {
file_id: ctx.current_file_id,
line_number,
},
});
lines.push(line);

Ok(())
Expand Down Expand Up @@ -260,10 +265,15 @@ impl ForStatementParser {
pair: ParsePair<'_>,
ctx: &mut ParseContext,
) -> ParseResult<()> {
let location = pair.line_col().0;
let line_number = pair.line_col().0;
let line = StatementParser.parse(pair, ctx)?;

lines.push(Line::LocationReport { location });
lines.push(Line::LocationReport {
location: SourceLocation {
file_id: ctx.current_file_id,
line_number,
},
});
lines.push(line);

Ok(())
Expand Down Expand Up @@ -307,10 +317,15 @@ impl MatchStatementParser {
pair: ParsePair<'_>,
ctx: &mut ParseContext,
) -> ParseResult<()> {
let location = pair.line_col().0;
let line_number = pair.line_col().0;
let line = StatementParser.parse(pair, ctx)?;

lines.push(Line::LocationReport { location });
lines.push(Line::LocationReport {
location: SourceLocation {
file_id: ctx.current_file_id,
line_number,
},
});
lines.push(line);

Ok(())
Expand Down