move the work from lexer to parser: this makes the rules symetrics but impose the language to have the same syntax as constructor. This may change in the future
This commit is contained in:
parent
f25456a7a6
commit
0b8effbf2b
@ -401,6 +401,8 @@ and cond_expr = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
and code_insert = {
|
and code_insert = {
|
||||||
|
lbracket : lbracket;
|
||||||
|
percent : percent;
|
||||||
language : string reg;
|
language : string reg;
|
||||||
code : expr;
|
code : expr;
|
||||||
rbracket : rbracket;
|
rbracket : rbracket;
|
||||||
|
@ -42,6 +42,7 @@ type t =
|
|||||||
| PLUS of Region.t (* "+" *)
|
| PLUS of Region.t (* "+" *)
|
||||||
| SLASH of Region.t (* "/" *)
|
| SLASH of Region.t (* "/" *)
|
||||||
| TIMES of Region.t (* "*" *)
|
| TIMES of Region.t (* "*" *)
|
||||||
|
| PERCENT of Region.t (* "%" *)
|
||||||
|
|
||||||
(* Compounds *)
|
(* Compounds *)
|
||||||
|
|
||||||
@ -87,7 +88,6 @@ type t =
|
|||||||
| Verbatim of string Region.reg
|
| Verbatim of string Region.reg
|
||||||
| Bytes of (string * Hex.t) Region.reg
|
| Bytes of (string * Hex.t) Region.reg
|
||||||
| Attr of string Region.reg
|
| Attr of string Region.reg
|
||||||
| Insert of string Region.reg
|
|
||||||
|
|
||||||
(* Keywords *)
|
(* Keywords *)
|
||||||
|
|
||||||
@ -155,7 +155,6 @@ val mk_verbatim : lexeme -> Region.t -> token
|
|||||||
val mk_bytes : lexeme -> Region.t -> token
|
val mk_bytes : lexeme -> Region.t -> token
|
||||||
val mk_constr : lexeme -> Region.t -> token
|
val mk_constr : lexeme -> Region.t -> token
|
||||||
val mk_attr : string -> lexeme -> Region.t -> (token, attr_err) result
|
val mk_attr : string -> lexeme -> Region.t -> (token, attr_err) result
|
||||||
val mk_insert : lexeme -> Region.t -> token
|
|
||||||
val eof : Region.t -> token
|
val eof : Region.t -> token
|
||||||
|
|
||||||
(* Predicates *)
|
(* Predicates *)
|
||||||
|
@ -26,6 +26,7 @@ type t =
|
|||||||
| PLUS of Region.t (* "+" *)
|
| PLUS of Region.t (* "+" *)
|
||||||
| SLASH of Region.t (* "/" *)
|
| SLASH of Region.t (* "/" *)
|
||||||
| TIMES of Region.t (* "*" *)
|
| TIMES of Region.t (* "*" *)
|
||||||
|
| PERCENT of Region.t (* "%" *)
|
||||||
|
|
||||||
(* Compounds *)
|
(* Compounds *)
|
||||||
|
|
||||||
@ -71,7 +72,6 @@ type t =
|
|||||||
| Verbatim of string Region.reg
|
| Verbatim of string Region.reg
|
||||||
| Bytes of (string * Hex.t) Region.reg
|
| Bytes of (string * Hex.t) Region.reg
|
||||||
| Attr of string Region.reg
|
| Attr of string Region.reg
|
||||||
| Insert of string Region.reg
|
|
||||||
|
|
||||||
(* Keywords *)
|
(* Keywords *)
|
||||||
|
|
||||||
@ -131,8 +131,6 @@ let proj_token = function
|
|||||||
region, sprintf "Constr %s" value
|
region, sprintf "Constr %s" value
|
||||||
| Attr Region.{region; value} ->
|
| Attr Region.{region; value} ->
|
||||||
region, sprintf "Attr \"%s\"" value
|
region, sprintf "Attr \"%s\"" value
|
||||||
| Insert Region.{region; value} ->
|
|
||||||
region, sprintf "Insert \"%s\"" value
|
|
||||||
|
|
||||||
(* Symbols *)
|
(* Symbols *)
|
||||||
|
|
||||||
@ -143,6 +141,7 @@ let proj_token = function
|
|||||||
| PLUS region -> region, "PLUS"
|
| PLUS region -> region, "PLUS"
|
||||||
| SLASH region -> region, "SLASH"
|
| SLASH region -> region, "SLASH"
|
||||||
| TIMES region -> region, "TIMES"
|
| TIMES region -> region, "TIMES"
|
||||||
|
| PERCENT region -> region, "PERCENT"
|
||||||
| LPAR region -> region, "LPAR"
|
| LPAR region -> region, "LPAR"
|
||||||
| RPAR region -> region, "RPAR"
|
| RPAR region -> region, "RPAR"
|
||||||
| LBRACKET region -> region, "LBRACKET"
|
| LBRACKET region -> region, "LBRACKET"
|
||||||
@ -207,7 +206,6 @@ let to_lexeme = function
|
|||||||
| Ident id -> id.Region.value
|
| Ident id -> id.Region.value
|
||||||
| Constr id -> id.Region.value
|
| Constr id -> id.Region.value
|
||||||
| Attr a -> a.Region.value
|
| Attr a -> a.Region.value
|
||||||
| Insert i -> i.Region.value
|
|
||||||
|
|
||||||
(* Symbols *)
|
(* Symbols *)
|
||||||
|
|
||||||
@ -218,6 +216,7 @@ let to_lexeme = function
|
|||||||
| PLUS _ -> "+"
|
| PLUS _ -> "+"
|
||||||
| SLASH _ -> "/"
|
| SLASH _ -> "/"
|
||||||
| TIMES _ -> "*"
|
| TIMES _ -> "*"
|
||||||
|
| PERCENT _ -> "%"
|
||||||
| LPAR _ -> "("
|
| LPAR _ -> "("
|
||||||
| RPAR _ -> ")"
|
| RPAR _ -> ")"
|
||||||
| LBRACKET _ -> "["
|
| LBRACKET _ -> "["
|
||||||
@ -479,6 +478,7 @@ let mk_sym lexeme region =
|
|||||||
| "-" -> Ok (MINUS region)
|
| "-" -> Ok (MINUS region)
|
||||||
| "*" -> Ok (TIMES region)
|
| "*" -> Ok (TIMES region)
|
||||||
| "/" -> Ok (SLASH region)
|
| "/" -> Ok (SLASH region)
|
||||||
|
| "%" -> Ok (PERCENT region)
|
||||||
| "<" -> Ok (LT region)
|
| "<" -> Ok (LT region)
|
||||||
| "<=" -> Ok (LE region)
|
| "<=" -> Ok (LE region)
|
||||||
| ">" -> Ok (GT region)
|
| ">" -> Ok (GT region)
|
||||||
@ -512,9 +512,6 @@ let mk_attr header lexeme region =
|
|||||||
if header = "[@" then Error Invalid_attribute
|
if header = "[@" then Error Invalid_attribute
|
||||||
else Ok (Attr Region.{value=lexeme; region})
|
else Ok (Attr Region.{value=lexeme; region})
|
||||||
|
|
||||||
let mk_insert lexeme region =
|
|
||||||
Insert Region.{value=lexeme;region}
|
|
||||||
|
|
||||||
(* Predicates *)
|
(* Predicates *)
|
||||||
|
|
||||||
let is_string = function String _ -> true | _ -> false
|
let is_string = function String _ -> true | _ -> false
|
||||||
|
@ -14,14 +14,14 @@
|
|||||||
%token <string Region.reg> Ident "<ident>"
|
%token <string Region.reg> Ident "<ident>"
|
||||||
%token <string Region.reg> Constr "<constr>"
|
%token <string Region.reg> Constr "<constr>"
|
||||||
%token <string Region.reg> Attr "<attr>"
|
%token <string Region.reg> Attr "<attr>"
|
||||||
%token <string Region.reg> Insert "<insert>"
|
|
||||||
|
|
||||||
(* Symbols *)
|
(* Symbols *)
|
||||||
|
|
||||||
%token <Region.t> MINUS "-"
|
%token <Region.t> MINUS "-"
|
||||||
%token <Region.t> PLUS "+"
|
%token <Region.t> PLUS "+"
|
||||||
%token <Region.t> SLASH "/"
|
%token <Region.t> SLASH "/"
|
||||||
%token <Region.t> TIMES "*"
|
%token <Region.t> TIMES "*"
|
||||||
|
%token <Region.t> PERCENT "%"
|
||||||
|
|
||||||
%token <Region.t> LPAR "("
|
%token <Region.t> LPAR "("
|
||||||
%token <Region.t> RPAR ")"
|
%token <Region.t> RPAR ")"
|
||||||
|
@ -709,10 +709,12 @@ seq_expr:
|
|||||||
disj_expr_level | if_then_else (seq_expr) { $1 }
|
disj_expr_level | if_then_else (seq_expr) { $1 }
|
||||||
|
|
||||||
code_insert:
|
code_insert:
|
||||||
Insert expr "]" {
|
"[" "%" Constr expr "]" {
|
||||||
let region = cover $1.region $3 in
|
let region = cover $1 $5 in
|
||||||
let value = {
|
let value = {
|
||||||
language =$1;
|
lbracket =$1;
|
||||||
code =$2;
|
percent =$2;
|
||||||
rbracket =$3}
|
language =$3;
|
||||||
|
code =$4;
|
||||||
|
rbracket =$5}
|
||||||
in {region; value} }
|
in {region; value} }
|
||||||
|
@ -520,7 +520,9 @@ and print_record_expr state e =
|
|||||||
print_ne_injection state print_field_assign e
|
print_ne_injection state print_field_assign e
|
||||||
|
|
||||||
and print_code_insert state {value; _} =
|
and print_code_insert state {value; _} =
|
||||||
let {language;code;rbracket} : code_insert = value in
|
let {lbracket;percent;language;code;rbracket} : code_insert = value in
|
||||||
|
print_token state lbracket "[";
|
||||||
|
print_token state percent "%";
|
||||||
print_string state language;
|
print_string state language;
|
||||||
print_expr state code;
|
print_expr state code;
|
||||||
print_token state rbracket "]"
|
print_token state rbracket "]"
|
||||||
|
@ -438,6 +438,8 @@ and for_collect = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
and code_insert = {
|
and code_insert = {
|
||||||
|
lbracket : lbracket;
|
||||||
|
percent : percent;
|
||||||
language : string reg;
|
language : string reg;
|
||||||
code : expr;
|
code : expr;
|
||||||
rbracket : rbracket;
|
rbracket : rbracket;
|
||||||
|
@ -44,7 +44,6 @@ type t =
|
|||||||
| Mutez of (lexeme * Z.t) Region.reg
|
| Mutez of (lexeme * Z.t) Region.reg
|
||||||
| Ident of lexeme Region.reg
|
| Ident of lexeme Region.reg
|
||||||
| Constr of lexeme Region.reg
|
| Constr of lexeme Region.reg
|
||||||
| Insert of lexeme Region.reg
|
|
||||||
|
|
||||||
(* Symbols *)
|
(* Symbols *)
|
||||||
|
|
||||||
@ -74,6 +73,7 @@ type t =
|
|||||||
| DOT of Region.t (* "." *)
|
| DOT of Region.t (* "." *)
|
||||||
| WILD of Region.t (* "_" *)
|
| WILD of Region.t (* "_" *)
|
||||||
| CAT of Region.t (* "^" *)
|
| CAT of Region.t (* "^" *)
|
||||||
|
| PERCENT of Region.t (* "%" *)
|
||||||
|
|
||||||
(* Keywords *)
|
(* Keywords *)
|
||||||
|
|
||||||
@ -162,7 +162,6 @@ val mk_verbatim : lexeme -> Region.t -> token
|
|||||||
val mk_bytes : lexeme -> Region.t -> token
|
val mk_bytes : lexeme -> Region.t -> token
|
||||||
val mk_constr : lexeme -> Region.t -> token
|
val mk_constr : lexeme -> Region.t -> token
|
||||||
val mk_attr : string -> lexeme -> Region.t -> (token, attr_err) result
|
val mk_attr : string -> lexeme -> Region.t -> (token, attr_err) result
|
||||||
val mk_insert : lexeme -> Region.t -> token
|
|
||||||
val eof : Region.t -> token
|
val eof : Region.t -> token
|
||||||
|
|
||||||
(* Predicates *)
|
(* Predicates *)
|
||||||
|
@ -32,7 +32,6 @@ type t =
|
|||||||
| Mutez of (lexeme * Z.t) Region.reg
|
| Mutez of (lexeme * Z.t) Region.reg
|
||||||
| Ident of lexeme Region.reg
|
| Ident of lexeme Region.reg
|
||||||
| Constr of lexeme Region.reg
|
| Constr of lexeme Region.reg
|
||||||
| Insert of lexeme Region.reg
|
|
||||||
|
|
||||||
(* Symbols *)
|
(* Symbols *)
|
||||||
|
|
||||||
@ -62,6 +61,7 @@ type t =
|
|||||||
| DOT of Region.t
|
| DOT of Region.t
|
||||||
| WILD of Region.t
|
| WILD of Region.t
|
||||||
| CAT of Region.t
|
| CAT of Region.t
|
||||||
|
| PERCENT of Region.t (* "%" *)
|
||||||
|
|
||||||
(* Keywords *)
|
(* Keywords *)
|
||||||
|
|
||||||
@ -142,9 +142,6 @@ let proj_token = function
|
|||||||
| Constr Region.{region; value} ->
|
| Constr Region.{region; value} ->
|
||||||
region, sprintf "Constr \"%s\"" value
|
region, sprintf "Constr \"%s\"" value
|
||||||
|
|
||||||
| Insert Region.{region; value} ->
|
|
||||||
region, sprintf "Insert \"%s\"" value
|
|
||||||
|
|
||||||
(*
|
(*
|
||||||
| Attr {header; string={region; value}} ->
|
| Attr {header; string={region; value}} ->
|
||||||
region, sprintf "Attr (\"%s\",\"%s\")" header value
|
region, sprintf "Attr (\"%s\",\"%s\")" header value
|
||||||
@ -178,6 +175,7 @@ let proj_token = function
|
|||||||
| DOT region -> region, "DOT"
|
| DOT region -> region, "DOT"
|
||||||
| WILD region -> region, "WILD"
|
| WILD region -> region, "WILD"
|
||||||
| CAT region -> region, "CAT"
|
| CAT region -> region, "CAT"
|
||||||
|
| PERCENT region -> region, "PERCENT"
|
||||||
|
|
||||||
(* Keywords *)
|
(* Keywords *)
|
||||||
|
|
||||||
@ -242,7 +240,6 @@ let to_lexeme = function
|
|||||||
| Mutez i -> fst i.Region.value
|
| Mutez i -> fst i.Region.value
|
||||||
| Ident id
|
| Ident id
|
||||||
| Constr id -> id.Region.value
|
| Constr id -> id.Region.value
|
||||||
| Insert i -> i.Region.value
|
|
||||||
|
|
||||||
(* Symbols *)
|
(* Symbols *)
|
||||||
|
|
||||||
@ -272,6 +269,7 @@ let to_lexeme = function
|
|||||||
| DOT _ -> "."
|
| DOT _ -> "."
|
||||||
| WILD _ -> "_"
|
| WILD _ -> "_"
|
||||||
| CAT _ -> "^"
|
| CAT _ -> "^"
|
||||||
|
| PERCENT _ -> "%"
|
||||||
|
|
||||||
(* Keywords *)
|
(* Keywords *)
|
||||||
|
|
||||||
@ -523,6 +521,7 @@ let mk_sym lexeme region =
|
|||||||
| "-" -> Ok (MINUS region)
|
| "-" -> Ok (MINUS region)
|
||||||
| "*" -> Ok (TIMES region)
|
| "*" -> Ok (TIMES region)
|
||||||
| "/" -> Ok (SLASH region)
|
| "/" -> Ok (SLASH region)
|
||||||
|
| "%" -> Ok (PERCENT region)
|
||||||
| "<" -> Ok (LT region)
|
| "<" -> Ok (LT region)
|
||||||
| "<=" -> Ok (LE region)
|
| "<=" -> Ok (LE region)
|
||||||
| ">" -> Ok (GT region)
|
| ">" -> Ok (GT region)
|
||||||
@ -553,11 +552,6 @@ type attr_err = Invalid_attribute
|
|||||||
|
|
||||||
let mk_attr _ _ _ = Error Invalid_attribute
|
let mk_attr _ _ _ = Error Invalid_attribute
|
||||||
|
|
||||||
(* Raw Code Insertion *)
|
|
||||||
|
|
||||||
let mk_insert lexeme region =
|
|
||||||
Insert Region.{value=lexeme;region}
|
|
||||||
|
|
||||||
(* Predicates *)
|
(* Predicates *)
|
||||||
|
|
||||||
let is_string = function String _ -> true | _ -> false
|
let is_string = function String _ -> true | _ -> false
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
%token <(LexToken.lexeme * Z.t) Region.reg> Mutez "<mutez>"
|
%token <(LexToken.lexeme * Z.t) Region.reg> Mutez "<mutez>"
|
||||||
%token <LexToken.lexeme Region.reg> Ident "<ident>"
|
%token <LexToken.lexeme Region.reg> Ident "<ident>"
|
||||||
%token <LexToken.lexeme Region.reg> Constr "<constr>"
|
%token <LexToken.lexeme Region.reg> Constr "<constr>"
|
||||||
%token <LexToken.lexeme Region.reg> Insert "<insert>"
|
|
||||||
|
|
||||||
(* Symbols *)
|
(* Symbols *)
|
||||||
|
|
||||||
@ -43,6 +42,7 @@
|
|||||||
%token <Region.t> DOT "."
|
%token <Region.t> DOT "."
|
||||||
%token <Region.t> WILD "_"
|
%token <Region.t> WILD "_"
|
||||||
%token <Region.t> CAT "^"
|
%token <Region.t> CAT "^"
|
||||||
|
%token <Region.t> PERCENT "%"
|
||||||
|
|
||||||
(* Keywords *)
|
(* Keywords *)
|
||||||
|
|
||||||
|
@ -975,12 +975,14 @@ update_record:
|
|||||||
in {region; value} }
|
in {region; value} }
|
||||||
|
|
||||||
code_insert_expr:
|
code_insert_expr:
|
||||||
Insert expr "]" {
|
"[" "%" Constr expr "]" {
|
||||||
let region = cover $1.region $3 in
|
let region = cover $1 $5 in
|
||||||
let value = {
|
let value = {
|
||||||
language =$1;
|
lbracket =$1;
|
||||||
code =$2;
|
percent =$2;
|
||||||
rbracket =$3}
|
language =$3;
|
||||||
|
code =$4;
|
||||||
|
rbracket =$5}
|
||||||
in {region; value} }
|
in {region; value} }
|
||||||
|
|
||||||
field_assignment:
|
field_assignment:
|
||||||
|
@ -231,7 +231,9 @@ and print_fun_expr state {value; _} =
|
|||||||
print_expr state return
|
print_expr state return
|
||||||
|
|
||||||
and print_code_insert state {value; _} =
|
and print_code_insert state {value; _} =
|
||||||
let {language;code;rbracket} : code_insert = value in
|
let {lbracket;percent;language;code;rbracket} : code_insert = value in
|
||||||
|
print_token state lbracket "[";
|
||||||
|
print_token state percent "%";
|
||||||
print_string state language;
|
print_string state language;
|
||||||
print_expr state code;
|
print_expr state code;
|
||||||
print_token state rbracket "]"
|
print_token state rbracket "]"
|
||||||
|
@ -32,6 +32,7 @@ interactive_expr: BigMap LBRACKET With
|
|||||||
##
|
##
|
||||||
## Ends in an error in state: 140.
|
## Ends in an error in state: 140.
|
||||||
##
|
##
|
||||||
|
## code_insert_expr -> LBRACKET . PERCENT Constr expr RBRACKET [ TIMES SLASH PLUS Or NE Mod MINUS LT LE GT GE EQ Contains CONS CAT And ARROW ]
|
||||||
## injection(BigMap,binding) -> BigMap LBRACKET . sep_or_term_list(binding,SEMI) RBRACKET [ VBAR Type To Then TIMES Step SLASH SEMI Recursive RPAR RBRACKET RBRACE PLUS Or Of NE Mod MINUS LT LE GT GE Function From End Else EQ EOF Contains Const CONS COMMA COLON CAT Block Begin Attributes And ARROW ]
|
## injection(BigMap,binding) -> BigMap LBRACKET . sep_or_term_list(binding,SEMI) RBRACKET [ VBAR Type To Then TIMES Step SLASH SEMI Recursive RPAR RBRACKET RBRACE PLUS Or Of NE Mod MINUS LT LE GT GE Function From End Else EQ EOF Contains Const CONS COMMA COLON CAT Block Begin Attributes And ARROW ]
|
||||||
## injection(BigMap,binding) -> BigMap LBRACKET . RBRACKET [ VBAR Type To Then TIMES Step SLASH SEMI Recursive RPAR RBRACKET RBRACE PLUS Or Of NE Mod MINUS LT LE GT GE Function From End Else EQ EOF Contains Const CONS COMMA COLON CAT Block Begin Attributes And ARROW ]
|
## injection(BigMap,binding) -> BigMap LBRACKET . RBRACKET [ VBAR Type To Then TIMES Step SLASH SEMI Recursive RPAR RBRACKET RBRACE PLUS Or Of NE Mod MINUS LT LE GT GE Function From End Else EQ EOF Contains Const CONS COMMA COLON CAT Block Begin Attributes And ARROW ]
|
||||||
##
|
##
|
||||||
@ -876,7 +877,7 @@ interactive_expr: Function LPAR With
|
|||||||
|
|
||||||
interactive_expr: Function With
|
interactive_expr: Function With
|
||||||
##
|
##
|
||||||
## Ends in an error in state: 111.
|
## Ends in an error in state: 120.
|
||||||
##
|
##
|
||||||
## fun_expr -> Function . parameters COLON type_expr Is expr [ VBAR Type To Then Step SEMI Recursive RPAR RBRACKET RBRACE Of Function From End Else EOF Const COMMA Block Begin Attributes ARROW ]
|
## fun_expr -> Function . parameters COLON type_expr Is expr [ VBAR Type To Then Step SEMI Recursive RPAR RBRACKET RBRACE Of Function From End Else EOF Const COMMA Block Begin Attributes ARROW ]
|
||||||
##
|
##
|
||||||
@ -1228,7 +1229,7 @@ interactive_expr: Ident With Record Ident While
|
|||||||
|
|
||||||
interactive_expr: Ident With Record Ident With
|
interactive_expr: Ident With Record Ident With
|
||||||
##
|
##
|
||||||
## Ends in an error in state: 166.
|
## Ends in an error in state: 169.
|
||||||
##
|
##
|
||||||
## field_path_assignment -> path . EQ expr [ SEMI RBRACKET End ]
|
## field_path_assignment -> path . EQ expr [ SEMI RBRACKET End ]
|
||||||
##
|
##
|
||||||
@ -1576,6 +1577,7 @@ interactive_expr: List LBRACKET With
|
|||||||
##
|
##
|
||||||
## Ends in an error in state: 359.
|
## Ends in an error in state: 359.
|
||||||
##
|
##
|
||||||
|
## code_insert_expr -> LBRACKET . PERCENT Constr expr RBRACKET [ TIMES SLASH SEMI PLUS Or NE Mod MINUS LT LE GT GE End EQ Contains CONS CAT And ]
|
||||||
## injection(List,expr) -> List LBRACKET . sep_or_term_list(expr,SEMI) RBRACKET [ VBAR Type To Then TIMES Step SLASH SEMI Recursive RPAR RBRACKET RBRACE PLUS Or Of NE Mod MINUS LT LE GT GE Function From End Else EQ EOF Contains Const CONS COMMA COLON CAT Block Begin Attributes And ARROW ]
|
## injection(List,expr) -> List LBRACKET . sep_or_term_list(expr,SEMI) RBRACKET [ VBAR Type To Then TIMES Step SLASH SEMI Recursive RPAR RBRACKET RBRACE PLUS Or Of NE Mod MINUS LT LE GT GE Function From End Else EQ EOF Contains Const CONS COMMA COLON CAT Block Begin Attributes And ARROW ]
|
||||||
## injection(List,expr) -> List LBRACKET . RBRACKET [ VBAR Type To Then TIMES Step SLASH SEMI Recursive RPAR RBRACKET RBRACE PLUS Or Of NE Mod MINUS LT LE GT GE Function From End Else EQ EOF Contains Const CONS COMMA COLON CAT Block Begin Attributes And ARROW ]
|
## injection(List,expr) -> List LBRACKET . RBRACKET [ VBAR Type To Then TIMES Step SLASH SEMI Recursive RPAR RBRACKET RBRACE PLUS Or Of NE Mod MINUS LT LE GT GE Function From End Else EQ EOF Contains Const CONS COMMA COLON CAT Block Begin Attributes And ARROW ]
|
||||||
##
|
##
|
||||||
@ -1675,6 +1677,7 @@ interactive_expr: Map LBRACKET With
|
|||||||
##
|
##
|
||||||
## Ends in an error in state: 376.
|
## Ends in an error in state: 376.
|
||||||
##
|
##
|
||||||
|
## code_insert_expr -> LBRACKET . PERCENT Constr expr RBRACKET [ TIMES SLASH PLUS Or NE Mod MINUS LT LE GT GE EQ Contains CONS CAT And ARROW ]
|
||||||
## injection(Map,binding) -> Map LBRACKET . sep_or_term_list(binding,SEMI) RBRACKET [ VBAR Type To Then TIMES Step SLASH SEMI Recursive RPAR RBRACKET RBRACE PLUS Or Of NE Mod MINUS LT LE GT GE Function From End Else EQ EOF Contains Const CONS COMMA COLON CAT Block Begin Attributes And ARROW ]
|
## injection(Map,binding) -> Map LBRACKET . sep_or_term_list(binding,SEMI) RBRACKET [ VBAR Type To Then TIMES Step SLASH SEMI Recursive RPAR RBRACKET RBRACE PLUS Or Of NE Mod MINUS LT LE GT GE Function From End Else EQ EOF Contains Const CONS COMMA COLON CAT Block Begin Attributes And ARROW ]
|
||||||
## injection(Map,binding) -> Map LBRACKET . RBRACKET [ VBAR Type To Then TIMES Step SLASH SEMI Recursive RPAR RBRACKET RBRACE PLUS Or Of NE Mod MINUS LT LE GT GE Function From End Else EQ EOF Contains Const CONS COMMA COLON CAT Block Begin Attributes And ARROW ]
|
## injection(Map,binding) -> Map LBRACKET . RBRACKET [ VBAR Type To Then TIMES Step SLASH SEMI Recursive RPAR RBRACKET RBRACE PLUS Or Of NE Mod MINUS LT LE GT GE Function From End Else EQ EOF Contains Const CONS COMMA COLON CAT Block Begin Attributes And ARROW ]
|
||||||
##
|
##
|
||||||
@ -2109,6 +2112,7 @@ interactive_expr: Set LBRACKET With
|
|||||||
##
|
##
|
||||||
## Ends in an error in state: 398.
|
## Ends in an error in state: 398.
|
||||||
##
|
##
|
||||||
|
## code_insert_expr -> LBRACKET . PERCENT Constr expr RBRACKET [ TIMES SLASH SEMI PLUS Or NE Mod MINUS LT LE GT GE End EQ Contains CONS CAT And ]
|
||||||
## injection(Set,expr) -> Set LBRACKET . sep_or_term_list(expr,SEMI) RBRACKET [ VBAR Type To Then TIMES Step SLASH SEMI Recursive RPAR RBRACKET RBRACE PLUS Or Of NE Mod MINUS LT LE GT GE Function From End Else EQ EOF Contains Const CONS COMMA COLON CAT Block Begin Attributes And ARROW ]
|
## injection(Set,expr) -> Set LBRACKET . sep_or_term_list(expr,SEMI) RBRACKET [ VBAR Type To Then TIMES Step SLASH SEMI Recursive RPAR RBRACKET RBRACE PLUS Or Of NE Mod MINUS LT LE GT GE Function From End Else EQ EOF Contains Const CONS COMMA COLON CAT Block Begin Attributes And ARROW ]
|
||||||
## injection(Set,expr) -> Set LBRACKET . RBRACKET [ VBAR Type To Then TIMES Step SLASH SEMI Recursive RPAR RBRACKET RBRACE PLUS Or Of NE Mod MINUS LT LE GT GE Function From End Else EQ EOF Contains Const CONS COMMA COLON CAT Block Begin Attributes And ARROW ]
|
## injection(Set,expr) -> Set LBRACKET . RBRACKET [ VBAR Type To Then TIMES Step SLASH SEMI Recursive RPAR RBRACKET RBRACE PLUS Or Of NE Mod MINUS LT LE GT GE Function From End Else EQ EOF Contains Const CONS COMMA COLON CAT Block Begin Attributes And ARROW ]
|
||||||
##
|
##
|
||||||
@ -3487,6 +3491,7 @@ contract: Function Ident LPAR Const Ident COLON Ident RPAR COLON String Is Begin
|
|||||||
##
|
##
|
||||||
## Ends in an error in state: 441.
|
## Ends in an error in state: 441.
|
||||||
##
|
##
|
||||||
|
## code_insert_expr -> LBRACKET . PERCENT Constr expr RBRACKET [ TIMES SLASH PLUS Or NE Mod MINUS LT LE GT GE EQ Contains CONS CAT And ARROW ]
|
||||||
## ne_injection(Map,binding) -> Map LBRACKET . sep_or_term_list(binding,SEMI) RBRACKET [ VBAR SEMI RBRACKET RBRACE End Else ]
|
## ne_injection(Map,binding) -> Map LBRACKET . sep_or_term_list(binding,SEMI) RBRACKET [ VBAR SEMI RBRACKET RBRACE End Else ]
|
||||||
##
|
##
|
||||||
## The known suffix of the stack is as follows:
|
## The known suffix of the stack is as follows:
|
||||||
@ -3656,6 +3661,7 @@ contract: Function Ident LPAR Const Ident COLON Ident RPAR COLON String Is Begin
|
|||||||
##
|
##
|
||||||
## Ends in an error in state: 429.
|
## Ends in an error in state: 429.
|
||||||
##
|
##
|
||||||
|
## code_insert_expr -> LBRACKET . PERCENT Constr expr RBRACKET [ TIMES SLASH SEMI PLUS Or NE Mod MINUS LT LE GT GE End EQ Contains CONS CAT And ]
|
||||||
## ne_injection(Set,expr) -> Set LBRACKET . sep_or_term_list(expr,SEMI) RBRACKET [ VBAR SEMI RBRACKET RBRACE End Else ]
|
## ne_injection(Set,expr) -> Set LBRACKET . sep_or_term_list(expr,SEMI) RBRACKET [ VBAR SEMI RBRACKET RBRACE End Else ]
|
||||||
##
|
##
|
||||||
## The known suffix of the stack is as follows:
|
## The known suffix of the stack is as follows:
|
||||||
@ -4767,4 +4773,3 @@ contract: With
|
|||||||
##
|
##
|
||||||
|
|
||||||
<YOUR SYNTAX ERROR MESSAGE HERE>
|
<YOUR SYNTAX ERROR MESSAGE HERE>
|
||||||
|
|
||||||
|
@ -35,10 +35,11 @@ type t =
|
|||||||
|
|
||||||
(* Arithmetics *)
|
(* Arithmetics *)
|
||||||
|
|
||||||
| MINUS of Region.t (* "-" *)
|
| MINUS of Region.t (* "-" *)
|
||||||
| PLUS of Region.t (* "+" *)
|
| PLUS of Region.t (* "+" *)
|
||||||
| SLASH of Region.t (* "/" *)
|
| SLASH of Region.t (* "/" *)
|
||||||
| TIMES of Region.t (* "*" *)
|
| TIMES of Region.t (* "*" *)
|
||||||
|
| PERCENT of Region.t (* "%" *)
|
||||||
|
|
||||||
(* Compounds *)
|
(* Compounds *)
|
||||||
|
|
||||||
@ -90,7 +91,6 @@ type t =
|
|||||||
| Verbatim of string Region.reg
|
| Verbatim of string Region.reg
|
||||||
| Bytes of (string * Hex.t) Region.reg
|
| Bytes of (string * Hex.t) Region.reg
|
||||||
| Attr of string Region.reg
|
| Attr of string Region.reg
|
||||||
| Insert of string Region.reg
|
|
||||||
|
|
||||||
(* Keywords *)
|
(* Keywords *)
|
||||||
|
|
||||||
@ -154,7 +154,6 @@ val mk_string : lexeme -> Region.t -> token
|
|||||||
val mk_verbatim : lexeme -> Region.t -> token
|
val mk_verbatim : lexeme -> Region.t -> token
|
||||||
val mk_bytes : lexeme -> Region.t -> token
|
val mk_bytes : lexeme -> Region.t -> token
|
||||||
val mk_constr : lexeme -> Region.t -> token
|
val mk_constr : lexeme -> Region.t -> token
|
||||||
val mk_insert : lexeme -> Region.t -> token
|
|
||||||
val eof : Region.t -> token
|
val eof : Region.t -> token
|
||||||
|
|
||||||
(* Predicates *)
|
(* Predicates *)
|
||||||
|
@ -21,10 +21,11 @@ type t =
|
|||||||
|
|
||||||
(* Arithmetics *)
|
(* Arithmetics *)
|
||||||
|
|
||||||
| MINUS of Region.t (* "-" *)
|
| MINUS of Region.t (* "-" *)
|
||||||
| PLUS of Region.t (* "+" *)
|
| PLUS of Region.t (* "+" *)
|
||||||
| SLASH of Region.t (* "/" *)
|
| SLASH of Region.t (* "/" *)
|
||||||
| TIMES of Region.t (* "*" *)
|
| TIMES of Region.t (* "*" *)
|
||||||
|
| PERCENT of Region.t (* "%" *)
|
||||||
|
|
||||||
(* Compounds *)
|
(* Compounds *)
|
||||||
|
|
||||||
@ -76,7 +77,6 @@ type t =
|
|||||||
| Verbatim of string Region.reg
|
| Verbatim of string Region.reg
|
||||||
| Bytes of (string * Hex.t) Region.reg
|
| Bytes of (string * Hex.t) Region.reg
|
||||||
| Attr of string Region.reg
|
| Attr of string Region.reg
|
||||||
| Insert of string Region.reg
|
|
||||||
|
|
||||||
(* Keywords *)
|
(* Keywords *)
|
||||||
|
|
||||||
@ -133,6 +133,7 @@ let proj_token = function
|
|||||||
| PLUS region -> region, "PLUS"
|
| PLUS region -> region, "PLUS"
|
||||||
| SLASH region -> region, "SLASH"
|
| SLASH region -> region, "SLASH"
|
||||||
| TIMES region -> region, "TIMES"
|
| TIMES region -> region, "TIMES"
|
||||||
|
| PERCENT region -> region, "PERCENT"
|
||||||
| LPAR region -> region, "LPAR"
|
| LPAR region -> region, "LPAR"
|
||||||
| RPAR region -> region, "RPAR"
|
| RPAR region -> region, "RPAR"
|
||||||
| LBRACKET region -> region, "LBRACKET"
|
| LBRACKET region -> region, "LBRACKET"
|
||||||
@ -170,7 +171,6 @@ let proj_token = function
|
|||||||
| C_None region -> region, "C_None"
|
| C_None region -> region, "C_None"
|
||||||
| C_Some region -> region, "C_Some"
|
| C_Some region -> region, "C_Some"
|
||||||
| Attr Region.{region; value} -> region, sprintf "Attr %s" value
|
| Attr Region.{region; value} -> region, sprintf "Attr %s" value
|
||||||
| Insert Region.{region; value} -> region, sprintf "Insert %s" value
|
|
||||||
| EOF region -> region, "EOF"
|
| EOF region -> region, "EOF"
|
||||||
|
|
||||||
let to_lexeme = function
|
let to_lexeme = function
|
||||||
@ -185,7 +185,6 @@ let to_lexeme = function
|
|||||||
| Ident id -> id.Region.value
|
| Ident id -> id.Region.value
|
||||||
| Constr id -> id.Region.value
|
| Constr id -> id.Region.value
|
||||||
| Attr a -> a.Region.value
|
| Attr a -> a.Region.value
|
||||||
| Insert i -> i.Region.value
|
|
||||||
|
|
||||||
(* Symbols *)
|
(* Symbols *)
|
||||||
|
|
||||||
@ -194,6 +193,7 @@ let to_lexeme = function
|
|||||||
| PLUS _ -> "+"
|
| PLUS _ -> "+"
|
||||||
| SLASH _ -> "/"
|
| SLASH _ -> "/"
|
||||||
| TIMES _ -> "*"
|
| TIMES _ -> "*"
|
||||||
|
| PERCENT _ -> "%"
|
||||||
| LPAR _ -> "("
|
| LPAR _ -> "("
|
||||||
| RPAR _ -> ")"
|
| RPAR _ -> ")"
|
||||||
| LBRACKET _ -> "["
|
| LBRACKET _ -> "["
|
||||||
@ -432,6 +432,7 @@ let mk_sym lexeme region =
|
|||||||
| "+" -> Ok (PLUS region)
|
| "+" -> Ok (PLUS region)
|
||||||
| "/" -> Ok (SLASH region)
|
| "/" -> Ok (SLASH region)
|
||||||
| "*" -> Ok (TIMES region)
|
| "*" -> Ok (TIMES region)
|
||||||
|
| "%" -> Ok (PERCENT region)
|
||||||
| "[" -> Ok (LBRACKET region)
|
| "[" -> Ok (LBRACKET region)
|
||||||
| "]" -> Ok (RBRACKET region)
|
| "]" -> Ok (RBRACKET region)
|
||||||
| "{" -> Ok (LBRACE region)
|
| "{" -> Ok (LBRACE region)
|
||||||
@ -487,11 +488,6 @@ let mk_attr header lexeme region =
|
|||||||
Ok (Attr Region.{value=lexeme; region})
|
Ok (Attr Region.{value=lexeme; region})
|
||||||
else Error Invalid_attribute
|
else Error Invalid_attribute
|
||||||
|
|
||||||
(* Raw Code Insertion *)
|
|
||||||
|
|
||||||
let mk_insert lexeme region =
|
|
||||||
Insert Region.{value=lexeme;region}
|
|
||||||
|
|
||||||
(* Predicates *)
|
(* Predicates *)
|
||||||
|
|
||||||
let is_string = function String _ -> true | _ -> false
|
let is_string = function String _ -> true | _ -> false
|
||||||
|
@ -14,14 +14,14 @@
|
|||||||
%token <string Region.reg> Ident "<ident>"
|
%token <string Region.reg> Ident "<ident>"
|
||||||
%token <string Region.reg> Constr "<constr>"
|
%token <string Region.reg> Constr "<constr>"
|
||||||
%token <string Region.reg> Attr "<attr>"
|
%token <string Region.reg> Attr "<attr>"
|
||||||
%token <string Region.reg> Insert "<insert>"
|
|
||||||
|
|
||||||
(* Symbols *)
|
(* Symbols *)
|
||||||
|
|
||||||
%token <Region.t> MINUS "-"
|
%token <Region.t> MINUS "-"
|
||||||
%token <Region.t> PLUS "+"
|
%token <Region.t> PLUS "+"
|
||||||
%token <Region.t> SLASH "/"
|
%token <Region.t> SLASH "/"
|
||||||
%token <Region.t> TIMES "*"
|
%token <Region.t> TIMES "*"
|
||||||
|
%token <Region.t> PERCENT "%"
|
||||||
|
|
||||||
%token <Region.t> LPAR "("
|
%token <Region.t> LPAR "("
|
||||||
%token <Region.t> RPAR ")"
|
%token <Region.t> RPAR ")"
|
||||||
|
@ -921,12 +921,14 @@ update_record:
|
|||||||
in {region; value} }
|
in {region; value} }
|
||||||
|
|
||||||
code_insert:
|
code_insert:
|
||||||
Insert expr "]" {
|
"[" "%" Constr expr "]" {
|
||||||
let region = cover $1.region $3 in
|
let region = cover $1 $5 in
|
||||||
let value = {
|
let value = {
|
||||||
language =$1;
|
lbracket =$1;
|
||||||
code =$2;
|
percent =$2;
|
||||||
rbracket =$3}
|
language =$3;
|
||||||
|
code =$4;
|
||||||
|
rbracket =$5}
|
||||||
in {region; value} }
|
in {region; value} }
|
||||||
|
|
||||||
expr_with_let_expr:
|
expr_with_let_expr:
|
||||||
|
@ -3794,4 +3794,3 @@ contract: WILD
|
|||||||
##
|
##
|
||||||
|
|
||||||
<YOUR SYNTAX ERROR MESSAGE HERE>
|
<YOUR SYNTAX ERROR MESSAGE HERE>
|
||||||
|
|
||||||
|
@ -79,7 +79,6 @@ module type TOKEN =
|
|||||||
val mk_bytes : lexeme -> Region.t -> token
|
val mk_bytes : lexeme -> Region.t -> token
|
||||||
val mk_constr : lexeme -> Region.t -> token
|
val mk_constr : lexeme -> Region.t -> token
|
||||||
val mk_attr : string -> lexeme -> Region.t -> (token, attr_err) result
|
val mk_attr : string -> lexeme -> Region.t -> (token, attr_err) result
|
||||||
val mk_insert : lexeme -> Region.t -> token
|
|
||||||
val eof : Region.t -> token
|
val eof : Region.t -> token
|
||||||
|
|
||||||
(* Predicates *)
|
(* Predicates *)
|
||||||
|
@ -43,7 +43,6 @@ module type TOKEN =
|
|||||||
val mk_bytes : lexeme -> Region.t -> token
|
val mk_bytes : lexeme -> Region.t -> token
|
||||||
val mk_constr : lexeme -> Region.t -> token
|
val mk_constr : lexeme -> Region.t -> token
|
||||||
val mk_attr : string -> lexeme -> Region.t -> (token, attr_err) result
|
val mk_attr : string -> lexeme -> Region.t -> (token, attr_err) result
|
||||||
val mk_insert : lexeme -> Region.t -> token
|
|
||||||
val eof : Region.t -> token
|
val eof : Region.t -> token
|
||||||
|
|
||||||
(* Predicates *)
|
(* Predicates *)
|
||||||
@ -269,11 +268,6 @@ module Make (Token : TOKEN) : (S with module Token = Token) =
|
|||||||
| Error Token.Invalid_attribute ->
|
| Error Token.Invalid_attribute ->
|
||||||
fail region Invalid_attribute
|
fail region Invalid_attribute
|
||||||
|
|
||||||
let mk_insert insert state buffer =
|
|
||||||
let region, _, state = state#sync buffer in
|
|
||||||
let token = Token.mk_insert insert region
|
|
||||||
in state#enqueue token
|
|
||||||
|
|
||||||
let mk_constr state buffer =
|
let mk_constr state buffer =
|
||||||
let region, lexeme, state = state#sync buffer in
|
let region, lexeme, state = state#sync buffer in
|
||||||
let token = Token.mk_constr lexeme region
|
let token = Token.mk_constr lexeme region
|
||||||
@ -359,7 +353,6 @@ let line_comments =
|
|||||||
(* #include files *)
|
(* #include files *)
|
||||||
|
|
||||||
let string = [^'"' '\\' '\n']* (* For strings of #include *)
|
let string = [^'"' '\\' '\n']* (* For strings of #include *)
|
||||||
let insert = attr
|
|
||||||
|
|
||||||
(* RULES *)
|
(* RULES *)
|
||||||
|
|
||||||
@ -395,7 +388,6 @@ and scan state = parse
|
|||||||
| eof { mk_eof state lexbuf }
|
| eof { mk_eof state lexbuf }
|
||||||
| "[@" (attr as a) "]" { mk_attr "[@" a state lexbuf }
|
| "[@" (attr as a) "]" { mk_attr "[@" a state lexbuf }
|
||||||
| "[@@" (attr as a) "]" { mk_attr "[@@" a state lexbuf }
|
| "[@@" (attr as a) "]" { mk_attr "[@@" a state lexbuf }
|
||||||
| "[%" (insert as i) { mk_insert i state lexbuf }
|
|
||||||
|
|
||||||
(* Management of #include preprocessing directives
|
(* Management of #include preprocessing directives
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user