Add associativity table

This commit is contained in:
백현웅 2022-01-19 15:28:41 +09:00
parent 856c2b359e
commit 7fd3917572

View file

@ -29,9 +29,20 @@ let precedence = [
let precedence_of op =
Hashtbl.find precedence op
let op_is_right_to_left = function
| Exp -> true
| _ -> false
type associativity =
| Left_to_right
| Right_to_left
let oper_assoc = [
Exp, Right_to_left;
] |> List.to_seq |> Hashtbl.of_seq
let op_is_right_to_left op =
let a =
Hashtbl.find_opt oper_assoc op
|> Option.value ~default: Left_to_right
in
a = Right_to_left
let operators = [
Token.Plus, Add;