begin writing parser
This commit is contained in:
parent
3d6157e03a
commit
49408a310b
4 changed files with 46 additions and 15 deletions
|
|
@ -6,4 +6,4 @@ edition = "2021"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
argus-core = { version = "0.1.0", path = "../argus-core" }
|
argus-core = { version = "0.1.0", path = "../argus-core" }
|
||||||
ariadne = "0.3.0"
|
ariadne = "0.3.0"
|
||||||
chumsky = "0.9.2"
|
chumsky = "1.0.0-alpha.4"
|
||||||
|
|
|
||||||
41
argus-parser/src/lexer.rs
Normal file
41
argus-parser/src/lexer.rs
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
use std::collections::HashMap;
|
||||||
|
use std::{env, fmt, fs};
|
||||||
|
|
||||||
|
use ariadne::{sources, Color, Label, Report, ReportKind};
|
||||||
|
use chumsky::prelude::*;
|
||||||
|
|
||||||
|
pub type Span = SimpleSpan<usize>;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
|
pub enum Token<'src> {
|
||||||
|
Semicolon,
|
||||||
|
LBracket,
|
||||||
|
RBracket,
|
||||||
|
LParen,
|
||||||
|
RParen,
|
||||||
|
Comma,
|
||||||
|
Bool(bool),
|
||||||
|
Num(&'src str),
|
||||||
|
Ident(&'src str),
|
||||||
|
Minus,
|
||||||
|
Plus,
|
||||||
|
Times,
|
||||||
|
Divide,
|
||||||
|
Lt,
|
||||||
|
Le,
|
||||||
|
Gt,
|
||||||
|
Ge,
|
||||||
|
Eq,
|
||||||
|
Neq,
|
||||||
|
Assign,
|
||||||
|
Not,
|
||||||
|
And,
|
||||||
|
Or,
|
||||||
|
Implies,
|
||||||
|
Xor,
|
||||||
|
Equiv,
|
||||||
|
Next,
|
||||||
|
Always,
|
||||||
|
Eventually,
|
||||||
|
Until,
|
||||||
|
}
|
||||||
|
|
@ -1,16 +1,5 @@
|
||||||
//! # Argus logic syntax
|
//! # Argus logic syntax
|
||||||
|
#![allow(dead_code)]
|
||||||
|
|
||||||
pub fn add(left: usize, right: usize) -> usize {
|
mod lexer;
|
||||||
left + right
|
mod parser;
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn it_works() {
|
|
||||||
let result = add(2, 2);
|
|
||||||
assert_eq!(result, 4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
1
argus-parser/src/parser.rs
Normal file
1
argus-parser/src/parser.rs
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue