1 % Tokenizer definitions for ESF (refer : http://www.lwes.org/docs/)
9 INTEGER_LITERAL = [-+]?[1-9]([0-9])*
10 BIG_INTEGER_LITERAL = [-+]?[1-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]([0-9])*
11 DOUBLE_LITERAL = [-+]?([0-9])*\.([0-9])+
12 STRING_LITERAL = \"(\\.|[^"])*\"
13 IPADDR_LITERAL = ([0-9])+\.([0-9])+\.([0-9])+\.([0-9])+
14 MACROS = \$\{[-A-Za-z0-9_.]+\}
16 WORD = [a-zA-Z_]([-_:.a-zA-Z0-9])*
17 COMMENT = #[^\r\n]*(\r\n|\r|\n)?
21 {WORD} : { token, { token_type(list_to_atom(TokenChars)) , TokenLine, TokenChars } }.
22 {INTEGER_LITERAL}|{BIG_INTEGER_LITERAL}|{DOUBLE_LITERAL}|{STRING_LITERAL}|{IPADDR_LITERAL}|{MACROS} :
23 { token, { value , TokenLine, TokenChars } }.
24 [\{\};=\[\]] : { token, { list_to_atom(TokenChars), TokenLine } }.
27 {COMMENT} : skip_token.
34 -export([token_type/1]).
36 token_type (true) -> value;
37 token_type (false) -> value;
39 token_type (required) -> qualifier;
40 token_type (nullable) -> qualifier;
41 token_type (optional) -> qualifier;
43 token_type (byte) -> type;
44 token_type (uint16) -> type;
45 token_type (int16) -> type;
46 token_type (uint32) -> type;
47 token_type (int32) -> type;
48 token_type (uint64) -> type;
49 token_type (int64) -> type;
50 token_type (float) -> type;
51 token_type (double) -> type;
52 token_type (boolean) -> type;
53 token_type (string) -> type;
54 token_type (ip_addr) -> type;
56 token_type (_) -> identifier.