Wire functions through everything, with some unimplemented, and add a basic scoped map.

This commit is contained in:
2023-10-07 11:06:28 +02:00
parent eba5227ebc
commit 736d27953f
18 changed files with 392 additions and 97 deletions

View File

@@ -9,7 +9,7 @@
//! eventually want to leave lalrpop behind.)
//!
use crate::syntax::{LexerError, Location};
use crate::syntax::ast::{Program,Statement,Expression,Value,Name};
use crate::syntax::ast::{Program,TopLevel,Statement,Expression,Value,Name};
use crate::syntax::tokens::{ConstantType, Token};
use internment::ArcIntern;
@@ -57,21 +57,25 @@ extern {
pub Program: Program = {
// a program is just a set of statements
<stmts:ProgramTopLevel> => Program {
statements: stmts
<items:ProgramTopLevel> => Program {
items
}
}
ProgramTopLevel: Vec<Statement> = {
<rest: ProgramTopLevel> Function => unimplemented!(),
<mut rest: ProgramTopLevel> <next:Statement> => {
rest.push(next);
ProgramTopLevel: Vec<TopLevel> = {
<mut rest: ProgramTopLevel> <t:TopLevel> => {
rest.push(t);
rest
},
=> Vec::new(),
}
Function: () = {
pub TopLevel: TopLevel = {
<f:Function> => f,
<s:Statement> => TopLevel::Statement(s),
}
Function: TopLevel = {
"function" "(" Arguments OptionalComma ")" Expression => unimplemented!(),
}
@@ -123,7 +127,7 @@ Statements: Vec<Statement> = {
}
}
pub Statement: Statement = {
Statement: Statement = {
// A statement can be a variable binding. Note, here, that we use this
// funny @L thing to get the source location before the variable, so that
// we can say that this statement spans across everything.