Michelson: allow . in annotations
This commit is contained in:
parent
371ce150ce
commit
82022acabb
@ -13,6 +13,6 @@ code { DUP; DUP;
|
|||||||
DIP{CADR %actual_level}; # Get actual rain
|
DIP{CADR %actual_level}; # Get actual rain
|
||||||
CDDAR %rain_level; # Get rain threshold
|
CDDAR %rain_level; # Get rain threshold
|
||||||
CMPLT; IF {CAR %under_key} {CDR %over_key}; # Select contract to receive tokens
|
CMPLT; IF {CAR %under_key} {CDR %over_key}; # Select contract to receive tokens
|
||||||
BALANCE; UNIT ; TRANSFER_TOKENS @trans_op; # Setup and execute transfer
|
BALANCE; UNIT ; TRANSFER_TOKENS @trans.op; # Setup and execute transfer
|
||||||
NIL operation ; SWAP ; CONS ;
|
NIL operation ; SWAP ; CONS ;
|
||||||
PAIR };
|
PAIR };
|
||||||
|
@ -146,6 +146,14 @@ let tokenize source =
|
|||||||
Some (Uchar.to_char c)
|
Some (Uchar.to_char c)
|
||||||
else
|
else
|
||||||
None in
|
None in
|
||||||
|
let allowed_ident_char c =
|
||||||
|
match uchar_to_char c with
|
||||||
|
| Some ('a'..'z' | 'A'..'Z' | '_' | '0'..'9') -> true
|
||||||
|
| Some _ | None -> false in
|
||||||
|
let allowed_annot_char c =
|
||||||
|
match uchar_to_char c with
|
||||||
|
| Some ('a'..'z' | 'A'..'Z' | '_' | '.' | '0'..'9') -> true
|
||||||
|
| Some _ | None -> false in
|
||||||
let rec skip acc =
|
let rec skip acc =
|
||||||
match next () with
|
match next () with
|
||||||
| `End, _ -> List.rev acc
|
| `End, _ -> List.rev acc
|
||||||
@ -153,7 +161,7 @@ let tokenize source =
|
|||||||
begin match uchar_to_char c with
|
begin match uchar_to_char c with
|
||||||
| Some ('a'..'z' | 'A'..'Z') -> ident acc start (fun s _ -> Ident s)
|
| Some ('a'..'z' | 'A'..'Z') -> ident acc start (fun s _ -> Ident s)
|
||||||
| Some ('@' | ':' | '$' | '&' | '%' | '!' | '?') ->
|
| Some ('@' | ':' | '$' | '&' | '%' | '!' | '?') ->
|
||||||
ident acc start
|
annot acc start
|
||||||
(fun str stop ->
|
(fun str stop ->
|
||||||
if String.length str > max_annot_length
|
if String.length str > max_annot_length
|
||||||
then errors := (Annotation_length { start ; stop }) :: !errors ;
|
then errors := (Annotation_length { start ; stop }) :: !errors ;
|
||||||
@ -290,23 +298,24 @@ let tokenize source =
|
|||||||
let byte = Uutf.decoder_byte_count decoder in
|
let byte = Uutf.decoder_byte_count decoder in
|
||||||
let s = String.sub source stop.byte (byte - stop.byte) in
|
let s = String.sub source stop.byte (byte - stop.byte) in
|
||||||
string acc (s :: sacc) start
|
string acc (s :: sacc) start
|
||||||
and ident acc start (ret : string -> point -> token_value) =
|
and generic_ident allow_char acc start (ret : string -> point -> token_value) =
|
||||||
let tok stop =
|
let tok stop =
|
||||||
let name =
|
let name =
|
||||||
String.sub source start.byte (stop.byte - start.byte) in
|
String.sub source start.byte (stop.byte - start.byte) in
|
||||||
tok start stop (ret name stop) in
|
tok start stop (ret name stop) in
|
||||||
match next () with
|
match next () with
|
||||||
| (`Uchar c, stop) as charloc ->
|
| (`Uchar c, stop) as charloc ->
|
||||||
begin match uchar_to_char c with
|
if allow_char c then
|
||||||
| Some ('a'..'z' | 'A'..'Z' | '_' | '0'..'9') ->
|
generic_ident allow_char acc start ret
|
||||||
ident acc start ret
|
else begin
|
||||||
| Some _ | None ->
|
|
||||||
back charloc ;
|
back charloc ;
|
||||||
skip (tok stop :: acc)
|
skip (tok stop :: acc)
|
||||||
end
|
end
|
||||||
| (_, stop) as other ->
|
| (_, stop) as other ->
|
||||||
back other ;
|
back other ;
|
||||||
skip (tok stop :: acc)
|
skip (tok stop :: acc)
|
||||||
|
and ident acc start ret = generic_ident allowed_ident_char acc start ret
|
||||||
|
and annot acc start ret = generic_ident allowed_annot_char acc start ret
|
||||||
and comment acc start lvl =
|
and comment acc start lvl =
|
||||||
match next () with
|
match next () with
|
||||||
| `End, stop ->
|
| `End, stop ->
|
||||||
|
Loading…
Reference in New Issue
Block a user