mirror of
https://forge.katzen.cafe/katzen-cafe/iowo.git
synced 2025-09-24 23:41:30 +02:00
lang: basic parser
This commit is contained in:
parent
ae86ae29ab
commit
ca84af4e1b
11 changed files with 362 additions and 33 deletions
|
@ -1,8 +1,15 @@
|
|||
use logos::Logos;
|
||||
|
||||
#[derive(Logos, Debug, PartialEq, Eq)]
|
||||
#[derive(Logos, Debug, PartialEq, Eq, Clone)]
|
||||
#[logos(skip r"[ \t\n\f]+")]
|
||||
pub enum Token<'a> {
|
||||
// hack!
|
||||
// this isn't actually supposed to be in the language.
|
||||
// i just can't figure out how to automatically choose between a top level declaration
|
||||
// or a top level expression
|
||||
// so a declaration needs the keyword def until i can figure this out
|
||||
#[token("def")]
|
||||
Def,
|
||||
#[regex("[a-zA-Z0-9_\\-]+", |lex| lex.slice())]
|
||||
Word(&'a str),
|
||||
#[regex("\\$[a-zA-Z0-9_\\-]+", |lex| &lex.slice()[1..])]
|
||||
|
@ -27,6 +34,8 @@ pub enum Token<'a> {
|
|||
Equals,
|
||||
#[token(":")]
|
||||
Colon,
|
||||
#[token(";")]
|
||||
SemiColon,
|
||||
#[token("[")]
|
||||
BracketOpen,
|
||||
#[token("]")]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue