| 31 | static Pattern WORD_PAT; |
| 32 | |
| 33 | static public KeyValue parse(String input) throws ParseError |
| 34 | { |
| 35 | int symbol_ends = 0; |
| 36 | final int input_len = input.length(); |
| 37 | while (symbol_ends < input_len && input.charAt(symbol_ends) != ':') |
| 38 | symbol_ends++; |
| 39 | if (symbol_ends == 0) // Old syntax |
| 40 | return Starting_with_colon.parse(input); |
| 41 | if (symbol_ends == input_len) // String key |
| 42 | return KeyValue.makeStringKey(input); |
| 43 | String symbol = input.substring(0, symbol_ends); |
| 44 | init(); |
| 45 | Matcher m = KEYDEF_TOKEN.matcher(input); |
| 46 | m.region(symbol_ends + 1, input_len); |
| 47 | KeyValue first_key = parse_key_def(m); |
| 48 | if (!parse_comma(m)) // Input is a single key def with a specified symbol |
| 49 | return first_key.withSymbol(symbol); |
| 50 | // Input is a macro |
| 51 | ArrayList<KeyValue> keydefs = new ArrayList<KeyValue>(); |
| 52 | keydefs.add(first_key); |
| 53 | do { keydefs.add(parse_key_def(m)); } |
| 54 | while (parse_comma(m)); |
| 55 | return KeyValue.makeMacro(symbol, keydefs.toArray(new KeyValue[]{}), 0); |
| 56 | } |
| 57 | |
| 58 | static void init() |
| 59 | { |