aboutsummaryrefslogtreecommitdiff
path: root/expressionParser.mly
diff options
context:
space:
mode:
Diffstat (limited to 'expressionParser.mly')
-rwxr-xr-xexpressionParser.mly47
1 files changed, 22 insertions, 25 deletions
diff --git a/expressionParser.mly b/expressionParser.mly
index a9f685f..b7f77ae 100755
--- a/expressionParser.mly
+++ b/expressionParser.mly
@@ -8,8 +8,8 @@
%}
-%token <string * Num.num> REAL
-%token <string * Num.num> NUM
+%token <string> REAL
+%token <string> NUM
%token <string> STR
%token <string> LETTERS
@@ -46,30 +46,27 @@ content:
| basic EOF {$1}
basic:
- | PLUS num {Result (number (DataType.Num.of_num (snd $2)))}
- | MINUS num {Result (number (DataType.Num.of_num @@ Num.minus_num (snd $2)))}
- | num {Result (number (DataType.Num.of_num (snd $1)))}
+ | PLUS num {Result (number $2)}
+ | MINUS num {Result (number (DataType.Num.neg $2))}
+ | num {Result (number $1)}
| NUM DIVIDE NUM DIVIDE NUM {Result (
date (
- DataType.Num.of_num @@ (Date.get_julian_day
- (Num.int_of_num @@ snd $1)
- (Num.int_of_num @@ snd $3)
- (Num.int_of_num @@ snd $5)
- )))}
+ DataType.Date.get_julian_day
+ (int_of_string $1)
+ (int_of_string $3)
+ (int_of_string $5)
+ ))}
| NUM COLON NUM COLON NUM {Result (
date (
- Num.(
- let nhour = (snd $1) // (num_of_int 24)
- and nmin = (snd $3) // (num_of_int 1440)
- and nsec = (snd $5) // (num_of_int 86400)
- in DataType.Num.of_num @@ nhour +/ nmin +/ nsec)
+ let nhour = DataType.Num.div (DataType.Num.of_int @@ int_of_string $1) (DataType.Num.of_int 24)
+ and nmin = DataType.Num.div (DataType.Num.of_int @@ int_of_string $3) (DataType.Num.of_int 1440)
+ and nsec = DataType.Num.div (DataType.Num.of_int @@ int_of_string $5) (DataType.Num.of_int 86400)
+ in DataType.Num.add (DataType.Num.add nhour nmin) nsec
)
)}
expr:
- | num {Value (number (
- DataType.Num.of_num (snd $1)
- ))}
+ | num {Value (number ($1))}
| MINUS expr {Call (F.sub, [$2])}
| PLUS expr {Call (F.add, [$2])}
@@ -99,18 +96,18 @@ expr:
| expr GE expr {Call (F.ge, [$1; $3])}
%inline cell:
- | LETTERS NUM { Cell.from_string (false, $1) (false, snd $2) }
- | DOLLAR LETTERS NUM { Cell.from_string (true, $2) (false, snd $3) }
- | LETTERS DOLLAR NUM { Cell.from_string (false, $1) (true, snd $3) }
- | DOLLAR LETTERS DOLLAR NUM { Cell.from_string (true, $2) (true, snd $4) }
+ | LETTERS NUM { Cell.from_string (false, $1) (false, int_of_string $2) }
+ | DOLLAR LETTERS NUM { Cell.from_string (true, $2) (false, int_of_string $3) }
+ | LETTERS DOLLAR NUM { Cell.from_string (false, $1) (true, int_of_string $3) }
+ | DOLLAR LETTERS DOLLAR NUM { Cell.from_string (true, $2) (true, int_of_string $4) }
num:
- | REAL {$1}
- | NUM {$1}
+ | REAL {DataType.Num.of_float @@ float_of_string $1}
+ | NUM {DataType.Num.of_int @@ int_of_string $1}
ident:
| text* { String.concat "" $1 }
text:
| LETTERS { $1 }
- | NUM { fst $1 }
+ | NUM { $1 }