Fixed CameLIGO parsing of -> vs *

Fixed reserved_name.ligo ("arguments" instead of "args").
This commit is contained in:
Christian Rinderknecht 2020-01-22 12:33:29 +01:00
parent 7437d6ae1a
commit d46d95ee90
3 changed files with 11 additions and 24 deletions

View File

@ -129,23 +129,23 @@ type_decl:
in {region; value} } in {region; value} }
type_expr: type_expr:
cartesian | sum_type | record_type { $1 } fun_type | sum_type | record_type { $1 }
cartesian:
fun_type { $1 }
| fun_type "*" nsepseq(fun_type,"*") {
let value = Utils.nsepseq_cons $1 $2 $3 in
let region = nsepseq_to_region type_expr_to_region value
in TProd {region; value} }
fun_type: fun_type:
core_type { $1 } cartesian { $1 }
| core_type "->" fun_type { | cartesian "->" fun_type {
let start = type_expr_to_region $1 let start = type_expr_to_region $1
and stop = type_expr_to_region $3 in and stop = type_expr_to_region $3 in
let region = cover start stop in let region = cover start stop in
TFun {region; value=$1,$2,$3} } TFun {region; value=$1,$2,$3} }
cartesian:
core_type { $1 }
| core_type "*" nsepseq(core_type,"*") {
let value = Utils.nsepseq_cons $1 $2 $3 in
let region = nsepseq_to_region type_expr_to_region value
in TProd {region; value} }
core_type: core_type:
type_name { TVar $1 } type_name { TVar $1 }
| par(type_expr) { TPar $1 } | par(type_expr) { TPar $1 }

View File

@ -145,19 +145,6 @@ let parse_file (source: string) : AST.t result =
let lexbuf = Lexing.from_channel channel in let lexbuf = Lexing.from_channel channel in
parse (Parser.contract) source lexbuf parse (Parser.contract) source lexbuf
(*
let parse_file' (source: string) : AST.t result =
let module IO =
struct
let ext = "ligo"
let options = pre_options ~input:(Some source) ~expr:false
end in
let module Unit = PreUnit(IO) in
match Unit.parse Unit.parse_contract with
Ok ast -> ok ast
| Error error -> failwith "TODO" (* fail @@ parser_or_lexer_error error *)
*)
let parse_string (s:string) : AST.t result = let parse_string (s:string) : AST.t result =
let lexbuf = Lexing.from_string s in let lexbuf = Lexing.from_string s in
parse (Parser.contract) "" lexbuf parse (Parser.contract) "" lexbuf

View File

@ -1 +1 @@
let args = 1; let arguments = 1;