Merge branch 'rinderknecht@fix-sequences' into 'dev'
[CameLIGO] Fix parsing of sequences See merge request ligolang/ligo!688
This commit is contained in:
commit
77eb1335a1
@ -56,7 +56,6 @@ type c_Some = Region.t
|
|||||||
|
|
||||||
type arrow = Region.t (* "->" *)
|
type arrow = Region.t (* "->" *)
|
||||||
type cons = Region.t (* "::" *)
|
type cons = Region.t (* "::" *)
|
||||||
type percent = Region.t (* "%" *)
|
|
||||||
type cat = Region.t (* "^" *)
|
type cat = Region.t (* "^" *)
|
||||||
type append = Region.t (* "@" *)
|
type append = Region.t (* "@" *)
|
||||||
type dot = Region.t (* "." *)
|
type dot = Region.t (* "." *)
|
||||||
|
@ -586,6 +586,12 @@ core_expr:
|
|||||||
| par(expr) { EPar $1 }
|
| par(expr) { EPar $1 }
|
||||||
| par(annot_expr) { EAnnot $1 }
|
| par(annot_expr) { EAnnot $1 }
|
||||||
|
|
||||||
|
code_inj:
|
||||||
|
"<lang>" expr "]" {
|
||||||
|
let region = cover $1.region $3
|
||||||
|
and value = {language=$1; code=$2; rbracket=$3}
|
||||||
|
in {region; value} }
|
||||||
|
|
||||||
annot_expr:
|
annot_expr:
|
||||||
expr ":" type_expr { $1,$2,$3 }
|
expr ":" type_expr { $1,$2,$3 }
|
||||||
|
|
||||||
@ -652,49 +658,41 @@ field_path_assignment :
|
|||||||
field_assignment:
|
field_assignment:
|
||||||
field_name "=" expr {
|
field_name "=" expr {
|
||||||
let region = cover $1.region (expr_to_region $3)
|
let region = cover $1.region (expr_to_region $3)
|
||||||
and value = {field_name = $1;
|
and value = {field_name=$1; assignment=$2; field_expr=$3}
|
||||||
assignment = $2;
|
|
||||||
field_expr = $3}
|
|
||||||
in {region; value} }
|
in {region; value} }
|
||||||
|
|
||||||
path :
|
path :
|
||||||
"<ident>" { Name $1 }
|
"<ident>" { Name $1 }
|
||||||
| projection { Path $1 }
|
| projection { Path $1 }
|
||||||
|
|
||||||
|
(* Sequences *)
|
||||||
|
|
||||||
sequence:
|
sequence:
|
||||||
"begin" series? "end" {
|
"begin" series? "end" {
|
||||||
let region = cover $1 $3
|
let region = cover $1 $3
|
||||||
and compound = BeginEnd ($1,$3) in
|
and compound = BeginEnd ($1,$3) in
|
||||||
let elements, terminator =
|
let elements = $2 in
|
||||||
match $2 with
|
let value = {compound; elements; terminator=None}
|
||||||
None -> None, None
|
|
||||||
| Some (ne_elements, terminator) ->
|
|
||||||
Some ne_elements, terminator in
|
|
||||||
let value = {compound; elements; terminator}
|
|
||||||
in {region; value} }
|
in {region; value} }
|
||||||
|
|
||||||
series:
|
series:
|
||||||
last_expr {
|
seq_expr ";" series { Utils.nsepseq_cons $1 $2 $3 }
|
||||||
let expr, term = $1 in (expr, []), term
|
| last_expr { $1,[] }
|
||||||
}
|
|
||||||
| seq_expr ";" series {
|
|
||||||
let rest, term = $3 in
|
|
||||||
let seq = Utils.nsepseq_cons $1 $2 rest
|
|
||||||
in seq, term }
|
|
||||||
|
|
||||||
last_expr:
|
last_expr:
|
||||||
seq_expr ";"?
|
seq_expr
|
||||||
| fun_expr(seq_expr) ";"?
|
| fun_expr(last_expr)
|
||||||
| match_expr(seq_expr) ";"? {
|
| match_expr(last_expr)
|
||||||
$1,$2
|
| let_in_sequence { $1 }
|
||||||
}
|
|
||||||
| "let" ioption("rec") let_binding seq(Attr) "in" series {
|
let_in_sequence:
|
||||||
let seq, term = $6 in
|
"let" ioption("rec") let_binding seq(Attr) "in" series {
|
||||||
|
let seq = $6 in
|
||||||
let stop = nsepseq_to_region expr_to_region seq in
|
let stop = nsepseq_to_region expr_to_region seq in
|
||||||
let region = cover $1 stop in
|
let region = cover $1 stop in
|
||||||
let compound = BeginEnd (Region.ghost, Region.ghost) in
|
let compound = BeginEnd (Region.ghost, Region.ghost) in
|
||||||
let elements = Some seq in
|
let elements = Some seq in
|
||||||
let value = {compound; elements; terminator=term} in
|
let value = {compound; elements; terminator=None} in
|
||||||
let body = ESeq {region; value} in
|
let body = ESeq {region; value} in
|
||||||
let value = {kwd_let = $1;
|
let value = {kwd_let = $1;
|
||||||
kwd_rec = $2;
|
kwd_rec = $2;
|
||||||
@ -702,13 +700,7 @@ last_expr:
|
|||||||
attributes = $4;
|
attributes = $4;
|
||||||
kwd_in = $5;
|
kwd_in = $5;
|
||||||
body}
|
body}
|
||||||
in ELetIn {region; value}, term }
|
in ELetIn {region; value} }
|
||||||
|
|
||||||
seq_expr:
|
seq_expr:
|
||||||
disj_expr_level | if_then_else (seq_expr) { $1 }
|
disj_expr_level | if_then_else (seq_expr) { $1 }
|
||||||
|
|
||||||
code_inj:
|
|
||||||
"<lang>" expr "]" {
|
|
||||||
let region = cover $1.region $3
|
|
||||||
and value = {language=$1; code=$2; rbracket=$3}
|
|
||||||
in {region; value} }
|
|
||||||
|
@ -53,7 +53,7 @@
|
|||||||
(executable
|
(executable
|
||||||
(name ParserMain)
|
(name ParserMain)
|
||||||
(libraries parser_cameligo)
|
(libraries parser_cameligo)
|
||||||
(modules ParserMain)
|
(modules ParserMain Parser_msg)
|
||||||
(preprocess
|
(preprocess
|
||||||
(pps bisect_ppx --conditional))
|
(pps bisect_ppx --conditional))
|
||||||
(flags (:standard -open Simple_utils -open Parser_shared -open Parser_cameligo)))
|
(flags (:standard -open Simple_utils -open Parser_shared -open Parser_cameligo)))
|
||||||
@ -65,6 +65,19 @@
|
|||||||
(deps (:script_messages ../../../../vendors/ligo-utils/simple-utils/messages.sh) Parser.mly LexToken.mli ParToken.mly)
|
(deps (:script_messages ../../../../vendors/ligo-utils/simple-utils/messages.sh) Parser.mly LexToken.mli ParToken.mly)
|
||||||
(action (run %{script_messages} --lex-tokens=LexToken.mli --par-tokens=ParToken.mly Parser.mly)))
|
(action (run %{script_messages} --lex-tokens=LexToken.mli --par-tokens=ParToken.mly Parser.mly)))
|
||||||
|
|
||||||
|
(rule
|
||||||
|
(targets Parser_msg.ml)
|
||||||
|
(deps Parser.mly ParToken.mly Parser.msg)
|
||||||
|
(action
|
||||||
|
(with-stdout-to %{targets}
|
||||||
|
(bash
|
||||||
|
"menhir \
|
||||||
|
--compile-errors Parser.msg \
|
||||||
|
--external-tokens LexToken \
|
||||||
|
--base Parser \
|
||||||
|
ParToken.mly \
|
||||||
|
Parser.mly"))))
|
||||||
|
|
||||||
;; Build of all the LIGO source file that cover all error states
|
;; Build of all the LIGO source file that cover all error states
|
||||||
|
|
||||||
(rule
|
(rule
|
||||||
@ -74,27 +87,6 @@
|
|||||||
|
|
||||||
;; Error messages
|
;; Error messages
|
||||||
|
|
||||||
;; Generate error messages from scratch
|
|
||||||
; (rule
|
|
||||||
; (targets error.messages)
|
|
||||||
; (deps Parser.mly ParToken.mly error.messages.checked-in)
|
|
||||||
; (action
|
|
||||||
; (with-stdout-to %{targets}
|
|
||||||
; (bash
|
|
||||||
; "menhir \
|
|
||||||
; --unused-tokens \
|
|
||||||
; --list-errors \
|
|
||||||
; --table \
|
|
||||||
; --strict \
|
|
||||||
; --external-tokens LexToken.mli \
|
|
||||||
; --base Parser.mly \
|
|
||||||
; ParToken.mly \
|
|
||||||
; Parser.mly
|
|
||||||
; "
|
|
||||||
; )
|
|
||||||
; ))
|
|
||||||
; )
|
|
||||||
|
|
||||||
(rule
|
(rule
|
||||||
(targets error.messages)
|
(targets error.messages)
|
||||||
(mode (promote (until-clean) (only *)))
|
(mode (promote (until-clean) (only *)))
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -66,6 +66,19 @@
|
|||||||
(deps (:script_messages ../../../../vendors/ligo-utils/simple-utils/messages.sh) Parser.mly LexToken.mli ParToken.mly)
|
(deps (:script_messages ../../../../vendors/ligo-utils/simple-utils/messages.sh) Parser.mly LexToken.mli ParToken.mly)
|
||||||
(action (run %{script_messages} --lex-tokens=LexToken.mli --par-tokens=ParToken.mly Parser.mly)))
|
(action (run %{script_messages} --lex-tokens=LexToken.mli --par-tokens=ParToken.mly Parser.mly)))
|
||||||
|
|
||||||
|
(rule
|
||||||
|
(targets Parser_msg.ml)
|
||||||
|
(deps Parser.mly ParToken.mly Parser.msg)
|
||||||
|
(action
|
||||||
|
(with-stdout-to %{targets}
|
||||||
|
(bash
|
||||||
|
"menhir \
|
||||||
|
--compile-errors Parser.msg \
|
||||||
|
--external-tokens LexToken \
|
||||||
|
--base Parser \
|
||||||
|
ParToken.mly \
|
||||||
|
Parser.mly"))))
|
||||||
|
|
||||||
;; Build of all the LIGO source file that cover all error states
|
;; Build of all the LIGO source file that cover all error states
|
||||||
|
|
||||||
(rule
|
(rule
|
||||||
@ -75,27 +88,6 @@
|
|||||||
|
|
||||||
;; Error messages
|
;; Error messages
|
||||||
|
|
||||||
;; Generate error messages from scratch
|
|
||||||
; (rule
|
|
||||||
; (targets error.messages)
|
|
||||||
; (deps Parser.mly ParToken.mly error.messages.checked-in)
|
|
||||||
; (action
|
|
||||||
; (with-stdout-to %{targets}
|
|
||||||
; (bash
|
|
||||||
; "menhir \
|
|
||||||
; --unused-tokens \
|
|
||||||
; --list-errors \
|
|
||||||
; --table \
|
|
||||||
; --strict \
|
|
||||||
; --external-tokens LexToken.mli \
|
|
||||||
; --base Parser.mly \
|
|
||||||
; ParToken.mly \
|
|
||||||
; Parser.mly
|
|
||||||
; "
|
|
||||||
; )
|
|
||||||
; ))
|
|
||||||
; )
|
|
||||||
|
|
||||||
(rule
|
(rule
|
||||||
(targets error.messages)
|
(targets error.messages)
|
||||||
(mode (promote (until-clean) (only *)))
|
(mode (promote (until-clean) (only *)))
|
||||||
@ -155,8 +147,6 @@
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(rule
|
(rule
|
||||||
(targets ParErr.ml)
|
(targets ParErr.ml)
|
||||||
(mode (promote (until-clean) (only *)))
|
(mode (promote (until-clean) (only *)))
|
||||||
|
@ -65,6 +65,19 @@
|
|||||||
(deps (:script_messages ../../../../vendors/ligo-utils/simple-utils/messages.sh) Parser.mly LexToken.mli ParToken.mly)
|
(deps (:script_messages ../../../../vendors/ligo-utils/simple-utils/messages.sh) Parser.mly LexToken.mli ParToken.mly)
|
||||||
(action (run %{script_messages} --lex-tokens=LexToken.mli --par-tokens=ParToken.mly Parser.mly )))
|
(action (run %{script_messages} --lex-tokens=LexToken.mli --par-tokens=ParToken.mly Parser.mly )))
|
||||||
|
|
||||||
|
(rule
|
||||||
|
(targets Parser_msg.ml)
|
||||||
|
(deps Parser.mly ParToken.mly Parser.msg)
|
||||||
|
(action
|
||||||
|
(with-stdout-to %{targets}
|
||||||
|
(bash
|
||||||
|
"menhir \
|
||||||
|
--compile-errors Parser.msg \
|
||||||
|
--external-tokens LexToken \
|
||||||
|
--base Parser \
|
||||||
|
ParToken.mly \
|
||||||
|
Parser.mly"))))
|
||||||
|
|
||||||
;; Build of all the LIGO source file that cover all error states
|
;; Build of all the LIGO source file that cover all error states
|
||||||
|
|
||||||
(rule
|
(rule
|
||||||
@ -72,28 +85,6 @@
|
|||||||
(deps (:script_cover ../../../../vendors/ligo-utils/simple-utils/cover.sh) Parser.mly LexToken.mli ParToken.mly Parser.msg Unlexer.exe)
|
(deps (:script_cover ../../../../vendors/ligo-utils/simple-utils/cover.sh) Parser.mly LexToken.mli ParToken.mly Parser.msg Unlexer.exe)
|
||||||
(action (run %{script_cover} --lex-tokens=LexToken.mli --par-tokens=ParToken.mly --ext=religo --unlexer=./Unlexer.exe --messages=Parser.msg --dir=. --concatenate Parser.mly )))
|
(action (run %{script_cover} --lex-tokens=LexToken.mli --par-tokens=ParToken.mly --ext=religo --unlexer=./Unlexer.exe --messages=Parser.msg --dir=. --concatenate Parser.mly )))
|
||||||
|
|
||||||
;; Error messages
|
|
||||||
;; Generate error messages from scratch
|
|
||||||
; (rule
|
|
||||||
; (targets error.messages)
|
|
||||||
; (deps Parser.mly ParToken.mly error.messages.checked-in)
|
|
||||||
; (action
|
|
||||||
; (with-stdout-to %{targets}
|
|
||||||
; (bash
|
|
||||||
; "menhir \
|
|
||||||
; --unused-tokens \
|
|
||||||
; --list-errors \
|
|
||||||
; --table \
|
|
||||||
; --strict \
|
|
||||||
; --external-tokens LexToken.mli \
|
|
||||||
; --base Parser.mly \
|
|
||||||
; ParToken.mly \
|
|
||||||
; Parser.mly
|
|
||||||
; "
|
|
||||||
; )
|
|
||||||
; ))
|
|
||||||
; )
|
|
||||||
|
|
||||||
(rule
|
(rule
|
||||||
(targets error.messages)
|
(targets error.messages)
|
||||||
(mode (promote (until-clean) (only *)))
|
(mode (promote (until-clean) (only *)))
|
||||||
|
Loading…
Reference in New Issue
Block a user