Compare commits

..

No commits in common. "248af74ec0f2cdd8fc367cb23c4ee55ac6250b84" and "4a366fda30d6cea8419402b2a808c138891bf783" have entirely different histories.

9 changed files with 8 additions and 91 deletions

View File

@ -114,28 +114,9 @@ pub enum Declaration {
Interface {
name: Rc<String>,
signatures: Vec<Signature>
},
Annotation {
name: Rc<String>,
arguments: Vec<Expression>
}
}
/*
* @foo(arg1, arg2)
* fn hello() {
*
* }
*
* Declaration::Annotation {
* name: "foo",
* arguments: vec!["arg1", "arg2"]
* }
*
*
*
*/
#[derive(Debug, PartialEq, Clone)]
pub struct Signature {
pub name: Rc<String>,

View File

@ -60,8 +60,6 @@ fn declaration<V: ASTVisitor>(v: &mut V, decl: &Declaration) {
v.implemention(type_name, interface_name.as_ref(), block);
}
Interface { name, signatures } => v.interface(name, signatures),
//TODO fill this in
Annotation { .. } => ()
}
}

View File

@ -371,7 +371,6 @@ impl Parser {
//TODO handle error recovery here
let tok = self.token_handler.peek();
let kind = match tok.get_kind() {
AtSign => self.annotation().map(StatementKind::Declaration),
Keyword(Type) => self.type_declaration().map(|decl| { StatementKind::Declaration(decl) }),
Keyword(Func)=> self.func_declaration().map(|func| { StatementKind::Declaration(func) }),
Keyword(Let) => self.binding_declaration().map(StatementKind::Declaration),
@ -385,23 +384,6 @@ impl Parser {
Ok(Statement { kind, id, location: tok.location })
}
#[recursive_descent_method]
fn annotation(&mut self) -> ParseResult<Declaration> {
expect!(self, AtSign);
let name = self.identifier()?;
let arguments = if let LParen = self.token_handler.peek().get_kind() {
delimited!(self, LParen, expression, Comma, RParen)
} else {
vec![]
};
Ok(Declaration::Annotation {
name,
arguments,
})
}
#[recursive_descent_method]
fn type_declaration(&mut self) -> ParseResult<Declaration> {
expect!(self, Keyword(Type));
@ -686,7 +668,6 @@ impl Parser {
#[recursive_descent_method]
fn call_expr(&mut self) -> ParseResult<Expression> {
let mut expr = self.index_expr()?;
//TODO look at this
while let LParen = self.token_handler.peek_kind() {
let arguments = delimited!(self, LParen, invocation_argument, Comma, RParen);
expr = Expression::new(self.id_store.fresh(), ExpressionKind::Call { f: Box::new(expr), arguments }); //TODO no type anno is incorrect

View File

@ -840,47 +840,3 @@ module!(
)
}
}
#[test]
fn annotations() {
parse_test! {
r#"
@test_annotation
fn some_function() {
}"#,
AST {
id: Default::default(),
statements: vec![
decl!(Annotation { name: rc!(test_annotation), arguments: vec![] }),
decl!(FuncDecl(
Signature { name: rc!(some_function), operator: false, params: vec![], type_anno: None }
, vec![]
)
)
]
}
};
parse_test! {
r#"
@test_annotation(some, value)
fn some_function() {
}"#,
AST {
id: Default::default(),
statements: vec![
decl!(Annotation { name: rc!(test_annotation), arguments: vec![
ex!(val!("some")),
ex!(val!("value"))
] }),
decl!(FuncDecl(
Signature { name: rc!(some_function), operator: false, params: vec![], type_anno: None }
, vec![]
)
)
]
}
};
}

View File

@ -327,7 +327,6 @@ impl<'a> Reducer<'a> {
TypeAlias { .. } => Stmt::Noop,
Interface { .. } => Stmt::Noop,
Impl { .. } => Stmt::Expr(Expr::UnimplementedSigilValue),
Annotation { .. } => Stmt::Noop,
_ => Stmt::Expr(Expr::UnimplementedSigilValue),
}
}

View File

@ -152,7 +152,6 @@ fn stage_names() -> Vec<&'static str> {
}
impl ProgrammingLanguageInterface for Schala {
//TODO flesh out Config
type Config = ();
fn language_name() -> String {
"Schala".to_owned()

View File

@ -29,8 +29,6 @@ pub enum TokenKind {
LAngleBracket, RAngleBracket,
LCurlyBrace, RCurlyBrace,
Pipe, Backslash,
AtSign,
Comma, Period, Colon, Underscore,
Slash, Equals,
@ -127,7 +125,7 @@ impl Token {
}
}
const OPERATOR_CHARS: [char; 17] = ['!', '$', '%', '&', '*', '+', '-', '.', ':', '<', '>', '=', '?', '^', '|', '~', '`'];
const OPERATOR_CHARS: [char; 18] = ['!', '$', '%', '&', '*', '+', '-', '.', ':', '<', '>', '=', '?', '@', '^', '|', '~', '`'];
fn is_operator(c: &char) -> bool {
OPERATOR_CHARS.iter().any(|x| x == c)
}
@ -185,7 +183,6 @@ pub fn tokenize(input: &str) -> Vec<Token> {
'[' => LSquareBracket, ']' => RSquareBracket,
'"' => handle_quote(&mut input, None),
'\\' => Backslash,
'@' => AtSign,
c if c.is_digit(10) => handle_digit(c, &mut input),
c if c.is_alphabetic() || c == '_' => handle_alphabetic(c, &mut input),
c if is_operator(&c) => handle_operator(c, &mut input),

View File

@ -16,6 +16,13 @@ pub trait ProgrammingLanguageInterface {
}
}
//TODO this is what I want
/*
struct Options<T> {
lang_options: T
}
*/
pub struct ComputationRequest<'a, T> {
pub source: &'a str,
pub config: T,

View File

@ -6,7 +6,6 @@ fn main() {
}
@annotations use the @ sigil
// variable expressions