-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from lykia-rs/feature/parsing-tests
feat: Major changes to AST, parsing, SQL parsing, module structure
- Loading branch information
Showing
50 changed files
with
2,434 additions
and
1,575 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,7 @@ | ||
[package] | ||
name = "lykia" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
bumpalo = "3.12.2" | ||
clap = { version = "4.4.6", features = ["derive"] } | ||
phf = { version = "0.11", default-features = false, features = ["macros"] } | ||
rustc-hash = "1.1.0" | ||
serde = { version = "1.0.188", features=["derive"] } | ||
serde_json = "1.0.105" | ||
ariadne = { features = ["auto-color"] } | ||
[workspace] | ||
resolver = "1" | ||
members = ["server"] | ||
|
||
[profile.release] | ||
debug = true | ||
|
||
[dev-dependencies] | ||
criterion = { version = "0.4", features = ["html_reports"] } | ||
|
||
[[bench]] | ||
name = "interpreter" | ||
harness = false | ||
opt-level = 3 | ||
strip = "debuginfo" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
[package] | ||
authors = ["Vedat Can Keklik <[email protected]>"] | ||
name = "lykiadb-server" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
bumpalo = "3.12.2" | ||
clap = { version = "4.4.6", features = ["derive"] } | ||
phf = { version = "0.11", default-features = false, features = ["macros"] } | ||
rustc-hash = "1.1.0" | ||
serde = { version = "1.0.188", features=["derive"] } | ||
serde_json = "1.0.105" | ||
ariadne = { features = ["auto-color"] } | ||
assert-json-diff = "2.0.2" | ||
|
||
[dev-dependencies] | ||
criterion = { version = "0.4", features = ["html_reports"] } | ||
|
||
[[bench]] | ||
name = "interpreter" | ||
harness = false |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Define recursive Fibonacci function | ||
fun fib($n) { | ||
if ($n < 2) return $n; | ||
return fib($n - 2) + fib($n - 1); | ||
}; | ||
|
||
var $start_ly = Time.clock(); | ||
print(fib(35) == 9227465); | ||
print("elapsed (user defined):", Time.clock() - $start_ly); | ||
|
||
var $start_rs = Time.clock(); | ||
print(Benchmark.fib(35) == 9227465); | ||
print("elapsed (native):", Time.clock() - $start_rs); |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
use std::rc::Rc; | ||
|
||
use super::{sql::SqlSelect, stmt::StmtId, Literal}; | ||
use crate::lang::token::{Span, Spanned, Token, TokenType}; | ||
|
||
#[derive(Debug, Eq, PartialEq)] | ||
pub enum Expr { | ||
Select { | ||
query: SqlSelect, | ||
span: Span, | ||
}, | ||
Variable { | ||
name: Token, | ||
span: Span, | ||
}, | ||
Grouping { | ||
expr: ExprId, | ||
span: Span, | ||
}, | ||
Literal { | ||
value: Literal, | ||
raw: String, | ||
span: Span, | ||
}, | ||
Function { | ||
name: Option<Token>, | ||
parameters: Vec<Token>, | ||
body: Rc<Vec<StmtId>>, | ||
span: Span, | ||
}, | ||
Binary { | ||
left: ExprId, | ||
symbol: TokenType, | ||
right: ExprId, | ||
span: Span, | ||
}, | ||
Unary { | ||
symbol: TokenType, | ||
expr: ExprId, | ||
span: Span, | ||
}, | ||
Assignment { | ||
dst: Token, | ||
expr: ExprId, | ||
span: Span, | ||
}, | ||
Logical { | ||
left: ExprId, | ||
symbol: TokenType, | ||
right: ExprId, | ||
span: Span, | ||
}, | ||
Call { | ||
callee: ExprId, | ||
args: Vec<ExprId>, | ||
span: Span, | ||
}, | ||
Get { | ||
object: ExprId, | ||
name: Token, | ||
span: Span, | ||
}, | ||
Set { | ||
object: ExprId, | ||
name: Token, | ||
value: ExprId, | ||
span: Span, | ||
}, | ||
} | ||
|
||
impl Spanned for Expr { | ||
fn get_span(&self) -> Span { | ||
match self { | ||
Expr::Select { query: _, span } | ||
| Expr::Variable { name: _, span } | ||
| Expr::Grouping { expr: _, span } | ||
| Expr::Literal { | ||
value: _, | ||
raw: _, | ||
span, | ||
} | ||
| Expr::Function { | ||
name: _, | ||
parameters: _, | ||
body: _, | ||
span, | ||
} | ||
| Expr::Binary { | ||
left: _, | ||
symbol: _, | ||
right: _, | ||
span, | ||
} | ||
| Expr::Unary { | ||
symbol: _, | ||
expr: _, | ||
span, | ||
} | ||
| Expr::Assignment { | ||
dst: _, | ||
expr: _, | ||
span, | ||
} | ||
| Expr::Logical { | ||
left: _, | ||
symbol: _, | ||
right: _, | ||
span, | ||
} | ||
| Expr::Call { | ||
callee: _, | ||
args: _, | ||
span, | ||
} | ||
| Expr::Get { | ||
object: _, | ||
name: _, | ||
span, | ||
} | ||
| Expr::Set { | ||
object: _, | ||
name: _, | ||
value: _, | ||
span, | ||
} => *span, | ||
} | ||
} | ||
} | ||
|
||
#[repr(transparent)] | ||
#[derive(Debug, Clone, Copy, Eq, PartialEq)] | ||
pub struct ExprId(pub usize); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.