Compare commits

..

No commits in common. "82460a22fd75e6969eca3a6535467dbc6b8f8015" and "323b17e4a926d0c24d44071497922acb7a80bd3b" have entirely different histories.

3 changed files with 13 additions and 31 deletions

View File

@ -69,8 +69,6 @@ and expression_primary =
| DateLiteral of string
| TimeLiteral of string
| TimestampLiteral of string
| IntegerLiteral of int
| FloatLiteral of float
| Concatenation of expression_primary * expression_primary
| Numeric of expression_primary * sign * expression_primary
| Signed of sign * expression_primary
@ -105,18 +103,8 @@ and pp_expression exp =
| DateLiteral(d) -> "'" ^ d ^ "'"
| TimeLiteral(t) -> "'" ^ t ^ "'"
| TimestampLiteral(ts) -> "'" ^ ts ^ "'"
| IntegerLiteral(i) -> string_of_int i
| FloatLiteral(f) -> string_of_float f
| Numeric(n1, s, n2) -> pp_expression n1 ^ pp_sign s ^ pp_expression n2
| _ -> "Expression not yet supported"
and pp_sign sign =
match sign with
| Plus -> "+"
| Minus -> "-"
| Times -> "*"
| Divide -> "/"
and pp_table_expression table_exp =
match table_exp with
| TableExpression(tables, filter, _) -> pp_tables tables ^ pp_filter filter

View File

@ -24,7 +24,7 @@ open Ast
%token DATE TIME TIMESTAMP
%token <int> INTEGER
%token <float> FLOAT
%token QUOTE COLON
%token UNDERSCORE QUOTE COLON
%token EOF
%start main
%type <query> main
@ -61,7 +61,7 @@ literal :
| general_literal { $1 }
unsigned_literal:
| unsigned_numeric_literal { $1 }
(* | unsigned_numeric_literal { $1 }*)
| general_literal { $1 }
general_literal:
@ -71,17 +71,19 @@ general_literal:
character_string_literal:
| QUOTE IDENT QUOTE { StringLiteral($2) }
introducer:
| UNDERSCORE { }
signed_numeric_literal:
| sign unsigned_numeric_literal { Signed($1,$2) }
| unsigned_numeric_literal { $1 }
| sign unsigned_numeric_literal {}
| unsigned_numeric_literal {}
unsigned_numeric_literal :
| exact_numeric_literal { $1 }
exact_numeric_literal:
| FLOAT { FloatLiteral($1) }
| INTEGER { IntegerLiteral($1) }
| FLOAT { }
| INTEGER {}
sign:
| PLUS_SIGN { Plus }
@ -188,6 +190,10 @@ nonparenthesized_value_expression_primary:
unsigned_value_specification:
| unsigned_literal { $1 }
(*| general_value_specification {}*)
general_value_specification:
| {}
(*********************************************)

View File

@ -58,7 +58,7 @@ let test_simple_select () =
in
Alcotest.(check query_testable) query q2 ast2 ;
let query = "SELECT 1+1, 1, 'b', 'a', DATE '2024-12-25' AS date" in
let query = "SELECT 'b', 'a', DATE '2024-12-25' AS date" in
let q3 = parse query in
let ast3 =
Select(
@ -76,18 +76,6 @@ let test_simple_select () =
Column(
StringLiteral("b"),
None
);
Column(
IntegerLiteral(1),
None
);
Column(
Numeric(
IntegerLiteral(1),
Plus,
IntegerLiteral(1)
),
None
)
],
TableExpression(