[WIP]
* Reverted [pos.mli] to the previous signature, except [Pos.min] that now takes a labelled parameter [file]. * Reverted [ParserAPI.ml] to the previous signature. * Reexported [shor_error] in [ParserUnit]. * Changed the modules [LexToken] so that they export one function to make attributes, the first, additional paramater being "[@" or "[@@" (and invalid in PascaLIGO). * Added support in all [ParserLog] for attributes (pretty-printings). * Added AST nodes [Attr] and [AttrDecl] to PascaLIGO. The simplifier takes care of hooking them with their respective declarations or discarding them. (In the future, we should issue a warning for detached attributes.)
This commit is contained in:
parent
8384e3d1f7
commit
786b183d40
@ -35,7 +35,7 @@ module Errors = struct
|
||||
let message () = str in
|
||||
let loc = if start.pos_cnum = -1 then
|
||||
Region.make
|
||||
~start: Pos.min
|
||||
~start:(Pos.min ~file:source)
|
||||
~stop:(Pos.from_byte stop)
|
||||
else
|
||||
Region.make
|
||||
|
@ -85,7 +85,7 @@ type t =
|
||||
| Mutez of (string * Z.t) Region.reg
|
||||
| String of string Region.reg
|
||||
| Bytes of (string * Hex.t) Region.reg
|
||||
| Attr2 of string Region.reg
|
||||
| Attr of string Region.reg
|
||||
|
||||
(* Keywords *)
|
||||
|
||||
@ -150,8 +150,7 @@ val mk_kwd : lexeme -> Region.t -> (token, kwd_err) result
|
||||
val mk_string : lexeme -> Region.t -> token
|
||||
val mk_bytes : lexeme -> Region.t -> token
|
||||
val mk_constr : lexeme -> Region.t -> token
|
||||
val mk_attr : lexeme -> Region.t -> (token, attr_err) result
|
||||
val mk_attr2 : lexeme -> Region.t -> (token, attr_err) result
|
||||
val mk_attr : string -> lexeme -> Region.t -> (token, attr_err) result
|
||||
val eof : Region.t -> token
|
||||
|
||||
(* Predicates *)
|
||||
|
@ -69,7 +69,7 @@ type t =
|
||||
| Mutez of (string * Z.t) Region.reg
|
||||
| String of string Region.reg
|
||||
| Bytes of (string * Hex.t) Region.reg
|
||||
| Attr2 of string Region.reg
|
||||
| Attr of string Region.reg
|
||||
|
||||
(* Keywords *)
|
||||
|
||||
@ -147,6 +147,8 @@ let proj_token = function
|
||||
region,
|
||||
sprintf "Bytes (\"%s\", \"0x%s\")"
|
||||
s (Hex.show b)
|
||||
| Attr Region.{region; value} ->
|
||||
region, sprintf "Attr \"%s\"" value
|
||||
| Begin region -> region, "Begin"
|
||||
| Else region -> region, "Else"
|
||||
| End region -> region, "End"
|
||||
@ -166,7 +168,6 @@ let proj_token = function
|
||||
| With region -> region, "With"
|
||||
| C_None region -> region, "C_None"
|
||||
| C_Some region -> region, "C_Some"
|
||||
| Attr2 Region.{region; value} -> region, sprintf "Attr2 %s" value
|
||||
| EOF region -> region, "EOF"
|
||||
|
||||
let to_lexeme = function
|
||||
@ -205,6 +206,7 @@ let to_lexeme = function
|
||||
| Mutez i -> fst i.Region.value
|
||||
| String s -> String.escaped s.Region.value
|
||||
| Bytes b -> fst b.Region.value
|
||||
| Attr a -> a.Region.value
|
||||
|
||||
| Begin _ -> "begin"
|
||||
| Else _ -> "else"
|
||||
@ -226,7 +228,7 @@ let to_lexeme = function
|
||||
|
||||
| C_None _ -> "None"
|
||||
| C_Some _ -> "Some"
|
||||
| Attr2 a -> a.Region.value
|
||||
|
||||
| EOF _ -> ""
|
||||
|
||||
let to_string token ?(offsets=true) mode =
|
||||
@ -469,11 +471,10 @@ let mk_constr lexeme region =
|
||||
|
||||
(* Attributes *)
|
||||
|
||||
let mk_attr _lexeme _region =
|
||||
let mk_attr header lexeme region =
|
||||
if header = "[@" then
|
||||
Error Invalid_attribute
|
||||
|
||||
let mk_attr2 lexeme region =
|
||||
Ok (Attr2 { value = lexeme; region })
|
||||
else Ok (Attr Region.{value=lexeme; region})
|
||||
|
||||
(* Predicates *)
|
||||
|
||||
|
@ -46,7 +46,7 @@ let message =
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 33 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 460 ->
|
||||
| 478 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 27 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
@ -68,9 +68,13 @@ let message =
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 133 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 373 ->
|
||||
| 379 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 375 ->
|
||||
| 381 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 472 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 169 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 134 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
@ -80,7 +84,7 @@ let message =
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 153 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 374 ->
|
||||
| 380 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 63 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
@ -144,137 +148,141 @@ let message =
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 156 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 463 ->
|
||||
| 481 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 465 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 217 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 242 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 219 ->
|
||||
| 483 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 221 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 215 ->
|
||||
| 246 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 226 ->
|
||||
| 223 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 255 ->
|
||||
| 225 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 256 ->
|
||||
| 219 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 243 ->
|
||||
| 230 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 264 ->
|
||||
| 259 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 228 ->
|
||||
| 260 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 257 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 258 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 266 ->
|
||||
| 247 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 268 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 232 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 261 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 262 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 270 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 272 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 274 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 192 ->
|
||||
| 276 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 259 ->
|
||||
| 278 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 285 ->
|
||||
| 195 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 288 ->
|
||||
| 263 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 245 ->
|
||||
| 289 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 293 ->
|
||||
| 292 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 262 ->
|
||||
| 249 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 297 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 266 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 160 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 164 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 429 ->
|
||||
| 445 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 332 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 313 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 431 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 315 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 316 ->
|
||||
| 337 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 317 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 432 ->
|
||||
| 447 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 445 ->
|
||||
| 319 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 446 ->
|
||||
| 320 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 433 ->
|
||||
| 321 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 434 ->
|
||||
| 448 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 435 ->
|
||||
| 462 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 436 ->
|
||||
| 463 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 437 ->
|
||||
| 449 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 438 ->
|
||||
| 450 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 440 ->
|
||||
| 452 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 328 ->
|
||||
| 451 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 330 ->
|
||||
| 453 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 454 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 455 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 457 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 333 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 335 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 339 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 336 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 334 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 331 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 329 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 340 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 341 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 342 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 343 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 344 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 345 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 367 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 346 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 348 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 441 ->
|
||||
| 347 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 443 ->
|
||||
| 349 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 447 ->
|
||||
| 350 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 430 ->
|
||||
| 351 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 312 ->
|
||||
| 373 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 428 ->
|
||||
| 352 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 354 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 458 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 460 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 464 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 446 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 316 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 444 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 165 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
@ -282,65 +290,71 @@ let message =
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 168 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 169 ->
|
||||
| 172 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 171 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 163 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 448 ->
|
||||
| 465 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 450 ->
|
||||
| 467 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 451 ->
|
||||
| 468 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 166 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 235 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 236 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 239 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 240 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 425 ->
|
||||
| 243 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 170 ->
|
||||
| 244 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 171 ->
|
||||
| 441 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 172 ->
|
||||
| 173 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 418 ->
|
||||
| 428 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 419 ->
|
||||
| 429 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 174 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 175 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 434 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 435 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 438 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 439 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 427 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 421 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 422 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 423 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 174 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 304 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 305 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 405 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 412 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 404 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 306 ->
|
||||
| 177 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 308 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 320 ->
|
||||
| 309 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 321 ->
|
||||
| 412 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 322 ->
|
||||
| 419 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 323 ->
|
||||
| 411 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 310 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 312 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 324 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
@ -350,67 +364,79 @@ let message =
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 327 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 378 ->
|
||||
| 329 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 379 ->
|
||||
| 328 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 381 ->
|
||||
| 330 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 335 ->
|
||||
| 331 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 310 ->
|
||||
| 332 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 307 ->
|
||||
| 384 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 395 ->
|
||||
| 385 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 396 ->
|
||||
| 387 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 397 ->
|
||||
| 340 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 398 ->
|
||||
| 314 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 399 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 400 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 408 ->
|
||||
| 311 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 401 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 402 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 404 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 403 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 175 ->
|
||||
| 405 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 176 ->
|
||||
| 406 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 407 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 415 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 408 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 410 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 178 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 179 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 180 ->
|
||||
| 182 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 183 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 302 ->
|
||||
| 186 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 300 ->
|
||||
| 306 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 185 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 187 ->
|
||||
| 304 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 188 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 189 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 190 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 195 ->
|
||||
| 191 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 192 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 193 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 198 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 218 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 197 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 214 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 194 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 210 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| _ ->
|
||||
raise Not_found
|
||||
|
@ -12,7 +12,7 @@
|
||||
%token <(string * Z.t) Region.reg> Mutez "<mutez>"
|
||||
%token <string Region.reg> Ident "<ident>"
|
||||
%token <string Region.reg> Constr "<constr>"
|
||||
%token <string Region.reg> Attr2 "<attr>"
|
||||
%token <string Region.reg> Attr "<attr>"
|
||||
|
||||
(* Symbols *)
|
||||
|
||||
|
@ -206,7 +206,7 @@ field_decl:
|
||||
(* Top-level non-recursive definitions *)
|
||||
|
||||
let_declaration:
|
||||
"let" let_binding seq(Attr2) {
|
||||
"let" let_binding seq(Attr) {
|
||||
let kwd_let = $1 in
|
||||
let attributes = $3 in
|
||||
let binding = $2 in
|
||||
@ -452,7 +452,7 @@ case_clause(right_expr):
|
||||
{pattern=$1; arrow=$2; rhs=$3} }
|
||||
|
||||
let_expr(right_expr):
|
||||
"let" let_binding seq(Attr2) "in" right_expr {
|
||||
"let" let_binding seq(Attr) "in" right_expr {
|
||||
let kwd_let = $1
|
||||
and binding = $2
|
||||
and attributes = $3
|
||||
|
@ -131,7 +131,7 @@ let rec print_tokens state {decl;eof} =
|
||||
and print_attributes state attributes =
|
||||
List.iter (
|
||||
fun ({value = attribute; region}) ->
|
||||
let attribute_formatted = sprintf "[@%s]" attribute in
|
||||
let attribute_formatted = sprintf "[@@%s]" attribute in
|
||||
print_token state region attribute_formatted
|
||||
) attributes
|
||||
|
||||
@ -610,31 +610,41 @@ let rec pp_ast state {decl; _} =
|
||||
List.iteri (List.length decls |> apply) decls
|
||||
|
||||
and pp_declaration state = function
|
||||
Let {value = (_, let_binding, _); region} ->
|
||||
Let {value = (_, let_binding, attr); region} ->
|
||||
pp_loc_node state "Let" region;
|
||||
pp_let_binding state let_binding
|
||||
pp_let_binding state let_binding attr;
|
||||
| TypeDecl {value; region} ->
|
||||
pp_loc_node state "TypeDecl" region;
|
||||
pp_type_decl state value
|
||||
|
||||
and pp_let_binding state node =
|
||||
and pp_let_binding state node attr =
|
||||
let {binders; lhs_type; let_rhs; _} = node in
|
||||
let fields = if lhs_type = None then 2 else 3 in
|
||||
let () =
|
||||
let fields = if attr = [] then fields else fields+1 in
|
||||
let arity =
|
||||
let state = state#pad fields 0 in
|
||||
pp_node state "<binders>";
|
||||
pp_binders state binders in
|
||||
let () =
|
||||
pp_binders state binders; 0 in
|
||||
let arity =
|
||||
match lhs_type with
|
||||
None -> ()
|
||||
None -> arity
|
||||
| Some (_, type_expr) ->
|
||||
let state = state#pad fields 1 in
|
||||
let state = state#pad fields (arity+1) in
|
||||
pp_node state "<lhs type>";
|
||||
pp_type_expr (state#pad 1 0) type_expr in
|
||||
let () =
|
||||
let state = state#pad fields (fields - 1) in
|
||||
pp_type_expr (state#pad 1 0) type_expr;
|
||||
arity+1 in
|
||||
let arity =
|
||||
let state = state#pad fields (arity+1) in
|
||||
pp_node state "<rhs>";
|
||||
pp_expr (state#pad 1 0) let_rhs
|
||||
pp_expr (state#pad 1 0) let_rhs;
|
||||
arity+1 in
|
||||
let () =
|
||||
if attr <> [] then
|
||||
let state = state#pad fields (arity+1) in
|
||||
pp_node state "<attributes>";
|
||||
let length = List.length attr in
|
||||
let apply len rank = pp_ident (state#pad len rank)
|
||||
in List.iteri (apply length) attr
|
||||
in ()
|
||||
|
||||
and pp_type_decl state decl =
|
||||
@ -838,28 +848,39 @@ and pp_fun_expr state node =
|
||||
in ()
|
||||
|
||||
and pp_let_in state node =
|
||||
let {binding; body; _} = node in
|
||||
let {binding; body; attributes; _} = node in
|
||||
let {binders; lhs_type; let_rhs; _} = binding in
|
||||
let fields = if lhs_type = None then 3 else 4 in
|
||||
let () =
|
||||
let fields = if attributes = [] then fields else fields+1 in
|
||||
let arity =
|
||||
let state = state#pad fields 0 in
|
||||
pp_node state "<binders>";
|
||||
pp_binders state binders in
|
||||
let () =
|
||||
pp_binders state binders; 0 in
|
||||
let arity =
|
||||
match lhs_type with
|
||||
None -> ()
|
||||
None -> arity
|
||||
| Some (_, type_expr) ->
|
||||
let state = state#pad fields 1 in
|
||||
let state = state#pad fields (arity+1) in
|
||||
pp_node state "<lhs type>";
|
||||
pp_type_expr (state#pad 1 0) type_expr in
|
||||
let () =
|
||||
let state = state#pad fields (fields - 2) in
|
||||
pp_type_expr (state#pad 1 0) type_expr;
|
||||
arity+1 in
|
||||
let arity =
|
||||
let state = state#pad fields (arity+1) in
|
||||
pp_node state "<rhs>";
|
||||
pp_expr (state#pad 1 0) let_rhs in
|
||||
let () =
|
||||
let state = state#pad fields (fields - 1) in
|
||||
pp_expr (state#pad 1 0) let_rhs;
|
||||
arity+1 in
|
||||
let arity =
|
||||
let state = state#pad fields (arity+1) in
|
||||
pp_node state "<body>";
|
||||
pp_expr (state#pad 1 0) body
|
||||
pp_expr (state#pad 1 0) body;
|
||||
arity+1 in
|
||||
let () =
|
||||
if attributes <> [] then
|
||||
let state = state#pad fields (arity+1) in
|
||||
pp_node state "<attributes>";
|
||||
let length = List.length attributes in
|
||||
let apply len rank = pp_ident (state#pad len rank)
|
||||
in List.iteri (apply length) attributes
|
||||
in ()
|
||||
|
||||
and pp_tuple_expr state {value; _} =
|
||||
|
@ -1,10 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
if test -d ../../.git; then
|
||||
echo true > dot_git_is_dir
|
||||
else
|
||||
echo false > dot_git_is_dir
|
||||
cat .git >> dot_git_is_dir
|
||||
fi
|
@ -1,48 +1,10 @@
|
||||
open Trace
|
||||
|
||||
(*module Parser = Parser_pascaligo.Parser*)
|
||||
(*module ParserLog = Parser_pascaligo.ParserLog*)
|
||||
module AST = Parser_pascaligo.AST
|
||||
module ParErr = Parser_pascaligo.ParErr
|
||||
module LexToken = Parser_pascaligo.LexToken
|
||||
module Lexer = Lexer.Make(LexToken)
|
||||
module Scoping = Parser_pascaligo.Scoping
|
||||
module SSet = Utils.String.Set
|
||||
|
||||
(* Mock options. TODO: Plug in cmdliner. *)
|
||||
|
||||
let pre_options =
|
||||
EvalOpt.make
|
||||
~libs:[]
|
||||
~verbose:SSet.empty
|
||||
~offsets:true
|
||||
~mode:`Point
|
||||
~cmd:EvalOpt.Quiet
|
||||
~mono:true (* Monolithic API of Menhir for now *)
|
||||
(* ~input:None *)
|
||||
(* ~expr:true *)
|
||||
|
||||
module Parser =
|
||||
struct
|
||||
type ast = AST.t
|
||||
type expr = AST.expr
|
||||
include Parser_pascaligo.Parser
|
||||
end
|
||||
|
||||
module ParserLog =
|
||||
struct
|
||||
type ast = AST.t
|
||||
type expr = AST.expr
|
||||
include Parser_pascaligo.ParserLog
|
||||
end
|
||||
|
||||
module PreUnit = ParserUnit.Make (Lexer)(AST)(Parser)(ParErr)(ParserLog)
|
||||
module Front = ParserAPI.Make (Lexer)(Parser)(ParErr)
|
||||
|
||||
let issue_error point =
|
||||
let error = Front.format_error ~offsets:true (* TODO: CLI *)
|
||||
`Point (* TODO: CLI *) point
|
||||
in Stdlib.Error error
|
||||
module Parser = Parser_pascaligo.Parser
|
||||
|
||||
module Errors =
|
||||
struct
|
||||
@ -103,14 +65,6 @@ module Errors =
|
||||
fun () -> Format.asprintf "%a" Location.pp_lift @@ loc)]
|
||||
in error ~data title message
|
||||
|
||||
let detached_attributes (attrs: AST.attributes) =
|
||||
let title () = "detached attributes" in
|
||||
let message () = "" in
|
||||
let data = [
|
||||
("location",
|
||||
fun () -> Format.asprintf "%a" Location.pp_lift @@ attrs.region)]
|
||||
in error ~data title message
|
||||
|
||||
let parser_error source (start: Lexing.position)
|
||||
(stop: Lexing.position) lexbuf =
|
||||
let title () = "parser error" in
|
||||
@ -127,7 +81,8 @@ module Errors =
|
||||
file in
|
||||
let loc =
|
||||
if start.pos_cnum = -1 then
|
||||
Region.make ~start: Pos.min ~stop:(Pos.from_byte stop)
|
||||
Region.make
|
||||
~start:(Pos.min ~file:source) ~stop:(Pos.from_byte stop)
|
||||
else
|
||||
Region.make ~start:(Pos.from_byte start)
|
||||
~stop:(Pos.from_byte stop) in
|
||||
@ -167,14 +122,6 @@ let parse (parser: 'a parser) source lexbuf =
|
||||
fail @@ duplicate_variant name
|
||||
| Scoping.Error (Reserved_name name) ->
|
||||
fail @@ reserved_name name
|
||||
| Scoping.Error (Detached_attributes attrs) ->
|
||||
fail @@ detached_attributes attrs
|
||||
| Parser.Error ->
|
||||
let start = Lexing.lexeme_start_p lexbuf in
|
||||
let end_ = Lexing.lexeme_end_p lexbuf in
|
||||
fail @@ (parser_error source start end_ lexbuf)
|
||||
| Lexer.Error e ->
|
||||
fail @@ lexer_error e
|
||||
| _ ->
|
||||
let () = Printexc.print_backtrace Pervasives.stdout in
|
||||
let start = Lexing.lexeme_start_p lexbuf in
|
||||
@ -198,6 +145,7 @@ let parse_file (source: string) : AST.t result =
|
||||
let lexbuf = Lexing.from_channel channel in
|
||||
parse (Parser.contract) source lexbuf
|
||||
|
||||
(*
|
||||
let parse_file' (source: string) : AST.t result =
|
||||
let module IO =
|
||||
struct
|
||||
@ -208,6 +156,7 @@ let parse_file' (source: string) : AST.t result =
|
||||
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 lexbuf = Lexing.from_string s in
|
||||
|
@ -145,12 +145,13 @@ type t = {
|
||||
|
||||
and ast = t
|
||||
|
||||
and attributes = attribute ne_injection reg
|
||||
|
||||
and declaration =
|
||||
TypeDecl of type_decl reg
|
||||
| ConstDecl of const_decl reg
|
||||
| FunDecl of fun_decl reg
|
||||
| AttrDecl of attr_decl
|
||||
|
||||
and attr_decl = string reg ne_injection reg
|
||||
|
||||
and const_decl = {
|
||||
kwd_const : kwd_const;
|
||||
@ -160,7 +161,7 @@ and const_decl = {
|
||||
equal : equal;
|
||||
init : expr;
|
||||
terminator : semi option;
|
||||
attributes : attributes option
|
||||
attributes : attr_decl option
|
||||
}
|
||||
|
||||
(* Type declarations *)
|
||||
@ -218,7 +219,7 @@ and fun_decl = {
|
||||
block_with : (block reg * kwd_with) option;
|
||||
return : expr;
|
||||
terminator : semi option;
|
||||
attributes : attributes option;
|
||||
attributes : attr_decl option
|
||||
}
|
||||
|
||||
and parameters = (param_decl, semi) nsepseq par reg
|
||||
@ -261,6 +262,7 @@ and statements = (statement, semi) nsepseq
|
||||
and statement =
|
||||
Instr of instruction
|
||||
| Data of data_decl
|
||||
| Attr of attr_decl
|
||||
|
||||
and data_decl =
|
||||
LocalConst of const_decl reg
|
||||
|
@ -43,7 +43,6 @@ type t =
|
||||
| Mutez of (lexeme * Z.t) Region.reg
|
||||
| Ident of lexeme Region.reg
|
||||
| Constr of lexeme Region.reg
|
||||
| Attr of attribute
|
||||
|
||||
(* Symbols *)
|
||||
|
||||
|
@ -41,7 +41,6 @@ type t =
|
||||
| Mutez of (lexeme * Z.t) Region.reg
|
||||
| Ident of lexeme Region.reg
|
||||
| Constr of lexeme Region.reg
|
||||
| Attr of attribute
|
||||
|
||||
(* Symbols *)
|
||||
|
||||
@ -150,8 +149,10 @@ let proj_token = function
|
||||
| Constr Region.{region; value} ->
|
||||
region, sprintf "Constr \"%s\"" value
|
||||
|
||||
(*
|
||||
| Attr {header; string={region; value}} ->
|
||||
region, sprintf "Attr (\"%s\",\"%s\")" header value
|
||||
*)
|
||||
|
||||
(* Symbols *)
|
||||
|
||||
@ -242,7 +243,6 @@ let to_lexeme = function
|
||||
| Mutez i -> fst i.Region.value
|
||||
| Ident id
|
||||
| Constr id -> id.Region.value
|
||||
| Attr {string; _} -> string.Region.value
|
||||
|
||||
(* Symbols *)
|
||||
|
||||
|
39
src/passes/1-parser/pascaligo/Misc/pascaligo.ml
Normal file
39
src/passes/1-parser/pascaligo/Misc/pascaligo.ml
Normal file
@ -0,0 +1,39 @@
|
||||
|
||||
module ParserLog = Parser_pascaligo.ParserLog
|
||||
module ParErr = Parser_pascaligo.ParErr
|
||||
module SSet = Utils.String.Set
|
||||
|
||||
(* Mock options. TODO: Plug in cmdliner. *)
|
||||
|
||||
let pre_options =
|
||||
EvalOpt.make
|
||||
~libs:[]
|
||||
~verbose:SSet.empty
|
||||
~offsets:true
|
||||
~mode:`Point
|
||||
~cmd:EvalOpt.Quiet
|
||||
~mono:true (* Monolithic API of Menhir for now *)
|
||||
(* ~input:None *)
|
||||
(* ~expr:true *)
|
||||
|
||||
module Parser =
|
||||
struct
|
||||
type ast = AST.t
|
||||
type expr = AST.expr
|
||||
include Parser_pascaligo.Parser
|
||||
end
|
||||
|
||||
module ParserLog =
|
||||
struct
|
||||
type ast = AST.t
|
||||
type expr = AST.expr
|
||||
include Parser_pascaligo.ParserLog
|
||||
end
|
||||
|
||||
module PreUnit = ParserUnit.Make (Lexer)(AST)(Parser)(ParErr)(ParserLog)
|
||||
module Front = ParserAPI.Make (Lexer)(Parser)(ParErr)
|
||||
|
||||
let issue_error point =
|
||||
let error = Front.format_error ~offsets:true (* TODO: CLI *)
|
||||
`Point (* TODO: CLI *) point
|
||||
in Stdlib.Error error
|
@ -58,13 +58,13 @@ let message =
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 64 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 517 ->
|
||||
| 543 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 29 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 32 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 515 ->
|
||||
| 541 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 35 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
@ -78,23 +78,9 @@ let message =
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 67 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 70 ->
|
||||
| 68 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 71 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 72 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 73 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 80 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 81 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 76 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 77 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 78 ->
|
||||
| 84 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 85 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
@ -102,241 +88,225 @@ let message =
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 87 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 88 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 512 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 358 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 359 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 499 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 362 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 360 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 361 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 363 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 364 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 365 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 366 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 367 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 475 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 476 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 477 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 478 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 496 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 503 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 502 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 371 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 372 ->
|
||||
| 514 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 373 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 374 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 507 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 377 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 375 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 376 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 378 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 379 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 380 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 381 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 382 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 383 ->
|
||||
| 484 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 485 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 486 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 487 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 504 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 511 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 510 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 386 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 387 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 384 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 385 ->
|
||||
| 388 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 389 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 390 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 391 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 393 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 395 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 399 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 396 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 397 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 375 ->
|
||||
| 398 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 381 ->
|
||||
| 402 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 399 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 400 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 404 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 408 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 405 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 406 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 492 ->
|
||||
| 390 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 493 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 494 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 407 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 488 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 408 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 452 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 447 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 453 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 409 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 410 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 416 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 420 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 421 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 411 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 424 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 425 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 426 ->
|
||||
| 396 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 413 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 414 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 415 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 435 ->
|
||||
| 500 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 436 ->
|
||||
| 501 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 437 ->
|
||||
| 502 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 440 ->
|
||||
| 416 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 441 ->
|
||||
| 496 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 469 ->
|
||||
| 417 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 470 ->
|
||||
| 461 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 473 ->
|
||||
| 456 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 472 ->
|
||||
| 462 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 438 ->
|
||||
| 418 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 467 ->
|
||||
| 419 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 439 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 69 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 428 ->
|
||||
| 425 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 429 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 430 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 431 ->
|
||||
| 420 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 432 ->
|
||||
| 433 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 508 ->
|
||||
| 434 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 521 ->
|
||||
| 435 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 159 ->
|
||||
| 422 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 523 ->
|
||||
| 424 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 137 ->
|
||||
| 444 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 150 ->
|
||||
| 445 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 166 ->
|
||||
| 446 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 167 ->
|
||||
| 449 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 158 ->
|
||||
| 450 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 173 ->
|
||||
| 478 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 152 ->
|
||||
| 479 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 168 ->
|
||||
| 482 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 169 ->
|
||||
| 481 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 175 ->
|
||||
| 447 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 177 ->
|
||||
| 476 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 179 ->
|
||||
| 448 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 437 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 438 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 439 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 440 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 441 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 536 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 515 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 516 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 517 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 518 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 519 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 520 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 529 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 532 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 524 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 525 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 547 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 181 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 183 ->
|
||||
| 549 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 160 ->
|
||||
| 159 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 170 ->
|
||||
| 172 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 157 ->
|
||||
| 188 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 163 ->
|
||||
| 189 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 187 ->
|
||||
| 180 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 92 ->
|
||||
| 195 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 318 ->
|
||||
| 174 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 319 ->
|
||||
| 190 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 322 ->
|
||||
| 191 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 323 ->
|
||||
| 197 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 356 ->
|
||||
| 199 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 351 ->
|
||||
| 201 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 353 ->
|
||||
| 203 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 93 ->
|
||||
| 205 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 94 ->
|
||||
| 182 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 338 ->
|
||||
| 192 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 95 ->
|
||||
| 179 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 96 ->
|
||||
| 185 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 209 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 91 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 342 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
@ -346,169 +316,231 @@ let message =
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 347 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 349 ->
|
||||
| 371 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 97 ->
|
||||
| 366 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 136 ->
|
||||
| 368 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 92 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 93 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 362 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 94 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 95 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 144 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 145 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 148 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 149 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 364 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 96 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 158 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 100 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 217 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 218 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 220 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 221 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 224 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 225 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 358 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 353 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 355 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 101 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 195 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 196 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 198 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 199 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 202 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 203 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 334 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 329 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 331 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 102 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 350 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 336 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 338 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 103 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 326 ->
|
||||
| 332 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 312 ->
|
||||
| 330 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 314 ->
|
||||
| 333 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 104 ->
|
||||
| 334 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 308 ->
|
||||
| 328 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 306 ->
|
||||
| 156 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 105 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 320 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 321 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 322 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 323 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 324 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 137 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 138 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 139 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 140 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 151 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 106 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 107 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 309 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 310 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 304 ->
|
||||
| 154 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 134 ->
|
||||
| 177 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 106 ->
|
||||
| 312 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 296 ->
|
||||
| 315 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 297 ->
|
||||
| 316 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 298 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 299 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 300 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 107 ->
|
||||
| 133 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 108 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 285 ->
|
||||
| 69 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 286 ->
|
||||
| 70 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 132 ->
|
||||
| 71 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 155 ->
|
||||
| 72 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 79 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 80 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 75 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 76 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 77 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 109 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 110 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 111 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 112 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 114 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 117 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 230 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 231 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 269 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 293 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 270 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 272 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 273 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 294 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 300 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 299 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 303 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 302 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 240 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 283 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 284 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 287 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 288 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 291 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 292 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 128 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 110 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 113 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 208 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 209 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 247 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 271 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 248 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 250 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 251 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 272 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 278 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 277 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 281 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 280 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 218 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 261 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 262 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 265 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 266 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 269 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 255 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 257 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 219 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 244 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 245 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 253 ->
|
||||
| 279 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 241 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 210 ->
|
||||
| 266 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 267 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 275 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 211 ->
|
||||
| 263 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 223 ->
|
||||
| 232 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 224 ->
|
||||
| 297 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 240 ->
|
||||
| 233 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 225 ->
|
||||
| 245 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 226 ->
|
||||
| 246 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 234 ->
|
||||
| 262 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 114 ->
|
||||
| 247 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 248 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 256 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 118 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 206 ->
|
||||
| 122 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 119 ->
|
||||
| 228 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 125 ->
|
||||
| 123 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 130 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| _ ->
|
||||
raise Not_found
|
||||
|
@ -12,7 +12,6 @@
|
||||
%token <(LexToken.lexeme * Z.t) Region.reg> Mutez "<mutez>"
|
||||
%token <LexToken.lexeme Region.reg> Ident "<ident>"
|
||||
%token <LexToken.lexeme Region.reg> Constr "<constr>"
|
||||
%token <LexToken.attribute Region.reg> Attr "<attr>"
|
||||
|
||||
(* Symbols *)
|
||||
|
||||
|
@ -5,40 +5,6 @@
|
||||
|
||||
open Region
|
||||
open AST
|
||||
(*
|
||||
type statement_attributes_mixed =
|
||||
PInstr of instruction
|
||||
| PData of data_decl
|
||||
| PAttr of attributes
|
||||
|
||||
let attributes_to_statement (statement, statements) =
|
||||
match statements with
|
||||
[] ->
|
||||
(match statement with
|
||||
| PInstr i -> Instr i, []
|
||||
| PData d -> Data d, []
|
||||
| PAttr a ->
|
||||
raise (Scoping.Error (Scoping.Detached_attributes a)))
|
||||
| _ -> (
|
||||
let statements = (Region.ghost, statement) :: statements in
|
||||
let rec inner result = function
|
||||
| (t, PData (LocalConst const)) :: (_, PAttr a) :: rest ->
|
||||
inner (result @ [(t, Data (LocalConst {const with value = {const.value with attributes = a}}))]) rest
|
||||
| (t, PData (LocalFun func)) :: (_, PAttr a) :: rest ->
|
||||
inner (result @ [(t, Data (LocalFun {func with value = {func.value with attributes = a}}))]) rest
|
||||
| (t, PData d) :: rest ->
|
||||
inner (result @ [(t, Data d)]) rest
|
||||
| (t, PInstr i) :: rest ->
|
||||
inner (result @ [(t, Instr i)]) rest
|
||||
| (_, PAttr _) :: rest ->
|
||||
inner result rest
|
||||
| [] ->
|
||||
result
|
||||
in
|
||||
let result = inner [] statements in
|
||||
(snd (List.hd result), List.tl result)
|
||||
)
|
||||
*)
|
||||
|
||||
(* END HEADER *)
|
||||
%}
|
||||
@ -147,6 +113,15 @@ declaration:
|
||||
type_decl { TypeDecl $1 }
|
||||
| const_decl { ConstDecl $1 }
|
||||
| fun_decl { FunDecl $1 }
|
||||
| attr_decl { AttrDecl $1 }
|
||||
|
||||
(* Attribute declarations *)
|
||||
|
||||
attr_decl:
|
||||
open_attr_decl ";"? { $1 }
|
||||
|
||||
open_attr_decl:
|
||||
ne_injection("attributes","<string>") { $1 }
|
||||
|
||||
(* Type declarations *)
|
||||
|
||||
@ -269,16 +244,14 @@ fun_expr:
|
||||
colon = $3;
|
||||
ret_type = $4;
|
||||
kwd_is = $5;
|
||||
return = $6
|
||||
}
|
||||
return = $6}
|
||||
in {region; value} }
|
||||
|
||||
(* Function declarations *)
|
||||
|
||||
open_fun_decl:
|
||||
"function" fun_name parameters ":" type_expr "is"
|
||||
block
|
||||
"with" expr {
|
||||
block "with" expr {
|
||||
Scoping.check_reserved_name $2;
|
||||
let stop = expr_to_region $9 in
|
||||
let region = cover $1 stop
|
||||
@ -292,7 +265,8 @@ open_fun_decl:
|
||||
return = $9;
|
||||
terminator = None;
|
||||
attributes = None}
|
||||
in {region; value} }
|
||||
in {region; value}
|
||||
}
|
||||
| "function" fun_name parameters ":" type_expr "is" expr {
|
||||
Scoping.check_reserved_name $2;
|
||||
let stop = expr_to_region $7 in
|
||||
@ -310,19 +284,14 @@ open_fun_decl:
|
||||
in {region; value} }
|
||||
|
||||
fun_decl:
|
||||
open_fun_decl maybe_attributes? {
|
||||
match $2 with
|
||||
None -> $1
|
||||
| Some (terminator, attributes) ->
|
||||
let value = {$1.value with terminator; attributes}
|
||||
in {$1 with value} }
|
||||
open_fun_decl ";"? {
|
||||
{$1 with value = {$1.value with terminator=$2}} }
|
||||
|
||||
parameters:
|
||||
par(nsepseq(param_decl,";")) {
|
||||
let params =
|
||||
Utils.nsepseq_to_list ($1.value: _ par).inside
|
||||
in Scoping.check_parameters params;
|
||||
$1 }
|
||||
in Scoping.check_parameters params; $1 }
|
||||
|
||||
param_decl:
|
||||
"var" var ":" param_type {
|
||||
@ -353,7 +322,7 @@ block:
|
||||
let statements, terminator = $2 in
|
||||
let region = cover $1 $3
|
||||
and value = {opening = Begin $1;
|
||||
statements (*= attributes_to_statement statements*);
|
||||
statements;
|
||||
terminator;
|
||||
closing = End $3}
|
||||
in {region; value}
|
||||
@ -362,15 +331,15 @@ block:
|
||||
let statements, terminator = $3 in
|
||||
let region = cover $1 $4
|
||||
and value = {opening = Block ($1,$2);
|
||||
statements (*= attributes_to_statement statements*);
|
||||
statements;
|
||||
terminator;
|
||||
closing = Block $4}
|
||||
in {region; value} }
|
||||
|
||||
statement:
|
||||
instruction { (*P*)Instr $1 }
|
||||
| open_data_decl { (*P*)Data $1 }
|
||||
(*| attributes { PAttr $1 }*)
|
||||
instruction { Instr $1 }
|
||||
| open_data_decl { Data $1 }
|
||||
| open_attr_decl { Attr $1 }
|
||||
|
||||
open_data_decl:
|
||||
open_const_decl { LocalConst $1 }
|
||||
@ -410,20 +379,9 @@ unqualified_decl(OP):
|
||||
let region = expr_to_region $5
|
||||
in $1, $2, $3, $4, $5, region }
|
||||
|
||||
attributes:
|
||||
ne_injection("attributes","<string>") { $1 }
|
||||
|
||||
maybe_attributes:
|
||||
";" { Some $1, None }
|
||||
| ";" attributes ";" { Some $1, Some $2 }
|
||||
|
||||
const_decl:
|
||||
open_const_decl maybe_attributes? {
|
||||
match $2 with
|
||||
None -> $1
|
||||
| Some (terminator, attributes) ->
|
||||
let value = {$1.value with terminator; attributes}
|
||||
in {$1 with value} }
|
||||
open_const_decl ";"? {
|
||||
{$1 with value = {$1.value with terminator=$2}} }
|
||||
|
||||
instruction:
|
||||
conditional { Cond $1 }
|
||||
@ -587,7 +545,7 @@ clause_block:
|
||||
let statements, terminator = $2 in
|
||||
let region = cover $1 $3 in
|
||||
let value = {lbrace = $1;
|
||||
inside = (*attributes_to_statement*) statements, terminator;
|
||||
inside = statements, terminator;
|
||||
rbrace = $3} in
|
||||
ShortBlock {value; region} }
|
||||
|
||||
|
@ -114,27 +114,25 @@ let rec print_tokens state ast =
|
||||
Utils.nseq_iter (print_decl state) decl;
|
||||
print_token state eof "EOF"
|
||||
|
||||
and print_attributes state = function
|
||||
None -> ()
|
||||
| Some attr ->
|
||||
print_ne_injection state "attributes" print_string attr
|
||||
and print_attr_decl state =
|
||||
print_ne_injection state "attributes" print_string
|
||||
|
||||
and print_decl state = function
|
||||
TypeDecl decl -> print_type_decl state decl
|
||||
| ConstDecl decl -> print_const_decl state decl
|
||||
| FunDecl decl -> print_fun_decl state decl
|
||||
| AttrDecl decl -> print_attr_decl state decl
|
||||
|
||||
and print_const_decl state {value; _} =
|
||||
let {kwd_const; name; colon; const_type;
|
||||
equal; init; terminator; attributes} = value in
|
||||
equal; init; terminator; _} = value in
|
||||
print_token state kwd_const "const";
|
||||
print_var state name;
|
||||
print_token state colon ":";
|
||||
print_type_expr state const_type;
|
||||
print_token state equal "=";
|
||||
print_expr state init;
|
||||
print_terminator state terminator;
|
||||
print_attributes state attributes
|
||||
print_terminator state terminator
|
||||
|
||||
and print_type_decl state {value; _} =
|
||||
let {kwd_type; name; kwd_is;
|
||||
@ -204,7 +202,7 @@ and print_type_tuple state {value; _} =
|
||||
and print_fun_decl state {value; _} =
|
||||
let {kwd_function; fun_name; param; colon;
|
||||
ret_type; kwd_is; block_with;
|
||||
return; terminator; attributes } = value in
|
||||
return; terminator; _} = value in
|
||||
print_token state kwd_function "function";
|
||||
print_var state fun_name;
|
||||
print_parameters state param;
|
||||
@ -218,7 +216,6 @@ and print_fun_decl state {value; _} =
|
||||
print_token state kwd_with "with");
|
||||
print_expr state return;
|
||||
print_terminator state terminator;
|
||||
print_attributes state attributes
|
||||
|
||||
and print_fun_expr state {value; _} =
|
||||
let {kwd_function; param; colon;
|
||||
@ -294,6 +291,7 @@ and print_statements state sequence =
|
||||
and print_statement state = function
|
||||
Instr instr -> print_instruction state instr
|
||||
| Data data -> print_data_decl state data
|
||||
| Attr attr -> print_attr_decl state attr
|
||||
|
||||
and print_instruction state = function
|
||||
Cond {value; _} -> print_conditional state value
|
||||
@ -686,10 +684,10 @@ and print_opening state lexeme = function
|
||||
print_token state kwd lexeme
|
||||
| KwdBracket (kwd, lbracket) ->
|
||||
print_token state kwd lexeme;
|
||||
print_token state lbracket "{"
|
||||
print_token state lbracket "["
|
||||
|
||||
and print_closing state = function
|
||||
RBracket rbracket -> print_token state rbracket "}"
|
||||
RBracket rbracket -> print_token state rbracket "]"
|
||||
| End kwd_end -> print_token state kwd_end "end"
|
||||
|
||||
and print_binding state {value; _} =
|
||||
@ -846,12 +844,14 @@ and pp_declaration state = function
|
||||
| FunDecl {value; region} ->
|
||||
pp_loc_node state "FunDecl" region;
|
||||
pp_fun_decl state value
|
||||
| AttrDecl {value; region} ->
|
||||
pp_loc_node state "AttrDecl" region;
|
||||
pp_attr_decl state value
|
||||
|
||||
and pp_attr_decl state = pp_ne_injection pp_string state
|
||||
|
||||
and pp_fun_decl state decl =
|
||||
let arity =
|
||||
match decl.attributes with
|
||||
None -> 5
|
||||
| Some _ -> 6 in
|
||||
let arity = 5 in
|
||||
let () =
|
||||
let state = state#pad arity 0 in
|
||||
pp_ident state decl.fun_name in
|
||||
@ -874,33 +874,14 @@ and pp_fun_decl state decl =
|
||||
let () =
|
||||
let state = state#pad arity 4 in
|
||||
pp_node state "<return>";
|
||||
pp_expr (state#pad 1 0) decl.return in
|
||||
let () =
|
||||
match decl.attributes with
|
||||
None -> ()
|
||||
| Some attr ->
|
||||
let state = state#pad arity 5 in
|
||||
pp_node state "<attributes>";
|
||||
pp_attributes (state#pad 1 0) attr
|
||||
pp_expr (state#pad 1 0) decl.return
|
||||
in ()
|
||||
|
||||
and pp_attributes state {value; _} =
|
||||
pp_ne_injection pp_string state value
|
||||
|
||||
and pp_const_decl state decl =
|
||||
let arity =
|
||||
match decl.attributes with
|
||||
None -> 3
|
||||
| Some _ -> 4 in
|
||||
let arity = 3 in
|
||||
pp_ident (state#pad arity 0) decl.name;
|
||||
pp_type_expr (state#pad arity 1) decl.const_type;
|
||||
pp_expr (state#pad arity 2) decl.init;
|
||||
match decl.attributes with
|
||||
None -> ()
|
||||
| Some attr ->
|
||||
let state = state#pad arity 3 in
|
||||
pp_node state "<attributes>";
|
||||
pp_attributes (state#pad 1 0) attr
|
||||
pp_expr (state#pad arity 2) decl.init
|
||||
|
||||
and pp_type_expr state = function
|
||||
TProd cartesian ->
|
||||
@ -1001,6 +982,9 @@ and pp_statement state = function
|
||||
| Data data_decl ->
|
||||
pp_node state "Data";
|
||||
pp_data_decl (state#pad 1 0) data_decl
|
||||
| Attr attr_decl ->
|
||||
pp_node state "Attr";
|
||||
pp_attr_decl state attr_decl.value
|
||||
|
||||
and pp_instruction state = function
|
||||
Cond {value; region} ->
|
||||
|
@ -7,7 +7,6 @@ type t =
|
||||
| Duplicate_variant of AST.variable
|
||||
| Non_linear_pattern of AST.variable
|
||||
| Duplicate_field of AST.variable
|
||||
| Detached_attributes of AST.attributes
|
||||
|
||||
type error = t
|
||||
|
||||
|
@ -6,7 +6,6 @@ type t =
|
||||
| Duplicate_variant of AST.variable
|
||||
| Non_linear_pattern of AST.variable
|
||||
| Duplicate_field of AST.variable
|
||||
| Detached_attributes of AST.attributes
|
||||
|
||||
type error = t
|
||||
|
||||
|
@ -1,10 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
if test -d ../../.git; then
|
||||
echo true > dot_git_is_dir
|
||||
else
|
||||
echo false > dot_git_is_dir
|
||||
cat .git >> dot_git_is_dir
|
||||
fi
|
@ -45,7 +45,7 @@ module Errors =
|
||||
let loc =
|
||||
if start.pos_cnum = -1
|
||||
then Region.make
|
||||
~start: Pos.min
|
||||
~start:(Pos.min ~file:source)
|
||||
~stop:(Pos.from_byte end_)
|
||||
else Region.make
|
||||
~start:(Pos.from_byte start)
|
||||
|
@ -143,8 +143,7 @@ val mk_int : lexeme -> Region.t -> (token, int_err) result
|
||||
val mk_nat : lexeme -> Region.t -> (token, nat_err) result
|
||||
val mk_mutez : lexeme -> Region.t -> (token, int_err) result
|
||||
val mk_ident : lexeme -> Region.t -> (token, ident_err) result
|
||||
val mk_attr : lexeme -> Region.t -> (token, attr_err) result
|
||||
val mk_attr2 : lexeme -> Region.t -> (token, attr_err) result
|
||||
val mk_attr : string -> lexeme -> Region.t -> (token, attr_err) result
|
||||
val mk_sym : lexeme -> Region.t -> (token, sym_err) result
|
||||
val mk_kwd : lexeme -> Region.t -> (token, kwd_err) result
|
||||
val mk_string : lexeme -> Region.t -> token
|
||||
|
@ -453,11 +453,10 @@ let mk_constr lexeme region = mk_constr' lexeme region lexicon
|
||||
|
||||
(* Attributes *)
|
||||
|
||||
let mk_attr lexeme region =
|
||||
Ok (Attr { value = lexeme; region })
|
||||
|
||||
let mk_attr2 _lexeme _region =
|
||||
Error Invalid_attribute
|
||||
let mk_attr header lexeme region =
|
||||
if header = "[@" then
|
||||
Ok (Attr Region.{value=lexeme; region})
|
||||
else Error Invalid_attribute
|
||||
|
||||
(* Predicates *)
|
||||
|
||||
|
65
src/passes/1-parser/reasonligo/Misc/Misc.ml
Normal file
65
src/passes/1-parser/reasonligo/Misc/Misc.ml
Normal file
@ -0,0 +1,65 @@
|
||||
type error =
|
||||
IntErr of LexToken.int_err
|
||||
| IdentErr of LexToken.ident_err
|
||||
| NatErr of LexToken.nat_err
|
||||
| SymErr of LexToken.sym_err
|
||||
| KwdErr of LexToken.kwd_err
|
||||
|
||||
let rec first_of_expr = function
|
||||
ECase {value; _} ->
|
||||
(match LexToken.mk_kwd "switch" value.kwd_match with
|
||||
Error e -> Error (KwdErr e)
|
||||
| Ok token -> Ok token)
|
||||
| ECond {value; _} ->
|
||||
(match LexToken.mk_kwd "if" value.kwd_if with
|
||||
Error e -> Error (KwdErr e)
|
||||
| Ok token -> Ok token)
|
||||
| EPar {value; _} ->
|
||||
(match LexToken.mk_sym "(" value.lpar with
|
||||
Error e -> Error (SymErr e)
|
||||
| Ok token -> Ok token)
|
||||
| EAnnot {value; _} ->
|
||||
(match LexToken.mk_sym "(" value.lpar with
|
||||
Error e -> Error (SymErr e)
|
||||
| Ok token -> Ok token)
|
||||
| EUnit {value=opening, _; _} ->
|
||||
(match LexToken.mk_sym "(" opening with
|
||||
Error e -> Error (SymErr e)
|
||||
| Ok token -> Ok token)
|
||||
| EBytes b ->
|
||||
Ok (LexToken.mk_bytes (fst b.value) b.region)
|
||||
| EVar v ->
|
||||
(match LexToken.mk_ident v.value v.region with
|
||||
Error e -> Error (IdentErr e)
|
||||
| Ok token -> Ok token)
|
||||
| ESeq {value; _} ->
|
||||
let opening =
|
||||
match value.compound with
|
||||
BeginEnd (opening, _)
|
||||
| Braces (opening, _)
|
||||
| Brackets (opening, _) -> opening
|
||||
in (match LexToken.mk_sym "{" opening with
|
||||
Error e -> Error (SymErr e)
|
||||
| Ok token -> Ok token)
|
||||
| EProj {value; _} ->
|
||||
let structure = value.struct_name in
|
||||
(match LexToken.mk_ident structure.value structure.region with
|
||||
Error e -> Error (IdentErr e)
|
||||
| Ok token -> Ok token)
|
||||
| EFun {value; _} ->
|
||||
(match LexToken.mk_kwd "fun" value.kwd_fun with
|
||||
Error e -> Error (KwdErr e)
|
||||
| Ok token -> Ok token)
|
||||
| _ -> failwith "TODO"
|
||||
(*
|
||||
|
||||
| ELogic expr -> first_of_logic_expr expr
|
||||
| EArith expr -> first_of_arith_expr expr
|
||||
| EString expr -> first_of_string_expr expr
|
||||
| EList expr -> first_of_list_expr expr
|
||||
| EConstr expr -> first_of_constr_expr expr
|
||||
| ECall {value=expr,_; _} -> first_of_expr expr
|
||||
| ERecord {value; _} -> (*field_assign reg ne_injection *)
|
||||
| ETuple {value; _} -> (* (expr, comma) nsepseq *)
|
||||
| ELetIn {value; _} -> first_of_let_in value
|
||||
*)
|
@ -46,9 +46,9 @@ let message =
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 11 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 509 ->
|
||||
| 528 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 503 ->
|
||||
| 61 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 48 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
@ -68,335 +68,387 @@ let message =
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 14 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 60 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 65 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 505 ->
|
||||
| 70 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 145 ->
|
||||
| 524 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 146 ->
|
||||
| 185 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 144 ->
|
||||
| 186 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 329 ->
|
||||
| 184 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 331 ->
|
||||
| 302 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 330 ->
|
||||
| 304 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 61 ->
|
||||
| 303 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 66 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 69 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 64 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 59 ->
|
||||
| 183 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 143 ->
|
||||
| 311 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 338 ->
|
||||
| 313 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 340 ->
|
||||
| 312 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 339 ->
|
||||
| 191 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 151 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 152 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 78 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 325 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 327 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 326 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 92 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 155 ->
|
||||
| 192 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 118 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 125 ->
|
||||
| 298 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 87 ->
|
||||
| 300 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 105 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 107 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 108 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 106 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 88 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 93 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 80 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 81 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 82 ->
|
||||
| 299 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 132 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 334 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 336 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 335 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 133 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 136 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 137 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 157 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 159 ->
|
||||
| 195 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 158 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 512 ->
|
||||
| 165 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 218 ->
|
||||
| 127 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 514 ->
|
||||
| 145 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 216 ->
|
||||
| 147 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 250 ->
|
||||
| 148 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 248 ->
|
||||
| 146 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 249 ->
|
||||
| 128 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 230 ->
|
||||
| 133 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 235 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 252 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 254 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 255 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 258 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 219 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 226 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 227 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 260 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 262 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 264 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 266 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 194 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 195 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 206 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 215 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 199 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 207 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 208 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 196 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 197 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 198 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 256 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 257 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 277 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 233 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 279 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 67 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 463 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 464 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 387 ->
|
||||
| 120 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 121 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 122 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 120 ->
|
||||
| 172 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 466 ->
|
||||
| 307 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 467 ->
|
||||
| 309 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 308 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 173 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 176 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 177 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 197 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 199 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 198 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 59 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 531 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 225 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 533 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 223 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 257 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 255 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 256 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 237 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 242 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 259 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 261 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 262 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 265 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 226 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 233 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 234 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 267 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 269 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 271 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 273 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 201 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 202 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 213 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 222 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 206 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 214 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 215 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 203 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 204 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 205 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 263 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 284 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 240 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 286 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 72 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 483 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 492 ->
|
||||
| 484 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 469 ->
|
||||
| 423 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 470 ->
|
||||
| 161 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 468 ->
|
||||
| 162 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 471 ->
|
||||
| 160 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 472 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 473 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 475 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 476 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 477 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 478 ->
|
||||
| 486 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 487 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 488 ->
|
||||
| 504 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 474 ->
|
||||
| 513 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 498 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 499 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 497 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 465 ->
|
||||
| 488 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 321 ->
|
||||
| 489 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 490 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 492 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 493 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 494 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 495 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 509 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 510 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 491 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 520 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 518 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 485 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 372 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 366 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 367 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 369 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 368 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 365 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 76 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 446 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 326 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 332 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 333 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 336 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 337 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 328 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 339 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 100 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 78 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 80 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 315 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 316 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 318 ->
|
||||
| 117 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 317 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 314 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 71 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 410 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 298 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 304 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 305 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 308 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 309 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 300 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 178 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 73 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 75 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 419 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 420 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 77 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 160 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 412 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 413 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 415 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 416 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 193 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 229 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 74 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 447 ->
|
||||
| 82 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 448 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 456 ->
|
||||
| 449 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 457 ->
|
||||
| 451 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 459 ->
|
||||
| 452 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 200 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 236 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 79 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 467 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 468 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 476 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 477 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 479 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 480 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 469 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 470 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 81 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 460 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 449 ->
|
||||
| 461 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 450 ->
|
||||
| 455 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 76 ->
|
||||
| 454 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 458 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 348 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 356 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 360 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 359 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 355 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 349 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 457 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 340 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 341 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 346 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 347 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 342 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 343 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 344 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 84 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 85 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 318 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 323 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 324 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 389 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 436 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 437 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 438 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 439 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 440 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 441 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 425 ->
|
||||
| 435 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 422 ->
|
||||
| 325 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 428 ->
|
||||
| 362 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 429 ->
|
||||
| 363 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 434 ->
|
||||
| 373 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 438 ->
|
||||
| 374 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 437 ->
|
||||
| 413 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 433 ->
|
||||
| 420 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 423 ->
|
||||
| 408 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 427 ->
|
||||
| 409 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 162 ->
|
||||
| 407 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 163 ->
|
||||
| 375 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 290 ->
|
||||
| 376 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 295 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 296 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 357 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 400 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 401 ->
|
||||
| 377 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 402 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
@ -406,105 +458,69 @@ let message =
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 405 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 399 ->
|
||||
| 417 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 297 ->
|
||||
| 418 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 311 ->
|
||||
| 401 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 312 ->
|
||||
| 429 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 322 ->
|
||||
| 427 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 323 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 377 ->
|
||||
| 364 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 384 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 342 ->
|
||||
| 385 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 343 ->
|
||||
| 383 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 324 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 344 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 345 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 346 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 370 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 371 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 372 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 373 ->
|
||||
| 378 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 379 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 380 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 369 ->
|
||||
| 394 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 395 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 396 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 397 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 399 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 398 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 393 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 391 ->
|
||||
| 320 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 313 ->
|
||||
| 321 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 348 ->
|
||||
| 86 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 349 ->
|
||||
| 87 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 347 ->
|
||||
| 88 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 350 ->
|
||||
| 89 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 351 ->
|
||||
| 90 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 352 ->
|
||||
| 91 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 359 ->
|
||||
| 96 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 360 ->
|
||||
| 97 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 361 ->
|
||||
| 98 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 362 ->
|
||||
| 111 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 364 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 363 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 358 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 292 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 293 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 164 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 165 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 166 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 167 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 168 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 169 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 174 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 175 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 176 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 188 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| 237 ->
|
||||
| 244 ->
|
||||
"<YOUR SYNTAX ERROR MESSAGE HERE>\n"
|
||||
| _ ->
|
||||
raise Not_found
|
||||
|
@ -868,7 +868,7 @@ let open_token_stream file_path_opt =
|
||||
let file_path = match file_path_opt with
|
||||
None | Some "-" -> ""
|
||||
| Some file_path -> file_path in
|
||||
let pos = Pos.min#set_file file_path in
|
||||
let pos = Pos.min ~file:file_path in
|
||||
let buf_reg = ref (pos#byte, pos#byte)
|
||||
and first_call = ref true
|
||||
and decoder = Uutf.decoder ~encoding:`UTF_8 `Manual in
|
||||
|
@ -77,44 +77,6 @@ module Make (Lexer: Lexer.S)
|
||||
|
||||
exception Point of error
|
||||
|
||||
let failure get_win checkpoint =
|
||||
let message = ParErr.message (state checkpoint) in
|
||||
match get_win () with
|
||||
Lexer.Nil -> assert false
|
||||
| Lexer.One invalid ->
|
||||
raise (Point (message, None, invalid))
|
||||
| Lexer.Two (invalid, valid) ->
|
||||
raise (Point (message, Some valid, invalid))
|
||||
|
||||
(* The two Menhir APIs are called from the following functions. *)
|
||||
|
||||
module Incr = Parser.Incremental
|
||||
|
||||
let incr_contract memo Lexer.{read; buffer; get_win; close; _} =
|
||||
let supplier = I.lexer_lexbuf_to_supplier read buffer
|
||||
and failure = failure get_win in
|
||||
let parser = Incr.contract buffer.Lexing.lex_curr_p in
|
||||
let ast =
|
||||
try I.loop_handle success failure supplier parser with
|
||||
Point (message, valid_opt, invalid) ->
|
||||
let error = Memo. (* TODO *)
|
||||
in Stdlib.Error ()
|
||||
|
||||
in close (); ast
|
||||
|
||||
let mono_contract = Parser.contract
|
||||
|
||||
let incr_expr Lexer.{read; buffer; get_win; close; _} : Parser.expr =
|
||||
let supplier = I.lexer_lexbuf_to_supplier read buffer
|
||||
and failure = failure get_win in
|
||||
let parser = Incr.interactive_expr buffer.Lexing.lex_curr_p in
|
||||
let expr = I.loop_handle success failure supplier parser
|
||||
in close (); expr
|
||||
|
||||
let mono_expr = Parser.interactive_expr
|
||||
|
||||
(* Errors *)
|
||||
|
||||
let format_error ?(offsets=true) mode (msg, valid_opt, invalid) =
|
||||
let invalid_region = Lexer.Token.to_region invalid in
|
||||
let header =
|
||||
@ -135,4 +97,37 @@ module Make (Lexer: Lexer.S)
|
||||
let header = header ^ trailer in
|
||||
header ^ (if msg = "" then ".\n" else ":\n" ^ msg)
|
||||
|
||||
let failure get_win checkpoint =
|
||||
let message = ParErr.message (state checkpoint) in
|
||||
match get_win () with
|
||||
Lexer.Nil -> assert false
|
||||
| Lexer.One invalid ->
|
||||
raise (Point (message, None, invalid))
|
||||
| Lexer.Two (invalid, valid) ->
|
||||
raise (Point (message, Some valid, invalid))
|
||||
|
||||
(* The monolithic API of Menhir *)
|
||||
|
||||
let mono_contract = Parser.contract
|
||||
|
||||
let mono_expr = Parser.interactive_expr
|
||||
|
||||
(* Incremental API of Menhir *)
|
||||
|
||||
module Incr = Parser.Incremental
|
||||
|
||||
let incr_contract Lexer.{read; buffer; get_win; close; _} =
|
||||
let supplier = I.lexer_lexbuf_to_supplier read buffer
|
||||
and failure = failure get_win in
|
||||
let parser = Incr.contract buffer.Lexing.lex_curr_p in
|
||||
let ast = I.loop_handle success failure supplier parser
|
||||
in close (); ast
|
||||
|
||||
let incr_expr Lexer.{read; buffer; get_win; close; _} =
|
||||
let supplier = I.lexer_lexbuf_to_supplier read buffer
|
||||
and failure = failure get_win in
|
||||
let parser = Incr.interactive_expr buffer.Lexing.lex_curr_p in
|
||||
let expr = I.loop_handle success failure supplier parser
|
||||
in close (); expr
|
||||
|
||||
end
|
||||
|
@ -47,24 +47,25 @@ module Make (Lexer: Lexer.S)
|
||||
(Parser: PARSER with type token = Lexer.Token.token)
|
||||
(ParErr: sig val message : int -> string end) :
|
||||
sig
|
||||
(* The monolithic API of Menhir with memos *)
|
||||
(* The monolithic API of Menhir *)
|
||||
|
||||
val mono_contract :
|
||||
(Lexing.lexbuf -> Lexer.token) ->
|
||||
Lexing.lexbuf ->
|
||||
(Parser.ast, string) Stdlib.result
|
||||
(Lexing.lexbuf -> Lexer.token) -> Lexing.lexbuf -> Parser.ast
|
||||
|
||||
val mono_expr :
|
||||
(Lexing.lexbuf -> Lexer.token) ->
|
||||
Lexing.lexbuf ->
|
||||
(Parser.expr, string) Stdlib.result
|
||||
(Lexing.lexbuf -> Lexer.token) -> Lexing.lexbuf -> Parser.expr
|
||||
|
||||
(* Incremental API of Menhir with memos *)
|
||||
(* Incremental API of Menhir *)
|
||||
|
||||
val incr_contract :
|
||||
Lexer.instance -> (Parser.ast, string) Stdlib.result
|
||||
type message = string
|
||||
type valid = Parser.token
|
||||
type invalid = Parser.token
|
||||
type error = message * valid option * invalid
|
||||
|
||||
val incr_expr :
|
||||
Lexer.instance ->
|
||||
(Parser.expr, string) Stdlib.result
|
||||
exception Point of error
|
||||
|
||||
val incr_contract : Lexer.instance -> Parser.ast
|
||||
val incr_expr : Lexer.instance -> Parser.expr
|
||||
|
||||
val format_error : ?offsets:bool -> [`Point | `Byte] -> error -> string
|
||||
end
|
||||
|
@ -89,6 +89,9 @@ module Make (Lexer: Lexer.S)
|
||||
|
||||
let format_error = Front.format_error
|
||||
|
||||
let short_error ?(offsets=true) mode msg (reg: Region.t) =
|
||||
sprintf "Parse error %s:\n%s" (reg#to_string ~offsets mode) msg
|
||||
|
||||
(* Parsing an expression *)
|
||||
|
||||
let parse_expr lexer_inst tokeniser output state :
|
||||
|
@ -46,6 +46,9 @@ module Make (Lexer: Lexer.S)
|
||||
val format_error :
|
||||
?offsets:bool -> [`Byte | `Point] -> error -> string
|
||||
|
||||
val short_error :
|
||||
?offsets:bool -> [`Point | `Byte] -> string -> Region.t -> string
|
||||
|
||||
(* Parsers *)
|
||||
|
||||
val parse :
|
||||
|
@ -11,7 +11,7 @@ open Combinators
|
||||
let nseq_to_list (hd, tl) = hd :: tl
|
||||
let npseq_to_list (hd, tl) = hd :: (List.map snd tl)
|
||||
let pseq_to_list = function
|
||||
| None -> []
|
||||
None -> []
|
||||
| Some lst -> npseq_to_list lst
|
||||
let get_value : 'a Raw.reg -> 'a = fun x -> x.value
|
||||
let is_compiler_generated name = String.contains (Var.to_name name) '#'
|
||||
@ -563,10 +563,11 @@ and simpl_tuple_expression ?loc (lst:Raw.expr list) : expression result =
|
||||
| [] -> return @@ e_literal Literal_unit
|
||||
| [hd] -> simpl_expression hd
|
||||
| lst ->
|
||||
let%bind lst = bind_list @@ List.map simpl_expression lst in
|
||||
return @@ e_tuple ?loc lst
|
||||
let%bind lst = bind_list @@ List.map simpl_expression lst
|
||||
in return @@ e_tuple ?loc lst
|
||||
|
||||
and simpl_data_declaration : Raw.data_decl -> _ result = fun t ->
|
||||
and simpl_data_declaration : Raw.data_decl -> _ result =
|
||||
fun t ->
|
||||
match t with
|
||||
| LocalVar x ->
|
||||
let (x , loc) = r_split x in
|
||||
@ -579,15 +580,26 @@ and simpl_data_declaration : Raw.data_decl -> _ result = fun t ->
|
||||
let name = x.name.value in
|
||||
let%bind t = simpl_type_expression x.const_type in
|
||||
let%bind expression = simpl_expression x.init in
|
||||
let inline = List.exists (fun (f: Raw.attribute) -> f.value = "\"inline\"") x.attributes.value in
|
||||
return_let_in ~loc (Var.of_name name , Some t) inline expression
|
||||
let inline =
|
||||
match x.attributes with
|
||||
None -> false
|
||||
| Some {value; _} ->
|
||||
npseq_to_list value.ne_elements
|
||||
|> List.exists (fun Region.{value; _} -> value = "\"inline\"")
|
||||
in return_let_in ~loc (Var.of_name name, Some t) inline expression
|
||||
| LocalFun f ->
|
||||
let (f , loc) = r_split f in
|
||||
let%bind (binder, expr) = simpl_fun_decl ~loc f in
|
||||
let inline = List.exists (fun (f: Raw.attribute) -> f.value = "\"inline\"") f.attributes.value in
|
||||
return_let_in ~loc binder inline expr
|
||||
let inline =
|
||||
match f.attributes with
|
||||
None -> false
|
||||
| Some {value; _} ->
|
||||
npseq_to_list value.ne_elements
|
||||
|> List.exists (fun Region.{value; _} -> value = "\"inline\"")
|
||||
in return_let_in ~loc binder inline expr
|
||||
|
||||
and simpl_param : Raw.param_decl -> (expression_variable * type_expression) result =
|
||||
and simpl_param :
|
||||
Raw.param_decl -> (expression_variable * type_expression) result =
|
||||
fun t ->
|
||||
match t with
|
||||
| ParamConst c ->
|
||||
@ -602,11 +614,18 @@ and simpl_param : Raw.param_decl -> (expression_variable * type_expression) resu
|
||||
ok (type_name , type_expression)
|
||||
|
||||
and simpl_fun_decl :
|
||||
loc:_ -> Raw.fun_decl -> ((expression_variable * type_expression option) * expression) result =
|
||||
loc:_ -> Raw.fun_decl ->
|
||||
((expression_variable * type_expression option) * expression) result =
|
||||
fun ~loc x ->
|
||||
let open! Raw in
|
||||
let {fun_name;param;ret_type;block_with;return; attributes} : fun_decl = x in
|
||||
let inline = List.exists (fun (a: Raw.attribute) -> a.value = "\"inline\"") attributes.value in
|
||||
let {fun_name; param; ret_type; block_with;
|
||||
return; attributes} : fun_decl = x in
|
||||
let inline =
|
||||
match attributes with
|
||||
None -> false
|
||||
| Some {value; _} ->
|
||||
npseq_to_list value.ne_elements
|
||||
|> List.exists (fun Region.{value; _} -> value = "\"inline\"") in
|
||||
let statements =
|
||||
match block_with with
|
||||
| Some (block,_) -> npseq_to_list block.value.statements
|
||||
@ -616,9 +635,7 @@ and simpl_fun_decl :
|
||||
a, [] -> (
|
||||
let%bind input = simpl_param a in
|
||||
let (binder , input_type) = input in
|
||||
let%bind instructions = bind_list
|
||||
@@ List.map simpl_statement
|
||||
@@ statements in
|
||||
let%bind instructions = simpl_statement_list statements in
|
||||
let%bind result = simpl_expression return in
|
||||
let%bind output_type = simpl_type_expression ret_type in
|
||||
let body = instructions in
|
||||
@ -648,9 +665,7 @@ and simpl_fun_decl :
|
||||
ass
|
||||
in
|
||||
bind_list @@ List.mapi aux params in
|
||||
let%bind instructions = bind_list
|
||||
@@ List.map simpl_statement
|
||||
@@ statements in
|
||||
let%bind instructions = simpl_statement_list statements in
|
||||
let%bind result = simpl_expression return in
|
||||
let%bind output_type = simpl_type_expression ret_type in
|
||||
let body = tpl_declarations @ instructions in
|
||||
@ -674,9 +689,7 @@ and simpl_fun_expression :
|
||||
a, [] -> (
|
||||
let%bind input = simpl_param a in
|
||||
let (binder , input_type) = input in
|
||||
let%bind instructions = bind_list
|
||||
@@ List.map simpl_statement
|
||||
@@ statements in
|
||||
let%bind instructions = simpl_statement_list statements in
|
||||
let%bind result = simpl_expression return in
|
||||
let%bind output_type = simpl_type_expression ret_type in
|
||||
let body = instructions in
|
||||
@ -706,9 +719,7 @@ and simpl_fun_expression :
|
||||
ass
|
||||
in
|
||||
bind_list @@ List.mapi aux params in
|
||||
let%bind instructions = bind_list
|
||||
@@ List.map simpl_statement
|
||||
@@ statements in
|
||||
let%bind instructions = simpl_statement_list statements in
|
||||
let%bind result = simpl_expression return in
|
||||
let%bind output_type = simpl_type_expression ret_type in
|
||||
let body = tpl_declarations @ instructions in
|
||||
@ -722,44 +733,39 @@ and simpl_fun_expression :
|
||||
)
|
||||
)
|
||||
|
||||
and simpl_declaration : Raw.declaration -> declaration Location.wrap result =
|
||||
fun t ->
|
||||
let open! Raw in
|
||||
match t with
|
||||
| TypeDecl x ->
|
||||
let decl, loc = r_split x in
|
||||
let {name;type_expr} : Raw.type_decl = decl in
|
||||
let%bind type_expression = simpl_type_expression type_expr in
|
||||
ok @@ Location.wrap ~loc (Declaration_type
|
||||
(Var.of_name name.value, type_expression))
|
||||
|
||||
| ConstDecl x ->
|
||||
let simpl_const_decl = fun {name;const_type; init; attributes} ->
|
||||
let%bind expression = simpl_expression init in
|
||||
let%bind t = simpl_type_expression const_type in
|
||||
let type_annotation = Some t in
|
||||
let inline = List.exists (fun (a: Raw.attribute) -> a.value = "\"inline\"") attributes.value in
|
||||
ok @@ Declaration_constant
|
||||
(Var.of_name name.value, type_annotation, inline, expression)
|
||||
in bind_map_location simpl_const_decl (Location.lift_region x)
|
||||
| FunDecl x ->
|
||||
let decl, loc = r_split x in
|
||||
let%bind ((name, ty_opt), expr) = simpl_fun_decl ~loc decl in
|
||||
let inline = List.exists (fun (a: Raw.attribute) -> a.value = "\"inline\"") x.value.attributes.value in
|
||||
ok @@ Location.wrap ~loc (Declaration_constant (name, ty_opt, inline, expr))
|
||||
|
||||
and simpl_statement : Raw.statement -> (_ -> expression result) result =
|
||||
fun s ->
|
||||
match s with
|
||||
| Instr i -> simpl_instruction i
|
||||
| Data d -> simpl_data_declaration d
|
||||
and simpl_statement_list statements =
|
||||
let open Raw in
|
||||
let rec hook acc = function
|
||||
[] -> acc
|
||||
| [Attr _] ->
|
||||
(* Detached attributes are erased. TODO: Warning. *)
|
||||
acc
|
||||
| Attr _ :: (Attr _ :: _ as statements) ->
|
||||
(* Detached attributes are erased. TODO: Warning. *)
|
||||
hook acc statements
|
||||
| Attr decl :: Data (LocalConst {value; region}) :: statements ->
|
||||
let new_const =
|
||||
Data (LocalConst {value = {value with attributes = Some decl}; region})
|
||||
in hook acc (new_const :: statements)
|
||||
| Attr decl :: Data (LocalFun {value; region}) :: statements ->
|
||||
let new_fun =
|
||||
Data (LocalFun {value = {value with attributes = Some decl}; region})
|
||||
in hook acc (new_fun :: statements)
|
||||
| Attr _ :: statements ->
|
||||
(* Detached attributes are erased. TODO: Warning. *)
|
||||
hook acc statements
|
||||
| Instr i :: statements ->
|
||||
hook (simpl_instruction i :: acc) statements
|
||||
| Data d :: statements ->
|
||||
hook (simpl_data_declaration d :: acc) statements
|
||||
in bind_list @@ hook [] (List.rev statements)
|
||||
|
||||
and simpl_single_instruction : Raw.instruction -> (_ -> expression result) result =
|
||||
fun t ->
|
||||
match t with
|
||||
| ProcCall x -> (
|
||||
let ((f, args) , loc) = r_split x in
|
||||
let (args , args_loc) = r_split args in
|
||||
let (f, args) , loc = r_split x in
|
||||
let args, args_loc = r_split args in
|
||||
let args' = npseq_to_list args.inside in
|
||||
match f with
|
||||
| EVar name -> (
|
||||
@ -1058,7 +1064,7 @@ and simpl_cases : type a . (Raw.pattern * a) list -> (a, unit) matching result =
|
||||
let aux (x , y) =
|
||||
let error =
|
||||
let title () = "Pattern" in
|
||||
(** TODO: The labelled arguments should be flowing from the CLI. *)
|
||||
(* TODO: The labelled arguments should be flowing from the CLI. *)
|
||||
let content () =
|
||||
Printf.sprintf "Pattern : %s"
|
||||
(ParserLog.pattern_to_string
|
||||
@ -1072,23 +1078,22 @@ and simpl_cases : type a . (Raw.pattern * a) list -> (a, unit) matching result =
|
||||
ok @@ ez_match_variant constrs
|
||||
|
||||
and simpl_instruction : Raw.instruction -> (_ -> expression result) result =
|
||||
fun t ->
|
||||
trace (simplifying_instruction t) @@ simpl_single_instruction t
|
||||
fun t -> trace (simplifying_instruction t) @@ simpl_single_instruction t
|
||||
|
||||
and simpl_statements : Raw.statements -> (_ -> expression result) result =
|
||||
fun ss ->
|
||||
let lst = npseq_to_list ss in
|
||||
let%bind fs = bind_map_list simpl_statement lst in
|
||||
fun statements ->
|
||||
let lst = npseq_to_list statements in
|
||||
let%bind fs = simpl_statement_list lst in
|
||||
let aux : _ -> (expression option -> expression result) -> _ =
|
||||
fun prec cur ->
|
||||
let%bind res = cur prec in
|
||||
ok @@ Some res in
|
||||
let%bind res = cur prec
|
||||
in ok @@ Some res in
|
||||
ok @@ fun (expr' : _ option) ->
|
||||
let%bind ret = bind_fold_right_list aux expr' fs in
|
||||
ok @@ Option.unopt_exn ret
|
||||
|
||||
and simpl_block : Raw.block -> (_ -> expression result) result = fun t ->
|
||||
simpl_statements t.statements
|
||||
and simpl_block : Raw.block -> (_ -> expression result) result =
|
||||
fun t -> simpl_statements t.statements
|
||||
|
||||
and simpl_for_int : Raw.for_int -> (_ -> expression result) result = fun fi ->
|
||||
(* cond part *)
|
||||
@ -1264,11 +1269,13 @@ and simpl_for_collect : Raw.for_collect -> (_ -> expression result) result = fun
|
||||
(* STEP 5 *)
|
||||
let rec add_return (expr : expression) = match expr.expression with
|
||||
| E_sequence (a,b) -> e_sequence a (add_return b)
|
||||
| _ -> e_sequence expr (e_variable (Var.of_name "#COMPILER#acc")) in (* TODO fresh *)
|
||||
| _ -> (* TODO fresh *)
|
||||
e_sequence expr (e_variable (Var.of_name "#COMPILER#acc")) in
|
||||
let for_body = add_return for_body in
|
||||
(* STEP 6 *)
|
||||
let for_body =
|
||||
let ( arg_access: Types.access_path -> expression ) = e_accessor (e_variable (Var.of_name "arguments")) in (* TODO fresh *)
|
||||
let ( arg_access: Types.access_path -> expression ) =
|
||||
e_accessor (e_variable (Var.of_name "arguments")) in (* TODO fresh *)
|
||||
( match fc.collection with
|
||||
| Map _ ->
|
||||
let acc = arg_access [Access_tuple 0 ] in
|
||||
@ -1291,7 +1298,8 @@ and simpl_for_collect : Raw.for_collect -> (_ -> expression result) result = fun
|
||||
let fold = e_constant op_name [lambda; collect ; init_record] in
|
||||
(* STEP 8 *)
|
||||
let assign_back (prev : expression option) (captured_varname : string) : expression option =
|
||||
let access = e_accessor (e_variable (Var.of_name "#COMPILER#folded_record")) (* TODO fresh *)
|
||||
let access = (* TODO fresh *)
|
||||
e_accessor (e_variable (Var.of_name "#COMPILER#folded_record"))
|
||||
[Access_record captured_varname] in
|
||||
let assign = e_assign captured_varname [] access in
|
||||
match prev with
|
||||
@ -1304,6 +1312,73 @@ and simpl_for_collect : Raw.for_collect -> (_ -> expression result) result = fun
|
||||
| None -> e_skip ()
|
||||
| Some seq -> e_let_in (Var.of_name "#COMPILER#folded_record", None) false fold seq in (* TODO fresh *)
|
||||
return_statement @@ final_sequence
|
||||
(*
|
||||
and simpl_declaration : Raw.declaration -> declaration Location.wrap result =
|
||||
*)
|
||||
|
||||
let simpl_program : Raw.ast -> program result = fun t ->
|
||||
bind_list @@ List.map simpl_declaration @@ nseq_to_list t.decl
|
||||
and simpl_declaration_list declarations :
|
||||
Ast_simplified.declaration Location.wrap list result =
|
||||
let open Raw in
|
||||
let rec hook acc = function
|
||||
[] -> acc
|
||||
| [AttrDecl _] ->
|
||||
(* Detached attributes are erased. TODO: Warning. *)
|
||||
acc
|
||||
| AttrDecl _ :: (AttrDecl _ :: _ as declarations) ->
|
||||
(* Detached attributes are erased. TODO: Warning. *)
|
||||
hook acc declarations
|
||||
| AttrDecl decl :: ConstDecl {value; region} :: declarations ->
|
||||
let new_const =
|
||||
ConstDecl {value = {value with attributes = Some decl}; region}
|
||||
in hook acc (new_const :: declarations)
|
||||
| AttrDecl decl :: FunDecl {value; region} :: declarations ->
|
||||
let new_fun =
|
||||
FunDecl {value = {value with attributes = Some decl}; region}
|
||||
in hook acc (new_fun :: declarations)
|
||||
| AttrDecl _ :: declarations ->
|
||||
(* Detached attributes are erased. TODO: Warning. *)
|
||||
hook acc declarations
|
||||
| TypeDecl decl :: declarations ->
|
||||
let decl, loc = r_split decl in
|
||||
let {name; type_expr} : Raw.type_decl = decl in
|
||||
let%bind type_expression = simpl_type_expression type_expr in
|
||||
let new_decl =
|
||||
Declaration_type (Var.of_name name.value, type_expression) in
|
||||
let res = ok @@ Location.wrap ~loc new_decl
|
||||
in hook (res::acc) declarations
|
||||
| ConstDecl decl :: declarations ->
|
||||
let simpl_const_decl =
|
||||
fun {name;const_type; init; attributes} ->
|
||||
let%bind expression = simpl_expression init in
|
||||
let%bind t = simpl_type_expression const_type in
|
||||
let type_annotation = Some t in
|
||||
let inline =
|
||||
match attributes with
|
||||
None -> false
|
||||
| Some {value; _} ->
|
||||
npseq_to_list value.ne_elements
|
||||
|> List.exists (fun Region.{value; _} -> value = "\"inline\"") in
|
||||
let new_decl =
|
||||
Declaration_constant
|
||||
(Var.of_name name.value, type_annotation, inline, expression)
|
||||
in ok new_decl in
|
||||
let res =
|
||||
bind_map_location simpl_const_decl (Location.lift_region decl)
|
||||
in hook (res::acc) declarations
|
||||
| FunDecl fun_decl :: declarations ->
|
||||
let decl, loc = r_split fun_decl in
|
||||
let%bind ((name, ty_opt), expr) = simpl_fun_decl ~loc decl in
|
||||
let inline =
|
||||
match fun_decl.value.attributes with
|
||||
None -> false
|
||||
| Some {value; _} ->
|
||||
npseq_to_list value.ne_elements
|
||||
|> List.exists (fun Region.{value; _} -> value = "\"inline\"") in
|
||||
let new_decl =
|
||||
Declaration_constant (name, ty_opt, inline, expr) in
|
||||
let res = ok @@ Location.wrap ~loc new_decl
|
||||
in hook (res::acc) declarations
|
||||
in bind_list @@ hook [] (List.rev declarations)
|
||||
|
||||
let simpl_program : Raw.ast -> program result =
|
||||
fun t -> simpl_declaration_list @@ nseq_to_list t.decl
|
||||
|
@ -1,17 +1,19 @@
|
||||
const x: int = 1; attributes ["inline"];
|
||||
const x : int = 1; attributes ["inline"]
|
||||
|
||||
function foo (const a : int) : int is
|
||||
block {
|
||||
const test: int = 2 + a; attributes ["inline"];
|
||||
} with test;
|
||||
begin
|
||||
const test : int = 2 + a;
|
||||
attributes ["inline"];
|
||||
end with test;
|
||||
attributes ["inline"];
|
||||
|
||||
const y: int = 1; attributes ["inline"; "other"];
|
||||
const y : int = 1; attributes ["inline"; "other"]
|
||||
|
||||
function bar (const b : int) : int is
|
||||
block {
|
||||
function test (const z : int) : int is begin
|
||||
begin
|
||||
function test (const z : int) : int is
|
||||
begin
|
||||
const r : int = 2 + b + z
|
||||
end with r;
|
||||
attributes ["inline"; "foo"; "bar"];
|
||||
} with test(b);
|
||||
attributes ["inline"; "foo"; "bar"]
|
||||
end with test(b)
|
||||
|
@ -1,13 +1,10 @@
|
||||
let x = 1 [@@inline]
|
||||
|
||||
let foo (a: int): int = (
|
||||
let test = 2 + a [@@inline] in
|
||||
test
|
||||
) [@@inline]
|
||||
let foo (a: int): int =
|
||||
(let test = 2 + a [@@inline] in test) [@@inline]
|
||||
|
||||
let y = 1 [@@inline][@@other]
|
||||
|
||||
let bar (b: int): int = (
|
||||
let test = fun (z: int) -> 2 + b + z [@@inline][@@foo][@@bar] in
|
||||
test b
|
||||
)
|
||||
let bar (b: int): int =
|
||||
let test = fun (z: int) -> 2 + b + z [@@inline][@@foo][@@bar]
|
||||
in test b
|
||||
|
9
vendors/ligo-utils/simple-utils/pos.ml
vendored
9
vendors/ligo-utils/simple-utils/pos.ml
vendored
@ -56,11 +56,8 @@ let make ~byte ~point_num ~point_bol =
|
||||
method set_offset offset =
|
||||
{< byte = Lexing.{byte with pos_cnum = byte.pos_bol + offset} >}
|
||||
|
||||
method set ?file ~line ~offset =
|
||||
let pos =
|
||||
match file with
|
||||
None -> self
|
||||
| Some name -> self#set_file name in
|
||||
method set ~file ~line ~offset =
|
||||
let pos = self#set_file file in
|
||||
let pos = pos#set_line line in
|
||||
let pos = pos#set_offset offset
|
||||
in pos
|
||||
@ -136,7 +133,7 @@ let from_byte byte =
|
||||
|
||||
let ghost = make ~byte:Lexing.dummy_pos ~point_num:(-1) ~point_bol:(-1)
|
||||
|
||||
let min file =
|
||||
let min ~file =
|
||||
let pos = make ~byte:Lexing.dummy_pos ~point_num:0 ~point_bol:0
|
||||
in pos#set_file file
|
||||
|
||||
|
28
vendors/ligo-utils/simple-utils/pos.mli
vendored
28
vendors/ligo-utils/simple-utils/pos.mli
vendored
@ -58,17 +58,7 @@
|
||||
{li The call [pos#byte_offset] is the offset of the position
|
||||
[pos] since the begininng of the file, counted in bytes.}}
|
||||
*)
|
||||
|
||||
type invalid_pos = [
|
||||
`Invalid_line
|
||||
| `Invalid_offset
|
||||
]
|
||||
|
||||
type invalid_line = `Invalid_line
|
||||
type invalid_offset = `Invalid_offset
|
||||
type invalid_nl = `Invalid_newline
|
||||
|
||||
type t = private <
|
||||
type t = <
|
||||
(* Payload *)
|
||||
|
||||
byte : Lexing.position;
|
||||
@ -80,14 +70,12 @@ type t = private <
|
||||
(* Setters *)
|
||||
|
||||
set_file : string -> t;
|
||||
set_line : int -> (t, invalid_line) Stdlib.result;
|
||||
set_offset : int -> (t, invalid_offset) Stdlib.result;
|
||||
set_line : int -> t;
|
||||
set_offset : int -> t;
|
||||
|
||||
set : ?file:string -> line:int -> offset:int ->
|
||||
(t, invalid_pos) Stdlib.result;
|
||||
set : file:string -> line:int -> offset:int -> t;
|
||||
|
||||
(* String must be "\n" or "\c\r" *)
|
||||
new_line : string -> (t, invalid_newline) Stdlib.result
|
||||
new_line : string -> t; (* String must be "\n" or "\c\r" *)
|
||||
add_nl : t;
|
||||
|
||||
shift_bytes : int -> t;
|
||||
@ -119,11 +107,9 @@ type pos = t
|
||||
(** {1 Constructors} *)
|
||||
|
||||
val make :
|
||||
byte:Lexing.position -> point_num:int -> point_bol:int ->
|
||||
(t, invalid_pos) Stdlin.result
|
||||
byte:Lexing.position -> point_num:int -> point_bol:int -> t
|
||||
|
||||
val from_byte :
|
||||
Lexing.position -> (t, invalid_pos) Stdlib.result
|
||||
val from_byte : Lexing.position -> t
|
||||
|
||||
(** {1 Special positions} *)
|
||||
|
||||
|
2
vendors/ligo-utils/simple-utils/region.ml
vendored
2
vendors/ligo-utils/simple-utils/region.ml
vendored
@ -120,7 +120,7 @@ let ghost = make ~start:Pos.ghost ~stop:Pos.ghost
|
||||
|
||||
let wrap_ghost value = {value ; region = ghost}
|
||||
|
||||
let min = make ~start:Pos.min ~stop:Pos.min
|
||||
let min ~file = make ~start:(Pos.min ~file) ~stop:(Pos.min ~file)
|
||||
|
||||
(* Comparisons *)
|
||||
|
||||
|
4
vendors/ligo-utils/simple-utils/region.mli
vendored
4
vendors/ligo-utils/simple-utils/region.mli
vendored
@ -56,7 +56,7 @@
|
||||
convention as [to_string], except that the resulting string
|
||||
is shorter (usually for debugging or tracing).}}
|
||||
*)
|
||||
type t = private <
|
||||
type t = <
|
||||
start : Pos.t;
|
||||
stop : Pos.t;
|
||||
|
||||
@ -119,7 +119,7 @@ val wrap_ghost : 'a -> 'a reg
|
||||
(** Occasionnally, we may need a minimum region. It is here made of
|
||||
two minimal positions.
|
||||
*)
|
||||
val min : t
|
||||
val min : file:string -> t
|
||||
|
||||
(** {1 Comparisons} *)
|
||||
|
||||
|
263
vendors/ligo-utils/simple-utils/trace.ml
vendored
263
vendors/ligo-utils/simple-utils/trace.ml
vendored
@ -1,4 +1,4 @@
|
||||
(** Trace tutorial
|
||||
(* Trace tutorial
|
||||
|
||||
This module guides the reader through the writing of a simplified
|
||||
version of the trace monad [result], and the definition of a few
|
||||
@ -6,13 +6,13 @@
|
||||
*)
|
||||
|
||||
module Trace_tutorial = struct
|
||||
(** The trace monad is fairly similar to the predefined [option]
|
||||
(* The trace monad is fairly similar to the predefined [option]
|
||||
type. It is an instance of the predefined [result] type. *)
|
||||
|
||||
type annotation = string
|
||||
type error = string
|
||||
|
||||
(** The type ['a result] is used by the trace monad to both model an
|
||||
(* The type ['a result] is used by the trace monad to both model an
|
||||
expected value of type ['a] or the failure to obtain it, instead
|
||||
of working directly with ['a] values and handling separately
|
||||
errors, for example by means of exceptions. (See the type [('a,'b)
|
||||
@ -23,36 +23,36 @@ module Trace_tutorial = struct
|
||||
list of annotations (information about past successful
|
||||
computations), or it is a list of errors accumulated so far.
|
||||
The former case is denoted by the data constructor [Ok], and the
|
||||
second by [Error].
|
||||
*)
|
||||
second by [Error]. *)
|
||||
|
||||
type nonrec 'a result = ('a * annotation list, error list) result
|
||||
(*
|
||||
= Ok of 'a * annotation list
|
||||
| Error of error list
|
||||
*)
|
||||
|
||||
(** The function [divide_trace] shows the basic use of the trace
|
||||
monad.
|
||||
*)
|
||||
(* The function [divide_trace] shows the basic use of the trace
|
||||
monad. *)
|
||||
|
||||
let divide_trace a b =
|
||||
if b = 0
|
||||
then Error [Printf.sprintf "division by zero: %d/%d" a b]
|
||||
else Ok (a/b, [])
|
||||
|
||||
(** The function [divide_three] shows that when composing two
|
||||
(* The function [divide_three] shows that when composing two
|
||||
functions, if the first call fails, the error is passed along
|
||||
and the second call is not evaluated. (A pattern called
|
||||
"error-passing style").
|
||||
*)
|
||||
"error-passing style"). *)
|
||||
|
||||
let divide_three a b c =
|
||||
match divide_trace a b with
|
||||
Ok (a_div_b , _) -> divide_trace a_div_b c
|
||||
| errors -> errors
|
||||
|
||||
(** The function [divide_three_annot] shows that when composing two
|
||||
(* The function [divide_three_annot] shows that when composing two
|
||||
functions, if both calls are successful, the lists of
|
||||
annotations are joined.
|
||||
*)
|
||||
annotations are joined. *)
|
||||
|
||||
let divide_three_annot a b c =
|
||||
match divide_trace a b with
|
||||
Ok (a_div_b, annot1) -> (
|
||||
@ -62,21 +62,19 @@ module Trace_tutorial = struct
|
||||
| errors -> errors)
|
||||
| errors -> errors
|
||||
|
||||
(** The systematic matching of the result of each call in a function
|
||||
(* The systematic matching of the result of each call in a function
|
||||
composition is bulky, so we define a [bind] function which takes
|
||||
a function [f: 'a -> 'b result] and applies it to a current ['a
|
||||
result] (not ['a]).
|
||||
{ul
|
||||
{li If the current result is an error, then [bind]
|
||||
returns that same error without calling [f];}
|
||||
|
||||
{li otherwise [bind] unwraps the [Ok] of the current result
|
||||
* If the current result is an error, then [bind]
|
||||
returns that same error without calling [f];
|
||||
|
||||
* otherwise [bind] unwraps the [Ok] of the current result
|
||||
and calls [f] on it:
|
||||
{ul
|
||||
{li That call itself may return an error;}
|
||||
{li if not, [bind] combines the annotations and returns the last
|
||||
result.}}}}
|
||||
*)
|
||||
* That call itself may return an error;}
|
||||
* if not, [bind] combines the annotations and returns the
|
||||
last result. *)
|
||||
let bind (f: 'a -> 'b result) : 'a result -> 'b result =
|
||||
function
|
||||
Ok (x, annot) -> (
|
||||
@ -85,36 +83,36 @@ module Trace_tutorial = struct
|
||||
| errors -> ignore annot; errors)
|
||||
| Error _ as e -> e
|
||||
|
||||
(** The function [divide_three_bind] is equivalent to the verbose
|
||||
[divide_three] above, but makes use of [bind].
|
||||
*)
|
||||
(* The function [divide_three_bind] is equivalent to the verbose
|
||||
[divide_three] above, but makes use of [bind]. *)
|
||||
|
||||
let divide_three_bind a b c =
|
||||
let maybe_a_div_b = divide_trace a b in
|
||||
let continuation a_div_b = divide_trace a_div_b c
|
||||
in bind continuation maybe_a_div_b
|
||||
|
||||
(** The operator [(>>?)] is a redefinition of [bind] that makes the
|
||||
(* The operator [(>>?)] is a redefinition of [bind] that makes the
|
||||
program shorter, at the cost of a slightly
|
||||
awkward reading because the two parameters are swapped.
|
||||
*)
|
||||
awkward reading because the two parameters are swapped. *)
|
||||
|
||||
let (>>?) x f = bind f x
|
||||
|
||||
(** The function [divide_three_bind_symbol] is equivalent to
|
||||
[divide_three_bind], but makes use of the operator [(>>?)].
|
||||
*)
|
||||
(* The function [divide_three_bind_symbol] is equivalent to
|
||||
[divide_three_bind], but makes use of the operator [(>>?)]. *)
|
||||
|
||||
let divide_three_bind_symbol a b c =
|
||||
let maybe_a_div_b = divide_trace a b in
|
||||
let continuation a_div_b = divide_trace a_div_b c in
|
||||
maybe_a_div_b >>? continuation
|
||||
|
||||
(** The function [divide_three_bind_symbol'] is equivalent to
|
||||
(* The function [divide_three_bind_symbol'] is equivalent to
|
||||
[divide_three_bind_symbol], where the two temporary [let]
|
||||
definitions are inlined for a more compact reading.
|
||||
*)
|
||||
definitions are inlined for a more compact reading. *)
|
||||
|
||||
let divide_three_bind_symbol' a b c =
|
||||
divide_trace a b >>? (fun a_div_b -> divide_trace a_div_b c)
|
||||
|
||||
(** This is now fairly legible, but chaining many such functions is
|
||||
(* This is now fairly legible, but chaining many such functions is
|
||||
not the usual way of writing code. We use the PPX extension to
|
||||
the OCaml compiler [ppx_let] to add some syntactic sugar.
|
||||
The extension framework PPX is enabled by adding the following
|
||||
@ -123,26 +121,26 @@ module Trace_tutorial = struct
|
||||
[(preprocess
|
||||
(pps simple-utils.ppx_let_generalized))]
|
||||
The extension [ppx_let] requires the module [Let_syntax] to be
|
||||
defined.
|
||||
*)
|
||||
defined. *)
|
||||
|
||||
module Let_syntax = struct
|
||||
let bind m ~f = m >>? f
|
||||
module Open_on_rhs_bind = struct end
|
||||
end
|
||||
|
||||
(** The function [divide_three_bind_ppx_let] is equivalent to the
|
||||
(* The function [divide_three_bind_ppx_let] is equivalent to the
|
||||
function [divide_three_bind_symbol']. The only difference is
|
||||
that the module [Open_on_rhs_bind] is implicitly opened around
|
||||
the expression on the righ-hand side of the [=] sign, namely
|
||||
[divide_trace a b].
|
||||
*)
|
||||
[divide_trace a b]. *)
|
||||
|
||||
let divide_three_bind_ppx_let a b c =
|
||||
let%bind a_div_b = divide_trace a b
|
||||
in divide_trace a_div_b c
|
||||
|
||||
(** The function [divide_many_bind_ppx_let] shows how well this
|
||||
notation composes.
|
||||
*)
|
||||
notation composes. *)
|
||||
|
||||
let divide_many_bind_ppx_let a b c d e f =
|
||||
let x = a in
|
||||
let%bind x = divide_trace x b in
|
||||
@ -153,34 +151,35 @@ module Trace_tutorial = struct
|
||||
in Ok (x, [])
|
||||
|
||||
(** The function [ok] is a shorthand for an [Ok] without
|
||||
annotations.
|
||||
*)
|
||||
annotations. *)
|
||||
|
||||
let ok x = Ok (x, [])
|
||||
|
||||
(** The function [map] lifts a regular ['a -> 'b] function on values to
|
||||
a function on results, of type ['a result -> 'b result].
|
||||
*)
|
||||
(* The function [map] lifts a regular ['a -> 'b] function on values to
|
||||
a function on results, of type ['a result -> 'b result]. *)
|
||||
|
||||
let map f = function
|
||||
Ok (x, annotations) -> Ok (f x, annotations)
|
||||
| e -> e
|
||||
|
||||
(** The function [bind_list] turns a list of results of type [('a
|
||||
(* The function [bind_list] turns a list of results of type [('a
|
||||
result) list] into a result of list, of type [('a list) result],
|
||||
as follows.
|
||||
{ul
|
||||
{li If the list only contains [Ok] values, it strips the [Ok]
|
||||
* If the list only contains [Ok] values, it strips the [Ok]
|
||||
of each element and returns that list wrapped with [Ok].}
|
||||
{li Otherwise, one or more of the elements of the input list
|
||||
|
||||
* Otherwise, one or more of the elements of the input list
|
||||
is [Error], then [bind_list] returns the first error in the
|
||||
list.}}
|
||||
list.
|
||||
*)
|
||||
|
||||
let rec bind_list = function
|
||||
[] -> ok []
|
||||
| hd::tl ->
|
||||
hd >>? fun hd ->
|
||||
bind_list tl >>? fun tl ->
|
||||
ok @@ hd::tl
|
||||
(** A major feature of [Trace] is that it enables having a stack of
|
||||
(* A major feature of [Trace] is that it enables having a stack of
|
||||
errors (that should act as a simplified stack frame), rather
|
||||
than a unique error. It is done by using the function
|
||||
[trace]. For instance, let's say that you have a function that
|
||||
@ -198,17 +197,17 @@ module Trace_tutorial = struct
|
||||
trace (simple_error "error getting key") @@
|
||||
get key map
|
||||
in ...]
|
||||
And this will pass along the error triggered by [get key map].
|
||||
*)
|
||||
And this will pass along the error triggered by [get key map]. *)
|
||||
|
||||
let trace err = function
|
||||
Error e -> Error (err::e)
|
||||
| ok -> ok
|
||||
|
||||
(** The real trace monad is very similar to the one that we have
|
||||
(* The real trace monad is very similar to the one that we have
|
||||
defined above. The main difference is that the errors and
|
||||
annotations are structured data (instead of plain strings) and
|
||||
are generated lazily.
|
||||
*)
|
||||
are generated lazily. *)
|
||||
|
||||
let the_end = "End of the tutorial."
|
||||
|
||||
end (* end Trace_tutorial. *)
|
||||
@ -239,8 +238,7 @@ module JSON_string_utils = struct
|
||||
match assoc j with
|
||||
None -> j
|
||||
| Some assoc -> `Assoc (
|
||||
List.map (fun (k', v') -> (k', if k = k' then v else v')) assoc
|
||||
)
|
||||
List.map (fun (k', v') -> (k', if k = k' then v else v')) assoc)
|
||||
|
||||
let swap f l r = f r l
|
||||
|
||||
@ -264,38 +262,39 @@ module JSON_string_utils = struct
|
||||
let (||) l r = l |> default r
|
||||
|
||||
let (|^) = bind2 (^)
|
||||
|
||||
end
|
||||
|
||||
type 'a thunk = unit -> 'a
|
||||
|
||||
(** Errors are encoded in JSON. This is because different libraries
|
||||
(* Errors are encoded in JSON. This is because different libraries
|
||||
will implement their own helpers, and we do not want to hardcode
|
||||
in their type how they are supposed to interact.
|
||||
*)
|
||||
in their type how they are supposed to interact. *)
|
||||
|
||||
type error = J.t
|
||||
|
||||
(** Thunks are used because computing some errors can be costly, and
|
||||
(* Thunks are used because computing some errors can be costly, and
|
||||
we do not want to spend most of our time building errors. Instead,
|
||||
their computation is deferred.
|
||||
*)
|
||||
their computation is deferred.*)
|
||||
|
||||
type error_thunk = error thunk
|
||||
|
||||
(** Annotations should be used in debug mode to aggregate information
|
||||
(* Annotations should be used in debug mode to aggregate information
|
||||
about some value history. Where it was produced, when it was
|
||||
modified, etc. It is currently not being used. *)
|
||||
|
||||
type annotation = J.t
|
||||
|
||||
(** Even in debug mode, building annotations can be quite
|
||||
(* Even in debug mode, building annotations can be quite
|
||||
resource-intensive. Instead, a thunk is passed, that is computed
|
||||
only when debug information is queried (typically before a print).
|
||||
*)
|
||||
only when debug information is queried (typically before a print).*)
|
||||
|
||||
type annotation_thunk = annotation thunk
|
||||
|
||||
(** Types of traced elements. It might be good to rename it [trace] at
|
||||
some point.
|
||||
*)
|
||||
(* Types of traced elements. It might be good to rename it [trace] at
|
||||
some point. *)
|
||||
|
||||
type nonrec 'a result = ('a * annotation_thunk list, error_thunk) result
|
||||
|
||||
(*
|
||||
= Ok of 'a * annotation_thunk list
|
||||
| Error of error_thunk
|
||||
@ -308,29 +307,28 @@ let ok x = Ok (x, [])
|
||||
|
||||
let fail err = Error err
|
||||
|
||||
(** {1 Monadic operators} *)
|
||||
(* Monadic operators *)
|
||||
|
||||
let bind f = function
|
||||
Ok (x, ann) -> (
|
||||
Error _ as e -> e
|
||||
| Ok (x, ann) ->
|
||||
match f x with
|
||||
Ok (x', ann') -> Ok (x', ann' @ ann)
|
||||
| Error _ as e' -> ignore ann; e')
|
||||
| Error _ as e -> e
|
||||
| Error _ as e' -> ignore ann; e'
|
||||
|
||||
let map f = function
|
||||
Ok (x, annotations) -> Ok (f x, annotations)
|
||||
| Error _ as e -> e
|
||||
|
||||
(** The lexical convention usually adopted for the bind function is
|
||||
(* The lexical convention usually adopted for the bind function is
|
||||
[>>=], but ours comes from the Tezos code base, where the [result]
|
||||
bind is [>>?], and [Lwt]'s (threading library) is [>>=], and the
|
||||
combination of both is [>>=?].
|
||||
*)
|
||||
combination of both is [>>=?]. *)
|
||||
|
||||
let (>>?) x f = bind f x
|
||||
let (>>|?) x f = map f x
|
||||
|
||||
(**
|
||||
Used by PPX_let, an OCaml preprocessor.
|
||||
(* Used by PPX_let, an OCaml preprocessor.
|
||||
What it does is that, when you only care about the case where a result isn't
|
||||
an error, instead of writing:
|
||||
[
|
||||
@ -344,21 +342,20 @@ let (>>|?) x f = map f x
|
||||
]
|
||||
This is much more typical of OCaml. This makes the code more
|
||||
readable, easy to write and refactor. It is used pervasively in
|
||||
LIGO.
|
||||
*)
|
||||
LIGO. *)
|
||||
|
||||
module Let_syntax = struct
|
||||
let bind m ~f = m >>? f
|
||||
module Open_on_rhs_bind = struct end
|
||||
end
|
||||
|
||||
(* Build a thunk from a constant. *)
|
||||
|
||||
(** Build a thunk from a constant.
|
||||
*)
|
||||
let thunk x () = x
|
||||
|
||||
(** Build a standard error, with a title, a message, an error code and
|
||||
some data.
|
||||
*)
|
||||
(* Build a standard error, with a title, a message, an error code and
|
||||
some data. *)
|
||||
|
||||
let mk_error
|
||||
?(error_code : int thunk option) ?(message : string thunk option)
|
||||
?(data : (string * string thunk) list option)
|
||||
@ -373,9 +370,11 @@ let mk_error
|
||||
let type' = Some ("type" , `String "error") in
|
||||
let children' = Some ("children" , `List children) in
|
||||
let infos' = Some ("infos" , `List infos) in
|
||||
`Assoc (X_option.collapse_list [ error_code' ; title' ; message' ; data' ; type' ; children' ; infos' ])
|
||||
`Assoc (X_option.collapse_list
|
||||
[error_code'; title'; message'; data'; type'; children'; infos'])
|
||||
|
||||
let error ?data ?error_code ?children ?infos title message () = mk_error ?data ?error_code ?children ?infos ~title:(title) ~message:(message) ()
|
||||
let error ?data ?error_code ?children ?infos title message () =
|
||||
mk_error ?data ?error_code ?children ?infos ~title ~message ()
|
||||
|
||||
let prepend_child = fun child err ->
|
||||
let open JSON_string_utils in
|
||||
@ -389,9 +388,8 @@ let patch_children = fun children err ->
|
||||
let open JSON_string_utils in
|
||||
patch err "children" (`List (List.map (fun f -> f ()) children))
|
||||
|
||||
(**
|
||||
Build a standard info, with a title, a message, an info code and some data.
|
||||
*)
|
||||
(* Build a standard info, with a title, a message, an info code and some data. *)
|
||||
|
||||
let mk_info
|
||||
?(info_code : int thunk option) ?(message : string thunk option)
|
||||
?(data : (string * string thunk) list option)
|
||||
@ -405,7 +403,8 @@ let mk_info
|
||||
let type' = Some ("type" , `String "info") in
|
||||
`Assoc (X_option.collapse_list [ error_code' ; title' ; message' ; data' ; type' ])
|
||||
|
||||
let info ?data ?info_code title message () = mk_info ?data ?info_code ~title:(title) ~message:(message) ()
|
||||
let info ?data ?info_code title message () =
|
||||
mk_info ?data ?info_code ~title ~message ()
|
||||
|
||||
let prepend_info = fun info err ->
|
||||
let open JSON_string_utils in
|
||||
@ -416,32 +415,31 @@ let prepend_info = fun info err ->
|
||||
patch err "infos" (`List infos)
|
||||
|
||||
|
||||
(** Helpers that ideally should not be used in production.
|
||||
*)
|
||||
(* Helpers that ideally should not be used in production. *)
|
||||
|
||||
let simple_error str () = mk_error ~title:(thunk str) ()
|
||||
let simple_info str () = mk_info ~title:(thunk str) ()
|
||||
let simple_fail str = fail @@ simple_error str
|
||||
let internal_assertion_failure str = simple_error ("assertion failed: " ^ str)
|
||||
|
||||
(** To be used when you only want to signal an error. It can be useful
|
||||
when followed by [trace_strong].
|
||||
*)
|
||||
(* To be used when you only want to signal an error. It can be useful
|
||||
when followed by [trace_strong]. *)
|
||||
|
||||
let dummy_fail = simple_fail "dummy"
|
||||
|
||||
let trace info = function
|
||||
Ok _ as o -> o
|
||||
| Error err -> Error (fun () -> prepend_info (info ()) (err ()))
|
||||
|
||||
(** Erase the current error stack, and replace it by the given
|
||||
(* Erase the current error stack, and replace it by the given
|
||||
error. It's useful when using [Assert] and you want to discard its
|
||||
autogenerated message.
|
||||
*)
|
||||
autogenerated message. *)
|
||||
|
||||
let trace_strong err = function
|
||||
Ok _ as o -> o
|
||||
| Error _ -> Error err
|
||||
|
||||
(**
|
||||
Sometimes, when you have a list of potentially erroneous elements, you need
|
||||
(* Sometimes, when you have a list of potentially erroneous elements, you need
|
||||
to retrieve all the errors, instead of just the first one. In that case, do:
|
||||
[let type_list lst =
|
||||
let%bind lst' =
|
||||
@ -451,8 +449,7 @@ let trace_strong err = function
|
||||
Where before you would have written:
|
||||
[let type_list lst =
|
||||
let%bind lst' = bind_map_list type_element lst in
|
||||
...]
|
||||
*)
|
||||
...] *)
|
||||
let trace_list err lst =
|
||||
let oks =
|
||||
let aux = function
|
||||
@ -468,30 +465,24 @@ let trace_list err lst =
|
||||
| [] -> ok oks
|
||||
| errs -> fail (fun () -> patch_children errs err)
|
||||
|
||||
(**
|
||||
Trace, but with an error which generation may itself fail.
|
||||
*)
|
||||
(* Trace, but with an error which generation may itself fail. *)
|
||||
|
||||
let trace_r err_thunk_may_fail = function
|
||||
| Ok _ as o -> o
|
||||
| Error _ -> (
|
||||
Ok _ as o -> o
|
||||
| Error _ ->
|
||||
match err_thunk_may_fail () with
|
||||
| Ok (err, annotations) -> ignore annotations; Error (err)
|
||||
Ok (err, annotations) -> ignore annotations; Error (err)
|
||||
| Error errors_while_generating_error ->
|
||||
(* TODO: the complexity could be O(n*n) in the worst case,
|
||||
this should use some catenable lists. *)
|
||||
Error (errors_while_generating_error)
|
||||
)
|
||||
|
||||
(**
|
||||
`trace_f f error` yields a function that acts the same as `f`, but with an
|
||||
error frame that has one more error.
|
||||
*)
|
||||
let trace_f f error x =
|
||||
trace error @@ f x
|
||||
(* [trace_f f error] yields a function that acts the same as `f`, but with an
|
||||
error frame that has one more error. *)
|
||||
|
||||
let trace_f f error x = trace error @@ f x
|
||||
(* Same, but for functions with 2 parameters. *)
|
||||
|
||||
(**
|
||||
Same, but for functions with 2 parameters.
|
||||
*)
|
||||
let trace_f_2 f error x y =
|
||||
trace error @@ f x y
|
||||
|
||||
@ -520,7 +511,7 @@ let to_option = function
|
||||
Convert an option to a result, with a given error if the parameter is None.
|
||||
*)
|
||||
let trace_option error = function
|
||||
| None -> fail error
|
||||
None -> fail error
|
||||
| Some s -> ok s
|
||||
|
||||
(** Utilities to interact with other data-structure. [bind_t] takes
|
||||
@ -535,22 +526,14 @@ let trace_option error = function
|
||||
*)
|
||||
|
||||
let bind_map_option f = function
|
||||
| None -> ok None
|
||||
None -> ok None
|
||||
| Some s -> f s >>? fun x -> ok (Some x)
|
||||
|
||||
let rec bind_list = function
|
||||
| [] -> ok []
|
||||
| hd :: tl -> (
|
||||
hd >>? fun hd ->
|
||||
bind_list tl >>? fun tl ->
|
||||
ok @@ hd :: tl
|
||||
)
|
||||
|
||||
let bind_ne_list = fun (hd , tl) ->
|
||||
hd >>? fun hd ->
|
||||
bind_list tl >>? fun tl ->
|
||||
ok @@ (hd , tl)
|
||||
|
||||
[] -> ok []
|
||||
| hd::tl -> hd >>? fun hd -> bind_list tl >>? fun tl -> ok @@ hd :: tl
|
||||
let bind_ne_list (hd, tl) =
|
||||
hd >>? fun hd -> bind_list tl >>? fun tl -> ok @@ (hd, tl)
|
||||
let bind_smap (s:_ X_map.String.t) =
|
||||
let open X_map.String in
|
||||
let aux k v prev =
|
||||
|
Loading…
Reference in New Issue
Block a user