Separate atom_char for jbuild and dune files

Dune files have a more strict definition of atoms

Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
This commit is contained in:
Rudi Grinberg 2018-06-19 01:14:19 +07:00
parent ec8860d0be
commit 8432ee42cf
1 changed files with 7 additions and 4 deletions

View File

@ -75,11 +75,14 @@ type block_string_line_kind =
let comment = ';' [^ '\n' '\r']* let comment = ';' [^ '\n' '\r']*
let newline = '\r'? '\n' let newline = '\r'? '\n'
let blank = [' ' '\t' '\012'] let blank = [' ' '\t' '\012']
let atom_char =
[^ ';' '(' ')' '"' ' ' '\t' '\r' '\n' '\000'-'\032' '\127'-'\255']
let digit = ['0'-'9'] let digit = ['0'-'9']
let hexdigit = ['0'-'9' 'a'-'f' 'A'-'F'] let hexdigit = ['0'-'9' 'a'-'f' 'A'-'F']
let atom_char_jbuild =
[^ ';' '(' ')' '"' ' ' '\t' '\r' '\n' '\012']
let atom_char_dune =
[^ ';' '(' ')' '"' ' ' '\t' '\r' '\n' '\000'-'\032' '\127'-'\255']
(* rule for jbuild files *) (* rule for jbuild files *)
rule jbuild_token = parse rule jbuild_token = parse
| newline | newline
@ -117,7 +120,7 @@ and jbuild_atom acc start = parse
{ lexbuf.lex_start_p <- start; { lexbuf.lex_start_p <- start;
error lexbuf "jbuild_atoms cannot contain |#" error lexbuf "jbuild_atoms cannot contain |#"
} }
| ('#'+ | '|'+ | (atom_char # ['|' '#'])) as s | ('#'+ | '|'+ | (atom_char_jbuild # ['|' '#'])) as s
{ jbuild_atom (if acc = "" then s else acc ^ s) start lexbuf { jbuild_atom (if acc = "" then s else acc ^ s) start lexbuf
} }
| "" | ""
@ -244,7 +247,7 @@ and token = parse
lexbuf.lex_start_p <- start; lexbuf.lex_start_p <- start;
Quoted_string s Quoted_string s
} }
| atom_char+ as s | atom_char_dune+ as s
{ Token.Atom (A s) } { Token.Atom (A s) }
| eof | eof
{ Eof } { Eof }