keyboardlayouteditor

[Fork] Archive of the keyboard layout editor.
git clone https://git.jojolepro.com/keyboardlayouteditor.git
Log | Files | Refs | README | LICENSE

commit ab211730b8bb25861f36d51b9eec0eb6fe5e98cc
parent 0d14f7b59998bef3173c564c215a40bc20081d93
Author: simos.lists <simos.lists@70737e48-4f4a-0410-8df8-290828ad50c4>
Date:   Fri, 20 Jun 2008 22:24:26 +0000

Keycode name is parsed ok

git-svn-id: http://keyboardlayouteditor.googlecode.com/svn/trunk@52 70737e48-4f4a-0410-8df8-290828ad50c4

Diffstat:
MXKBGrammar/XKBGrammar.g | 2+-
MXKBGrammar/XKBGrammarLexer.py | 2+-
MXKBGrammar/XKBGrammarLexer.pyc | 0
MXKBGrammar/XKBGrammarParser.py | 190+++++++++++++++++++++++++++++++++++++++++--------------------------------------
MXKBGrammar/XKBGrammarParser.pyc | 0
MXKBGrammar/XKBGrammarWalker.g | 2+-
MXKBGrammar/parse_xkb_to_xml.py | 11++++++++---
MXKBGrammar/parse_xml_to_xkb.py | 6+++---
8 files changed, 112 insertions(+), 101 deletions(-)

diff --git a/XKBGrammar/XKBGrammar.g b/XKBGrammar/XKBGrammar.g @@ -98,7 +98,7 @@ line_keytype line_key : OVERRIDE? 'key' '<' NAME '>' '{' keyelements (',' keyelements)* '}' - -> ^(TOKEN_KEY OVERRIDE? NAME keyelements+) + -> ^(TOKEN_KEY OVERRIDE? ^(KEYCODEX NAME) keyelements+) ; line_modifier_map diff --git a/XKBGrammar/XKBGrammarLexer.py b/XKBGrammar/XKBGrammarLexer.py @@ -1,4 +1,4 @@ -# $ANTLR 3.1b1 XKBGrammar.g 2008-06-19 21:40:26 +# $ANTLR 3.1b1 XKBGrammar.g 2008-06-20 23:20:20 import sys from antlr3 import * diff --git a/XKBGrammar/XKBGrammarLexer.pyc b/XKBGrammar/XKBGrammarLexer.pyc Binary files differ. diff --git a/XKBGrammar/XKBGrammarParser.py b/XKBGrammar/XKBGrammarParser.py @@ -1,4 +1,4 @@ -# $ANTLR 3.1b1 XKBGrammar.g 2008-06-19 21:40:26 +# $ANTLR 3.1b1 XKBGrammar.g 2008-06-20 23:20:19 import sys from antlr3 import * @@ -1019,7 +1019,7 @@ class XKBGrammarParser(Parser): # $ANTLR start line_key - # XKBGrammar.g:99:1: line_key : ( OVERRIDE )? 'key' '<' NAME '>' '{' keyelements ( ',' keyelements )* '}' -> ^( TOKEN_KEY ( OVERRIDE )? NAME ( keyelements )+ ) ; + # XKBGrammar.g:99:1: line_key : ( OVERRIDE )? 'key' '<' NAME '>' '{' keyelements ( ',' keyelements )* '}' -> ^( TOKEN_KEY ( OVERRIDE )? ^( KEYCODEX NAME ) ( keyelements )+ ) ; def line_key(self, ): retval = self.line_key_return() @@ -1059,7 +1059,7 @@ class XKBGrammarParser(Parser): stream_keyelements = RewriteRuleSubtreeStream(self.adaptor, "rule keyelements") try: try: - # XKBGrammar.g:100:2: ( ( OVERRIDE )? 'key' '<' NAME '>' '{' keyelements ( ',' keyelements )* '}' -> ^( TOKEN_KEY ( OVERRIDE )? NAME ( keyelements )+ ) ) + # XKBGrammar.g:100:2: ( ( OVERRIDE )? 'key' '<' NAME '>' '{' keyelements ( ',' keyelements )* '}' -> ^( TOKEN_KEY ( OVERRIDE )? ^( KEYCODEX NAME ) ( keyelements )+ ) ) # XKBGrammar.g:100:4: ( OVERRIDE )? 'key' '<' NAME '>' '{' keyelements ( ',' keyelements )* '}' # XKBGrammar.g:100:4: ( OVERRIDE )? alt7 = 2 @@ -1141,8 +1141,8 @@ class XKBGrammarParser(Parser): root_0 = self.adaptor.nil() - # 101:2: -> ^( TOKEN_KEY ( OVERRIDE )? NAME ( keyelements )+ ) - # XKBGrammar.g:101:5: ^( TOKEN_KEY ( OVERRIDE )? NAME ( keyelements )+ ) + # 101:2: -> ^( TOKEN_KEY ( OVERRIDE )? ^( KEYCODEX NAME ) ( keyelements )+ ) + # XKBGrammar.g:101:5: ^( TOKEN_KEY ( OVERRIDE )? ^( KEYCODEX NAME ) ( keyelements )+ ) root_1 = self.adaptor.nil() root_1 = self.adaptor.becomeRoot(self.adaptor.createFromType(TOKEN_KEY, "TOKEN_KEY"), root_1) @@ -1152,8 +1152,14 @@ class XKBGrammarParser(Parser): stream_OVERRIDE.reset(); - self.adaptor.addChild(root_1, stream_NAME.nextNode()) - # XKBGrammar.g:101:32: ( keyelements )+ + # XKBGrammar.g:101:27: ^( KEYCODEX NAME ) + root_2 = self.adaptor.nil() + root_2 = self.adaptor.becomeRoot(self.adaptor.createFromType(KEYCODEX, "KEYCODEX"), root_2) + + self.adaptor.addChild(root_2, stream_NAME.nextNode()) + + self.adaptor.addChild(root_1, root_2) + # XKBGrammar.g:101:44: ( keyelements )+ if not (stream_keyelements.hasNext()): raise RewriteEarlyExitException() @@ -1236,15 +1242,15 @@ class XKBGrammarParser(Parser): # XKBGrammar.g:105:2: ( 'modifier_map' STATE '{' keycode ( ',' keycode )* '}' -> ^( TOKEN_MODIFIER_MAP STATE ( keycode )+ ) ) # XKBGrammar.g:105:4: 'modifier_map' STATE '{' keycode ( ',' keycode )* '}' string_literal45 = self.input.LT(1) - self.match(self.input, 47, self.FOLLOW_47_in_line_modifier_map447) + self.match(self.input, 47, self.FOLLOW_47_in_line_modifier_map451) stream_47.add(string_literal45) STATE46 = self.input.LT(1) - self.match(self.input, STATE, self.FOLLOW_STATE_in_line_modifier_map449) + self.match(self.input, STATE, self.FOLLOW_STATE_in_line_modifier_map453) stream_STATE.add(STATE46) char_literal47 = self.input.LT(1) - self.match(self.input, 34, self.FOLLOW_34_in_line_modifier_map451) + self.match(self.input, 34, self.FOLLOW_34_in_line_modifier_map455) stream_34.add(char_literal47) - self._state.following.append(self.FOLLOW_keycode_in_line_modifier_map453) + self._state.following.append(self.FOLLOW_keycode_in_line_modifier_map457) keycode48 = self.keycode() self._state.following.pop() @@ -1261,9 +1267,9 @@ class XKBGrammarParser(Parser): if alt9 == 1: # XKBGrammar.g:105:38: ',' keycode char_literal49 = self.input.LT(1) - self.match(self.input, 46, self.FOLLOW_46_in_line_modifier_map456) + self.match(self.input, 46, self.FOLLOW_46_in_line_modifier_map460) stream_46.add(char_literal49) - self._state.following.append(self.FOLLOW_keycode_in_line_modifier_map458) + self._state.following.append(self.FOLLOW_keycode_in_line_modifier_map462) keycode50 = self.keycode() self._state.following.pop() @@ -1276,7 +1282,7 @@ class XKBGrammarParser(Parser): char_literal51 = self.input.LT(1) - self.match(self.input, 35, self.FOLLOW_35_in_line_modifier_map462) + self.match(self.input, 35, self.FOLLOW_35_in_line_modifier_map466) stream_35.add(char_literal51) # AST Rewrite # elements: keycode, STATE @@ -1375,10 +1381,10 @@ class XKBGrammarParser(Parser): # XKBGrammar.g:110:2: ( 'virtual_modifiers' NAME ( ',' NAME )* -> ^( TOKEN_VIRTUAL_MODIFIERS ( NAME )+ ) ) # XKBGrammar.g:110:4: 'virtual_modifiers' NAME ( ',' NAME )* string_literal52 = self.input.LT(1) - self.match(self.input, 48, self.FOLLOW_48_in_line_virtual_modifiers485) + self.match(self.input, 48, self.FOLLOW_48_in_line_virtual_modifiers489) stream_48.add(string_literal52) NAME53 = self.input.LT(1) - self.match(self.input, NAME, self.FOLLOW_NAME_in_line_virtual_modifiers487) + self.match(self.input, NAME, self.FOLLOW_NAME_in_line_virtual_modifiers491) stream_NAME.add(NAME53) # XKBGrammar.g:110:29: ( ',' NAME )* while True: #loop10 @@ -1392,10 +1398,10 @@ class XKBGrammarParser(Parser): if alt10 == 1: # XKBGrammar.g:110:30: ',' NAME char_literal54 = self.input.LT(1) - self.match(self.input, 46, self.FOLLOW_46_in_line_virtual_modifiers490) + self.match(self.input, 46, self.FOLLOW_46_in_line_virtual_modifiers494) stream_46.add(char_literal54) NAME55 = self.input.LT(1) - self.match(self.input, NAME, self.FOLLOW_NAME_in_line_virtual_modifiers492) + self.match(self.input, NAME, self.FOLLOW_NAME_in_line_virtual_modifiers496) stream_NAME.add(NAME55) @@ -1513,13 +1519,13 @@ class XKBGrammarParser(Parser): if alt11 == 1: # XKBGrammar.g:115:4: '<' NAME '>' char_literal56 = self.input.LT(1) - self.match(self.input, 44, self.FOLLOW_44_in_keycode516) + self.match(self.input, 44, self.FOLLOW_44_in_keycode520) stream_44.add(char_literal56) NAME57 = self.input.LT(1) - self.match(self.input, NAME, self.FOLLOW_NAME_in_keycode518) + self.match(self.input, NAME, self.FOLLOW_NAME_in_keycode522) stream_NAME.add(NAME57) char_literal58 = self.input.LT(1) - self.match(self.input, 45, self.FOLLOW_45_in_keycode520) + self.match(self.input, 45, self.FOLLOW_45_in_keycode524) stream_45.add(char_literal58) # AST Rewrite # elements: NAME @@ -1555,7 +1561,7 @@ class XKBGrammarParser(Parser): elif alt11 == 2: # XKBGrammar.g:116:4: NAME NAME59 = self.input.LT(1) - self.match(self.input, NAME, self.FOLLOW_NAME_in_keycode533) + self.match(self.input, NAME, self.FOLLOW_NAME_in_keycode537) stream_NAME.add(NAME59) # AST Rewrite # elements: NAME @@ -1637,7 +1643,7 @@ class XKBGrammarParser(Parser): root_0 = self.adaptor.nil() string_literal60 = self.input.LT(1) - self.match(self.input, OVERRIDE, self.FOLLOW_OVERRIDE_in_override552) + self.match(self.input, OVERRIDE, self.FOLLOW_OVERRIDE_in_override556) string_literal60_tree = self.adaptor.createWithPayload(string_literal60) self.adaptor.addChild(root_0, string_literal60_tree) @@ -1716,7 +1722,7 @@ class XKBGrammarParser(Parser): # XKBGrammar.g:124:4: elem_keysyms root_0 = self.adaptor.nil() - self._state.following.append(self.FOLLOW_elem_keysyms_in_keyelements563) + self._state.following.append(self.FOLLOW_elem_keysyms_in_keyelements567) elem_keysyms61 = self.elem_keysyms() self._state.following.pop() @@ -1728,7 +1734,7 @@ class XKBGrammarParser(Parser): # XKBGrammar.g:125:4: elem_keysymgroup root_0 = self.adaptor.nil() - self._state.following.append(self.FOLLOW_elem_keysymgroup_in_keyelements569) + self._state.following.append(self.FOLLOW_elem_keysymgroup_in_keyelements573) elem_keysymgroup62 = self.elem_keysymgroup() self._state.following.pop() @@ -1740,7 +1746,7 @@ class XKBGrammarParser(Parser): # XKBGrammar.g:126:4: elem_virtualmods root_0 = self.adaptor.nil() - self._state.following.append(self.FOLLOW_elem_virtualmods_in_keyelements574) + self._state.following.append(self.FOLLOW_elem_virtualmods_in_keyelements578) elem_virtualmods63 = self.elem_virtualmods() self._state.following.pop() @@ -1752,7 +1758,7 @@ class XKBGrammarParser(Parser): # XKBGrammar.g:127:4: elem_overlay root_0 = self.adaptor.nil() - self._state.following.append(self.FOLLOW_elem_overlay_in_keyelements579) + self._state.following.append(self.FOLLOW_elem_overlay_in_keyelements583) elem_overlay64 = self.elem_overlay() self._state.following.pop() @@ -1823,7 +1829,7 @@ class XKBGrammarParser(Parser): # XKBGrammar.g:131:2: ( 'type' ( '[' NAME ']' )? '=' DQSTRING -> ^( ELEM_KEYSYMS DQSTRING ) ) # XKBGrammar.g:131:4: 'type' ( '[' NAME ']' )? '=' DQSTRING string_literal65 = self.input.LT(1) - self.match(self.input, 49, self.FOLLOW_49_in_elem_keysyms590) + self.match(self.input, 49, self.FOLLOW_49_in_elem_keysyms594) stream_49.add(string_literal65) # XKBGrammar.g:131:11: ( '[' NAME ']' )? alt13 = 2 @@ -1834,23 +1840,23 @@ class XKBGrammarParser(Parser): if alt13 == 1: # XKBGrammar.g:131:12: '[' NAME ']' char_literal66 = self.input.LT(1) - self.match(self.input, 39, self.FOLLOW_39_in_elem_keysyms593) + self.match(self.input, 39, self.FOLLOW_39_in_elem_keysyms597) stream_39.add(char_literal66) NAME67 = self.input.LT(1) - self.match(self.input, NAME, self.FOLLOW_NAME_in_elem_keysyms595) + self.match(self.input, NAME, self.FOLLOW_NAME_in_elem_keysyms599) stream_NAME.add(NAME67) char_literal68 = self.input.LT(1) - self.match(self.input, 40, self.FOLLOW_40_in_elem_keysyms597) + self.match(self.input, 40, self.FOLLOW_40_in_elem_keysyms601) stream_40.add(char_literal68) char_literal69 = self.input.LT(1) - self.match(self.input, 41, self.FOLLOW_41_in_elem_keysyms601) + self.match(self.input, 41, self.FOLLOW_41_in_elem_keysyms605) stream_41.add(char_literal69) DQSTRING70 = self.input.LT(1) - self.match(self.input, DQSTRING, self.FOLLOW_DQSTRING_in_elem_keysyms603) + self.match(self.input, DQSTRING, self.FOLLOW_DQSTRING_in_elem_keysyms607) stream_DQSTRING.add(DQSTRING70) # AST Rewrite # elements: DQSTRING @@ -1962,29 +1968,29 @@ class XKBGrammarParser(Parser): if alt14 == 1: # XKBGrammar.g:136:5: 'symbols' '[' NAME ']' '=' string_literal71 = self.input.LT(1) - self.match(self.input, 50, self.FOLLOW_50_in_elem_keysymgroup624) + self.match(self.input, 50, self.FOLLOW_50_in_elem_keysymgroup628) stream_50.add(string_literal71) char_literal72 = self.input.LT(1) - self.match(self.input, 39, self.FOLLOW_39_in_elem_keysymgroup626) + self.match(self.input, 39, self.FOLLOW_39_in_elem_keysymgroup630) stream_39.add(char_literal72) NAME73 = self.input.LT(1) - self.match(self.input, NAME, self.FOLLOW_NAME_in_elem_keysymgroup628) + self.match(self.input, NAME, self.FOLLOW_NAME_in_elem_keysymgroup632) stream_NAME.add(NAME73) char_literal74 = self.input.LT(1) - self.match(self.input, 40, self.FOLLOW_40_in_elem_keysymgroup630) + self.match(self.input, 40, self.FOLLOW_40_in_elem_keysymgroup634) stream_40.add(char_literal74) char_literal75 = self.input.LT(1) - self.match(self.input, 41, self.FOLLOW_41_in_elem_keysymgroup632) + self.match(self.input, 41, self.FOLLOW_41_in_elem_keysymgroup636) stream_41.add(char_literal75) char_literal76 = self.input.LT(1) - self.match(self.input, 39, self.FOLLOW_39_in_elem_keysymgroup636) + self.match(self.input, 39, self.FOLLOW_39_in_elem_keysymgroup640) stream_39.add(char_literal76) keysym = self.input.LT(1) - self.match(self.input, NAME, self.FOLLOW_NAME_in_elem_keysymgroup640) + self.match(self.input, NAME, self.FOLLOW_NAME_in_elem_keysymgroup644) stream_NAME.add(keysym) if list_keysym is None: list_keysym = [] @@ -2002,10 +2008,10 @@ class XKBGrammarParser(Parser): if alt15 == 1: # XKBGrammar.g:136:52: ',' keysym+= NAME char_literal77 = self.input.LT(1) - self.match(self.input, 46, self.FOLLOW_46_in_elem_keysymgroup643) + self.match(self.input, 46, self.FOLLOW_46_in_elem_keysymgroup647) stream_46.add(char_literal77) keysym = self.input.LT(1) - self.match(self.input, NAME, self.FOLLOW_NAME_in_elem_keysymgroup647) + self.match(self.input, NAME, self.FOLLOW_NAME_in_elem_keysymgroup651) stream_NAME.add(keysym) if list_keysym is None: list_keysym = [] @@ -2019,7 +2025,7 @@ class XKBGrammarParser(Parser): char_literal78 = self.input.LT(1) - self.match(self.input, 40, self.FOLLOW_40_in_elem_keysymgroup651) + self.match(self.input, 40, self.FOLLOW_40_in_elem_keysymgroup655) stream_40.add(char_literal78) # AST Rewrite # elements: keysym @@ -2124,13 +2130,13 @@ class XKBGrammarParser(Parser): # XKBGrammar.g:141:4: ( 'virtualMods' '=' NAME ) # XKBGrammar.g:141:5: 'virtualMods' '=' NAME string_literal79 = self.input.LT(1) - self.match(self.input, 51, self.FOLLOW_51_in_elem_virtualmods679) + self.match(self.input, 51, self.FOLLOW_51_in_elem_virtualmods683) stream_51.add(string_literal79) char_literal80 = self.input.LT(1) - self.match(self.input, 41, self.FOLLOW_41_in_elem_virtualmods681) + self.match(self.input, 41, self.FOLLOW_41_in_elem_virtualmods685) stream_41.add(char_literal80) NAME81 = self.input.LT(1) - self.match(self.input, NAME, self.FOLLOW_NAME_in_elem_virtualmods683) + self.match(self.input, NAME, self.FOLLOW_NAME_in_elem_virtualmods687) stream_NAME.add(NAME81) @@ -2221,18 +2227,18 @@ class XKBGrammarParser(Parser): # XKBGrammar.g:146:2: ( NAME '=' keycode -> ^( OVERLAY NAME keycode ) ) # XKBGrammar.g:146:4: NAME '=' keycode NAME82 = self.input.LT(1) - self.match(self.input, NAME, self.FOLLOW_NAME_in_elem_overlay704) + self.match(self.input, NAME, self.FOLLOW_NAME_in_elem_overlay708) stream_NAME.add(NAME82) char_literal83 = self.input.LT(1) - self.match(self.input, 41, self.FOLLOW_41_in_elem_overlay706) + self.match(self.input, 41, self.FOLLOW_41_in_elem_overlay710) stream_41.add(char_literal83) - self._state.following.append(self.FOLLOW_keycode_in_elem_overlay708) + self._state.following.append(self.FOLLOW_keycode_in_elem_overlay712) keycode84 = self.keycode() self._state.following.pop() stream_keycode.add(keycode84.tree) # AST Rewrite - # elements: NAME, keycode + # elements: keycode, NAME # token labels: # rule labels: retval # token list labels: @@ -2333,48 +2339,48 @@ class XKBGrammarParser(Parser): FOLLOW_46_in_line_key415 = frozenset([30, 39, 49, 50, 51]) FOLLOW_keyelements_in_line_key417 = frozenset([35, 46]) FOLLOW_35_in_line_key421 = frozenset([1]) - FOLLOW_47_in_line_modifier_map447 = frozenset([21]) - FOLLOW_STATE_in_line_modifier_map449 = frozenset([34]) - FOLLOW_34_in_line_modifier_map451 = frozenset([30, 44]) - FOLLOW_keycode_in_line_modifier_map453 = frozenset([35, 46]) - FOLLOW_46_in_line_modifier_map456 = frozenset([30, 44]) - FOLLOW_keycode_in_line_modifier_map458 = frozenset([35, 46]) - FOLLOW_35_in_line_modifier_map462 = frozenset([1]) - FOLLOW_48_in_line_virtual_modifiers485 = frozenset([30]) - FOLLOW_NAME_in_line_virtual_modifiers487 = frozenset([1, 46]) - FOLLOW_46_in_line_virtual_modifiers490 = frozenset([30]) - FOLLOW_NAME_in_line_virtual_modifiers492 = frozenset([1, 46]) - FOLLOW_44_in_keycode516 = frozenset([30]) - FOLLOW_NAME_in_keycode518 = frozenset([45]) - FOLLOW_45_in_keycode520 = frozenset([1]) - FOLLOW_NAME_in_keycode533 = frozenset([1]) - FOLLOW_OVERRIDE_in_override552 = frozenset([1]) - FOLLOW_elem_keysyms_in_keyelements563 = frozenset([1]) - FOLLOW_elem_keysymgroup_in_keyelements569 = frozenset([1]) - FOLLOW_elem_virtualmods_in_keyelements574 = frozenset([1]) - FOLLOW_elem_overlay_in_keyelements579 = frozenset([1]) - FOLLOW_49_in_elem_keysyms590 = frozenset([39, 41]) - FOLLOW_39_in_elem_keysyms593 = frozenset([30]) - FOLLOW_NAME_in_elem_keysyms595 = frozenset([40]) - FOLLOW_40_in_elem_keysyms597 = frozenset([41]) - FOLLOW_41_in_elem_keysyms601 = frozenset([29]) - FOLLOW_DQSTRING_in_elem_keysyms603 = frozenset([1]) - FOLLOW_50_in_elem_keysymgroup624 = frozenset([39]) - FOLLOW_39_in_elem_keysymgroup626 = frozenset([30]) - FOLLOW_NAME_in_elem_keysymgroup628 = frozenset([40]) - FOLLOW_40_in_elem_keysymgroup630 = frozenset([41]) - FOLLOW_41_in_elem_keysymgroup632 = frozenset([39]) - FOLLOW_39_in_elem_keysymgroup636 = frozenset([30]) - FOLLOW_NAME_in_elem_keysymgroup640 = frozenset([40, 46]) - FOLLOW_46_in_elem_keysymgroup643 = frozenset([30]) - FOLLOW_NAME_in_elem_keysymgroup647 = frozenset([40, 46]) - FOLLOW_40_in_elem_keysymgroup651 = frozenset([1]) - FOLLOW_51_in_elem_virtualmods679 = frozenset([41]) - FOLLOW_41_in_elem_virtualmods681 = frozenset([30]) - FOLLOW_NAME_in_elem_virtualmods683 = frozenset([1]) - FOLLOW_NAME_in_elem_overlay704 = frozenset([41]) - FOLLOW_41_in_elem_overlay706 = frozenset([30, 44]) - FOLLOW_keycode_in_elem_overlay708 = frozenset([1]) + FOLLOW_47_in_line_modifier_map451 = frozenset([21]) + FOLLOW_STATE_in_line_modifier_map453 = frozenset([34]) + FOLLOW_34_in_line_modifier_map455 = frozenset([30, 44]) + FOLLOW_keycode_in_line_modifier_map457 = frozenset([35, 46]) + FOLLOW_46_in_line_modifier_map460 = frozenset([30, 44]) + FOLLOW_keycode_in_line_modifier_map462 = frozenset([35, 46]) + FOLLOW_35_in_line_modifier_map466 = frozenset([1]) + FOLLOW_48_in_line_virtual_modifiers489 = frozenset([30]) + FOLLOW_NAME_in_line_virtual_modifiers491 = frozenset([1, 46]) + FOLLOW_46_in_line_virtual_modifiers494 = frozenset([30]) + FOLLOW_NAME_in_line_virtual_modifiers496 = frozenset([1, 46]) + FOLLOW_44_in_keycode520 = frozenset([30]) + FOLLOW_NAME_in_keycode522 = frozenset([45]) + FOLLOW_45_in_keycode524 = frozenset([1]) + FOLLOW_NAME_in_keycode537 = frozenset([1]) + FOLLOW_OVERRIDE_in_override556 = frozenset([1]) + FOLLOW_elem_keysyms_in_keyelements567 = frozenset([1]) + FOLLOW_elem_keysymgroup_in_keyelements573 = frozenset([1]) + FOLLOW_elem_virtualmods_in_keyelements578 = frozenset([1]) + FOLLOW_elem_overlay_in_keyelements583 = frozenset([1]) + FOLLOW_49_in_elem_keysyms594 = frozenset([39, 41]) + FOLLOW_39_in_elem_keysyms597 = frozenset([30]) + FOLLOW_NAME_in_elem_keysyms599 = frozenset([40]) + FOLLOW_40_in_elem_keysyms601 = frozenset([41]) + FOLLOW_41_in_elem_keysyms605 = frozenset([29]) + FOLLOW_DQSTRING_in_elem_keysyms607 = frozenset([1]) + FOLLOW_50_in_elem_keysymgroup628 = frozenset([39]) + FOLLOW_39_in_elem_keysymgroup630 = frozenset([30]) + FOLLOW_NAME_in_elem_keysymgroup632 = frozenset([40]) + FOLLOW_40_in_elem_keysymgroup634 = frozenset([41]) + FOLLOW_41_in_elem_keysymgroup636 = frozenset([39]) + FOLLOW_39_in_elem_keysymgroup640 = frozenset([30]) + FOLLOW_NAME_in_elem_keysymgroup644 = frozenset([40, 46]) + FOLLOW_46_in_elem_keysymgroup647 = frozenset([30]) + FOLLOW_NAME_in_elem_keysymgroup651 = frozenset([40, 46]) + FOLLOW_40_in_elem_keysymgroup655 = frozenset([1]) + FOLLOW_51_in_elem_virtualmods683 = frozenset([41]) + FOLLOW_41_in_elem_virtualmods685 = frozenset([30]) + FOLLOW_NAME_in_elem_virtualmods687 = frozenset([1]) + FOLLOW_NAME_in_elem_overlay708 = frozenset([41]) + FOLLOW_41_in_elem_overlay710 = frozenset([30, 44]) + FOLLOW_keycode_in_elem_overlay712 = frozenset([1]) diff --git a/XKBGrammar/XKBGrammarParser.pyc b/XKBGrammar/XKBGrammarParser.pyc Binary files differ. diff --git a/XKBGrammar/XKBGrammarWalker.g b/XKBGrammar/XKBGrammarWalker.g @@ -27,7 +27,7 @@ mapMaterial : ^(TOKEN_INCLUDE DQSTRING) | ^(TOKEN_NAME DQSTRING) | ^(TOKEN_KEY_TYPE NAME? ^(VALUE DQSTRING)) - | ^(TOKEN_KEY OVERRIDE? NAME keyelements+) + | ^(TOKEN_KEY OVERRIDE? ^(KEYCODEX NAME) keyelements+) | ^(TOKEN_MODIFIER_MAP STATE keycode+) | ^(TOKEN_VIRTUAL_MODIFIERS NAME+) ; diff --git a/XKBGrammar/parse_xkb_to_xml.py b/XKBGrammar/parse_xkb_to_xml.py @@ -74,7 +74,7 @@ parser = XKBGrammarParser(tokens) result = parser.layout() -# print "tree =", result.tree.toStringTree() +print "tree =", result.tree.toStringTree() nodes = antlr3.tree.CommonTreeNodeStream(result.tree) nodes.setTokenStream(tokens) @@ -95,7 +95,7 @@ for symbols in result.tree.getChildren(): for maptypesect in mapobject.getChildren(): if maptypesect.getType() == MAPOPTIONS: for mapoption in maptypesect.getChildren(): - if mapoption.getText() == 'xkb_symbols': + if mapoption.getText() == 'xkb_symbols' or mapoption.getText() == 'hidden': eMapOption = etree.SubElement(eSymbol, 'mapoption') eMapOption.text = mapoption.getText() elif maptypesect.getType() == MAPNAME: @@ -136,7 +136,12 @@ for symbols in result.tree.getChildren(): override = getChildrenListByType(keyset, OVERRIDE) eTokenKey = etree.SubElement(eMapMaterial, 'tokenkey') eKeyCodeName = etree.SubElement(eTokenKey, 'keycodename') - eKeyCodeName.text = keyset.getChild(0).getText() + keycodex = getChildrenListByType(keyset, KEYCODEX) + if len(keycodex) == 1: + eKeyCodeName.text = keycodex[0].getChild(0).getText() + else: + print "Could not retrieve keycode name" + exit(-1) if len(override) == 1: eTokenKey.attrib['override'] = "True" else: diff --git a/XKBGrammar/parse_xml_to_xkb.py b/XKBGrammar/parse_xml_to_xkb.py @@ -52,7 +52,7 @@ def recurse_tree(node, depth): elif t.tag == "tokentype": fout.write("\tkey.type = \"%(s)s\";\n" % { "s": t.text }) elif t.tag == "tokenmodifiermap": - fout.write("\tmodifier_map %(s)s {" % { "s": t.attrib['state'] }) + fout.write("\tmodifier_map %(s)s { " % { "s": t.attrib['state'] }) count_mm = len(t) for mm in t: if mm.tag == "keycodex": @@ -62,12 +62,12 @@ def recurse_tree(node, depth): if count_mm > 1: fout.write(", ") count_mm -= 1 - fout.write("};\n") + fout.write(" };\n") elif t.tag == "tokenkey": fout.write("\t") if t.attrib["override"] == "True": - fout.write("override") + fout.write("override ") for tk in t: if tk.tag == "keycodename": fout.write("key <%(s)s> { " % { "s": tk.text })