diff options
author | Paul Steckler <steck@stecksoft.com> | 2017-11-27 15:05:14 -0500 |
---|---|---|
committer | Paul Steckler <steck@stecksoft.com> | 2017-11-27 15:05:14 -0500 |
commit | f228c2eb94346fb3b538d63d95fdd8ab2c0f8795 (patch) | |
tree | 045f36f73ccf7251c9f1eb87c30ea9d550ccfda4 /plugins | |
parent | 79da97a3e02a079e3d91f04fd012886c57d4c1e8 (diff) |
allow :: and , as infix ops
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/extraction/ocaml.ml | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/plugins/extraction/ocaml.ml b/plugins/extraction/ocaml.ml index fb8dfb459..5d0f9c167 100644 --- a/plugins/extraction/ocaml.ml +++ b/plugins/extraction/ocaml.ml @@ -107,6 +107,11 @@ let infix_symbols = let operator_chars = [ '!' ; '$' ; '%' ; '&' ; '*' ; '+' ; '-' ; '.' ; '/' ; ':' ; '<' ; '=' ; '>' ; '?' ; '@' ; '^' ; '|' ; '~' ] +(* infix ops in OCaml, but disallowed by preceding grammar *) + +let builtin_infixes = + [ "::" ; "," ] + let substring_all_opchars s start stop = let rec check_char i = if i >= stop then true @@ -120,15 +125,16 @@ let is_infix r = (let s = find_custom r in let len = String.length s in len >= 3 && - (* parenthesized *) - (s.[0] == '(' && s.[len-1] == ')' && - let inparens = String.trim (String.sub s 1 (len - 2)) in - let inparens_len = String.length inparens in - (* either, begins with infix symbol, any remainder is all operator chars *) - (List.mem inparens.[0] infix_symbols && substring_all_opchars inparens 1 inparens_len) - || - (* or, starts with #, at least one more char, all are operator chars *) - (inparens.[0] == '#' && inparens_len >= 2 && substring_all_opchars inparens 1 inparens_len))) + (* parenthesized *) + (s.[0] == '(' && s.[len-1] == ')' && + let inparens = String.trim (String.sub s 1 (len - 2)) in + let inparens_len = String.length inparens in + (* either, begins with infix symbol, any remainder is all operator chars *) + (List.mem inparens.[0] infix_symbols && substring_all_opchars inparens 1 inparens_len) || + (* or, starts with #, at least one more char, all are operator chars *) + (inparens.[0] == '#' && inparens_len >= 2 && substring_all_opchars inparens 1 inparens_len) || + (* or, is an OCaml built-in infix *) + (List.mem inparens builtin_infixes))) let get_infix r = let s = find_custom r in |