diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml
new file mode 100644
index 00000000..0f90f608
--- /dev/null
+++ b/.github/workflows/codecov.yml
@@ -0,0 +1,22 @@
+name: Coverage
+
+on: [pull_request, push]
+
+jobs:
+ coverage:
+ runs-on: ubuntu-latest
+ env:
+ CARGO_TERM_COLOR: always
+ steps:
+ - uses: actions/checkout@v4
+ - name: Install Rust
+ run: rustup update stable
+ - name: Install cargo-llvm-cov
+ uses: taiki-e/install-action@cargo-llvm-cov
+ - name: Generate code coverage
+ run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info
+ - name: Upload coverage to Codecov
+ uses: codecov/codecov-action@v3
+ with:
+ files: lcov.info
+ fail_ci_if_error: true
\ No newline at end of file
diff --git a/README.md b/README.md
index 3181714a..87ed232b 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,17 @@
# λykiaDB
+
+
+
[![CI](https://github.com/lykia-rs/lykiadb/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/lykia-rs/lykiadb/actions/workflows/ci.yml)
+
+
+
+[![codecov](https://codecov.io/gh/lykia-rs/lykiadb/graph/badge.svg?token=DGIK7BE3K1)](https://codecov.io/gh/lykia-rs/lykiadb)
+
+
+
+
diff --git a/server/benches/scripts/fib.ly b/server/benches/scripts/fib.ly
index ead6f524..78781219 100644
--- a/server/benches/scripts/fib.ly
+++ b/server/benches/scripts/fib.ly
@@ -1,5 +1,5 @@
// Define recursive Fibonacci function
-fun fib($n) {
+function fib($n) {
if ($n < 2) return $n;
return fib($n - 2) + fib($n - 1);
}
diff --git a/server/benches/scripts/while.ly b/server/benches/scripts/while.ly
index 8984f421..389a92e0 100644
--- a/server/benches/scripts/while.ly
+++ b/server/benches/scripts/while.ly
@@ -10,7 +10,6 @@ while ($i < 10000000) {
}
$i = 0;
-
while ($i < 10000000) {
$i = $i + 1;
@@ -18,4 +17,4 @@ while ($i < 10000000) {
null == null; null == 1; null == "str"; null == true;
true == true; true == 1; true == false; true == "str"; true == null;
"str" == "str"; "str" == "stru"; "str" == 1; "str" == null; "str" == true;
-}
\ No newline at end of file
+}
diff --git a/server/examples/fib.ly b/server/examples/fib.ly
index e9ae733c..ddeae2db 100644
--- a/server/examples/fib.ly
+++ b/server/examples/fib.ly
@@ -1,5 +1,5 @@
// Define recursive Fibonacci function
-fun fib($n) {
+function fib($n) {
if ($n < 2) return $n;
return fib($n - 2) + fib($n - 1);
};
diff --git a/server/examples/fn.ly b/server/examples/fn.ly
index 43a65694..90f2177e 100644
--- a/server/examples/fn.ly
+++ b/server/examples/fn.ly
@@ -1,4 +1,4 @@
-fun helloWorld ($message) {
+function helloWorld ($message) {
print("Hello world!", $message);
{
{
diff --git a/server/examples/scan_err.ly b/server/examples/scan_err.ly
index 0c72e47c..abfe9c87 100644
--- a/server/examples/scan_err.ly
+++ b/server/examples/scan_err.ly
@@ -1,5 +1,5 @@
// Define recursive Fibonacci function
-fun fib($n) {
+function fib($n) {
if ($n < 2) return $n;
return fib($n - 2) + fib($n - 1);
};
diff --git a/server/src/lang/ast/sql.rs b/server/src/lang/ast/sql.rs
index 85aea957..f600fe2d 100644
--- a/server/src/lang/ast/sql.rs
+++ b/server/src/lang/ast/sql.rs
@@ -39,39 +39,30 @@ pub enum SqlExpr {
Default(ExprId),
}
-#[derive(Debug, Eq, PartialEq)]
-pub enum SqlFrom {
- CollectionSubquery(Vec),
- JoinClause(Box),
-}
-
#[derive(Debug, Eq, PartialEq)]
pub enum SqlProjection {
- All,
- /*AllFieldsOf{
- collection: Token
- },*/
- Complex { expr: SqlExpr, alias: Option },
+ All { collection: Option },
+ Expr { expr: SqlExpr, alias: Option },
}
#[derive(Debug, Eq, PartialEq)]
-pub enum SqlJoinClause {
- None(SqlCollectionSubquery),
- Join(Vec<(SqlJoinType, SqlCollectionSubquery, SqlExpr)>),
+pub struct SqlJoin {
+ pub join_type: SqlJoinType,
+ pub subquery: SqlCollectionSubquery,
+ pub join_constraint: Option,
}
#[derive(Debug, Eq, PartialEq)]
pub enum SqlCollectionSubquery {
- Simple {
+ Group(Vec),
+ Join(Box, Vec),
+ Collection {
namespace: Option,
- collection: Token,
+ name: Token,
alias: Option,
},
- From {
- from: SqlFrom,
- },
Select {
- stmt: SqlSelect,
+ expr: ExprId,
alias: Option,
},
}
@@ -80,7 +71,7 @@ pub enum SqlCollectionSubquery {
pub struct SelectCore {
pub distinct: SqlDistinct,
pub projection: Vec,
- pub from: Option,
+ pub from: Option,
pub r#where: Option,
pub group_by: Option>,
pub having: Option,
diff --git a/server/src/lang/parser.rs b/server/src/lang/parser.rs
index d0675259..e1af48f7 100644
--- a/server/src/lang/parser.rs
+++ b/server/src/lang/parser.rs
@@ -1,7 +1,7 @@
use super::ast::expr::{Expr, ExprId};
use super::ast::sql::{
- SelectCore, SqlCollectionSubquery, SqlCompoundOperator, SqlDistinct, SqlExpr, SqlFrom,
- SqlOrdering, SqlProjection, SqlSelect,
+ SelectCore, SqlCollectionSubquery, SqlCompoundOperator, SqlDistinct, SqlExpr, SqlJoin,
+ SqlJoinType, SqlOrdering, SqlProjection, SqlSelect,
};
use super::ast::stmt::{Stmt, StmtId};
use super::ast::{Literal, ParserArena};
@@ -42,7 +42,7 @@ type ParseResult = Result;
macro_rules! binary {
($self: ident, [$($operator:expr),*], $builder: ident) => {
let mut current_expr: ExprId = $self.$builder()?;
- while $self.match_next_multi(&vec![$($operator,)*]) {
+ while $self.match_next_one_of(&vec![$($operator,)*]) {
let token = (*$self.peek_bw(1)).clone();
let left = current_expr;
let right = $self.$builder()?;
@@ -460,7 +460,7 @@ impl<'a> Parser<'a> {
}
fn unary(&mut self) -> ParseResult {
- if self.match_next_multi(&vec![sym!(Minus), sym!(Bang)]) {
+ if self.match_next_one_of(&vec![sym!(Minus), sym!(Bang)]) {
let token = (*self.peek_bw(1)).clone();
let unary = self.unary()?;
return Ok(self.arena.expression(Expr::Unary {
@@ -470,16 +470,16 @@ impl<'a> Parser<'a> {
.get_merged_span(&token.span, &self.arena.get_expression(unary).get_span()),
}));
}
- self.select()
+ self.sql_select()
}
- fn select(&mut self) -> ParseResult {
+ fn sql_select(&mut self) -> ParseResult {
if !self.cmp_tok(&skw!(Select)) {
return self.call();
}
- let core = self.select_core()?;
+ let core = self.sql_select_core()?;
let mut compounds: Vec<(SqlCompoundOperator, SelectCore)> = vec![];
- while self.match_next_multi(&vec![skw!(Union), skw!(Intersect), skw!(Except)]) {
+ while self.match_next_one_of(&vec![skw!(Union), skw!(Intersect), skw!(Except)]) {
let op = self.peek_bw(1);
let compound_op = if op.tok_type == skw!(Union) && self.match_next(skw!(All)) {
SqlCompoundOperator::UnionAll
@@ -493,7 +493,7 @@ impl<'a> Parser<'a> {
}
}
};
- let secondary_core = self.select_core()?;
+ let secondary_core = self.sql_select_core()?;
compounds.push((compound_op, secondary_core))
}
let order_by = if self.match_next(skw!(Order)) {
@@ -548,21 +548,20 @@ impl<'a> Parser<'a> {
}))
}
- fn select_core(&mut self) -> ParseResult {
+ fn sql_select_core(&mut self) -> ParseResult {
self.expected(skw!(Select))?;
let distinct = if self.match_next(skw!(Distinct)) {
SqlDistinct::Distinct
+ } else if self.match_next(skw!(All)) {
+ SqlDistinct::All
} else {
SqlDistinct::All
};
- /* else if self.match_next(skw!(All)) {
- SqlDistinct::All
- }*/
- let projection = self.sql_projection();
- let from = self.sql_from()?;
- let r#where = self.sql_where()?;
- let group_by = self.sql_group_by()?;
+ let projection = self.sql_select_projection();
+ let from = self.sql_select_from()?;
+ let r#where = self.sql_select_where()?;
+ let group_by = self.sql_select_group_by()?;
let having = if group_by.is_some() && self.match_next(skw!(Having)) {
Some(SqlExpr::Default(self.expression()?))
} else {
@@ -579,7 +578,7 @@ impl<'a> Parser<'a> {
})
}
- fn sql_group_by(&mut self) -> ParseResult