Skip to content

Commit

Permalink
Merge contents of current branch 'generic-parselets'
Browse files Browse the repository at this point in the history
This is NOT the generic-parselets feature yet, but it is a milestone in rewriting most parts of the compiler and its intermediate language, with generic parselets projected already.
  • Loading branch information
phorward committed Sep 1, 2022
2 parents feefb18 + d282a5f commit 3338b5c
Show file tree
Hide file tree
Showing 36 changed files with 2,231 additions and 2,252 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ tokay = "0.4"
glob = "0.3"

[dependencies]
charclass = "0.1"
charclass = "0.2" # use crates.io-version
#charclass = { version = "0.2", path = "../charclass" } # use local version
clap = { version = "3", features = ["derive"] }
indexmap = "1.8"
num = "0.4"
num-bigint = "0.4"
rustyline = "8.2"
#tokay-macros = "0.2"
tokay-macros = { version = "0.2", path = "macros" }
num-parse = "0.1"
#num-parse = { version = "0.1", path = "../num-parse" }
#tokay-macros = "0.2" # use crates.io-version
tokay-macros = { version = "0.2", path = "macros" } # use local version
num-parse = "0.1" # use crates.io-version
#num-parse = { version = "0.1", path = "../num-parse" } # use local version
35 changes: 19 additions & 16 deletions examples/tokay.tok
Original file line number Diff line number Diff line change
Expand Up @@ -189,20 +189,20 @@ TokenLiteral : @{
'[' Ccl ']' ast("value_token_ccl")
}

TokenCall : @{
TokenAtom : @{
TokenLiteral
T_Consumable '(' _ ___ CallParameters? ___ expect ')' ast("call")
T_Consumable ast("call")
T_Consumable
Parselet
InlineSequences
Block
}

Token1 : @{ # todo: Token1 can be renamed back to Token again when #31 is fixed and Self is used.
TokenCall '+' ast("op_mod_pos")
TokenCall '*' ast("op_mod_kle")
TokenCall '?' ast("op_mod_opt")
TokenCall
TokenAtom '+' ast("op_mod_pos")
TokenAtom '*' ast("op_mod_kle")
TokenAtom '?' ast("op_mod_opt")
TokenAtom
'peek' _SeparatedIdentifier expect Token1 ast("op_mod_peek")
'not' _SeparatedIdentifier expect Token1 ast("op_mod_not")
'expect' _SeparatedIdentifier expect Token1 ast("op_mod_expect")
Expand Down Expand Up @@ -283,10 +283,7 @@ LogicalOr : @{
}

Expression : @{
Lvalue _ '=' not {
'>'
'='
} _ expect Expression ast("assign_hold")
Lvalue _ '=' not ('>' | '=') _ expect Expression ast("assign_hold")
Lvalue _ '+=' _ expect Expression ast("assign_add_hold")
Lvalue _ '-=' _ expect Expression ast("assign_sub_hold")
Lvalue _ '*=' _ expect Expression ast("assign_mul_hold")
Expand All @@ -311,10 +308,7 @@ Statement : @{
'reject' _SeparatedIdentifier ast("op_reject")
'repeat' _SeparatedIdentifier Expression? ast("op_repeat")
'return' _SeparatedIdentifier Expression? ast("op_accept")
Lvalue _ '=' not {
'>'
'='
} _ expect Expression ast("assign")
Lvalue _ '=' not ('>' | '=') _ expect Expression ast("assign")
Lvalue _ '+=' _ expect Expression ast("assign_add")
Lvalue _ '-=' _ expect Expression ast("assign_sub")
Lvalue _ '*=' _ expect Expression ast("assign_mul")
Expand All @@ -325,8 +319,17 @@ Statement : @{
# Parselet

Parselet : @{
'@' _ Arguments? Block ast("value_parselet")
'@' _ Arguments? Token1 ast("value_parselet")
'@' _ Generics? _ Arguments? Expression ast("value_parselet")
}

## Parselet: Generics

Generic : @{
T_Identifier _ (':' _ expect Atomic)? ast("gen")
}

Generics : @{
'<' _ (Generic (',' _)?)* _ expect '>' _
}

## Parselet: Arguments
Expand Down
6 changes: 5 additions & 1 deletion src/_builtins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ DON'T CHANGE THIS FILE MANUALLY, IT WILL GO AWAY!!!
*/
use crate::builtin::Builtin;

pub static BUILTINS: [Builtin; 39] = [
pub static BUILTINS: [Builtin; 40] = [
Builtin {
name: "Float",
func: crate::value::token::tokay_token_float,
Expand Down Expand Up @@ -82,6 +82,10 @@ pub static BUILTINS: [Builtin; 39] = [
name: "list_add",
func: crate::value::list::List::tokay_method_list_add,
},
Builtin {
name: "list_flatten",
func: crate::value::list::List::tokay_method_list_flatten,
},
Builtin {
name: "list_iadd",
func: crate::value::list::List::tokay_method_list_iadd,
Expand Down
4 changes: 2 additions & 2 deletions src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ impl Object for BuiltinRef {

impl PartialEq for BuiltinRef {
fn eq(&self, other: &Self) -> bool {
self.id() == other.id()
self.0.name == other.0.name
}
}

impl PartialOrd for BuiltinRef {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.id().partial_cmp(&other.id())
self.0.name.partial_cmp(&other.0.name)
}
}

Expand Down

0 comments on commit 3338b5c

Please sign in to comment.