MCPcopy Create free account
hub / github.com/Julow/Unexpected-Keyboard / parse

Method parse

srcs/juloo.keyboard2/KeyValueParser.java:33–56  ·  view source on GitHub ↗
(String input)

Source from the content-addressed store, hash-verified

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 {

Callers 2

getKeyByNameMethod · 0.95
expect_errorMethod · 0.95

Calls 9

parseMethod · 0.95
makeStringKeyMethod · 0.95
initMethod · 0.95
parse_key_defMethod · 0.95
parse_commaMethod · 0.95
withSymbolMethod · 0.95
makeMacroMethod · 0.95
lengthMethod · 0.80
addMethod · 0.80

Tested by 1

expect_errorMethod · 0.76