keyboardlayouteditor

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

commit c2e0c02a3b62161b58a7777cc06f47322f8199ee
parent a2e15702a3d8f3eaf6e6530240fcabe6ceacb951
Author: simos.lists <simos.lists@70737e48-4f4a-0410-8df8-290828ad50c4>
Date:   Thu, 15 May 2008 18:19:20 +0000

Updated Walker, version 0.4

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

Diffstat:
MXKBGrammar/XKBGrammar.g | 27+++++++++++----------------
MXKBGrammar/XKBGrammar.tokens | 94++++++++++++++++++++++++++++++++++++++++++++++---------------------------------
MXKBGrammar/XKBGrammarLexer.py | 1218++++++++++++++++++++++++++++++++++---------------------------------------------
MXKBGrammar/XKBGrammarLexer.pyc | 0
MXKBGrammar/XKBGrammarParser.py | 705++++++++++++++++++++++++++++++++++++++++++++-----------------------------------
MXKBGrammar/XKBGrammarParser.pyc | 0
MXKBGrammar/XKBGrammarWalker.g | 46++++++++++++++++------------------------------
MXKBGrammar/check_xkb.py | 4++--
8 files changed, 996 insertions(+), 1098 deletions(-)

diff --git a/XKBGrammar/XKBGrammar.g b/XKBGrammar/XKBGrammar.g @@ -1,6 +1,6 @@ // XKB Grammar (X.org) // Written by Simos Xenitellis <simos.lists@googlemail.com>, 2008. -// Version 0.3 +// Version 0.4 grammar XKBGrammar; @@ -21,7 +21,7 @@ tokens TOKEN_ALTERNATE_GROUP; TOKEN_XKB_SYMBOLS; - // Keywords [TODO: check terminology] + // Keywords TOKEN_INCLUDE; TOKEN_KEY_TYPE; TOKEN_NAME; @@ -29,17 +29,13 @@ tokens // Tokens for tree. MAPTYPE; + MAPNAME; + MAPOPTIONS; MAPMATERIAL; - ATTRIBUTES; - ATTRIBUTE; - INCLUDE; - KEY; - KEYTYPE; - KEYCODE; SECTION; - SECTIONNAME; - QUOTEDSTRING; + KEYCODE; KEYSYMS; + VALUE; } // We cover XKB symbol files that look like @@ -69,16 +65,16 @@ section mapType : mapOptions+ '"' NAME '"' - -> ^(MAPTYPE mapOptions+ NAME) + -> ^(MAPTYPE ^(MAPOPTIONS mapOptions+) ^(MAPNAME NAME)) ; mapMaterial - : '{' + : '{' ( line_include | line_name ';'! | line_keytype ';'! | line_key ';'! - )+ '}' ';' + )+ '}' ';'! ; line_include @@ -88,12 +84,12 @@ line_include line_name : 'name' '[' n1=NAME ']' '=' '"' n2=NAME '"' - -> ^(TOKEN_NAME $n1 $n2) + -> ^(TOKEN_NAME $n1 ^(VALUE $n2)) ; line_keytype : 'key.type' '[' n1=NAME ']' '=' '"' n2=NAME '"' - -> ^(TOKEN_KEY_TYPE $n1 $n2) + -> ^(TOKEN_KEY_TYPE $n1 ^(VALUE $n2)) ; line_key @@ -124,7 +120,6 @@ NAME : ('a'..'z' | 'A'..'Z' | '_' | '-' | '(' | ')' | '0'..'9')* ; -// Comments are currently ignored. WS : ( ' ' | '\r' | '\t' | '\u000C' | '\n') diff --git a/XKBGrammar/XKBGrammar.tokens b/XKBGrammar/XKBGrammar.tokens @@ -1,47 +1,63 @@ -QUOTEDSTRING=25 -TOKEN_ALTERNATE_GROUP=9 -ATTRIBUTES=17 -SECTION=23 -LINE_COMMENT=30 -KEYCODE=22 +T__29=29 +T__28=28 +T__27=27 +MAPOPTIONS=17 TOKEN_INCLUDE=11 -KEY=20 -KEYTYPE=21 -ATTRIBUTE=18 -TOKEN_NAME=13 TOKEN_XKB_SYMBOLS=10 -SECTIONNAME=24 MAPTYPE=15 -NAME=27 TOKEN_PARTIAL=6 -WS=28 -TOKEN_ALPHANUMERIC_KEYS=7 +NAME=23 +MAPMATERIAL=18 +KEYSYMS=21 +COMMENT=25 +TOKEN_DEFAULT=4 +T__42=42 +T__43=43 +TOKEN_ALTERNATE_GROUP=9 +T__40=40 +T__41=41 +T__46=46 +T__44=44 +T__45=45 +SECTION=19 +LINE_COMMENT=26 +KEYCODE=20 +TOKEN_NAME=13 +VALUE=22 +T__30=30 +T__31=31 +T__32=32 +WS=24 +T__33=33 +T__34=34 +T__35=35 TOKEN_HIDDEN=5 -MAPMATERIAL=16 -INCLUDE=19 +TOKEN_ALPHANUMERIC_KEYS=7 +T__36=36 +T__37=37 +T__38=38 +T__39=39 TOKEN_MODIFIER_KEYS=8 -KEYSYMS=26 TOKEN_KEY=14 -COMMENT=29 -TOKEN_DEFAULT=4 +MAPNAME=16 TOKEN_KEY_TYPE=12 -'alphanumeric_keys'=48 -'"'=31 -'}'=34 -'alternate_group'=49 -'key'=41 -'partial'=47 -'{'=32 -'>'=43 -'include'=35 -'hidden'=46 -';'=33 -'='=39 -'key.type'=40 -'<'=42 -'xkb_symbols'=50 -'['=37 -'name'=36 -','=44 -'default'=45 -']'=38 +'alphanumeric_keys'=44 +'"'=27 +'}'=30 +'alternate_group'=45 +'key'=37 +'partial'=43 +'{'=28 +'>'=39 +'include'=31 +'hidden'=42 +';'=29 +'='=35 +'key.type'=36 +'<'=38 +'xkb_symbols'=46 +'['=33 +'name'=32 +','=40 +'default'=41 +']'=34 diff --git a/XKBGrammar/XKBGrammarLexer.py b/XKBGrammar/XKBGrammarLexer.py @@ -1,5 +1,6 @@ -# $ANTLR 3.0.1 XKBGrammar.g 2008-05-14 21:55:39 +# $ANTLR 3.1b1 XKBGrammar.g 2008-05-15 19:18:28 +import sys from antlr3 import * from antlr3.compat import set, frozenset @@ -8,514 +9,574 @@ from antlr3.compat import set, frozenset HIDDEN = BaseRecognizer.HIDDEN # token types -ATTRIBUTES=17 +T__29=29 +T__28=28 +T__27=27 +MAPOPTIONS=17 TOKEN_INCLUDE=11 -ATTRIBUTE=18 TOKEN_XKB_SYMBOLS=10 EOF=-1 -SECTIONNAME=24 MAPTYPE=15 +NAME=23 TOKEN_PARTIAL=6 -NAME=27 -MAPMATERIAL=16 -INCLUDE=19 -T38=38 -KEYSYMS=26 -T37=37 -T39=39 -COMMENT=29 -T34=34 +MAPMATERIAL=18 +KEYSYMS=21 +COMMENT=25 TOKEN_DEFAULT=4 -T33=33 -T36=36 -T35=35 -T32=32 -T31=31 -QUOTEDSTRING=25 +T__42=42 TOKEN_ALTERNATE_GROUP=9 -SECTION=23 -LINE_COMMENT=30 -KEYCODE=22 -KEY=20 -KEYTYPE=21 +T__43=43 +T__40=40 +T__41=41 +T__46=46 +T__44=44 +T__45=45 +SECTION=19 +LINE_COMMENT=26 +KEYCODE=20 TOKEN_NAME=13 -T49=49 -T48=48 -T43=43 -Tokens=51 -T42=42 -T41=41 -T40=40 -T47=47 -T46=46 -T45=45 -T44=44 -WS=28 -TOKEN_ALPHANUMERIC_KEYS=7 +VALUE=22 +T__30=30 +T__31=31 +T__32=32 +WS=24 +T__33=33 +T__34=34 +T__35=35 TOKEN_HIDDEN=5 -T50=50 +TOKEN_ALPHANUMERIC_KEYS=7 +T__36=36 +T__37=37 +T__38=38 +T__39=39 TOKEN_MODIFIER_KEYS=8 +MAPNAME=16 TOKEN_KEY=14 TOKEN_KEY_TYPE=12 + class XKBGrammarLexer(Lexer): grammarFileName = "XKBGrammar.g" - def __init__(self, input=None): - Lexer.__init__(self, input) + def __init__(self, input=None, state=None): + if state is None: + state = RecognizerSharedState() + Lexer.__init__(self, input, state) + + self.dfa5 = self.DFA5( + self, 5, + eot = self.DFA5_eot, + eof = self.DFA5_eof, + min = self.DFA5_min, + max = self.DFA5_max, + accept = self.DFA5_accept, + special = self.DFA5_special, + transition = self.DFA5_transition + ) + - # $ANTLR start T31 - def mT31(self, ): + # $ANTLR start T__27 + def mT__27(self, ): try: - self.type = T31 + _type = T__27 + _channel = DEFAULT_CHANNEL - # XKBGrammar.g:7:5: ( '\"' ) - # XKBGrammar.g:7:7: '\"' - self.match(u'"') + # XKBGrammar.g:7:7: ( '\"' ) + # XKBGrammar.g:7:9: '\"' + self.match(34) + self._state.type = _type + self._state.channel = _channel finally: pass - # $ANTLR end T31 + # $ANTLR end T__27 - # $ANTLR start T32 - def mT32(self, ): + # $ANTLR start T__28 + def mT__28(self, ): try: - self.type = T32 + _type = T__28 + _channel = DEFAULT_CHANNEL - # XKBGrammar.g:8:5: ( '{' ) - # XKBGrammar.g:8:7: '{' - self.match(u'{') + # XKBGrammar.g:8:7: ( '{' ) + # XKBGrammar.g:8:9: '{' + self.match(123) + self._state.type = _type + self._state.channel = _channel finally: pass - # $ANTLR end T32 + # $ANTLR end T__28 - # $ANTLR start T33 - def mT33(self, ): + # $ANTLR start T__29 + def mT__29(self, ): try: - self.type = T33 + _type = T__29 + _channel = DEFAULT_CHANNEL - # XKBGrammar.g:9:5: ( ';' ) - # XKBGrammar.g:9:7: ';' - self.match(u';') + # XKBGrammar.g:9:7: ( ';' ) + # XKBGrammar.g:9:9: ';' + self.match(59) + self._state.type = _type + self._state.channel = _channel finally: pass - # $ANTLR end T33 + # $ANTLR end T__29 - # $ANTLR start T34 - def mT34(self, ): + # $ANTLR start T__30 + def mT__30(self, ): try: - self.type = T34 + _type = T__30 + _channel = DEFAULT_CHANNEL - # XKBGrammar.g:10:5: ( '}' ) - # XKBGrammar.g:10:7: '}' - self.match(u'}') + # XKBGrammar.g:10:7: ( '}' ) + # XKBGrammar.g:10:9: '}' + self.match(125) + self._state.type = _type + self._state.channel = _channel finally: pass - # $ANTLR end T34 + # $ANTLR end T__30 - # $ANTLR start T35 - def mT35(self, ): + # $ANTLR start T__31 + def mT__31(self, ): try: - self.type = T35 + _type = T__31 + _channel = DEFAULT_CHANNEL - # XKBGrammar.g:11:5: ( 'include' ) - # XKBGrammar.g:11:7: 'include' + # XKBGrammar.g:11:7: ( 'include' ) + # XKBGrammar.g:11:9: 'include' self.match("include") - + self._state.type = _type + self._state.channel = _channel finally: pass - # $ANTLR end T35 + # $ANTLR end T__31 - # $ANTLR start T36 - def mT36(self, ): + # $ANTLR start T__32 + def mT__32(self, ): try: - self.type = T36 + _type = T__32 + _channel = DEFAULT_CHANNEL - # XKBGrammar.g:12:5: ( 'name' ) - # XKBGrammar.g:12:7: 'name' + # XKBGrammar.g:12:7: ( 'name' ) + # XKBGrammar.g:12:9: 'name' self.match("name") - + self._state.type = _type + self._state.channel = _channel finally: pass - # $ANTLR end T36 + # $ANTLR end T__32 - # $ANTLR start T37 - def mT37(self, ): + # $ANTLR start T__33 + def mT__33(self, ): try: - self.type = T37 + _type = T__33 + _channel = DEFAULT_CHANNEL - # XKBGrammar.g:13:5: ( '[' ) - # XKBGrammar.g:13:7: '[' - self.match(u'[') + # XKBGrammar.g:13:7: ( '[' ) + # XKBGrammar.g:13:9: '[' + self.match(91) + self._state.type = _type + self._state.channel = _channel finally: pass - # $ANTLR end T37 + # $ANTLR end T__33 - # $ANTLR start T38 - def mT38(self, ): + # $ANTLR start T__34 + def mT__34(self, ): try: - self.type = T38 + _type = T__34 + _channel = DEFAULT_CHANNEL - # XKBGrammar.g:14:5: ( ']' ) - # XKBGrammar.g:14:7: ']' - self.match(u']') + # XKBGrammar.g:14:7: ( ']' ) + # XKBGrammar.g:14:9: ']' + self.match(93) + self._state.type = _type + self._state.channel = _channel finally: pass - # $ANTLR end T38 + # $ANTLR end T__34 - # $ANTLR start T39 - def mT39(self, ): + # $ANTLR start T__35 + def mT__35(self, ): try: - self.type = T39 + _type = T__35 + _channel = DEFAULT_CHANNEL - # XKBGrammar.g:15:5: ( '=' ) - # XKBGrammar.g:15:7: '=' - self.match(u'=') + # XKBGrammar.g:15:7: ( '=' ) + # XKBGrammar.g:15:9: '=' + self.match(61) + self._state.type = _type + self._state.channel = _channel finally: pass - # $ANTLR end T39 + # $ANTLR end T__35 - # $ANTLR start T40 - def mT40(self, ): + # $ANTLR start T__36 + def mT__36(self, ): try: - self.type = T40 + _type = T__36 + _channel = DEFAULT_CHANNEL - # XKBGrammar.g:16:5: ( 'key.type' ) - # XKBGrammar.g:16:7: 'key.type' + # XKBGrammar.g:16:7: ( 'key.type' ) + # XKBGrammar.g:16:9: 'key.type' self.match("key.type") - + self._state.type = _type + self._state.channel = _channel finally: pass - # $ANTLR end T40 + # $ANTLR end T__36 - # $ANTLR start T41 - def mT41(self, ): + # $ANTLR start T__37 + def mT__37(self, ): try: - self.type = T41 + _type = T__37 + _channel = DEFAULT_CHANNEL - # XKBGrammar.g:17:5: ( 'key' ) - # XKBGrammar.g:17:7: 'key' + # XKBGrammar.g:17:7: ( 'key' ) + # XKBGrammar.g:17:9: 'key' self.match("key") - + self._state.type = _type + self._state.channel = _channel finally: pass - # $ANTLR end T41 + # $ANTLR end T__37 - # $ANTLR start T42 - def mT42(self, ): + # $ANTLR start T__38 + def mT__38(self, ): try: - self.type = T42 + _type = T__38 + _channel = DEFAULT_CHANNEL - # XKBGrammar.g:18:5: ( '<' ) - # XKBGrammar.g:18:7: '<' - self.match(u'<') + # XKBGrammar.g:18:7: ( '<' ) + # XKBGrammar.g:18:9: '<' + self.match(60) + self._state.type = _type + self._state.channel = _channel finally: pass - # $ANTLR end T42 + # $ANTLR end T__38 - # $ANTLR start T43 - def mT43(self, ): + # $ANTLR start T__39 + def mT__39(self, ): try: - self.type = T43 + _type = T__39 + _channel = DEFAULT_CHANNEL - # XKBGrammar.g:19:5: ( '>' ) - # XKBGrammar.g:19:7: '>' - self.match(u'>') + # XKBGrammar.g:19:7: ( '>' ) + # XKBGrammar.g:19:9: '>' + self.match(62) + self._state.type = _type + self._state.channel = _channel finally: pass - # $ANTLR end T43 + # $ANTLR end T__39 - # $ANTLR start T44 - def mT44(self, ): + # $ANTLR start T__40 + def mT__40(self, ): try: - self.type = T44 + _type = T__40 + _channel = DEFAULT_CHANNEL - # XKBGrammar.g:20:5: ( ',' ) - # XKBGrammar.g:20:7: ',' - self.match(u',') + # XKBGrammar.g:20:7: ( ',' ) + # XKBGrammar.g:20:9: ',' + self.match(44) + self._state.type = _type + self._state.channel = _channel finally: pass - # $ANTLR end T44 + # $ANTLR end T__40 - # $ANTLR start T45 - def mT45(self, ): + # $ANTLR start T__41 + def mT__41(self, ): try: - self.type = T45 + _type = T__41 + _channel = DEFAULT_CHANNEL - # XKBGrammar.g:21:5: ( 'default' ) - # XKBGrammar.g:21:7: 'default' + # XKBGrammar.g:21:7: ( 'default' ) + # XKBGrammar.g:21:9: 'default' self.match("default") - + self._state.type = _type + self._state.channel = _channel finally: pass - # $ANTLR end T45 + # $ANTLR end T__41 - # $ANTLR start T46 - def mT46(self, ): + # $ANTLR start T__42 + def mT__42(self, ): try: - self.type = T46 + _type = T__42 + _channel = DEFAULT_CHANNEL - # XKBGrammar.g:22:5: ( 'hidden' ) - # XKBGrammar.g:22:7: 'hidden' + # XKBGrammar.g:22:7: ( 'hidden' ) + # XKBGrammar.g:22:9: 'hidden' self.match("hidden") - + self._state.type = _type + self._state.channel = _channel finally: pass - # $ANTLR end T46 + # $ANTLR end T__42 - # $ANTLR start T47 - def mT47(self, ): + # $ANTLR start T__43 + def mT__43(self, ): try: - self.type = T47 + _type = T__43 + _channel = DEFAULT_CHANNEL - # XKBGrammar.g:23:5: ( 'partial' ) - # XKBGrammar.g:23:7: 'partial' + # XKBGrammar.g:23:7: ( 'partial' ) + # XKBGrammar.g:23:9: 'partial' self.match("partial") - + self._state.type = _type + self._state.channel = _channel finally: pass - # $ANTLR end T47 + # $ANTLR end T__43 - # $ANTLR start T48 - def mT48(self, ): + # $ANTLR start T__44 + def mT__44(self, ): try: - self.type = T48 + _type = T__44 + _channel = DEFAULT_CHANNEL - # XKBGrammar.g:24:5: ( 'alphanumeric_keys' ) - # XKBGrammar.g:24:7: 'alphanumeric_keys' + # XKBGrammar.g:24:7: ( 'alphanumeric_keys' ) + # XKBGrammar.g:24:9: 'alphanumeric_keys' self.match("alphanumeric_keys") - + self._state.type = _type + self._state.channel = _channel finally: pass - # $ANTLR end T48 + # $ANTLR end T__44 - # $ANTLR start T49 - def mT49(self, ): + # $ANTLR start T__45 + def mT__45(self, ): try: - self.type = T49 + _type = T__45 + _channel = DEFAULT_CHANNEL - # XKBGrammar.g:25:5: ( 'alternate_group' ) - # XKBGrammar.g:25:7: 'alternate_group' + # XKBGrammar.g:25:7: ( 'alternate_group' ) + # XKBGrammar.g:25:9: 'alternate_group' self.match("alternate_group") - + self._state.type = _type + self._state.channel = _channel finally: pass - # $ANTLR end T49 + # $ANTLR end T__45 - # $ANTLR start T50 - def mT50(self, ): + # $ANTLR start T__46 + def mT__46(self, ): try: - self.type = T50 + _type = T__46 + _channel = DEFAULT_CHANNEL - # XKBGrammar.g:26:5: ( 'xkb_symbols' ) - # XKBGrammar.g:26:7: 'xkb_symbols' + # XKBGrammar.g:26:7: ( 'xkb_symbols' ) + # XKBGrammar.g:26:9: 'xkb_symbols' self.match("xkb_symbols") - + self._state.type = _type + self._state.channel = _channel finally: pass - # $ANTLR end T50 + # $ANTLR end T__46 @@ -523,24 +584,24 @@ class XKBGrammarLexer(Lexer): def mNAME(self, ): try: - self.type = NAME + _type = NAME + _channel = DEFAULT_CHANNEL - # XKBGrammar.g:124:2: ( ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '-' | '(' | ')' | '0' .. '9' )* ) - # XKBGrammar.g:124:4: ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '-' | '(' | ')' | '0' .. '9' )* - # XKBGrammar.g:124:4: ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '-' | '(' | ')' | '0' .. '9' )* + # XKBGrammar.g:120:2: ( ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '-' | '(' | ')' | '0' .. '9' )* ) + # XKBGrammar.g:120:4: ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '-' | '(' | ')' | '0' .. '9' )* + # XKBGrammar.g:120:4: ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '-' | '(' | ')' | '0' .. '9' )* while True: #loop1 alt1 = 2 LA1_0 = self.input.LA(1) - if ((u'(' <= LA1_0 <= u')') or LA1_0 == u'-' or (u'0' <= LA1_0 <= u'9') or (u'A' <= LA1_0 <= u'Z') or LA1_0 == u'_' or (u'a' <= LA1_0 <= u'z')) : + if ((40 <= LA1_0 <= 41) or LA1_0 == 45 or (48 <= LA1_0 <= 57) or (65 <= LA1_0 <= 90) or LA1_0 == 95 or (97 <= LA1_0 <= 122)) : alt1 = 1 if alt1 == 1: # XKBGrammar.g: - if (u'(' <= self.input.LA(1) <= u')') or self.input.LA(1) == u'-' or (u'0' <= self.input.LA(1) <= u'9') or (u'A' <= self.input.LA(1) <= u'Z') or self.input.LA(1) == u'_' or (u'a' <= self.input.LA(1) <= u'z'): + if (40 <= self.input.LA(1) <= 41) or self.input.LA(1) == 45 or (48 <= self.input.LA(1) <= 57) or (65 <= self.input.LA(1) <= 90) or self.input.LA(1) == 95 or (97 <= self.input.LA(1) <= 122): self.input.consume(); - else: mse = MismatchedSetException(None, self.input) self.recover(mse) @@ -548,7 +609,6 @@ class XKBGrammarLexer(Lexer): - else: break #loop1 @@ -557,6 +617,9 @@ class XKBGrammarLexer(Lexer): + self._state.type = _type + self._state.channel = _channel + finally: pass @@ -569,26 +632,28 @@ class XKBGrammarLexer(Lexer): def mWS(self, ): try: - self.type = WS + _type = WS + _channel = DEFAULT_CHANNEL - # XKBGrammar.g:129:2: ( ( ' ' | '\\r' | '\\t' | '\\u000C' | '\\n' ) ) - # XKBGrammar.g:130:2: ( ' ' | '\\r' | '\\t' | '\\u000C' | '\\n' ) - if (u'\t' <= self.input.LA(1) <= u'\n') or (u'\f' <= self.input.LA(1) <= u'\r') or self.input.LA(1) == u' ': + # XKBGrammar.g:124:2: ( ( ' ' | '\\r' | '\\t' | '\\u000C' | '\\n' ) ) + # XKBGrammar.g:125:2: ( ' ' | '\\r' | '\\t' | '\\u000C' | '\\n' ) + if (9 <= self.input.LA(1) <= 10) or (12 <= self.input.LA(1) <= 13) or self.input.LA(1) == 32: self.input.consume(); - else: mse = MismatchedSetException(None, self.input) self.recover(mse) raise mse - #action start - self.channel=HIDDEN; + _channel=HIDDEN; #action end + self._state.type = _type + self._state.channel = _channel + finally: pass @@ -601,33 +666,32 @@ class XKBGrammarLexer(Lexer): def mCOMMENT(self, ): try: - self.type = COMMENT + _type = COMMENT + _channel = DEFAULT_CHANNEL - # XKBGrammar.g:135:6: ( '/*' ( . )* '*/' ) - # XKBGrammar.g:136:2: '/*' ( . )* '*/' + # XKBGrammar.g:130:6: ( '/*' ( . )* '*/' ) + # XKBGrammar.g:131:2: '/*' ( . )* '*/' self.match("/*") - - - # XKBGrammar.g:136:7: ( . )* + # XKBGrammar.g:131:7: ( . )* while True: #loop2 alt2 = 2 LA2_0 = self.input.LA(1) - if (LA2_0 == u'*') : + if (LA2_0 == 42) : LA2_1 = self.input.LA(2) - if (LA2_1 == u'/') : + if (LA2_1 == 47) : alt2 = 2 - elif ((u'\u0000' <= LA2_1 <= u'.') or (u'0' <= LA2_1 <= u'\uFFFE')) : + elif ((0 <= LA2_1 <= 46) or (48 <= LA2_1 <= 65534)) : alt2 = 1 - elif ((u'\u0000' <= LA2_0 <= u')') or (u'+' <= LA2_0 <= u'\uFFFE')) : + elif ((0 <= LA2_0 <= 41) or (43 <= LA2_0 <= 65534)) : alt2 = 1 if alt2 == 1: - # XKBGrammar.g:136:7: . + # XKBGrammar.g:131:7: . self.matchAny() @@ -637,15 +701,16 @@ class XKBGrammarLexer(Lexer): self.match("*/") - - #action start - self.channel=HIDDEN; + _channel=HIDDEN; #action end + self._state.type = _type + self._state.channel = _channel + finally: pass @@ -658,27 +723,25 @@ class XKBGrammarLexer(Lexer): def mLINE_COMMENT(self, ): try: - self.type = LINE_COMMENT + _type = LINE_COMMENT + _channel = DEFAULT_CHANNEL - # XKBGrammar.g:140:6: ( '//' (~ ( '\\n' | '\\r' ) )* ( '\\r' )? '\\n' ) - # XKBGrammar.g:141:2: '//' (~ ( '\\n' | '\\r' ) )* ( '\\r' )? '\\n' + # XKBGrammar.g:135:6: ( '//' (~ ( '\\n' | '\\r' ) )* ( '\\r' )? '\\n' ) + # XKBGrammar.g:136:2: '//' (~ ( '\\n' | '\\r' ) )* ( '\\r' )? '\\n' self.match("//") - - - # XKBGrammar.g:141:7: (~ ( '\\n' | '\\r' ) )* + # XKBGrammar.g:136:7: (~ ( '\\n' | '\\r' ) )* while True: #loop3 alt3 = 2 LA3_0 = self.input.LA(1) - if ((u'\u0000' <= LA3_0 <= u'\t') or (u'\u000B' <= LA3_0 <= u'\f') or (u'\u000E' <= LA3_0 <= u'\uFFFE')) : + if ((0 <= LA3_0 <= 9) or (11 <= LA3_0 <= 12) or (14 <= LA3_0 <= 65534)) : alt3 = 1 if alt3 == 1: - # XKBGrammar.g:141:7: ~ ( '\\n' | '\\r' ) - if (u'\u0000' <= self.input.LA(1) <= u'\t') or (u'\u000B' <= self.input.LA(1) <= u'\f') or (u'\u000E' <= self.input.LA(1) <= u'\uFFFE'): + # XKBGrammar.g:136:7: ~ ( '\\n' | '\\r' ) + if (0 <= self.input.LA(1) <= 9) or (11 <= self.input.LA(1) <= 12) or (14 <= self.input.LA(1) <= 65534): self.input.consume(); - else: mse = MismatchedSetException(None, self.input) self.recover(mse) @@ -691,28 +754,30 @@ class XKBGrammarLexer(Lexer): break #loop3 - # XKBGrammar.g:141:23: ( '\\r' )? + # XKBGrammar.g:136:23: ( '\\r' )? alt4 = 2 LA4_0 = self.input.LA(1) - if (LA4_0 == u'\r') : + if (LA4_0 == 13) : alt4 = 1 if alt4 == 1: - # XKBGrammar.g:141:23: '\\r' - self.match(u'\r') - + # XKBGrammar.g:136:23: '\\r' + self.match(13) - self.match(u'\n') + self.match(10) #action start - self.channel=HIDDEN; + _channel=HIDDEN; #action end + self._state.type = _type + self._state.channel = _channel + finally: pass @@ -722,578 +787,149 @@ class XKBGrammarLexer(Lexer): def mTokens(self): - # XKBGrammar.g:1:8: ( T31 | T32 | T33 | T34 | T35 | T36 | T37 | T38 | T39 | T40 | T41 | T42 | T43 | T44 | T45 | T46 | T47 | T48 | T49 | T50 | NAME | WS | COMMENT | LINE_COMMENT ) + # XKBGrammar.g:1:8: ( T__27 | T__28 | T__29 | T__30 | T__31 | T__32 | T__33 | T__34 | T__35 | T__36 | T__37 | T__38 | T__39 | T__40 | T__41 | T__42 | T__43 | T__44 | T__45 | T__46 | NAME | WS | COMMENT | LINE_COMMENT ) alt5 = 24 - LA5 = self.input.LA(1) - if LA5 == u'"': - alt5 = 1 - elif LA5 == u'{': - alt5 = 2 - elif LA5 == u';': - alt5 = 3 - elif LA5 == u'}': - alt5 = 4 - elif LA5 == u'i': - LA5_5 = self.input.LA(2) - - if (LA5_5 == u'n') : - LA5_22 = self.input.LA(3) - - if (LA5_22 == u'c') : - LA5_32 = self.input.LA(4) - - if (LA5_32 == u'l') : - LA5_41 = self.input.LA(5) - - if (LA5_41 == u'u') : - LA5_51 = self.input.LA(6) - - if (LA5_51 == u'd') : - LA5_59 = self.input.LA(7) - - if (LA5_59 == u'e') : - LA5_66 = self.input.LA(8) - - if ((u'(' <= LA5_66 <= u')') or LA5_66 == u'-' or (u'0' <= LA5_66 <= u'9') or (u'A' <= LA5_66 <= u'Z') or LA5_66 == u'_' or (u'a' <= LA5_66 <= u'z')) : - alt5 = 21 - else: - alt5 = 5 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - elif LA5 == u'n': - LA5_6 = self.input.LA(2) - - if (LA5_6 == u'a') : - LA5_23 = self.input.LA(3) - - if (LA5_23 == u'm') : - LA5_33 = self.input.LA(4) - - if (LA5_33 == u'e') : - LA5_42 = self.input.LA(5) - - if ((u'(' <= LA5_42 <= u')') or LA5_42 == u'-' or (u'0' <= LA5_42 <= u'9') or (u'A' <= LA5_42 <= u'Z') or LA5_42 == u'_' or (u'a' <= LA5_42 <= u'z')) : - alt5 = 21 - else: - alt5 = 6 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - elif LA5 == u'[': - alt5 = 7 - elif LA5 == u']': - alt5 = 8 - elif LA5 == u'=': - alt5 = 9 - elif LA5 == u'k': - LA5_10 = self.input.LA(2) - - if (LA5_10 == u'e') : - LA5_24 = self.input.LA(3) - - if (LA5_24 == u'y') : - LA5 = self.input.LA(4) - if LA5 == u'.': - alt5 = 10 - elif LA5 == u'(' or LA5 == u')' or LA5 == u'-' or LA5 == u'0' or LA5 == u'1' or LA5 == u'2' or LA5 == u'3' or LA5 == u'4' or LA5 == u'5' or LA5 == u'6' or LA5 == u'7' or LA5 == u'8' or LA5 == u'9' or LA5 == u'A' or LA5 == u'B' or LA5 == u'C' or LA5 == u'D' or LA5 == u'E' or LA5 == u'F' or LA5 == u'G' or LA5 == u'H' or LA5 == u'I' or LA5 == u'J' or LA5 == u'K' or LA5 == u'L' or LA5 == u'M' or LA5 == u'N' or LA5 == u'O' or LA5 == u'P' or LA5 == u'Q' or LA5 == u'R' or LA5 == u'S' or LA5 == u'T' or LA5 == u'U' or LA5 == u'V' or LA5 == u'W' or LA5 == u'X' or LA5 == u'Y' or LA5 == u'Z' or LA5 == u'_' or LA5 == u'a' or LA5 == u'b' or LA5 == u'c' or LA5 == u'd' or LA5 == u'e' or LA5 == u'f' or LA5 == u'g' or LA5 == u'h' or LA5 == u'i' or LA5 == u'j' or LA5 == u'k' or LA5 == u'l' or LA5 == u'm' or LA5 == u'n' or LA5 == u'o' or LA5 == u'p' or LA5 == u'q' or LA5 == u'r' or LA5 == u's' or LA5 == u't' or LA5 == u'u' or LA5 == u'v' or LA5 == u'w' or LA5 == u'x' or LA5 == u'y' or LA5 == u'z': - alt5 = 21 - else: - alt5 = 11 - else: - alt5 = 21 - else: - alt5 = 21 - elif LA5 == u'<': - alt5 = 12 - elif LA5 == u'>': - alt5 = 13 - elif LA5 == u',': - alt5 = 14 - elif LA5 == u'd': - LA5_14 = self.input.LA(2) - - if (LA5_14 == u'e') : - LA5_25 = self.input.LA(3) - - if (LA5_25 == u'f') : - LA5_35 = self.input.LA(4) - - if (LA5_35 == u'a') : - LA5_45 = self.input.LA(5) - - if (LA5_45 == u'u') : - LA5_53 = self.input.LA(6) - - if (LA5_53 == u'l') : - LA5_60 = self.input.LA(7) - - if (LA5_60 == u't') : - LA5_67 = self.input.LA(8) - - if ((u'(' <= LA5_67 <= u')') or LA5_67 == u'-' or (u'0' <= LA5_67 <= u'9') or (u'A' <= LA5_67 <= u'Z') or LA5_67 == u'_' or (u'a' <= LA5_67 <= u'z')) : - alt5 = 21 - else: - alt5 = 15 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - elif LA5 == u'h': - LA5_15 = self.input.LA(2) - - if (LA5_15 == u'i') : - LA5_26 = self.input.LA(3) - - if (LA5_26 == u'd') : - LA5_36 = self.input.LA(4) - - if (LA5_36 == u'd') : - LA5_46 = self.input.LA(5) - - if (LA5_46 == u'e') : - LA5_54 = self.input.LA(6) - - if (LA5_54 == u'n') : - LA5_61 = self.input.LA(7) - - if ((u'(' <= LA5_61 <= u')') or LA5_61 == u'-' or (u'0' <= LA5_61 <= u'9') or (u'A' <= LA5_61 <= u'Z') or LA5_61 == u'_' or (u'a' <= LA5_61 <= u'z')) : - alt5 = 21 - else: - alt5 = 16 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - elif LA5 == u'p': - LA5_16 = self.input.LA(2) - - if (LA5_16 == u'a') : - LA5_27 = self.input.LA(3) - - if (LA5_27 == u'r') : - LA5_37 = self.input.LA(4) - - if (LA5_37 == u't') : - LA5_47 = self.input.LA(5) - - if (LA5_47 == u'i') : - LA5_55 = self.input.LA(6) - - if (LA5_55 == u'a') : - LA5_62 = self.input.LA(7) - - if (LA5_62 == u'l') : - LA5_69 = self.input.LA(8) - - if ((u'(' <= LA5_69 <= u')') or LA5_69 == u'-' or (u'0' <= LA5_69 <= u'9') or (u'A' <= LA5_69 <= u'Z') or LA5_69 == u'_' or (u'a' <= LA5_69 <= u'z')) : - alt5 = 21 - else: - alt5 = 17 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - elif LA5 == u'a': - LA5_17 = self.input.LA(2) - - if (LA5_17 == u'l') : - LA5 = self.input.LA(3) - if LA5 == u'p': - LA5_38 = self.input.LA(4) - - if (LA5_38 == u'h') : - LA5_48 = self.input.LA(5) - - if (LA5_48 == u'a') : - LA5_56 = self.input.LA(6) - - if (LA5_56 == u'n') : - LA5_63 = self.input.LA(7) - - if (LA5_63 == u'u') : - LA5_70 = self.input.LA(8) - - if (LA5_70 == u'm') : - LA5_76 = self.input.LA(9) - - if (LA5_76 == u'e') : - LA5_79 = self.input.LA(10) - - if (LA5_79 == u'r') : - LA5_82 = self.input.LA(11) - - if (LA5_82 == u'i') : - LA5_85 = self.input.LA(12) - - if (LA5_85 == u'c') : - LA5_88 = self.input.LA(13) - - if (LA5_88 == u'_') : - LA5_91 = self.input.LA(14) - - if (LA5_91 == u'k') : - LA5_93 = self.input.LA(15) - - if (LA5_93 == u'e') : - LA5_95 = self.input.LA(16) - - if (LA5_95 == u'y') : - LA5_97 = self.input.LA(17) - - if (LA5_97 == u's') : - LA5_99 = self.input.LA(18) - - if ((u'(' <= LA5_99 <= u')') or LA5_99 == u'-' or (u'0' <= LA5_99 <= u'9') or (u'A' <= LA5_99 <= u'Z') or LA5_99 == u'_' or (u'a' <= LA5_99 <= u'z')) : - alt5 = 21 - else: - alt5 = 18 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - elif LA5 == u't': - LA5_39 = self.input.LA(4) - - if (LA5_39 == u'e') : - LA5_49 = self.input.LA(5) - - if (LA5_49 == u'r') : - LA5_57 = self.input.LA(6) - - if (LA5_57 == u'n') : - LA5_64 = self.input.LA(7) - - if (LA5_64 == u'a') : - LA5_71 = self.input.LA(8) - - if (LA5_71 == u't') : - LA5_77 = self.input.LA(9) - - if (LA5_77 == u'e') : - LA5_80 = self.input.LA(10) - - if (LA5_80 == u'_') : - LA5_83 = self.input.LA(11) - - if (LA5_83 == u'g') : - LA5_86 = self.input.LA(12) - - if (LA5_86 == u'r') : - LA5_89 = self.input.LA(13) - - if (LA5_89 == u'o') : - LA5_92 = self.input.LA(14) - - if (LA5_92 == u'u') : - LA5_94 = self.input.LA(15) - - if (LA5_94 == u'p') : - LA5_96 = self.input.LA(16) - - if ((u'(' <= LA5_96 <= u')') or LA5_96 == u'-' or (u'0' <= LA5_96 <= u'9') or (u'A' <= LA5_96 <= u'Z') or LA5_96 == u'_' or (u'a' <= LA5_96 <= u'z')) : - alt5 = 21 - else: - alt5 = 19 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - elif LA5 == u'x': - LA5_18 = self.input.LA(2) - - if (LA5_18 == u'k') : - LA5_29 = self.input.LA(3) - - if (LA5_29 == u'b') : - LA5_40 = self.input.LA(4) - - if (LA5_40 == u'_') : - LA5_50 = self.input.LA(5) - - if (LA5_50 == u's') : - LA5_58 = self.input.LA(6) - - if (LA5_58 == u'y') : - LA5_65 = self.input.LA(7) - - if (LA5_65 == u'm') : - LA5_72 = self.input.LA(8) - - if (LA5_72 == u'b') : - LA5_78 = self.input.LA(9) - - if (LA5_78 == u'o') : - LA5_81 = self.input.LA(10) - - if (LA5_81 == u'l') : - LA5_84 = self.input.LA(11) - - if (LA5_84 == u's') : - LA5_87 = self.input.LA(12) - - if ((u'(' <= LA5_87 <= u')') or LA5_87 == u'-' or (u'0' <= LA5_87 <= u'9') or (u'A' <= LA5_87 <= u'Z') or LA5_87 == u'_' or (u'a' <= LA5_87 <= u'z')) : - alt5 = 21 - else: - alt5 = 20 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - else: - alt5 = 21 - elif LA5 == u'\t' or LA5 == u'\n' or LA5 == u'\f' or LA5 == u'\r' or LA5 == u' ': - alt5 = 22 - elif LA5 == u'/': - LA5_21 = self.input.LA(2) - - if (LA5_21 == u'/') : - alt5 = 24 - elif (LA5_21 == u'*') : - alt5 = 23 - else: - nvae = NoViableAltException("1:1: Tokens : ( T31 | T32 | T33 | T34 | T35 | T36 | T37 | T38 | T39 | T40 | T41 | T42 | T43 | T44 | T45 | T46 | T47 | T48 | T49 | T50 | NAME | WS | COMMENT | LINE_COMMENT );", 5, 21, self.input) - - raise nvae - - else: - alt5 = 21 + alt5 = self.dfa5.predict(self.input) if alt5 == 1: - # XKBGrammar.g:1:10: T31 - self.mT31() + # XKBGrammar.g:1:10: T__27 + self.mT__27() elif alt5 == 2: - # XKBGrammar.g:1:14: T32 - self.mT32() + # XKBGrammar.g:1:16: T__28 + self.mT__28() elif alt5 == 3: - # XKBGrammar.g:1:18: T33 - self.mT33() + # XKBGrammar.g:1:22: T__29 + self.mT__29() elif alt5 == 4: - # XKBGrammar.g:1:22: T34 - self.mT34() + # XKBGrammar.g:1:28: T__30 + self.mT__30() elif alt5 == 5: - # XKBGrammar.g:1:26: T35 - self.mT35() + # XKBGrammar.g:1:34: T__31 + self.mT__31() elif alt5 == 6: - # XKBGrammar.g:1:30: T36 - self.mT36() + # XKBGrammar.g:1:40: T__32 + self.mT__32() elif alt5 == 7: - # XKBGrammar.g:1:34: T37 - self.mT37() + # XKBGrammar.g:1:46: T__33 + self.mT__33() elif alt5 == 8: - # XKBGrammar.g:1:38: T38 - self.mT38() + # XKBGrammar.g:1:52: T__34 + self.mT__34() elif alt5 == 9: - # XKBGrammar.g:1:42: T39 - self.mT39() + # XKBGrammar.g:1:58: T__35 + self.mT__35() elif alt5 == 10: - # XKBGrammar.g:1:46: T40 - self.mT40() + # XKBGrammar.g:1:64: T__36 + self.mT__36() elif alt5 == 11: - # XKBGrammar.g:1:50: T41 - self.mT41() + # XKBGrammar.g:1:70: T__37 + self.mT__37() elif alt5 == 12: - # XKBGrammar.g:1:54: T42 - self.mT42() + # XKBGrammar.g:1:76: T__38 + self.mT__38() elif alt5 == 13: - # XKBGrammar.g:1:58: T43 - self.mT43() + # XKBGrammar.g:1:82: T__39 + self.mT__39() elif alt5 == 14: - # XKBGrammar.g:1:62: T44 - self.mT44() + # XKBGrammar.g:1:88: T__40 + self.mT__40() elif alt5 == 15: - # XKBGrammar.g:1:66: T45 - self.mT45() + # XKBGrammar.g:1:94: T__41 + self.mT__41() elif alt5 == 16: - # XKBGrammar.g:1:70: T46 - self.mT46() + # XKBGrammar.g:1:100: T__42 + self.mT__42() elif alt5 == 17: - # XKBGrammar.g:1:74: T47 - self.mT47() + # XKBGrammar.g:1:106: T__43 + self.mT__43() elif alt5 == 18: - # XKBGrammar.g:1:78: T48 - self.mT48() + # XKBGrammar.g:1:112: T__44 + self.mT__44() elif alt5 == 19: - # XKBGrammar.g:1:82: T49 - self.mT49() + # XKBGrammar.g:1:118: T__45 + self.mT__45() elif alt5 == 20: - # XKBGrammar.g:1:86: T50 - self.mT50() + # XKBGrammar.g:1:124: T__46 + self.mT__46() elif alt5 == 21: - # XKBGrammar.g:1:90: NAME + # XKBGrammar.g:1:130: NAME self.mNAME() elif alt5 == 22: - # XKBGrammar.g:1:95: WS + # XKBGrammar.g:1:135: WS self.mWS() elif alt5 == 23: - # XKBGrammar.g:1:98: COMMENT + # XKBGrammar.g:1:138: COMMENT self.mCOMMENT() elif alt5 == 24: - # XKBGrammar.g:1:106: LINE_COMMENT + # XKBGrammar.g:1:146: LINE_COMMENT self.mLINE_COMMENT() @@ -1303,5 +939,185 @@ class XKBGrammarLexer(Lexer): + # lookup tables for DFA #5 + + DFA5_eot = DFA.unpack( + u"\1\23\4\uffff\2\23\3\uffff\1\23\3\uffff\5\23\3\uffff\10\23\2\uffff" + u"\2\23\1\54\7\23\1\64\2\uffff\7\23\1\uffff\10\23\1\104\4\23\1\111" + u"\1\112\1\uffff\1\113\3\23\3\uffff\13\23\1\132\2\23\1\uffff\5\23" + u"\1\142\1\23\1\uffff\1\144\1\uffff" + ) + + DFA5_eof = DFA.unpack( + u"\145\uffff" + ) + + DFA5_min = DFA.unpack( + u"\1\11\4\uffff\1\156\1\141\3\uffff\1\145\3\uffff\1\145\1\151\1\141" + u"\1\154\1\153\2\uffff\1\52\1\143\1\155\1\171\1\146\1\144\1\162\1" + u"\160\1\142\2\uffff\1\154\1\145\1\50\1\141\1\144\1\164\1\150\1\145" + u"\1\137\1\165\1\50\2\uffff\1\165\1\145\1\151\1\141\1\162\1\163\1" + u"\144\1\uffff\1\154\1\156\1\141\2\156\1\171\1\145\1\164\1\50\1\154" + u"\1\165\1\141\1\155\2\50\1\uffff\1\50\1\155\1\164\1\142\3\uffff" + u"\2\145\1\157\1\162\1\137\1\154\1\151\1\147\1\163\1\143\1\162\1" + u"\50\1\137\1\157\1\uffff\1\153\1\165\1\145\1\160\1\171\1\50\1\163" + u"\1\uffff\1\50\1\uffff" + ) + + DFA5_max = DFA.unpack( + u"\1\175\4\uffff\1\156\1\141\3\uffff\1\145\3\uffff\1\145\1\151\1" + u"\141\1\154\1\153\2\uffff\1\57\1\143\1\155\1\171\1\146\1\144\1\162" + u"\1\164\1\142\2\uffff\1\154\1\145\1\172\1\141\1\144\1\164\1\150" + u"\1\145\1\137\1\165\1\172\2\uffff\1\165\1\145\1\151\1\141\1\162" + u"\1\163\1\144\1\uffff\1\154\1\156\1\141\2\156\1\171\1\145\1\164" + u"\1\172\1\154\1\165\1\141\1\155\2\172\1\uffff\1\172\1\155\1\164" + u"\1\142\3\uffff\2\145\1\157\1\162\1\137\1\154\1\151\1\147\1\163" + u"\1\143\1\162\1\172\1\137\1\157\1\uffff\1\153\1\165\1\145\1\160" + u"\1\171\1\172\1\163\1\uffff\1\172\1\uffff" + ) + + DFA5_accept = DFA.unpack( + u"\1\uffff\1\1\1\2\1\3\1\4\2\uffff\1\7\1\10\1\11\1\uffff\1\14\1\15" + u"\1\16\5\uffff\1\25\1\26\11\uffff\1\27\1\30\13\uffff\1\12\1\13\7" + u"\uffff\1\6\17\uffff\1\20\4\uffff\1\5\1\17\1\21\16\uffff\1\24\7" + u"\uffff\1\23\1\uffff\1\22" + ) + + DFA5_special = DFA.unpack( + u"\145\uffff" + ) + + + DFA5_transition = [ + DFA.unpack(u"\2\24\1\uffff\2\24\22\uffff\1\24\1\uffff\1\1\11\uffff" + u"\1\15\2\uffff\1\25\13\uffff\1\3\1\13\1\11\1\14\34\uffff\1\7\1\uffff" + u"\1\10\3\uffff\1\21\2\uffff\1\16\3\uffff\1\17\1\5\1\uffff\1\12\2" + u"\uffff\1\6\1\uffff\1\20\7\uffff\1\22\2\uffff\1\2\1\uffff\1\4"), + DFA.unpack(u""), + DFA.unpack(u""), + DFA.unpack(u""), + DFA.unpack(u""), + DFA.unpack(u"\1\26"), + DFA.unpack(u"\1\27"), + DFA.unpack(u""), + DFA.unpack(u""), + DFA.unpack(u""), + DFA.unpack(u"\1\30"), + DFA.unpack(u""), + DFA.unpack(u""), + DFA.unpack(u""), + DFA.unpack(u"\1\31"), + DFA.unpack(u"\1\32"), + DFA.unpack(u"\1\33"), + DFA.unpack(u"\1\34"), + DFA.unpack(u"\1\35"), + DFA.unpack(u""), + DFA.unpack(u""), + DFA.unpack(u"\1\36\4\uffff\1\37"), + DFA.unpack(u"\1\40"), + DFA.unpack(u"\1\41"), + DFA.unpack(u"\1\42"), + DFA.unpack(u"\1\43"), + DFA.unpack(u"\1\44"), + DFA.unpack(u"\1\45"), + DFA.unpack(u"\1\46\3\uffff\1\47"), + DFA.unpack(u"\1\50"), + DFA.unpack(u""), + DFA.unpack(u""), + DFA.unpack(u"\1\51"), + DFA.unpack(u"\1\52"), + DFA.unpack(u"\2\23\3\uffff\1\23\1\53\1\uffff\12\23\7\uffff\32\23" + u"\4\uffff\1\23\1\uffff\32\23"), + DFA.unpack(u"\1\55"), + DFA.unpack(u"\1\56"), + DFA.unpack(u"\1\57"), + DFA.unpack(u"\1\60"), + DFA.unpack(u"\1\61"), + DFA.unpack(u"\1\62"), + DFA.unpack(u"\1\63"), + DFA.unpack(u"\2\23\3\uffff\1\23\2\uffff\12\23\7\uffff\32\23\4\uffff" + u"\1\23\1\uffff\32\23"), + DFA.unpack(u""), + DFA.unpack(u""), + DFA.unpack(u"\1\65"), + DFA.unpack(u"\1\66"), + DFA.unpack(u"\1\67"), + DFA.unpack(u"\1\70"), + DFA.unpack(u"\1\71"), + DFA.unpack(u"\1\72"), + DFA.unpack(u"\1\73"), + DFA.unpack(u""), + DFA.unpack(u"\1\74"), + DFA.unpack(u"\1\75"), + DFA.unpack(u"\1\76"), + DFA.unpack(u"\1\77"), + DFA.unpack(u"\1\100"), + DFA.unpack(u"\1\101"), + DFA.unpack(u"\1\102"), + DFA.unpack(u"\1\103"), + DFA.unpack(u"\2\23\3\uffff\1\23\2\uffff\12\23\7\uffff\32\23\4\uffff" + u"\1\23\1\uffff\32\23"), + DFA.unpack(u"\1\105"), + DFA.unpack(u"\1\106"), + DFA.unpack(u"\1\107"), + DFA.unpack(u"\1\110"), + DFA.unpack(u"\2\23\3\uffff\1\23\2\uffff\12\23\7\uffff\32\23\4\uffff" + u"\1\23\1\uffff\32\23"), + DFA.unpack(u"\2\23\3\uffff\1\23\2\uffff\12\23\7\uffff\32\23\4\uffff" + u"\1\23\1\uffff\32\23"), + DFA.unpack(u""), + DFA.unpack(u"\2\23\3\uffff\1\23\2\uffff\12\23\7\uffff\32\23\4\uffff" + u"\1\23\1\uffff\32\23"), + DFA.unpack(u"\1\114"), + DFA.unpack(u"\1\115"), + DFA.unpack(u"\1\116"), + DFA.unpack(u""), + DFA.unpack(u""), + DFA.unpack(u""), + DFA.unpack(u"\1\117"), + DFA.unpack(u"\1\120"), + DFA.unpack(u"\1\121"), + DFA.unpack(u"\1\122"), + DFA.unpack(u"\1\123"), + DFA.unpack(u"\1\124"), + DFA.unpack(u"\1\125"), + DFA.unpack(u"\1\126"), + DFA.unpack(u"\1\127"), + DFA.unpack(u"\1\130"), + DFA.unpack(u"\1\131"), + DFA.unpack(u"\2\23\3\uffff\1\23\2\uffff\12\23\7\uffff\32\23\4\uffff" + u"\1\23\1\uffff\32\23"), + DFA.unpack(u"\1\133"), + DFA.unpack(u"\1\134"), + DFA.unpack(u""), + DFA.unpack(u"\1\135"), + DFA.unpack(u"\1\136"), + DFA.unpack(u"\1\137"), + DFA.unpack(u"\1\140"), + DFA.unpack(u"\1\141"), + DFA.unpack(u"\2\23\3\uffff\1\23\2\uffff\12\23\7\uffff\32\23\4\uffff" + u"\1\23\1\uffff\32\23"), + DFA.unpack(u"\1\143"), + DFA.unpack(u""), + DFA.unpack(u"\2\23\3\uffff\1\23\2\uffff\12\23\7\uffff\32\23\4\uffff" + u"\1\23\1\uffff\32\23"), + DFA.unpack(u"") + ] + + # class definition for DFA #5 + + DFA5 = DFA + + +def main(argv, stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr): + from antlr3.main import LexerMain + main = LexerMain(XKBGrammarLexer) + main.stdin = stdin + main.stdout = stdout + main.stderr = stderr + main.execute(argv) + +if __name__ == '__main__': + main(sys.argv) diff --git a/XKBGrammar/XKBGrammarLexer.pyc b/XKBGrammar/XKBGrammarLexer.pyc Binary files differ. diff --git a/XKBGrammar/XKBGrammarParser.py b/XKBGrammar/XKBGrammarParser.py @@ -1,5 +1,6 @@ -# $ANTLR 3.0.1 XKBGrammar.g 2008-05-14 21:55:38 +# $ANTLR 3.1b1 XKBGrammar.g 2008-05-15 19:18:28 +import sys from antlr3 import * from antlr3.compat import set, frozenset @@ -11,33 +12,49 @@ from antlr3.tree import * HIDDEN = BaseRecognizer.HIDDEN # token types -QUOTEDSTRING=25 -TOKEN_ALTERNATE_GROUP=9 -ATTRIBUTES=17 -SECTION=23 -LINE_COMMENT=30 -KEYCODE=22 +T__29=29 +T__28=28 +T__27=27 +MAPOPTIONS=17 TOKEN_INCLUDE=11 -KEY=20 -KEYTYPE=21 -ATTRIBUTE=18 -TOKEN_NAME=13 TOKEN_XKB_SYMBOLS=10 EOF=-1 -SECTIONNAME=24 MAPTYPE=15 -NAME=27 TOKEN_PARTIAL=6 -WS=28 -TOKEN_ALPHANUMERIC_KEYS=7 +NAME=23 +MAPMATERIAL=18 +KEYSYMS=21 +COMMENT=25 +TOKEN_DEFAULT=4 +T__42=42 +T__43=43 +TOKEN_ALTERNATE_GROUP=9 +T__40=40 +T__41=41 +T__46=46 +T__44=44 +T__45=45 +SECTION=19 +LINE_COMMENT=26 +KEYCODE=20 +TOKEN_NAME=13 +VALUE=22 +T__30=30 +T__31=31 +T__32=32 +WS=24 +T__33=33 +T__34=34 +T__35=35 TOKEN_HIDDEN=5 -MAPMATERIAL=16 -INCLUDE=19 +TOKEN_ALPHANUMERIC_KEYS=7 +T__36=36 +T__37=37 +T__38=38 +T__39=39 TOKEN_MODIFIER_KEYS=8 -KEYSYMS=26 TOKEN_KEY=14 -COMMENT=29 -TOKEN_DEFAULT=4 +MAPNAME=16 TOKEN_KEY_TYPE=12 # token names @@ -46,22 +63,28 @@ tokenNames = [ "TOKEN_DEFAULT", "TOKEN_HIDDEN", "TOKEN_PARTIAL", "TOKEN_ALPHANUMERIC_KEYS", "TOKEN_MODIFIER_KEYS", "TOKEN_ALTERNATE_GROUP", "TOKEN_XKB_SYMBOLS", "TOKEN_INCLUDE", "TOKEN_KEY_TYPE", "TOKEN_NAME", "TOKEN_KEY", "MAPTYPE", - "MAPMATERIAL", "ATTRIBUTES", "ATTRIBUTE", "INCLUDE", "KEY", "KEYTYPE", - "KEYCODE", "SECTION", "SECTIONNAME", "QUOTEDSTRING", "KEYSYMS", "NAME", - "WS", "COMMENT", "LINE_COMMENT", "'\"'", "'{'", "';'", "'}'", "'include'", - "'name'", "'['", "']'", "'='", "'key.type'", "'key'", "'<'", "'>'", - "','", "'default'", "'hidden'", "'partial'", "'alphanumeric_keys'", + "MAPNAME", "MAPOPTIONS", "MAPMATERIAL", "SECTION", "KEYCODE", "KEYSYMS", + "VALUE", "NAME", "WS", "COMMENT", "LINE_COMMENT", "'\"'", "'{'", "';'", + "'}'", "'include'", "'name'", "'['", "']'", "'='", "'key.type'", "'key'", + "'<'", "'>'", "','", "'default'", "'hidden'", "'partial'", "'alphanumeric_keys'", "'alternate_group'", "'xkb_symbols'" ] + class XKBGrammarParser(Parser): grammarFileName = "XKBGrammar.g" tokenNames = tokenNames - def __init__(self, input): - Parser.__init__(self, input) + def __init__(self, input, state=None): + if state is None: + state = RecognizerSharedState() + + Parser.__init__(self, input, state) + + + @@ -70,6 +93,8 @@ class XKBGrammarParser(Parser): + + class layout_return(object): def __init__(self): @@ -79,8 +104,10 @@ class XKBGrammarParser(Parser): self.tree = None + + # $ANTLR start layout - # XKBGrammar.g:61:1: layout : ( section )+ EOF ; + # XKBGrammar.g:57:1: layout : ( section )+ EOF ; def layout(self, ): retval = self.layout_return() @@ -96,29 +123,30 @@ class XKBGrammarParser(Parser): try: try: - # XKBGrammar.g:62:2: ( ( section )+ EOF ) - # XKBGrammar.g:62:4: ( section )+ EOF + # XKBGrammar.g:58:2: ( ( section )+ EOF ) + # XKBGrammar.g:58:4: ( section )+ EOF root_0 = self.adaptor.nil() - # XKBGrammar.g:62:4: ( section )+ + # XKBGrammar.g:58:4: ( section )+ cnt1 = 0 while True: #loop1 alt1 = 2 LA1_0 = self.input.LA(1) - if ((45 <= LA1_0 <= 50)) : + if ((41 <= LA1_0 <= 46)) : alt1 = 1 if alt1 == 1: - # XKBGrammar.g:62:4: section - self.following.append(self.FOLLOW_section_in_layout160) + # XKBGrammar.g:58:4: section + self._state.following.append(self.FOLLOW_section_in_layout144) section1 = self.section() - self.following.pop() + self._state.following.pop() self.adaptor.addChild(root_0, section1.tree) + else: if cnt1 >= 1: break #loop1 @@ -130,7 +158,7 @@ class XKBGrammarParser(Parser): EOF2 = self.input.LT(1) - self.match(self.input, EOF, self.FOLLOW_EOF_in_layout163) + self.match(self.input, EOF, self.FOLLOW_EOF_in_layout147) @@ -141,9 +169,11 @@ class XKBGrammarParser(Parser): retval.tree = self.adaptor.rulePostProcessing(root_0) self.adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) + except RecognitionException, re: self.reportError(re) self.recover(self.input, re) + retval.tree = self.adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass @@ -160,8 +190,10 @@ class XKBGrammarParser(Parser): self.tree = None + + # $ANTLR start section - # XKBGrammar.g:65:1: section : mapType mapMaterial -> ^( SECTION mapType mapMaterial ) ; + # XKBGrammar.g:61:1: section : mapType mapMaterial -> ^( SECTION mapType mapMaterial ) ; def section(self, ): retval = self.section_return() @@ -178,20 +210,20 @@ class XKBGrammarParser(Parser): stream_mapType = RewriteRuleSubtreeStream(self.adaptor, "rule mapType") try: try: - # XKBGrammar.g:66:2: ( mapType mapMaterial -> ^( SECTION mapType mapMaterial ) ) - # XKBGrammar.g:66:4: mapType mapMaterial - self.following.append(self.FOLLOW_mapType_in_section177) + # XKBGrammar.g:62:2: ( mapType mapMaterial -> ^( SECTION mapType mapMaterial ) ) + # XKBGrammar.g:62:4: mapType mapMaterial + self._state.following.append(self.FOLLOW_mapType_in_section161) mapType3 = self.mapType() - self.following.pop() + self._state.following.pop() stream_mapType.add(mapType3.tree) - self.following.append(self.FOLLOW_mapMaterial_in_section179) + self._state.following.append(self.FOLLOW_mapMaterial_in_section163) mapMaterial4 = self.mapMaterial() - self.following.pop() + self._state.following.pop() stream_mapMaterial.add(mapMaterial4.tree) # AST Rewrite - # elements: mapType, mapMaterial + # elements: mapMaterial, mapType # token labels: # rule labels: retval # token list labels: @@ -206,18 +238,20 @@ class XKBGrammarParser(Parser): root_0 = self.adaptor.nil() - # 67:2: -> ^( SECTION mapType mapMaterial ) - # XKBGrammar.g:67:5: ^( SECTION mapType mapMaterial ) + # 63:2: -> ^( SECTION mapType mapMaterial ) + # XKBGrammar.g:63:5: ^( SECTION mapType mapMaterial ) root_1 = self.adaptor.nil() root_1 = self.adaptor.becomeRoot(self.adaptor.createFromType(SECTION, "SECTION"), root_1) - self.adaptor.addChild(root_1, stream_mapType.next()) - self.adaptor.addChild(root_1, stream_mapMaterial.next()) + self.adaptor.addChild(root_1, stream_mapType.nextTree()) + self.adaptor.addChild(root_1, stream_mapMaterial.nextTree()) self.adaptor.addChild(root_0, root_1) + retval.tree = root_0 + @@ -227,9 +261,11 @@ class XKBGrammarParser(Parser): retval.tree = self.adaptor.rulePostProcessing(root_0) self.adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) + except RecognitionException, re: self.reportError(re) self.recover(self.input, re) + retval.tree = self.adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass @@ -246,8 +282,10 @@ class XKBGrammarParser(Parser): self.tree = None + + # $ANTLR start mapType - # XKBGrammar.g:70:1: mapType : ( mapOptions )+ '\"' NAME '\"' -> ^( MAPTYPE ( mapOptions )+ NAME ) ; + # XKBGrammar.g:66:1: mapType : ( mapOptions )+ '\"' NAME '\"' -> ^( MAPTYPE ^( MAPOPTIONS ( mapOptions )+ ) ^( MAPNAME NAME ) ) ; def mapType(self, ): retval = self.mapType_return() @@ -265,31 +303,32 @@ class XKBGrammarParser(Parser): NAME7_tree = None char_literal8_tree = None stream_NAME = RewriteRuleTokenStream(self.adaptor, "token NAME") - stream_31 = RewriteRuleTokenStream(self.adaptor, "token 31") + stream_27 = RewriteRuleTokenStream(self.adaptor, "token 27") stream_mapOptions = RewriteRuleSubtreeStream(self.adaptor, "rule mapOptions") try: try: - # XKBGrammar.g:71:2: ( ( mapOptions )+ '\"' NAME '\"' -> ^( MAPTYPE ( mapOptions )+ NAME ) ) - # XKBGrammar.g:71:4: ( mapOptions )+ '\"' NAME '\"' - # XKBGrammar.g:71:4: ( mapOptions )+ + # XKBGrammar.g:67:2: ( ( mapOptions )+ '\"' NAME '\"' -> ^( MAPTYPE ^( MAPOPTIONS ( mapOptions )+ ) ^( MAPNAME NAME ) ) ) + # XKBGrammar.g:67:4: ( mapOptions )+ '\"' NAME '\"' + # XKBGrammar.g:67:4: ( mapOptions )+ cnt2 = 0 while True: #loop2 alt2 = 2 LA2_0 = self.input.LA(1) - if ((45 <= LA2_0 <= 50)) : + if ((41 <= LA2_0 <= 46)) : alt2 = 1 if alt2 == 1: - # XKBGrammar.g:71:4: mapOptions - self.following.append(self.FOLLOW_mapOptions_in_mapType202) + # XKBGrammar.g:67:4: mapOptions + self._state.following.append(self.FOLLOW_mapOptions_in_mapType186) mapOptions5 = self.mapOptions() - self.following.pop() + self._state.following.pop() stream_mapOptions.add(mapOptions5.tree) + else: if cnt2 >= 1: break #loop2 @@ -301,17 +340,14 @@ class XKBGrammarParser(Parser): char_literal6 = self.input.LT(1) - self.match(self.input, 31, self.FOLLOW_31_in_mapType205) - - stream_31.add(char_literal6) + self.match(self.input, 27, self.FOLLOW_27_in_mapType189) + stream_27.add(char_literal6) NAME7 = self.input.LT(1) - self.match(self.input, NAME, self.FOLLOW_NAME_in_mapType207) - + self.match(self.input, NAME, self.FOLLOW_NAME_in_mapType191) stream_NAME.add(NAME7) char_literal8 = self.input.LT(1) - self.match(self.input, 31, self.FOLLOW_31_in_mapType209) - - stream_31.add(char_literal8) + self.match(self.input, 27, self.FOLLOW_27_in_mapType193) + stream_27.add(char_literal8) # AST Rewrite # elements: mapOptions, NAME # token labels: @@ -328,26 +364,40 @@ class XKBGrammarParser(Parser): root_0 = self.adaptor.nil() - # 72:2: -> ^( MAPTYPE ( mapOptions )+ NAME ) - # XKBGrammar.g:72:5: ^( MAPTYPE ( mapOptions )+ NAME ) + # 68:2: -> ^( MAPTYPE ^( MAPOPTIONS ( mapOptions )+ ) ^( MAPNAME NAME ) ) + # XKBGrammar.g:68:5: ^( MAPTYPE ^( MAPOPTIONS ( mapOptions )+ ) ^( MAPNAME NAME ) ) root_1 = self.adaptor.nil() root_1 = self.adaptor.becomeRoot(self.adaptor.createFromType(MAPTYPE, "MAPTYPE"), root_1) - # XKBGrammar.g:72:15: ( mapOptions )+ + # XKBGrammar.g:68:15: ^( MAPOPTIONS ( mapOptions )+ ) + root_2 = self.adaptor.nil() + root_2 = self.adaptor.becomeRoot(self.adaptor.createFromType(MAPOPTIONS, "MAPOPTIONS"), root_2) + + # XKBGrammar.g:68:28: ( mapOptions )+ if not (stream_mapOptions.hasNext()): raise RewriteEarlyExitException() while stream_mapOptions.hasNext(): - self.adaptor.addChild(root_1, stream_mapOptions.next()) + self.adaptor.addChild(root_2, stream_mapOptions.nextTree()) stream_mapOptions.reset() - self.adaptor.addChild(root_1, stream_NAME.next()) + + self.adaptor.addChild(root_1, root_2) + # XKBGrammar.g:68:41: ^( MAPNAME NAME ) + root_2 = self.adaptor.nil() + root_2 = self.adaptor.becomeRoot(self.adaptor.createFromType(MAPNAME, "MAPNAME"), root_2) + + self.adaptor.addChild(root_2, stream_NAME.nextNode()) + + self.adaptor.addChild(root_1, root_2) self.adaptor.addChild(root_0, root_1) + retval.tree = root_0 + @@ -357,9 +407,11 @@ class XKBGrammarParser(Parser): retval.tree = self.adaptor.rulePostProcessing(root_0) self.adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) + except RecognitionException, re: self.reportError(re) self.recover(self.input, re) + retval.tree = self.adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass @@ -376,8 +428,10 @@ class XKBGrammarParser(Parser): self.tree = None + + # $ANTLR start mapMaterial - # XKBGrammar.g:75:1: mapMaterial : '{' ( line_include | line_name ';' | line_keytype ';' | line_key ';' )+ '}' ';' ; + # XKBGrammar.g:71:1: mapMaterial : '{' ( line_include | line_name ';' | line_keytype ';' | line_key ';' )+ '}' ';' ; def mapMaterial(self, ): retval = self.mapMaterial_return() @@ -409,73 +463,73 @@ class XKBGrammarParser(Parser): try: try: - # XKBGrammar.g:76:2: ( '{' ( line_include | line_name ';' | line_keytype ';' | line_key ';' )+ '}' ';' ) - # XKBGrammar.g:76:4: '{' ( line_include | line_name ';' | line_keytype ';' | line_key ';' )+ '}' ';' + # XKBGrammar.g:72:2: ( '{' ( line_include | line_name ';' | line_keytype ';' | line_key ';' )+ '}' ';' ) + # XKBGrammar.g:72:4: '{' ( line_include | line_name ';' | line_keytype ';' | line_key ';' )+ '}' ';' root_0 = self.adaptor.nil() char_literal9 = self.input.LT(1) - self.match(self.input, 32, self.FOLLOW_32_in_mapMaterial233) - + self.match(self.input, 28, self.FOLLOW_28_in_mapMaterial225) char_literal9_tree = self.adaptor.createWithPayload(char_literal9) self.adaptor.addChild(root_0, char_literal9_tree) - # XKBGrammar.g:77:2: ( line_include | line_name ';' | line_keytype ';' | line_key ';' )+ + # XKBGrammar.g:73:2: ( line_include | line_name ';' | line_keytype ';' | line_key ';' )+ cnt3 = 0 while True: #loop3 alt3 = 5 LA3 = self.input.LA(1) - if LA3 == 35: + if LA3 == 31: alt3 = 1 - elif LA3 == 36: + elif LA3 == 32: alt3 = 2 - elif LA3 == 40: + elif LA3 == 36: alt3 = 3 - elif LA3 == 41: + elif LA3 == 37: alt3 = 4 if alt3 == 1: - # XKBGrammar.g:77:4: line_include - self.following.append(self.FOLLOW_line_include_in_mapMaterial239) + # XKBGrammar.g:73:4: line_include + self._state.following.append(self.FOLLOW_line_include_in_mapMaterial230) line_include10 = self.line_include() - self.following.pop() + self._state.following.pop() self.adaptor.addChild(root_0, line_include10.tree) + elif alt3 == 2: - # XKBGrammar.g:78:4: line_name ';' - self.following.append(self.FOLLOW_line_name_in_mapMaterial245) + # XKBGrammar.g:74:4: line_name ';' + self._state.following.append(self.FOLLOW_line_name_in_mapMaterial236) line_name11 = self.line_name() - self.following.pop() + self._state.following.pop() self.adaptor.addChild(root_0, line_name11.tree) char_literal12 = self.input.LT(1) - self.match(self.input, 33, self.FOLLOW_33_in_mapMaterial247) + self.match(self.input, 29, self.FOLLOW_29_in_mapMaterial238) elif alt3 == 3: - # XKBGrammar.g:79:4: line_keytype ';' - self.following.append(self.FOLLOW_line_keytype_in_mapMaterial253) + # XKBGrammar.g:75:4: line_keytype ';' + self._state.following.append(self.FOLLOW_line_keytype_in_mapMaterial244) line_keytype13 = self.line_keytype() - self.following.pop() + self._state.following.pop() self.adaptor.addChild(root_0, line_keytype13.tree) char_literal14 = self.input.LT(1) - self.match(self.input, 33, self.FOLLOW_33_in_mapMaterial255) + self.match(self.input, 29, self.FOLLOW_29_in_mapMaterial246) elif alt3 == 4: - # XKBGrammar.g:80:4: line_key ';' - self.following.append(self.FOLLOW_line_key_in_mapMaterial261) + # XKBGrammar.g:76:4: line_key ';' + self._state.following.append(self.FOLLOW_line_key_in_mapMaterial252) line_key15 = self.line_key() - self.following.pop() + self._state.following.pop() self.adaptor.addChild(root_0, line_key15.tree) char_literal16 = self.input.LT(1) - self.match(self.input, 33, self.FOLLOW_33_in_mapMaterial263) + self.match(self.input, 29, self.FOLLOW_29_in_mapMaterial254) @@ -490,18 +544,13 @@ class XKBGrammarParser(Parser): char_literal17 = self.input.LT(1) - self.match(self.input, 34, self.FOLLOW_34_in_mapMaterial270) - + self.match(self.input, 30, self.FOLLOW_30_in_mapMaterial261) char_literal17_tree = self.adaptor.createWithPayload(char_literal17) self.adaptor.addChild(root_0, char_literal17_tree) char_literal18 = self.input.LT(1) - self.match(self.input, 33, self.FOLLOW_33_in_mapMaterial272) - - - char_literal18_tree = self.adaptor.createWithPayload(char_literal18) - self.adaptor.addChild(root_0, char_literal18_tree) + self.match(self.input, 29, self.FOLLOW_29_in_mapMaterial263) @@ -512,9 +561,11 @@ class XKBGrammarParser(Parser): retval.tree = self.adaptor.rulePostProcessing(root_0) self.adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) + except RecognitionException, re: self.reportError(re) self.recover(self.input, re) + retval.tree = self.adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass @@ -531,8 +582,10 @@ class XKBGrammarParser(Parser): self.tree = None + + # $ANTLR start line_include - # XKBGrammar.g:84:1: line_include : 'include' '\"' NAME '\"' -> ^( TOKEN_INCLUDE NAME ) ; + # XKBGrammar.g:80:1: line_include : 'include' '\"' NAME '\"' -> ^( TOKEN_INCLUDE NAME ) ; def line_include(self, ): retval = self.line_include_return() @@ -551,28 +604,24 @@ class XKBGrammarParser(Parser): char_literal22_tree = None stream_NAME = RewriteRuleTokenStream(self.adaptor, "token NAME") stream_31 = RewriteRuleTokenStream(self.adaptor, "token 31") - stream_35 = RewriteRuleTokenStream(self.adaptor, "token 35") + stream_27 = RewriteRuleTokenStream(self.adaptor, "token 27") try: try: - # XKBGrammar.g:85:2: ( 'include' '\"' NAME '\"' -> ^( TOKEN_INCLUDE NAME ) ) - # XKBGrammar.g:85:4: 'include' '\"' NAME '\"' + # XKBGrammar.g:81:2: ( 'include' '\"' NAME '\"' -> ^( TOKEN_INCLUDE NAME ) ) + # XKBGrammar.g:81:4: 'include' '\"' NAME '\"' string_literal19 = self.input.LT(1) - self.match(self.input, 35, self.FOLLOW_35_in_line_include283) - - stream_35.add(string_literal19) + self.match(self.input, 31, self.FOLLOW_31_in_line_include275) + stream_31.add(string_literal19) char_literal20 = self.input.LT(1) - self.match(self.input, 31, self.FOLLOW_31_in_line_include285) - - stream_31.add(char_literal20) + self.match(self.input, 27, self.FOLLOW_27_in_line_include277) + stream_27.add(char_literal20) NAME21 = self.input.LT(1) - self.match(self.input, NAME, self.FOLLOW_NAME_in_line_include287) - + self.match(self.input, NAME, self.FOLLOW_NAME_in_line_include279) stream_NAME.add(NAME21) char_literal22 = self.input.LT(1) - self.match(self.input, 31, self.FOLLOW_31_in_line_include289) - - stream_31.add(char_literal22) + self.match(self.input, 27, self.FOLLOW_27_in_line_include281) + stream_27.add(char_literal22) # AST Rewrite # elements: NAME # token labels: @@ -589,17 +638,19 @@ class XKBGrammarParser(Parser): root_0 = self.adaptor.nil() - # 86:2: -> ^( TOKEN_INCLUDE NAME ) - # XKBGrammar.g:86:5: ^( TOKEN_INCLUDE NAME ) + # 82:2: -> ^( TOKEN_INCLUDE NAME ) + # XKBGrammar.g:82:5: ^( TOKEN_INCLUDE NAME ) root_1 = self.adaptor.nil() root_1 = self.adaptor.becomeRoot(self.adaptor.createFromType(TOKEN_INCLUDE, "TOKEN_INCLUDE"), root_1) - self.adaptor.addChild(root_1, stream_NAME.next()) + self.adaptor.addChild(root_1, stream_NAME.nextNode()) self.adaptor.addChild(root_0, root_1) + retval.tree = root_0 + @@ -609,9 +660,11 @@ class XKBGrammarParser(Parser): retval.tree = self.adaptor.rulePostProcessing(root_0) self.adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) + except RecognitionException, re: self.reportError(re) self.recover(self.input, re) + retval.tree = self.adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass @@ -628,8 +681,10 @@ class XKBGrammarParser(Parser): self.tree = None + + # $ANTLR start line_name - # XKBGrammar.g:89:1: line_name : 'name' '[' n1= NAME ']' '=' '\"' n2= NAME '\"' -> ^( TOKEN_NAME $n1 $n2) ; + # XKBGrammar.g:85:1: line_name : 'name' '[' n1= NAME ']' '=' '\"' n2= NAME '\"' -> ^( TOKEN_NAME $n1 ^( VALUE $n2) ) ; def line_name(self, ): retval = self.line_name_return() @@ -655,50 +710,42 @@ class XKBGrammarParser(Parser): char_literal27_tree = None char_literal28_tree = None stream_NAME = RewriteRuleTokenStream(self.adaptor, "token NAME") - stream_31 = RewriteRuleTokenStream(self.adaptor, "token 31") - stream_36 = RewriteRuleTokenStream(self.adaptor, "token 36") - stream_39 = RewriteRuleTokenStream(self.adaptor, "token 39") - stream_37 = RewriteRuleTokenStream(self.adaptor, "token 37") - stream_38 = RewriteRuleTokenStream(self.adaptor, "token 38") + stream_32 = RewriteRuleTokenStream(self.adaptor, "token 32") + stream_35 = RewriteRuleTokenStream(self.adaptor, "token 35") + stream_33 = RewriteRuleTokenStream(self.adaptor, "token 33") + stream_34 = RewriteRuleTokenStream(self.adaptor, "token 34") + stream_27 = RewriteRuleTokenStream(self.adaptor, "token 27") try: try: - # XKBGrammar.g:90:2: ( 'name' '[' n1= NAME ']' '=' '\"' n2= NAME '\"' -> ^( TOKEN_NAME $n1 $n2) ) - # XKBGrammar.g:90:4: 'name' '[' n1= NAME ']' '=' '\"' n2= NAME '\"' + # XKBGrammar.g:86:2: ( 'name' '[' n1= NAME ']' '=' '\"' n2= NAME '\"' -> ^( TOKEN_NAME $n1 ^( VALUE $n2) ) ) + # XKBGrammar.g:86:4: 'name' '[' n1= NAME ']' '=' '\"' n2= NAME '\"' string_literal23 = self.input.LT(1) - self.match(self.input, 36, self.FOLLOW_36_in_line_name309) - - stream_36.add(string_literal23) + self.match(self.input, 32, self.FOLLOW_32_in_line_name301) + stream_32.add(string_literal23) char_literal24 = self.input.LT(1) - self.match(self.input, 37, self.FOLLOW_37_in_line_name311) - - stream_37.add(char_literal24) + self.match(self.input, 33, self.FOLLOW_33_in_line_name303) + stream_33.add(char_literal24) n1 = self.input.LT(1) - self.match(self.input, NAME, self.FOLLOW_NAME_in_line_name315) - + self.match(self.input, NAME, self.FOLLOW_NAME_in_line_name307) stream_NAME.add(n1) char_literal25 = self.input.LT(1) - self.match(self.input, 38, self.FOLLOW_38_in_line_name317) - - stream_38.add(char_literal25) + self.match(self.input, 34, self.FOLLOW_34_in_line_name309) + stream_34.add(char_literal25) char_literal26 = self.input.LT(1) - self.match(self.input, 39, self.FOLLOW_39_in_line_name319) - - stream_39.add(char_literal26) + self.match(self.input, 35, self.FOLLOW_35_in_line_name311) + stream_35.add(char_literal26) char_literal27 = self.input.LT(1) - self.match(self.input, 31, self.FOLLOW_31_in_line_name321) - - stream_31.add(char_literal27) + self.match(self.input, 27, self.FOLLOW_27_in_line_name313) + stream_27.add(char_literal27) n2 = self.input.LT(1) - self.match(self.input, NAME, self.FOLLOW_NAME_in_line_name325) - + self.match(self.input, NAME, self.FOLLOW_NAME_in_line_name317) stream_NAME.add(n2) char_literal28 = self.input.LT(1) - self.match(self.input, 31, self.FOLLOW_31_in_line_name327) - - stream_31.add(char_literal28) + self.match(self.input, 27, self.FOLLOW_27_in_line_name319) + stream_27.add(char_literal28) # AST Rewrite - # elements: n2, n1 + # elements: n1, n2 # token labels: n1, n2 # rule labels: retval # token list labels: @@ -715,18 +762,26 @@ class XKBGrammarParser(Parser): root_0 = self.adaptor.nil() - # 91:2: -> ^( TOKEN_NAME $n1 $n2) - # XKBGrammar.g:91:5: ^( TOKEN_NAME $n1 $n2) + # 87:2: -> ^( TOKEN_NAME $n1 ^( VALUE $n2) ) + # XKBGrammar.g:87:5: ^( TOKEN_NAME $n1 ^( VALUE $n2) ) root_1 = self.adaptor.nil() root_1 = self.adaptor.becomeRoot(self.adaptor.createFromType(TOKEN_NAME, "TOKEN_NAME"), root_1) - self.adaptor.addChild(root_1, stream_n1.next()) - self.adaptor.addChild(root_1, stream_n2.next()) + self.adaptor.addChild(root_1, stream_n1.nextNode()) + # XKBGrammar.g:87:22: ^( VALUE $n2) + root_2 = self.adaptor.nil() + root_2 = self.adaptor.becomeRoot(self.adaptor.createFromType(VALUE, "VALUE"), root_2) + + self.adaptor.addChild(root_2, stream_n2.nextNode()) + + self.adaptor.addChild(root_1, root_2) self.adaptor.addChild(root_0, root_1) + retval.tree = root_0 + @@ -736,9 +791,11 @@ class XKBGrammarParser(Parser): retval.tree = self.adaptor.rulePostProcessing(root_0) self.adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) + except RecognitionException, re: self.reportError(re) self.recover(self.input, re) + retval.tree = self.adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass @@ -755,8 +812,10 @@ class XKBGrammarParser(Parser): self.tree = None + + # $ANTLR start line_keytype - # XKBGrammar.g:94:1: line_keytype : 'key.type' '[' n1= NAME ']' '=' '\"' n2= NAME '\"' -> ^( TOKEN_KEY_TYPE $n1 $n2) ; + # XKBGrammar.g:90:1: line_keytype : 'key.type' '[' n1= NAME ']' '=' '\"' n2= NAME '\"' -> ^( TOKEN_KEY_TYPE $n1 ^( VALUE $n2) ) ; def line_keytype(self, ): retval = self.line_keytype_return() @@ -782,48 +841,40 @@ class XKBGrammarParser(Parser): char_literal33_tree = None char_literal34_tree = None stream_NAME = RewriteRuleTokenStream(self.adaptor, "token NAME") - stream_40 = RewriteRuleTokenStream(self.adaptor, "token 40") - stream_31 = RewriteRuleTokenStream(self.adaptor, "token 31") - stream_39 = RewriteRuleTokenStream(self.adaptor, "token 39") - stream_37 = RewriteRuleTokenStream(self.adaptor, "token 37") - stream_38 = RewriteRuleTokenStream(self.adaptor, "token 38") + stream_35 = RewriteRuleTokenStream(self.adaptor, "token 35") + stream_36 = RewriteRuleTokenStream(self.adaptor, "token 36") + stream_33 = RewriteRuleTokenStream(self.adaptor, "token 33") + stream_34 = RewriteRuleTokenStream(self.adaptor, "token 34") + stream_27 = RewriteRuleTokenStream(self.adaptor, "token 27") try: try: - # XKBGrammar.g:95:2: ( 'key.type' '[' n1= NAME ']' '=' '\"' n2= NAME '\"' -> ^( TOKEN_KEY_TYPE $n1 $n2) ) - # XKBGrammar.g:95:4: 'key.type' '[' n1= NAME ']' '=' '\"' n2= NAME '\"' + # XKBGrammar.g:91:2: ( 'key.type' '[' n1= NAME ']' '=' '\"' n2= NAME '\"' -> ^( TOKEN_KEY_TYPE $n1 ^( VALUE $n2) ) ) + # XKBGrammar.g:91:4: 'key.type' '[' n1= NAME ']' '=' '\"' n2= NAME '\"' string_literal29 = self.input.LT(1) - self.match(self.input, 40, self.FOLLOW_40_in_line_keytype351) - - stream_40.add(string_literal29) + self.match(self.input, 36, self.FOLLOW_36_in_line_keytype347) + stream_36.add(string_literal29) char_literal30 = self.input.LT(1) - self.match(self.input, 37, self.FOLLOW_37_in_line_keytype353) - - stream_37.add(char_literal30) + self.match(self.input, 33, self.FOLLOW_33_in_line_keytype349) + stream_33.add(char_literal30) n1 = self.input.LT(1) - self.match(self.input, NAME, self.FOLLOW_NAME_in_line_keytype357) - + self.match(self.input, NAME, self.FOLLOW_NAME_in_line_keytype353) stream_NAME.add(n1) char_literal31 = self.input.LT(1) - self.match(self.input, 38, self.FOLLOW_38_in_line_keytype359) - - stream_38.add(char_literal31) + self.match(self.input, 34, self.FOLLOW_34_in_line_keytype355) + stream_34.add(char_literal31) char_literal32 = self.input.LT(1) - self.match(self.input, 39, self.FOLLOW_39_in_line_keytype361) - - stream_39.add(char_literal32) + self.match(self.input, 35, self.FOLLOW_35_in_line_keytype357) + stream_35.add(char_literal32) char_literal33 = self.input.LT(1) - self.match(self.input, 31, self.FOLLOW_31_in_line_keytype363) - - stream_31.add(char_literal33) + self.match(self.input, 27, self.FOLLOW_27_in_line_keytype359) + stream_27.add(char_literal33) n2 = self.input.LT(1) - self.match(self.input, NAME, self.FOLLOW_NAME_in_line_keytype367) - + self.match(self.input, NAME, self.FOLLOW_NAME_in_line_keytype363) stream_NAME.add(n2) char_literal34 = self.input.LT(1) - self.match(self.input, 31, self.FOLLOW_31_in_line_keytype369) - - stream_31.add(char_literal34) + self.match(self.input, 27, self.FOLLOW_27_in_line_keytype365) + stream_27.add(char_literal34) # AST Rewrite # elements: n2, n1 # token labels: n1, n2 @@ -842,18 +893,26 @@ class XKBGrammarParser(Parser): root_0 = self.adaptor.nil() - # 96:2: -> ^( TOKEN_KEY_TYPE $n1 $n2) - # XKBGrammar.g:96:5: ^( TOKEN_KEY_TYPE $n1 $n2) + # 92:2: -> ^( TOKEN_KEY_TYPE $n1 ^( VALUE $n2) ) + # XKBGrammar.g:92:5: ^( TOKEN_KEY_TYPE $n1 ^( VALUE $n2) ) root_1 = self.adaptor.nil() root_1 = self.adaptor.becomeRoot(self.adaptor.createFromType(TOKEN_KEY_TYPE, "TOKEN_KEY_TYPE"), root_1) - self.adaptor.addChild(root_1, stream_n1.next()) - self.adaptor.addChild(root_1, stream_n2.next()) + self.adaptor.addChild(root_1, stream_n1.nextNode()) + # XKBGrammar.g:92:26: ^( VALUE $n2) + root_2 = self.adaptor.nil() + root_2 = self.adaptor.becomeRoot(self.adaptor.createFromType(VALUE, "VALUE"), root_2) + + self.adaptor.addChild(root_2, stream_n2.nextNode()) + + self.adaptor.addChild(root_1, root_2) self.adaptor.addChild(root_0, root_1) + retval.tree = root_0 + @@ -863,9 +922,11 @@ class XKBGrammarParser(Parser): retval.tree = self.adaptor.rulePostProcessing(root_0) self.adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) + except RecognitionException, re: self.reportError(re) self.recover(self.input, re) + retval.tree = self.adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass @@ -882,8 +943,10 @@ class XKBGrammarParser(Parser): self.tree = None + + # $ANTLR start line_key - # XKBGrammar.g:99:1: line_key : 'key' keycode keysyms -> ^( TOKEN_KEY keycode keysyms ) ; + # XKBGrammar.g:95:1: line_key : 'key' keycode keysyms -> ^( TOKEN_KEY keycode keysyms ) ; def line_key(self, ): retval = self.line_key_return() @@ -898,26 +961,25 @@ class XKBGrammarParser(Parser): string_literal35_tree = None - stream_41 = RewriteRuleTokenStream(self.adaptor, "token 41") + stream_37 = RewriteRuleTokenStream(self.adaptor, "token 37") stream_keysyms = RewriteRuleSubtreeStream(self.adaptor, "rule keysyms") stream_keycode = RewriteRuleSubtreeStream(self.adaptor, "rule keycode") try: try: - # XKBGrammar.g:100:2: ( 'key' keycode keysyms -> ^( TOKEN_KEY keycode keysyms ) ) - # XKBGrammar.g:100:4: 'key' keycode keysyms + # XKBGrammar.g:96:2: ( 'key' keycode keysyms -> ^( TOKEN_KEY keycode keysyms ) ) + # XKBGrammar.g:96:4: 'key' keycode keysyms string_literal35 = self.input.LT(1) - self.match(self.input, 41, self.FOLLOW_41_in_line_key394) - - stream_41.add(string_literal35) - self.following.append(self.FOLLOW_keycode_in_line_key396) + self.match(self.input, 37, self.FOLLOW_37_in_line_key394) + stream_37.add(string_literal35) + self._state.following.append(self.FOLLOW_keycode_in_line_key396) keycode36 = self.keycode() - self.following.pop() + self._state.following.pop() stream_keycode.add(keycode36.tree) - self.following.append(self.FOLLOW_keysyms_in_line_key398) + self._state.following.append(self.FOLLOW_keysyms_in_line_key398) keysyms37 = self.keysyms() - self.following.pop() + self._state.following.pop() stream_keysyms.add(keysyms37.tree) # AST Rewrite # elements: keycode, keysyms @@ -935,18 +997,20 @@ class XKBGrammarParser(Parser): root_0 = self.adaptor.nil() - # 101:2: -> ^( TOKEN_KEY keycode keysyms ) - # XKBGrammar.g:101:5: ^( TOKEN_KEY keycode keysyms ) + # 97:2: -> ^( TOKEN_KEY keycode keysyms ) + # XKBGrammar.g:97:5: ^( TOKEN_KEY keycode keysyms ) root_1 = self.adaptor.nil() root_1 = self.adaptor.becomeRoot(self.adaptor.createFromType(TOKEN_KEY, "TOKEN_KEY"), root_1) - self.adaptor.addChild(root_1, stream_keycode.next()) - self.adaptor.addChild(root_1, stream_keysyms.next()) + self.adaptor.addChild(root_1, stream_keycode.nextTree()) + self.adaptor.addChild(root_1, stream_keysyms.nextTree()) self.adaptor.addChild(root_0, root_1) + retval.tree = root_0 + @@ -956,9 +1020,11 @@ class XKBGrammarParser(Parser): retval.tree = self.adaptor.rulePostProcessing(root_0) self.adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) + except RecognitionException, re: self.reportError(re) self.recover(self.input, re) + retval.tree = self.adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass @@ -975,8 +1041,10 @@ class XKBGrammarParser(Parser): self.tree = None + + # $ANTLR start keycode - # XKBGrammar.g:104:1: keycode : '<' NAME '>' -> ^( KEYCODE NAME ) ; + # XKBGrammar.g:100:1: keycode : '<' NAME '>' -> ^( KEYCODE NAME ) ; def keycode(self, ): retval = self.keycode_return() @@ -992,25 +1060,22 @@ class XKBGrammarParser(Parser): NAME39_tree = None char_literal40_tree = None stream_NAME = RewriteRuleTokenStream(self.adaptor, "token NAME") - stream_43 = RewriteRuleTokenStream(self.adaptor, "token 43") - stream_42 = RewriteRuleTokenStream(self.adaptor, "token 42") + stream_39 = RewriteRuleTokenStream(self.adaptor, "token 39") + stream_38 = RewriteRuleTokenStream(self.adaptor, "token 38") try: try: - # XKBGrammar.g:105:2: ( '<' NAME '>' -> ^( KEYCODE NAME ) ) - # XKBGrammar.g:105:4: '<' NAME '>' + # XKBGrammar.g:101:2: ( '<' NAME '>' -> ^( KEYCODE NAME ) ) + # XKBGrammar.g:101:4: '<' NAME '>' char_literal38 = self.input.LT(1) - self.match(self.input, 42, self.FOLLOW_42_in_keycode422) - - stream_42.add(char_literal38) + self.match(self.input, 38, self.FOLLOW_38_in_keycode422) + stream_38.add(char_literal38) NAME39 = self.input.LT(1) - self.match(self.input, NAME, self.FOLLOW_NAME_in_keycode424) - + self.match(self.input, NAME, self.FOLLOW_NAME_in_keycode424) stream_NAME.add(NAME39) char_literal40 = self.input.LT(1) - self.match(self.input, 43, self.FOLLOW_43_in_keycode426) - - stream_43.add(char_literal40) + self.match(self.input, 39, self.FOLLOW_39_in_keycode426) + stream_39.add(char_literal40) # AST Rewrite # elements: NAME # token labels: @@ -1027,17 +1092,19 @@ class XKBGrammarParser(Parser): root_0 = self.adaptor.nil() - # 106:2: -> ^( KEYCODE NAME ) - # XKBGrammar.g:106:5: ^( KEYCODE NAME ) + # 102:2: -> ^( KEYCODE NAME ) + # XKBGrammar.g:102:5: ^( KEYCODE NAME ) root_1 = self.adaptor.nil() root_1 = self.adaptor.becomeRoot(self.adaptor.createFromType(KEYCODE, "KEYCODE"), root_1) - self.adaptor.addChild(root_1, stream_NAME.next()) + self.adaptor.addChild(root_1, stream_NAME.nextNode()) self.adaptor.addChild(root_0, root_1) + retval.tree = root_0 + @@ -1047,9 +1114,11 @@ class XKBGrammarParser(Parser): retval.tree = self.adaptor.rulePostProcessing(root_0) self.adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) + except RecognitionException, re: self.reportError(re) self.recover(self.input, re) + retval.tree = self.adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass @@ -1066,8 +1135,10 @@ class XKBGrammarParser(Parser): self.tree = None + + # $ANTLR start keysyms - # XKBGrammar.g:109:1: keysyms : '{' '[' keysym+= NAME ( ',' keysym+= NAME )* ']' '}' -> ^( KEYSYMS ( $keysym)+ ) ; + # XKBGrammar.g:105:1: keysyms : '{' '[' keysym+= NAME ( ',' keysym+= NAME )* ']' '}' -> ^( KEYSYMS ( $keysym)+ ) ; def keysyms(self, ): retval = self.keysyms_return() @@ -1090,50 +1161,45 @@ class XKBGrammarParser(Parser): char_literal45_tree = None keysym_tree = None stream_NAME = RewriteRuleTokenStream(self.adaptor, "token NAME") - stream_44 = RewriteRuleTokenStream(self.adaptor, "token 44") - stream_32 = RewriteRuleTokenStream(self.adaptor, "token 32") + stream_30 = RewriteRuleTokenStream(self.adaptor, "token 30") + stream_40 = RewriteRuleTokenStream(self.adaptor, "token 40") + stream_33 = RewriteRuleTokenStream(self.adaptor, "token 33") stream_34 = RewriteRuleTokenStream(self.adaptor, "token 34") - stream_37 = RewriteRuleTokenStream(self.adaptor, "token 37") - stream_38 = RewriteRuleTokenStream(self.adaptor, "token 38") + stream_28 = RewriteRuleTokenStream(self.adaptor, "token 28") try: try: - # XKBGrammar.g:110:2: ( '{' '[' keysym+= NAME ( ',' keysym+= NAME )* ']' '}' -> ^( KEYSYMS ( $keysym)+ ) ) - # XKBGrammar.g:110:4: '{' '[' keysym+= NAME ( ',' keysym+= NAME )* ']' '}' + # XKBGrammar.g:106:2: ( '{' '[' keysym+= NAME ( ',' keysym+= NAME )* ']' '}' -> ^( KEYSYMS ( $keysym)+ ) ) + # XKBGrammar.g:106:4: '{' '[' keysym+= NAME ( ',' keysym+= NAME )* ']' '}' char_literal41 = self.input.LT(1) - self.match(self.input, 32, self.FOLLOW_32_in_keysyms446) - - stream_32.add(char_literal41) + self.match(self.input, 28, self.FOLLOW_28_in_keysyms446) + stream_28.add(char_literal41) char_literal42 = self.input.LT(1) - self.match(self.input, 37, self.FOLLOW_37_in_keysyms448) - - stream_37.add(char_literal42) + self.match(self.input, 33, self.FOLLOW_33_in_keysyms448) + stream_33.add(char_literal42) keysym = self.input.LT(1) - self.match(self.input, NAME, self.FOLLOW_NAME_in_keysyms452) - + self.match(self.input, NAME, self.FOLLOW_NAME_in_keysyms452) stream_NAME.add(keysym) if list_keysym is None: list_keysym = [] list_keysym.append(keysym) - # XKBGrammar.g:110:25: ( ',' keysym+= NAME )* + # XKBGrammar.g:106:25: ( ',' keysym+= NAME )* while True: #loop4 alt4 = 2 LA4_0 = self.input.LA(1) - if (LA4_0 == 44) : + if (LA4_0 == 40) : alt4 = 1 if alt4 == 1: - # XKBGrammar.g:110:26: ',' keysym+= NAME + # XKBGrammar.g:106:26: ',' keysym+= NAME char_literal43 = self.input.LT(1) - self.match(self.input, 44, self.FOLLOW_44_in_keysyms455) - - stream_44.add(char_literal43) + self.match(self.input, 40, self.FOLLOW_40_in_keysyms455) + stream_40.add(char_literal43) keysym = self.input.LT(1) - self.match(self.input, NAME, self.FOLLOW_NAME_in_keysyms459) - + self.match(self.input, NAME, self.FOLLOW_NAME_in_keysyms459) stream_NAME.add(keysym) if list_keysym is None: list_keysym = [] @@ -1141,18 +1207,17 @@ class XKBGrammarParser(Parser): + else: break #loop4 char_literal44 = self.input.LT(1) - self.match(self.input, 38, self.FOLLOW_38_in_keysyms463) - - stream_38.add(char_literal44) + self.match(self.input, 34, self.FOLLOW_34_in_keysyms463) + stream_34.add(char_literal44) char_literal45 = self.input.LT(1) - self.match(self.input, 34, self.FOLLOW_34_in_keysyms465) - - stream_34.add(char_literal45) + self.match(self.input, 30, self.FOLLOW_30_in_keysyms465) + stream_30.add(char_literal45) # AST Rewrite # elements: keysym # token labels: @@ -1170,17 +1235,17 @@ class XKBGrammarParser(Parser): root_0 = self.adaptor.nil() - # 111:2: -> ^( KEYSYMS ( $keysym)+ ) - # XKBGrammar.g:111:5: ^( KEYSYMS ( $keysym)+ ) + # 107:2: -> ^( KEYSYMS ( $keysym)+ ) + # XKBGrammar.g:107:5: ^( KEYSYMS ( $keysym)+ ) root_1 = self.adaptor.nil() root_1 = self.adaptor.becomeRoot(self.adaptor.createFromType(KEYSYMS, "KEYSYMS"), root_1) - # XKBGrammar.g:111:15: ( $keysym)+ + # XKBGrammar.g:107:15: ( $keysym)+ if not (stream_keysym.hasNext()): raise RewriteEarlyExitException() while stream_keysym.hasNext(): - self.adaptor.addChild(root_1, stream_keysym.next()) + self.adaptor.addChild(root_1, stream_keysym.nextNode()) stream_keysym.reset() @@ -1189,6 +1254,8 @@ class XKBGrammarParser(Parser): + retval.tree = root_0 + @@ -1198,9 +1265,11 @@ class XKBGrammarParser(Parser): retval.tree = self.adaptor.rulePostProcessing(root_0) self.adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) + except RecognitionException, re: self.reportError(re) self.recover(self.input, re) + retval.tree = self.adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass @@ -1217,8 +1286,10 @@ class XKBGrammarParser(Parser): self.tree = None + + # $ANTLR start mapOptions - # XKBGrammar.g:114:1: mapOptions : ( 'default' | 'hidden' | 'partial' | 'alphanumeric_keys' | 'alternate_group' | 'xkb_symbols' ); + # XKBGrammar.g:110:1: mapOptions : ( 'default' | 'hidden' | 'partial' | 'alphanumeric_keys' | 'alternate_group' | 'xkb_symbols' ); def mapOptions(self, ): retval = self.mapOptions_return() @@ -1232,21 +1303,18 @@ class XKBGrammarParser(Parser): try: try: - # XKBGrammar.g:115:2: ( 'default' | 'hidden' | 'partial' | 'alphanumeric_keys' | 'alternate_group' | 'xkb_symbols' ) + # XKBGrammar.g:111:2: ( 'default' | 'hidden' | 'partial' | 'alphanumeric_keys' | 'alternate_group' | 'xkb_symbols' ) # XKBGrammar.g: root_0 = self.adaptor.nil() set46 = self.input.LT(1) - if (45 <= self.input.LA(1) <= 50): + if (41 <= self.input.LA(1) <= 46): self.input.consume(); self.adaptor.addChild(root_0, self.adaptor.createWithPayload(set46)) - self.errorRecovery = False + self._state.errorRecovery = False else: mse = MismatchedSetException(None, self.input) - self.recoverFromMismatchedSet( - self.input, mse, self.FOLLOW_set_in_mapOptions0 - ) raise mse @@ -1259,9 +1327,11 @@ class XKBGrammarParser(Parser): retval.tree = self.adaptor.rulePostProcessing(root_0) self.adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop) + except RecognitionException, re: self.reportError(re) self.recover(self.input, re) + retval.tree = self.adaptor.errorNode(self.input, retval.start, self.input.LT(-1), re) finally: pass @@ -1271,58 +1341,73 @@ class XKBGrammarParser(Parser): # $ANTLR end mapOptions + # Delegated rules + + - FOLLOW_section_in_layout160 = frozenset([45, 46, 47, 48, 49, 50]) - FOLLOW_EOF_in_layout163 = frozenset([1]) - FOLLOW_mapType_in_section177 = frozenset([32]) - FOLLOW_mapMaterial_in_section179 = frozenset([1]) - FOLLOW_mapOptions_in_mapType202 = frozenset([31, 45, 46, 47, 48, 49, 50]) - FOLLOW_31_in_mapType205 = frozenset([27]) - FOLLOW_NAME_in_mapType207 = frozenset([31]) - FOLLOW_31_in_mapType209 = frozenset([1]) - FOLLOW_32_in_mapMaterial233 = frozenset([35, 36, 40, 41]) - FOLLOW_line_include_in_mapMaterial239 = frozenset([34, 35, 36, 40, 41]) - FOLLOW_line_name_in_mapMaterial245 = frozenset([33]) - FOLLOW_33_in_mapMaterial247 = frozenset([34, 35, 36, 40, 41]) - FOLLOW_line_keytype_in_mapMaterial253 = frozenset([33]) - FOLLOW_33_in_mapMaterial255 = frozenset([34, 35, 36, 40, 41]) - FOLLOW_line_key_in_mapMaterial261 = frozenset([33]) - FOLLOW_33_in_mapMaterial263 = frozenset([34, 35, 36, 40, 41]) - FOLLOW_34_in_mapMaterial270 = frozenset([33]) - FOLLOW_33_in_mapMaterial272 = frozenset([1]) - FOLLOW_35_in_line_include283 = frozenset([31]) - FOLLOW_31_in_line_include285 = frozenset([27]) - FOLLOW_NAME_in_line_include287 = frozenset([31]) - FOLLOW_31_in_line_include289 = frozenset([1]) - FOLLOW_36_in_line_name309 = frozenset([37]) - FOLLOW_37_in_line_name311 = frozenset([27]) - FOLLOW_NAME_in_line_name315 = frozenset([38]) - FOLLOW_38_in_line_name317 = frozenset([39]) - FOLLOW_39_in_line_name319 = frozenset([31]) - FOLLOW_31_in_line_name321 = frozenset([27]) - FOLLOW_NAME_in_line_name325 = frozenset([31]) - FOLLOW_31_in_line_name327 = frozenset([1]) - FOLLOW_40_in_line_keytype351 = frozenset([37]) - FOLLOW_37_in_line_keytype353 = frozenset([27]) - FOLLOW_NAME_in_line_keytype357 = frozenset([38]) - FOLLOW_38_in_line_keytype359 = frozenset([39]) - FOLLOW_39_in_line_keytype361 = frozenset([31]) - FOLLOW_31_in_line_keytype363 = frozenset([27]) - FOLLOW_NAME_in_line_keytype367 = frozenset([31]) - FOLLOW_31_in_line_keytype369 = frozenset([1]) - FOLLOW_41_in_line_key394 = frozenset([42]) - FOLLOW_keycode_in_line_key396 = frozenset([32]) + FOLLOW_section_in_layout144 = frozenset([41, 42, 43, 44, 45, 46]) + FOLLOW_EOF_in_layout147 = frozenset([1]) + FOLLOW_mapType_in_section161 = frozenset([28]) + FOLLOW_mapMaterial_in_section163 = frozenset([1]) + FOLLOW_mapOptions_in_mapType186 = frozenset([27, 41, 42, 43, 44, 45, 46]) + FOLLOW_27_in_mapType189 = frozenset([23]) + FOLLOW_NAME_in_mapType191 = frozenset([27]) + FOLLOW_27_in_mapType193 = frozenset([1]) + FOLLOW_28_in_mapMaterial225 = frozenset([31, 32, 36, 37]) + FOLLOW_line_include_in_mapMaterial230 = frozenset([30, 31, 32, 36, 37]) + FOLLOW_line_name_in_mapMaterial236 = frozenset([29]) + FOLLOW_29_in_mapMaterial238 = frozenset([30, 31, 32, 36, 37]) + FOLLOW_line_keytype_in_mapMaterial244 = frozenset([29]) + FOLLOW_29_in_mapMaterial246 = frozenset([30, 31, 32, 36, 37]) + FOLLOW_line_key_in_mapMaterial252 = frozenset([29]) + FOLLOW_29_in_mapMaterial254 = frozenset([30, 31, 32, 36, 37]) + FOLLOW_30_in_mapMaterial261 = frozenset([29]) + FOLLOW_29_in_mapMaterial263 = frozenset([1]) + FOLLOW_31_in_line_include275 = frozenset([27]) + FOLLOW_27_in_line_include277 = frozenset([23]) + FOLLOW_NAME_in_line_include279 = frozenset([27]) + FOLLOW_27_in_line_include281 = frozenset([1]) + FOLLOW_32_in_line_name301 = frozenset([33]) + FOLLOW_33_in_line_name303 = frozenset([23]) + FOLLOW_NAME_in_line_name307 = frozenset([34]) + FOLLOW_34_in_line_name309 = frozenset([35]) + FOLLOW_35_in_line_name311 = frozenset([27]) + FOLLOW_27_in_line_name313 = frozenset([23]) + FOLLOW_NAME_in_line_name317 = frozenset([27]) + FOLLOW_27_in_line_name319 = frozenset([1]) + FOLLOW_36_in_line_keytype347 = frozenset([33]) + FOLLOW_33_in_line_keytype349 = frozenset([23]) + FOLLOW_NAME_in_line_keytype353 = frozenset([34]) + FOLLOW_34_in_line_keytype355 = frozenset([35]) + FOLLOW_35_in_line_keytype357 = frozenset([27]) + FOLLOW_27_in_line_keytype359 = frozenset([23]) + FOLLOW_NAME_in_line_keytype363 = frozenset([27]) + FOLLOW_27_in_line_keytype365 = frozenset([1]) + FOLLOW_37_in_line_key394 = frozenset([38]) + FOLLOW_keycode_in_line_key396 = frozenset([28]) FOLLOW_keysyms_in_line_key398 = frozenset([1]) - FOLLOW_42_in_keycode422 = frozenset([27]) - FOLLOW_NAME_in_keycode424 = frozenset([43]) - FOLLOW_43_in_keycode426 = frozenset([1]) - FOLLOW_32_in_keysyms446 = frozenset([37]) - FOLLOW_37_in_keysyms448 = frozenset([27]) - FOLLOW_NAME_in_keysyms452 = frozenset([38, 44]) - FOLLOW_44_in_keysyms455 = frozenset([27]) - FOLLOW_NAME_in_keysyms459 = frozenset([38, 44]) - FOLLOW_38_in_keysyms463 = frozenset([34]) - FOLLOW_34_in_keysyms465 = frozenset([1]) + FOLLOW_38_in_keycode422 = frozenset([23]) + FOLLOW_NAME_in_keycode424 = frozenset([39]) + FOLLOW_39_in_keycode426 = frozenset([1]) + FOLLOW_28_in_keysyms446 = frozenset([33]) + FOLLOW_33_in_keysyms448 = frozenset([23]) + FOLLOW_NAME_in_keysyms452 = frozenset([34, 40]) + FOLLOW_40_in_keysyms455 = frozenset([23]) + FOLLOW_NAME_in_keysyms459 = frozenset([34, 40]) + FOLLOW_34_in_keysyms463 = frozenset([30]) + FOLLOW_30_in_keysyms465 = frozenset([1]) FOLLOW_set_in_mapOptions0 = frozenset([1]) + + +def main(argv, stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr): + from antlr3.main import ParserMain + main = ParserMain("XKBGrammarLexer", XKBGrammarParser) + main.stdin = stdin + main.stdout = stdout + main.stderr = stderr + main.execute(argv) + +if __name__ == '__main__': + main(sys.argv) diff --git a/XKBGrammar/XKBGrammarParser.pyc b/XKBGrammar/XKBGrammarParser.pyc Binary files differ. diff --git a/XKBGrammar/XKBGrammarWalker.g b/XKBGrammar/XKBGrammarWalker.g @@ -1,14 +1,14 @@ // XKB Grammar (X.org) // Written by Simos Xenitellis <simos.lists@googlemail.com>, 2008. -// Version 0.3 +// Version 0.4 tree grammar XKBGrammarWalker; options { - tokenVocab=XKBGrammar; - ASTLabelType=CommonTree; - language=Python; + language = Python; + tokenVocab = XKBGrammar; + ASTLabelType = CommonTree; } // We cover XKB symbol files that look like @@ -36,29 +36,23 @@ section ; mapType - : ^(MAPTYPE mapOptions+ NAME) + : ^(MAPTYPE ^(MAPOPTIONS mapOptions+) ^(MAPNAME NAME)) ; -mapMaterial - : ^(MAPMATERIAL line_include line_name line_keytype line_key) +mapOptions + : 'default' + | 'hidden' + | 'partial' + | 'alphanumeric_keys' + | 'alternate_group' + | 'xkb_symbols' ; -// : ^(MAPMATERIAL TOKEN_INCLUDE TOKEN_NAME TOKEN_KEY_TYPE TOKEY_KEY) -// ; -line_include +mapMaterial : ^(TOKEN_INCLUDE NAME) - ; - -line_name - : ^(TOKEN_NAME NAME+) - ; - -line_keytype - : ^(TOKEN_KEY_TYPE NAME+) - ; - -line_key - : ^(TOKEN_KEY keycode keysyms) + | ^(TOKEN_NAME NAME ^(VALUE NAME)) + | ^(TOKEN_KEY_TYPE NAME ^(VALUE NAME)) + | ^(TOKEN_KEY keycode keysyms) ; keycode @@ -69,11 +63,3 @@ keysyms : ^(KEYSYMS NAME+) ; -mapOptions - : 'default' - | 'hidden' - | 'partial' - | 'alphanumeric_keys' - | 'alternate_group' - | 'xkb_symbols' - ; diff --git a/XKBGrammar/check_xkb.py b/XKBGrammar/check_xkb.py @@ -24,7 +24,6 @@ char_stream = antlr3.ANTLRFileStream(xkbfilename, encoding='utf-8') lexer = XKBGrammarLexer(char_stream) tokens = antlr3.CommonTokenStream(lexer) parser = XKBGrammarParser(tokens) - # pdb.set_trace() result = parser.layout() @@ -33,5 +32,6 @@ print "tree =", result.tree.toStringTree() nodes = antlr3.tree.CommonTreeNodeStream(result.tree) nodes.setTokenStream(tokens) walker = XKBGrammarWalker(nodes) -# walker.layout() +walker.layout() +# pdb.set_trace()