-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement new parsing pipeline #490
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! I left some comments inline.
3b09447
to
099e566
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! I've added some comments inline.
3430fdc
to
dc153fa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Thank you! I left a few comments inline.
Some more thoughts about #[derive(Default)]
struct SpanBuilder {
ops: Vec<Operation>,
decorators: DecoratorList,
}
impl SpanBuilder {
pub fn add_op(&mut self, op: Operation) -> Result<Option<CodeBlock>, AssemblyError> {
self.ops.push(op);
Ok(None)
}
pub fn add_ops(&mut self, ops: &[Operation]) -> Result<Option<CodeBlock>, AssemblyError> {
ops.iter().for_each(|&op| self.ops.push(op));
Ok(None)
}
pub fn push_op(&mut self, op: Operation) {
self.ops.push(op);
}
pub fn has_ops(&self) -> bool {
self.ops.is_empty()
}
pub fn extract_span_into(&mut self, target: &mut Vec<CodeBlock>) {
if !self.ops.is_empty() {
let ops: Vec<_> = self.ops.drain(..).collect();
target.push(CodeBlock::new_span(ops));
}
}
} The pub(super) fn compile_instruction(
&self,
instruction: Instruction,
span: &mut SpanBuilder,
context: &AssemblyContext,
) -> Result<Option<CodeBlock>, AssemblyError> {
match instruction {
Instruction::Assert => span.add_op(Assert),
Instruction::AssertEq => span.add_ops(&[Eq, Assert]),
Instruction::Assertz => span.add_ops(&[Eqz, Assert]),
Instruction::Add => span.add_op(Add),
Instruction::AddImm(imm) => field_ops::add_imm(span, imm),
...
Instruction::ExecLocal(idx) => flow_ops::exec_local(*idx, context),
...
}
} This way, for simple instructions we could add to the span directly in the |
99dc8ec
to
eb76144
Compare
a3abefb
to
97b2494
Compare
97b2494
to
c465f78
Compare
feat: replace assembler with pipeline
eq and neq parsers, u32 error message
Implement handling of advice injectors in new assembler
Add functions and docs for AST parsers
Implement compilation of exp operations
Assorted assembler bug fixes
Assembly module structure refactoring
Refactor AssemblyError and fix Miden executable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All looks good! Thank you, everyone - this was a big one!
WiP