keyboardlayouteditor

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

commit 2b374103d98d174a9971ebe1bf25b706fcfc87d3
parent 21308024d7959c34c4ba906c46c96c80f457f59c
Author: Simos Xenitellis <simos.bugzilla@gmail.com>
Date:   Tue, 20 Jan 2009 12:44:21 -0800

Reordered files, merged to singly directory for git migration.

Diffstat:
RKeyboardLayoutEditor/.project -> .project | 0
RKeyboardLayoutEditor/.pydevproject -> .pydevproject | 0
RKeyboardLayoutEditor/.settings/org.eclipse.ltk.core.refactoring.prefs -> .settings/org.eclipse.ltk.core.refactoring.prefs | 0
RKeyboardLayoutEditor/.settings/org.eclipse.mylyn.tasks.ui.prefs -> .settings/org.eclipse.mylyn.tasks.ui.prefs | 0
RKeyboardLayoutEditor/src/COPYING -> COPYING | 0
RKeyboardLayoutEditor/src/Common.py -> Common.py | 0
DCompose/Compose.g | 58----------------------------------------------------------
DCompose/ComposeWalker.g | 16----------------
DCompose/print_tree.py | 71-----------------------------------------------------------------------
RKeyboardLayoutEditor/src/DeadKeysDict.py -> DeadKeysDict.py | 0
RKeyboardLayoutEditor/src/Disconnect. -> Disconnect. | 0
RKeyboardLayoutEditor/src/DumbKey.py -> DumbKey.py | 0
RKeyboardLayoutEditor/src/Enum.py -> Enum.py | 0
RKeyboardLayoutEditor/src/GenericLayout.py -> GenericLayout.py | 0
RKeyboardLayoutEditor/src/Key.py -> Key.py | 0
RKeyboardLayoutEditor/src/KeyDict.py -> KeyDict.py | 0
RKeyboardLayoutEditor/src/KeyValue.py -> KeyValue.py | 0
RKeyboardLayoutEditor/src/Keyboard.py -> Keyboard.py | 0
RKeyboardLayoutEditor/src/KeyboardLayoutEditor.py -> KeyboardLayoutEditor.py | 0
DKeyboardLayoutEditor/src/README.txt | 41-----------------------------------------
RKeyboardLayoutEditor/src/Keycodes.g -> Keycodes.g | 0
DKeycodes/Keycodes.g | 110-------------------------------------------------------------------------------
DKeycodes/KeycodesWalker.g | 34----------------------------------
DKeycodes/create_keycode_dict.py | 121-------------------------------------------------------------------------------
DKeycodes/extract_keycodes.py | 123-------------------------------------------------------------------------------
DKeycodes/print_tree.py | 69---------------------------------------------------------------------
RKeyboardLayoutEditor/src/KeycodesReader.py -> KeycodesReader.py | 0
RKeyboardLayoutEditor/src/KeycodesWalker.g -> KeycodesWalker.g | 0
RKeyboardLayoutEditor/src/Keysyms.py -> Keysyms.py | 0
RKeyboardLayoutEditor/src/KeysymsUni.py -> KeysymsUni.py | 0
RKeyboardLayoutEditor/src/KeysymsUniByValue.py -> KeysymsUniByValue.py | 0
RKeyboardLayoutEditor/src/Levels.png -> Levels.png | 0
RKeyboardLayoutEditor/src/Levels.svg -> Levels.svg | 0
RKeyboardLayoutEditor/src/ParseXKB.py -> ParseXKB.py | 0
RKeyboardLayoutEditor/src/ParseXML.py -> ParseXML.py | 0
RKeyboardLayoutEditor/README.txt -> README | 0
RKeyboardLayoutEditor/src/SelectVariant.py -> SelectVariant.py | 0
RKeyboardLayoutEditor/src/XKBGrammar.g -> XKBGrammar.g | 0
DXKBGrammar/README | 4----
DXKBGrammar/XKBGrammar.g | 204-------------------------------------------------------------------------------
DXKBGrammar/XKBGrammar.tokens | 67-------------------------------------------------------------------
DXKBGrammar/XKBGrammarLexer.py | 1595-------------------------------------------------------------------------------
DXKBGrammar/XKBGrammarLexer.pyc | 0
DXKBGrammar/XKBGrammarParser.py | 2396-------------------------------------------------------------------------------
DXKBGrammar/XKBGrammarParser.pyc | 0
DXKBGrammar/XKBGrammarWalker.g | 58----------------------------------------------------------
DXKBGrammar/XKBGrammar__.g | 53-----------------------------------------------------
DXKBGrammar/check_xkb.py | 159-------------------------------------------------------------------------------
DXKBGrammar/gr | 17-----------------
DXKBGrammar/parse_xkb_to_xml.py | 188-------------------------------------------------------------------------------
DXKBGrammar/parse_xml_to_xkb.py | 106-------------------------------------------------------------------------------
DXKBGrammar/print_tree.py | 70----------------------------------------------------------------------
DXKBGrammar/xkb.rng | 129-------------------------------------------------------------------------------
DXKBGrammar/xkbsample.xml | 118-------------------------------------------------------------------------------
RKeyboardLayoutEditor/src/XKBGrammarWalker.g -> XKBGrammarWalker.g | 0
RKeyboardLayoutEditor/src/aliases -> aliases | 0
RKeyboardLayoutEditor/src/evdev -> evdev | 0
RKeyboardLayoutEditor/src/kle-icon.svg -> kle-icon.svg | 0
RKeyboardLayoutEditor/src/kle-icon2.svg -> kle-icon2.svg | 0
RKeyboardLayoutEditor/src/kle-icon3.svg -> kle-icon3.svg | 0
RKeyboardLayoutEditor/src/kle-icon4.svg -> kle-icon4.svg | 0
RKeyboardLayoutEditor/src/parse_xkb_to_xml.py -> parse_xkb_to_xml.py | 0
RKeyboardLayoutEditor/src/parse_xml_to_xkb.py -> parse_xml_to_xkb.py | 0
RKeyboardLayoutEditor/src/print_tree.py -> print_tree.py | 0
RKeyboardLayoutEditor/src/utils/Keysyms.g -> utils/Keysyms.g | 0
RKeyboardLayoutEditor/src/utils/KeysymsWalker.g -> utils/KeysymsWalker.g | 0
RKeyboardLayoutEditor/src/utils/extract_keysymdefh.py -> utils/extract_keysymdefh.py | 0
RKeyboardLayoutEditor/src/utils/extract_keysymstxt.py -> utils/extract_keysymstxt.py | 0
RKeyboardLayoutEditor/src/utils/keysymdef.h -> utils/keysymdef.h | 0
RKeyboardLayoutEditor/src/utils/keysyms.txt -> utils/keysyms.txt | 0
RKeyboardLayoutEditor/src/xfree86 -> xfree86 | 0
71 files changed, 0 insertions(+), 5807 deletions(-)

diff --git a/KeyboardLayoutEditor/.project b/.project diff --git a/KeyboardLayoutEditor/.pydevproject b/.pydevproject diff --git a/KeyboardLayoutEditor/.settings/org.eclipse.ltk.core.refactoring.prefs b/.settings/org.eclipse.ltk.core.refactoring.prefs diff --git a/KeyboardLayoutEditor/.settings/org.eclipse.mylyn.tasks.ui.prefs b/.settings/org.eclipse.mylyn.tasks.ui.prefs diff --git a/KeyboardLayoutEditor/src/COPYING b/COPYING diff --git a/KeyboardLayoutEditor/src/Common.py b/Common.py diff --git a/Compose/Compose.g b/Compose/Compose.g @@ -1,58 +0,0 @@ -// Compose Grammar (X.org) -// Written by Simos Xenitellis <simos.lists@googlemail.com>, 2008. -// Version 0.1 - -grammar Compose; - -options -{ - language = Python; - output = AST; -} - -tokens -{ - COMPOSE; - CODEPOINT; - SEQUENCE; - SYM; -} - -compose - : sequence+ EOF - -> ^(COMPOSE sequence+) - ; - -sequence - : sym+ ':' DQSTRING NAME? - -> ^(SEQUENCE sym+ ^(CODEPOINT DQSTRING NAME?)) - ; - -sym - : '<' NAME '>' - -> ^(SYM NAME) - ; - -NAME - : ( 'a'..'z' | 'A'..'Z' | '_' | '0'..'9' )* - ; - -WS - : - ( ' ' | '\r' | '\t' | '\u000C' | '\n') - { $channel=HIDDEN; } - ; - -LINE_COMMENT - : - '#' ~('\n' | '\r')* '\r'? '\n' - { $channel=HIDDEN; } - ; - -/** Match various string types. Note that greedy=false implies ''' - * should make us exit loop not continue. - */ -DQSTRING - : '"' str=('\\\"' | (options {greedy=false;}:~('"'))*) '"' - ; - diff --git a/Compose/ComposeWalker.g b/Compose/ComposeWalker.g @@ -1,16 +0,0 @@ -// Compose Grammar (X.org) -// Written by Simos Xenitellis <simos.lists@googlemail.com>, 2008. -// Version 0.1 - -tree grammar ComposeWalker; - -options -{ - language = Python; - tokenVocab = Compose; - ASTLabelType = CommonTree; -} - -compose : ^(COMPOSE sequence+) ; -sequence: ^(SEQUENCe sym+ ^(CODEPOINT DQSTRING NAME?)) ; -sym : ^(SYM NAME) ; diff --git a/Compose/print_tree.py b/Compose/print_tree.py @@ -1,71 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -# Version 0.7 - -import sys -import pdb -import antlr3 -from ComposeLexer import ComposeLexer -from ComposeParser import ComposeParser -from ComposeWalker import ComposeWalker - -# Helper function to iterate through all children of a given type -def getChildrenByType(tree, type_value): - for i in range(tree.getChildCount()): - child = tree.getChild(i) - if child.getType() == type_value: - yield child - -# Helper function to iterate through all children of a given type -def getChildrenListByType(tree, type_value): - list = [] - for i in range(tree.getChildCount()): - child = tree.getChild(i) - if child.getType() == type_value: - list.append(child) - return list - -xkbfilename = "/usr/share/X11/locale/en_US.UTF-8/Compose" -if len(sys.argv) > 1: - xkbfilename = sys.argv[1] - -try: - xkbfile = open(xkbfilename, 'r') -except OSError: - print "Could not open file ", xkbfilename, ". Aborting..." - sys.exit(-1) - -xkbfile.close - -char_stream = antlr3.ANTLRFileStream(xkbfilename, encoding='utf-8') -lexer = ComposeLexer(char_stream) -tokens = antlr3.CommonTokenStream(lexer) -parser = ComposeParser(tokens) - -#pdb.set_trace() -result = parser.compose() - -print "XXXXXXXXXXXXXXXXXXXXXXX", xkbfilename -print "tree =", result.tree.toStringTree() - -nodes = antlr3.tree.CommonTreeNodeStream(result.tree) -nodes.setTokenStream(tokens) -walker = ComposeWalker(nodes) -walker.compose() - - -MAX = 10 -TABS = "\t\t\t\t\t\t\t\t\t\t" - -def print_tree(node, depth): - if depth >= MAX: - return - for n in node.getChildren(): - print TABS[:depth], "===", n.getText(), "===" - print_tree(n, depth + 1) - - -print result.tree.getChild(0).getText() -print -print_tree(result.tree, 0) diff --git a/KeyboardLayoutEditor/src/DeadKeysDict.py b/DeadKeysDict.py diff --git a/KeyboardLayoutEditor/src/Disconnect. b/Disconnect. diff --git a/KeyboardLayoutEditor/src/DumbKey.py b/DumbKey.py diff --git a/KeyboardLayoutEditor/src/Enum.py b/Enum.py diff --git a/KeyboardLayoutEditor/src/GenericLayout.py b/GenericLayout.py diff --git a/KeyboardLayoutEditor/src/Key.py b/Key.py diff --git a/KeyboardLayoutEditor/src/KeyDict.py b/KeyDict.py diff --git a/KeyboardLayoutEditor/src/KeyValue.py b/KeyValue.py diff --git a/KeyboardLayoutEditor/src/Keyboard.py b/Keyboard.py diff --git a/KeyboardLayoutEditor/src/KeyboardLayoutEditor.py b/KeyboardLayoutEditor.py diff --git a/KeyboardLayoutEditor/src/README.txt b/KeyboardLayoutEditor/src/README.txt @@ -1,41 +0,0 @@ -This is the Keyboard Layout Editor (KLE), a pygtk program that helps create -or edit XKB keyboard layouts. This allows you to type characters from different -languages or other special Unicode characters on your Linux desktop. - -The project page of the Keyboard Layout Editor is -http://code.google.com/p/keyboardlayouteditor/ - -You are strongly encouraged to use the version that is found at the above URL, -as it includes several bug fixes. - -The project was developed using Eclipse (Ganymede), with the Python (PyDev) -and Antlr (AntlrIDE) add-ons. - -PyDev is found at -http://pydev.sourceforge.net/ - -AntlrIDE is found at -http://antlrv3ide.sourceforge.net/ - -If you also have SVN support in Eclipse (hint: Subclipse), -you can grab the latest source from within Eclipse. -There is also integration with Mylene so that you can get the list of -issues/bugs/todo items automatically. - -To run the application, you need the python binding packages for -* Cairo -* Pango -* GObject -* lxml - -and the Antlr 3.1 Runtime environment for Python. You grab that at -http://antlr.org/download/Python/ -Choose the appropriate *.egg file for the 3.1 version, then type - -sudo easy_install antlr_python_runtime-3.1-py2.5.egg - -This should do the installation for you. - -You run the Keyboard Layout Editor with - -./KeyboardLayoutEditor.py diff --git a/KeyboardLayoutEditor/src/Keycodes.g b/Keycodes.g diff --git a/Keycodes/Keycodes.g b/Keycodes/Keycodes.g @@ -1,110 +0,0 @@ -// Keycodes Grammar (X.org) -// Written by Simos Xenitellis <simos.lists@googlemail.com>, 2008. -// Version 0.8 - -grammar Keycodes; - -options -{ - language = Python; - output = AST; -} - -tokens -{ - KEYCODEDOC; - KEYCODELIST; - KEYCODELISTTYPE; - KEYCODELISTOPTIONS; - KEYCODELISTOPTS; - KEYCODELISTNAME; - KEYCODEMATERIAL; - INCLUDE; - MINIMUM; - MAXIMUM; - ALIAS; - INDICATOR; - KEYCODE; -} - -keycodedoc - : keycodelist+ EOF - -> ^(KEYCODEDOC keycodelist+) - ; - -keycodelist - : keycodelisttype '{' keycodeMaterial+ '}' ';' - -> ^(KEYCODELIST keycodelisttype ^(KEYCODEMATERIAL keycodeMaterial+)) - ; - -keycodelisttype - : KEYCODELISTOPTS+ DQSTRING - -> ^(KEYCODELISTTYPE ^(KEYCODELISTOPTIONS KEYCODELISTOPTS+) ^(KEYCODELISTNAME DQSTRING)) - ; - -keycodeMaterial - : line_include - | line_minmax ';'! - | line_alias ';'! - | line_keycode ';'! - | line_indicator ';'! - ; - -line_include - : 'include' DQSTRING - -> ^(INCLUDE DQSTRING) - ; - -line_minmax - : 'minimum' '=' NAME -> ^(MINIMUM NAME) - | 'maximum' '=' NAME -> ^(MAXIMUM NAME) - ; - -line_alias - : 'alias' '<' val+=NAME '>' '=' '<' val+=NAME '>' - -> ^(ALIAS $val+) - ; - -line_keycode - : '<' val+=NAME '>' '=' val+=NAME - -> ^(KEYCODE NAME+) - ; - -line_indicator - : 'indicator' NAME '=' DQSTRING - -> ^(INDICATOR NAME DQSTRING) - ; - -KEYCODELISTOPTS - : 'default' - | 'xkb_keycodes' - ; - -NAME - : ( 'a'..'z' | 'A'..'Z' | '_' | '0'..'9' | '+' | '-' )* - ; - -WS - : - ( ' ' | '\r' | '\t' | '\u000C' | '\n') - { $channel=HIDDEN; } - ; - -COMMENT - : - '/*' .* '*/' {$channel=HIDDEN;} - ; - -LINE_COMMENT - : - ('//' | '#') ~('\n' | '\r')* '\r'? '\n' - { $channel=HIDDEN; } - ; - -/** Match various string types. Note that greedy=false implies ''' - * should make us exit loop not continue. - */ -DQSTRING - : '"' ((options {greedy=false;}:~('"'))*) '"' - ; - diff --git a/Keycodes/KeycodesWalker.g b/Keycodes/KeycodesWalker.g @@ -1,34 +0,0 @@ -// Keycodes Grammar (X.org) -// Written by Simos Xenitellis <simos.lists@googlemail.com>, 2008. -// Version 0.8 - -tree grammar KeycodesWalker; - -options -{ - language = Python; - tokenVocab = Keycodes; - ASTLabelType = CommonTree; -} - - -keycodedoc - : ^(KEYCODEDOC keycodelist+) - ; - -keycodelist - : ^(KEYCODELIST keycodelisttype ^(KEYCODEMATERIAL keycodeMaterial+)) - ; - -keycodelisttype - : ^(KEYCODELISTTYPE ^(KEYCODELISTOPTIONS KEYCODELISTOPTS+) ^(KEYCODELISTNAME DQSTRING)) - ; - -keycodeMaterial - : ^(INCLUDE DQSTRING) - | ^(MINIMUM NAME) - | ^(MAXIMUM NAME) - | ^(ALIAS NAME+) - | ^(KEYCODE NAME+) - | ^(INDICATOR NAME DQSTRING) - ; diff --git a/Keycodes/create_keycode_dict.py b/Keycodes/create_keycode_dict.py @@ -1,121 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -# Version 0.9 - -import sys -import pdb -import antlr3 -import re -from KeycodesLexer import KeycodesLexer, KEYCODELISTTYPE, KEYCODEMATERIAL, KEYCODELISTOPTIONS, KEYCODELISTNAME, INCLUDE, MINIMUM, MAXIMUM, KEYCODE, ALIAS, INDICATOR -from KeycodesParser import KeycodesParser -from KeycodesWalker import KeycodesWalker - -# Helper function to iterate through all children of a given type -def getChildrenByType(tree, type_value): - for i in range(tree.getChildCount()): - child = tree.getChild(i) - if child.getType() == type_value: - yield child - -# Helper function to iterate through all children of a given type -def getChildrenListByType(tree, type_value): - list = [] - for i in range(tree.getChildCount()): - child = tree.getChild(i) - if child.getType() == type_value: - list.append(child) - return list - -# Helper function to iterate through all children of a given type -def getChildrenListValuesByType(tree, type_value): - list = [] - for i in range(tree.getChildCount()): - child = tree.getChild(i) - if child.getType() == type_value: - list.append(child.getChild(0).getText()) - return list - -filename = "xfree86" -if len(sys.argv) > 1: - filename = sys.argv[1] - -try: - file = open(filename, 'r') -except OSError: - print "Could not open file ", filename, ". Aborting..." - sys.exit(-1) - -file.close - -char_stream = antlr3.ANTLRFileStream(filename) -lexer = KeycodesLexer(char_stream) -tokens = antlr3.CommonTokenStream(lexer) -parser = KeycodesParser(tokens) - -result = parser.keycodedoc() - -#print "XXXXXXXXXXXXXXXXXXXXXXX", filename -#print "tree =", result.tree.toStringTree() - -nodes = antlr3.tree.CommonTreeNodeStream(result.tree) -nodes.setTokenStream(tokens) -walker = KeycodesWalker(nodes) -walker.keycodedoc() - -MAX = 10 -TABS = "\t\t\t\t\t\t\t\t\t\t" - -def print_tree(node, depth): - if depth >= MAX: - return - for n in node.getChildren(): - print TABS[:depth], "===", n.getText(), "===" - print_tree(n, depth + 1) - - -#print result.tree.getChild(0).getText() -#print -#print_tree(result.tree, 0) - -keycodedb = {} -keycodeid = "xfree86" -keycodeidinclude = [keycodeid] -copying = False - -for itemKeycodeDoc in result.tree.getChildren(): - listType = getChildrenListByType(itemKeycodeDoc, KEYCODELISTTYPE) - material = getChildrenListByType(itemKeycodeDoc, KEYCODEMATERIAL) - if len(listType) != 1: - print "Requires single node for KEYCODELISTTYPE. Found", len(listType) - sys.exit(-1) - if len(material) != 1: - print "Requires single node for KEYCODEMATERIAL. Found", len(material) - sys.exit(-1) - - for listNameGroup in getChildrenListByType(listType[0], KEYCODELISTNAME): - for listName in listNameGroup.getChildren(): - if listName.getText()[1:-1] == keycodeid or listName.getText()[1:-1] in keycodeidinclude: - print "About to process", listName.getText()[1:-1] - copying = True - - for materialIncludeGroup in getChildrenListByType(material[0], INCLUDE): - for includeName in materialIncludeGroup.getChildren(): - includeKeycodelist = re.findall('(\w+)\((\w+)\)', includeName.getText()[1:-1]) - if includeKeycodelist[0][1] not in keycodeidinclude: - print "Added", includeKeycodelist[0][0], includeKeycodelist[0][1] - keycodeidinclude.append(includeKeycodelist[0][1]) - - for keycode in getChildrenListByType(material[0], KEYCODE): - keycodedb[keycode.getChild(0).getText()] = keycode.getChild(1).getText() - - for alias in getChildrenListByType(material[0], ALIAS): - keycodedb[alias.getChild(0).getText()] = keycodedb[alias.getChild(1).getText()] - - for indicator in getChildrenListByType(material[0], INDICATOR): - pass - - copying = False - -for item in keycodedb.keys(): - print item, keycodedb[item] diff --git a/Keycodes/extract_keycodes.py b/Keycodes/extract_keycodes.py @@ -1,123 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -# Version 0.9 - -import sys -import pdb -import antlr3 -from KeycodesLexer import KeycodesLexer, KEYCODELISTTYPE, KEYCODEMATERIAL, KEYCODELISTOPTIONS, KEYCODELISTNAME, INCLUDE, MINIMUM, MAXIMUM, KEYCODE, ALIAS, INDICATOR -from KeycodesParser import KeycodesParser -from KeycodesWalker import KeycodesWalker - -# Helper function to iterate through all children of a given type -def getChildrenByType(tree, type_value): - for i in range(tree.getChildCount()): - child = tree.getChild(i) - if child.getType() == type_value: - yield child - -# Helper function to iterate through all children of a given type -def getChildrenListByType(tree, type_value): - list = [] - for i in range(tree.getChildCount()): - child = tree.getChild(i) - if child.getType() == type_value: - list.append(child) - return list - -# Helper function to iterate through all children of a given type -def getChildrenListValuesByType(tree, type_value): - list = [] - for i in range(tree.getChildCount()): - child = tree.getChild(i) - if child.getType() == type_value: - list.append(child.getChild(0).getText()) - return list - -filename = "xfree86" -if len(sys.argv) > 1: - filename = sys.argv[1] - -try: - file = open(filename, 'r') -except OSError: - print "Could not open file ", filename, ". Aborting..." - sys.exit(-1) - -file.close - -char_stream = antlr3.ANTLRFileStream(filename) -lexer = KeycodesLexer(char_stream) -tokens = antlr3.CommonTokenStream(lexer) -parser = KeycodesParser(tokens) - -result = parser.keycodedoc() - -#print "XXXXXXXXXXXXXXXXXXXXXXX", filename -#print "tree =", result.tree.toStringTree() - -nodes = antlr3.tree.CommonTreeNodeStream(result.tree) -nodes.setTokenStream(tokens) -walker = KeycodesWalker(nodes) -walker.keycodedoc() - -MAX = 10 -TABS = "\t\t\t\t\t\t\t\t\t\t" - -def print_tree(node, depth): - if depth >= MAX: - return - for n in node.getChildren(): - print TABS[:depth], "===", n.getText(), "===" - print_tree(n, depth + 1) - - -#print result.tree.getChild(0).getText() -#print -#print_tree(result.tree, 0) - -for itemKeycodeDoc in result.tree.getChildren(): - listType = getChildrenListByType(itemKeycodeDoc, KEYCODELISTTYPE) - material = getChildrenListByType(itemKeycodeDoc, KEYCODEMATERIAL) - if len(listType) != 1: - print "Requires single node for KEYCODELISTTYPE. Found", len(listType) - sys.exit(-1) - if len(material) != 1: - print "Requires single node for KEYCODEMATERIAL. Found", len(material) - sys.exit(-1) - - for listOptionsGroup in getChildrenListByType(listType[0], KEYCODELISTOPTIONS): - for listOptions in listOptionsGroup.getChildren(): - print listOptions.getText(), - for listNameGroup in getChildrenListByType(listType[0], KEYCODELISTNAME): - for listName in listNameGroup.getChildren(): - print listName.getText(), - print "{" - - for materialIncludeGroup in getChildrenListByType(material[0], INCLUDE): - for includeName in materialIncludeGroup.getChildren(): - print "\tinclude", includeName.getText() - - if len(getChildrenListByType(material[0], MINIMUM)) not in [0, 1]: - print "More than one Minimum entries found. Aborting..." - sys.exit(-1) - if len(getChildrenListByType(material[0], MAXIMUM)) not in [0, 1]: - print "More than one Maximym entries found. Aborting..." - sys.exit(-1) - if len(getChildrenListByType(material[0], MINIMUM)) == 1: - print "\tminimum %(v)s;" % { "v": getChildrenListByType(material[0], MINIMUM)[0].getChild(0).getText() } - if len(getChildrenListByType(material[0], MAXIMUM)) == 1: - print "\tmaximum %(v)s;" % { "v": getChildrenListByType(material[0], MAXIMUM)[0].getChild(0).getText() } - - for keycode in getChildrenListByType(material[0], KEYCODE): - print "\tkeycode <%(k)s> = %(v)s;" % { "k": keycode.getChild(0).getText(), "v": keycode.getChild(1).getText()} - - for alias in getChildrenListByType(material[0], ALIAS): - print "\talias <%(k1)s> = <%(k2)s>;" % { "k1": alias.getChild(0).getText(), "k2": alias.getChild(1).getText()} - - for indicator in getChildrenListByType(material[0], INDICATOR): - print "\tindicator %(id)s = %(val)s;" % { "id": indicator.getChild(0).getText(), "val": indicator.getChild(1).getText()} - - print '};\n' - diff --git a/Keycodes/print_tree.py b/Keycodes/print_tree.py @@ -1,69 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -# Version 0.8 - -import sys -import pdb -import antlr3 -from KeycodesLexer import KeycodesLexer -from KeycodesParser import KeycodesParser -from KeycodesWalker import KeycodesWalker - -# Helper function to iterate through all children of a given type -def getChildrenByType(tree, type_value): - for i in range(tree.getChildCount()): - child = tree.getChild(i) - if child.getType() == type_value: - yield child - -# Helper function to iterate through all children of a given type -def getChildrenListByType(tree, type_value): - list = [] - for i in range(tree.getChildCount()): - child = tree.getChild(i) - if child.getType() == type_value: - list.append(child) - return list - -filename = "xfree86" -if len(sys.argv) > 1: - filename = sys.argv[1] - -try: - file = open(filename, 'r') -except OSError: - print "Could not open file ", filename, ". Aborting..." - sys.exit(-1) - -file.close - -char_stream = antlr3.ANTLRFileStream(filename) -lexer = KeycodesLexer(char_stream) -tokens = antlr3.CommonTokenStream(lexer) -parser = KeycodesParser(tokens) - -result = parser.keycodedoc() - -print "XXXXXXXXXXXXXXXXXXXXXXX", filename -print "tree =", result.tree.toStringTree() - -nodes = antlr3.tree.CommonTreeNodeStream(result.tree) -nodes.setTokenStream(tokens) -walker = KeycodesWalker(nodes) -walker.keycodedoc() - -MAX = 10 -TABS = "\t\t\t\t\t\t\t\t\t\t" - -def print_tree(node, depth): - if depth >= MAX: - return - for n in node.getChildren(): - print TABS[:depth], "===", n.getText(), "===" - print_tree(n, depth + 1) - - -print result.tree.getChild(0).getText() -print -print_tree(result.tree, 0) diff --git a/KeyboardLayoutEditor/src/KeycodesReader.py b/KeycodesReader.py diff --git a/KeyboardLayoutEditor/src/KeycodesWalker.g b/KeycodesWalker.g diff --git a/KeyboardLayoutEditor/src/Keysyms.py b/Keysyms.py diff --git a/KeyboardLayoutEditor/src/KeysymsUni.py b/KeysymsUni.py diff --git a/KeyboardLayoutEditor/src/KeysymsUniByValue.py b/KeysymsUniByValue.py diff --git a/KeyboardLayoutEditor/src/Levels.png b/Levels.png Binary files differ. diff --git a/KeyboardLayoutEditor/src/Levels.svg b/Levels.svg diff --git a/KeyboardLayoutEditor/src/ParseXKB.py b/ParseXKB.py diff --git a/KeyboardLayoutEditor/src/ParseXML.py b/ParseXML.py diff --git a/KeyboardLayoutEditor/README.txt b/README diff --git a/KeyboardLayoutEditor/src/SelectVariant.py b/SelectVariant.py diff --git a/KeyboardLayoutEditor/src/XKBGrammar.g b/XKBGrammar.g diff --git a/XKBGrammar/README b/XKBGrammar/README @@ -1,4 +0,0 @@ - -To check if some files are non-UTF-8, use -find . -type f | awk '{ printf "echo %s; iconv -f utf-8 -t utf-8 < %s > /dev/null \n", $1, $1 }' | sh - diff --git a/XKBGrammar/XKBGrammar.g b/XKBGrammar/XKBGrammar.g @@ -1,204 +0,0 @@ -// XKB Grammar (X.org) -// Written by Simos Xenitellis <simos.lists@googlemail.com>, 2008. -// Version 0.8 - -grammar XKBGrammar; - -options -{ - language = Python; - output = AST; -} - -tokens -{ - // Keywords - TOKEN_INCLUDE; - TOKEN_KEY_TYPE; - TOKEN_NAME; - TOKEN_KEY; - TOKEN_TYPE; - TOKEN_MODIFIER_MAP; - TOKEN_SYMBOL; - TOKEN_VIRTUAL_MODIFIERS; - - // Tokens for tree. - LAYOUT; - SYMBOLS; - MAPTYPE; - MAPNAME; - MAPOPTIONS; - MAPMATERIAL; - KEYCODE; - KEYCODEX; - VALUE; - STATE; - ELEM_KEYSYMGROUP; - ELEM_KEYSYMS; - ELEM_VIRTUALMODS; - KEYELEMENTS; - OVERRIDE; - OVERLAY; -} - -// We cover XKB symbol files that look like -// -// // comments can appear here. -// one of more modifiers "mysymbolsname" -// { -// // comments can appear here. -// include "somename" // comments can also appear here. -// name[somestring] = "sometext"; -// key.type[someotherstring] = "someothertext"; -// key <someotherstring> { [ somesymbol, someothersymbol, ... uptoEightSymbols ] }; -// modifier_map someothertext { somesymbol, someothersymbol, ... uptoEightSymbols }; -// // can also have multiples of the above. -// }; -// -// // can have several symbol sections as above. - -layout - : symbols+ EOF - -> ^(LAYOUT symbols+) - ; - -symbols - : mapType '{' mapMaterial+ '}' ';' - -> ^(SYMBOLS mapType ^(MAPMATERIAL mapMaterial+)) - ; - -mapType - : MAPOPTS+ DQSTRING - -> ^(MAPTYPE ^(MAPOPTIONS MAPOPTS+) ^(MAPNAME DQSTRING)) - ; - -mapMaterial - : line_include - | line_name ';'! - | line_keytype ';'! - | line_key ';'! - | line_modifier_map ';'! - | line_virtual_modifiers ';'! - ; - -line_include - : 'include' DQSTRING - -> ^(TOKEN_INCLUDE DQSTRING) - ; - -line_name - : 'name' ('[' NAME ']')? '=' DQSTRING - -> ^(TOKEN_NAME DQSTRING) - ; - -line_keytype - : 'key.type' ('[' NAME ']')? '=' DQSTRING - -> ^(TOKEN_KEY_TYPE DQSTRING) - ; - -line_key - : OVERRIDE? 'key' '<' NAME '>' '{' keyelements (',' keyelements)* '}' - -> ^(TOKEN_KEY OVERRIDE? ^(KEYCODEX NAME) keyelements+) - ; - -line_modifier_map - : 'modifier_map' STATE '{' keycode (',' keycode)* '}' - -> ^(TOKEN_MODIFIER_MAP STATE keycode+) - ; - -line_virtual_modifiers - : 'virtual_modifiers' NAME (',' NAME)* - -> ^(TOKEN_VIRTUAL_MODIFIERS NAME+) - ; - -keycode - : '<' NAME '>' -> ^(KEYCODEX NAME) - | NAME -> ^(KEYCODE NAME) - ; - -override - : 'override' - ; - -keyelements - : elem_keysyms - | elem_keysymgroup - | elem_virtualmods - | elem_overlay - ; - -elem_keysyms - : 'type' ('[' NAME ']')? '=' DQSTRING - -> ^(ELEM_KEYSYMS DQSTRING) - ; - -elem_keysymgroup - : ('symbols' '[' NAME ']' '=')? '[' keysym+=NAME (',' keysym+=NAME)* ']' - -> ^(ELEM_KEYSYMGROUP ^(VALUE $keysym+ )) - ; - -elem_virtualmods - : ('virtualMods' '=' NAME) - -> ^(ELEM_VIRTUALMODS NAME) - ; - -elem_overlay - : NAME '=' keycode - -> ^(OVERLAY NAME keycode) - ; - -MAPOPTS - : 'default' - | 'hidden' - | 'partial' - | 'alphanumeric_keys' - | 'keypad_keys' - | 'function_keys' - | 'modifier_keys' - | 'alternate_group' - | 'xkb_symbols' - ; - -STATE - : 'Shift' - | 'Control' - | 'Lock' - | 'Mod1' - | 'Mod2' - | 'Mod3' - | 'Mod4' - | 'Mod5' - ; - -OVERRIDE - : 'override' - ; - -NAME - : ( 'a'..'z' | 'A'..'Z' | '_' | '0'..'9' | '+' | '-' )* - ; - -WS - : - ( ' ' | '\r' | '\t' | '\u000C' | '\n') - { $channel=HIDDEN; } - ; - -COMMENT - : - '/*' .* '*/' {$channel=HIDDEN;} - ; - -LINE_COMMENT - : - ('//' | '#') ~('\n' | '\r')* '\r'? '\n' - { $channel=HIDDEN; } - ; - -/** Match various string types. Note that greedy=false implies ''' - * should make us exit loop not continue. - */ -DQSTRING - : '"' (options {greedy=false;}:~('"'))* '"' - ; - diff --git a/XKBGrammar/XKBGrammar.tokens b/XKBGrammar/XKBGrammar.tokens @@ -1,67 +0,0 @@ -MAPOPTIONS=16 -OVERLAY=27 -TOKEN_INCLUDE=4 -ELEM_VIRTUALMODS=24 -ELEM_KEYSYMS=23 -TOKEN_MODIFIER_MAP=9 -TOKEN_TYPE=8 -MAPTYPE=14 -TOKEN_VIRTUAL_MODIFIERS=11 -NAME=30 -T__51=51 -MAPMATERIAL=17 -MAPOPTS=28 -COMMENT=32 -DQSTRING=29 -T__50=50 -T__42=42 -T__43=43 -T__40=40 -STATE=21 -T__41=41 -T__46=46 -T__47=47 -T__44=44 -T__45=45 -LINE_COMMENT=33 -KEYCODE=18 -T__48=48 -T__49=49 -TOKEN_NAME=6 -VALUE=20 -LAYOUT=12 -WS=31 -T__34=34 -T__35=35 -T__36=36 -T__37=37 -OVERRIDE=26 -T__38=38 -T__39=39 -TOKEN_SYMBOL=10 -ELEM_KEYSYMGROUP=22 -TOKEN_KEY=7 -MAPNAME=15 -SYMBOLS=13 -KEYELEMENTS=25 -TOKEN_KEY_TYPE=5 -KEYCODEX=19 -'}'=35 -'virtual_modifiers'=48 -'override'=26 -'key'=43 -'symbols'=50 -'type'=49 -'{'=34 -'>'=45 -'include'=37 -';'=36 -'='=41 -'virtualMods'=51 -'key.type'=42 -'<'=44 -'['=39 -'name'=38 -','=46 -'modifier_map'=47 -']'=40 diff --git a/XKBGrammar/XKBGrammarLexer.py b/XKBGrammar/XKBGrammarLexer.py @@ -1,1595 +0,0 @@ -# $ANTLR 3.1b1 XKBGrammar.g 2008-06-20 23:20:20 - -import sys -from antlr3 import * -from antlr3.compat import set, frozenset - - -# for convenience in actions -HIDDEN = BaseRecognizer.HIDDEN - -# token types -MAPOPTIONS=16 -OVERLAY=27 -TOKEN_INCLUDE=4 -ELEM_VIRTUALMODS=24 -ELEM_KEYSYMS=23 -TOKEN_MODIFIER_MAP=9 -EOF=-1 -TOKEN_TYPE=8 -MAPTYPE=14 -TOKEN_VIRTUAL_MODIFIERS=11 -NAME=30 -T__51=51 -MAPMATERIAL=17 -MAPOPTS=28 -COMMENT=32 -DQSTRING=29 -T__50=50 -T__42=42 -T__43=43 -T__40=40 -STATE=21 -T__41=41 -T__46=46 -T__47=47 -T__44=44 -T__45=45 -LINE_COMMENT=33 -KEYCODE=18 -T__48=48 -T__49=49 -TOKEN_NAME=6 -VALUE=20 -LAYOUT=12 -WS=31 -T__34=34 -T__35=35 -T__36=36 -T__37=37 -OVERRIDE=26 -T__38=38 -T__39=39 -ELEM_KEYSYMGROUP=22 -TOKEN_SYMBOL=10 -MAPNAME=15 -TOKEN_KEY=7 -SYMBOLS=13 -KEYELEMENTS=25 -TOKEN_KEY_TYPE=5 -KEYCODEX=19 - - -class XKBGrammarLexer(Lexer): - - grammarFileName = "XKBGrammar.g" - - def __init__(self, input=None, state=None): - if state is None: - state = RecognizerSharedState() - Lexer.__init__(self, input, state) - - self.dfa1 = self.DFA1( - self, 1, - eot = self.DFA1_eot, - eof = self.DFA1_eof, - min = self.DFA1_min, - max = self.DFA1_max, - accept = self.DFA1_accept, - special = self.DFA1_special, - transition = self.DFA1_transition - ) - - self.dfa2 = self.DFA2( - self, 2, - eot = self.DFA2_eot, - eof = self.DFA2_eof, - min = self.DFA2_min, - max = self.DFA2_max, - accept = self.DFA2_accept, - special = self.DFA2_special, - transition = self.DFA2_transition - ) - - self.dfa9 = self.DFA9( - self, 9, - eot = self.DFA9_eot, - eof = self.DFA9_eof, - min = self.DFA9_min, - max = self.DFA9_max, - accept = self.DFA9_accept, - special = self.DFA9_special, - transition = self.DFA9_transition - ) - - - - - - - # $ANTLR start T__34 - def mT__34(self, ): - - try: - _type = T__34 - _channel = DEFAULT_CHANNEL - - # XKBGrammar.g:7:7: ( '{' ) - # XKBGrammar.g:7:9: '{' - self.match(123) - - - - - self._state.type = _type - self._state.channel = _channel - - finally: - - pass - - # $ANTLR end T__34 - - - - # $ANTLR start T__35 - def mT__35(self, ): - - try: - _type = T__35 - _channel = DEFAULT_CHANNEL - - # XKBGrammar.g:8:7: ( '}' ) - # XKBGrammar.g:8:9: '}' - self.match(125) - - - - - self._state.type = _type - self._state.channel = _channel - - finally: - - pass - - # $ANTLR end T__35 - - - - # $ANTLR start T__36 - def mT__36(self, ): - - try: - _type = T__36 - _channel = DEFAULT_CHANNEL - - # XKBGrammar.g:9:7: ( ';' ) - # XKBGrammar.g:9:9: ';' - self.match(59) - - - - - self._state.type = _type - self._state.channel = _channel - - finally: - - pass - - # $ANTLR end T__36 - - - - # $ANTLR start T__37 - def mT__37(self, ): - - try: - _type = T__37 - _channel = DEFAULT_CHANNEL - - # XKBGrammar.g:10:7: ( 'include' ) - # XKBGrammar.g:10:9: 'include' - self.match("include") - - - - - self._state.type = _type - self._state.channel = _channel - - finally: - - pass - - # $ANTLR end T__37 - - - - # $ANTLR start T__38 - def mT__38(self, ): - - try: - _type = T__38 - _channel = DEFAULT_CHANNEL - - # XKBGrammar.g:11:7: ( 'name' ) - # XKBGrammar.g:11:9: 'name' - self.match("name") - - - - - self._state.type = _type - self._state.channel = _channel - - finally: - - pass - - # $ANTLR end T__38 - - - - # $ANTLR start T__39 - def mT__39(self, ): - - try: - _type = T__39 - _channel = DEFAULT_CHANNEL - - # XKBGrammar.g:12:7: ( '[' ) - # XKBGrammar.g:12:9: '[' - self.match(91) - - - - - self._state.type = _type - self._state.channel = _channel - - finally: - - pass - - # $ANTLR end T__39 - - - - # $ANTLR start T__40 - def mT__40(self, ): - - try: - _type = T__40 - _channel = DEFAULT_CHANNEL - - # XKBGrammar.g:13:7: ( ']' ) - # XKBGrammar.g:13:9: ']' - self.match(93) - - - - - self._state.type = _type - self._state.channel = _channel - - finally: - - pass - - # $ANTLR end T__40 - - - - # $ANTLR start T__41 - def mT__41(self, ): - - try: - _type = T__41 - _channel = DEFAULT_CHANNEL - - # XKBGrammar.g:14:7: ( '=' ) - # XKBGrammar.g:14:9: '=' - self.match(61) - - - - - self._state.type = _type - self._state.channel = _channel - - finally: - - pass - - # $ANTLR end T__41 - - - - # $ANTLR start T__42 - def mT__42(self, ): - - try: - _type = T__42 - _channel = DEFAULT_CHANNEL - - # XKBGrammar.g:15:7: ( 'key.type' ) - # XKBGrammar.g:15:9: 'key.type' - self.match("key.type") - - - - - self._state.type = _type - self._state.channel = _channel - - finally: - - pass - - # $ANTLR end T__42 - - - - # $ANTLR start T__43 - def mT__43(self, ): - - try: - _type = T__43 - _channel = DEFAULT_CHANNEL - - # XKBGrammar.g:16:7: ( 'key' ) - # XKBGrammar.g:16:9: 'key' - self.match("key") - - - - - self._state.type = _type - self._state.channel = _channel - - finally: - - pass - - # $ANTLR end T__43 - - - - # $ANTLR start T__44 - def mT__44(self, ): - - try: - _type = T__44 - _channel = DEFAULT_CHANNEL - - # XKBGrammar.g:17:7: ( '<' ) - # XKBGrammar.g:17:9: '<' - self.match(60) - - - - - self._state.type = _type - self._state.channel = _channel - - finally: - - pass - - # $ANTLR end T__44 - - - - # $ANTLR start T__45 - def mT__45(self, ): - - try: - _type = T__45 - _channel = DEFAULT_CHANNEL - - # XKBGrammar.g:18:7: ( '>' ) - # XKBGrammar.g:18:9: '>' - self.match(62) - - - - - self._state.type = _type - self._state.channel = _channel - - finally: - - pass - - # $ANTLR end T__45 - - - - # $ANTLR start T__46 - def mT__46(self, ): - - try: - _type = T__46 - _channel = DEFAULT_CHANNEL - - # XKBGrammar.g:19:7: ( ',' ) - # XKBGrammar.g:19:9: ',' - self.match(44) - - - - - self._state.type = _type - self._state.channel = _channel - - finally: - - pass - - # $ANTLR end T__46 - - - - # $ANTLR start T__47 - def mT__47(self, ): - - try: - _type = T__47 - _channel = DEFAULT_CHANNEL - - # XKBGrammar.g:20:7: ( 'modifier_map' ) - # XKBGrammar.g:20:9: 'modifier_map' - self.match("modifier_map") - - - - - self._state.type = _type - self._state.channel = _channel - - finally: - - pass - - # $ANTLR end T__47 - - - - # $ANTLR start T__48 - def mT__48(self, ): - - try: - _type = T__48 - _channel = DEFAULT_CHANNEL - - # XKBGrammar.g:21:7: ( 'virtual_modifiers' ) - # XKBGrammar.g:21:9: 'virtual_modifiers' - self.match("virtual_modifiers") - - - - - self._state.type = _type - self._state.channel = _channel - - finally: - - pass - - # $ANTLR end T__48 - - - - # $ANTLR start T__49 - def mT__49(self, ): - - try: - _type = T__49 - _channel = DEFAULT_CHANNEL - - # XKBGrammar.g:22:7: ( 'type' ) - # XKBGrammar.g:22:9: 'type' - self.match("type") - - - - - self._state.type = _type - self._state.channel = _channel - - finally: - - pass - - # $ANTLR end T__49 - - - - # $ANTLR start T__50 - def mT__50(self, ): - - try: - _type = T__50 - _channel = DEFAULT_CHANNEL - - # XKBGrammar.g:23:7: ( 'symbols' ) - # XKBGrammar.g:23:9: 'symbols' - self.match("symbols") - - - - - self._state.type = _type - self._state.channel = _channel - - finally: - - pass - - # $ANTLR end T__50 - - - - # $ANTLR start T__51 - def mT__51(self, ): - - try: - _type = T__51 - _channel = DEFAULT_CHANNEL - - # XKBGrammar.g:24:7: ( 'virtualMods' ) - # XKBGrammar.g:24:9: 'virtualMods' - self.match("virtualMods") - - - - - self._state.type = _type - self._state.channel = _channel - - finally: - - pass - - # $ANTLR end T__51 - - - - # $ANTLR start MAPOPTS - def mMAPOPTS(self, ): - - try: - _type = MAPOPTS - _channel = DEFAULT_CHANNEL - - # XKBGrammar.g:151:2: ( 'default' | 'hidden' | 'partial' | 'alphanumeric_keys' | 'keypad_keys' | 'function_keys' | 'modifier_keys' | 'alternate_group' | 'xkb_symbols' ) - alt1 = 9 - alt1 = self.dfa1.predict(self.input) - if alt1 == 1: - # XKBGrammar.g:151:4: 'default' - self.match("default") - - - - elif alt1 == 2: - # XKBGrammar.g:152:4: 'hidden' - self.match("hidden") - - - - elif alt1 == 3: - # XKBGrammar.g:153:4: 'partial' - self.match("partial") - - - - elif alt1 == 4: - # XKBGrammar.g:154:4: 'alphanumeric_keys' - self.match("alphanumeric_keys") - - - - elif alt1 == 5: - # XKBGrammar.g:155:4: 'keypad_keys' - self.match("keypad_keys") - - - - elif alt1 == 6: - # XKBGrammar.g:156:4: 'function_keys' - self.match("function_keys") - - - - elif alt1 == 7: - # XKBGrammar.g:157:4: 'modifier_keys' - self.match("modifier_keys") - - - - elif alt1 == 8: - # XKBGrammar.g:158:4: 'alternate_group' - self.match("alternate_group") - - - - elif alt1 == 9: - # XKBGrammar.g:159:4: 'xkb_symbols' - self.match("xkb_symbols") - - - - self._state.type = _type - self._state.channel = _channel - - finally: - - pass - - # $ANTLR end MAPOPTS - - - - # $ANTLR start STATE - def mSTATE(self, ): - - try: - _type = STATE - _channel = DEFAULT_CHANNEL - - # XKBGrammar.g:163:2: ( 'Shift' | 'Control' | 'Lock' | 'Mod1' | 'Mod2' | 'Mod3' | 'Mod4' | 'Mod5' ) - alt2 = 8 - alt2 = self.dfa2.predict(self.input) - if alt2 == 1: - # XKBGrammar.g:163:4: 'Shift' - self.match("Shift") - - - - elif alt2 == 2: - # XKBGrammar.g:164:4: 'Control' - self.match("Control") - - - - elif alt2 == 3: - # XKBGrammar.g:165:4: 'Lock' - self.match("Lock") - - - - elif alt2 == 4: - # XKBGrammar.g:166:4: 'Mod1' - self.match("Mod1") - - - - elif alt2 == 5: - # XKBGrammar.g:167:4: 'Mod2' - self.match("Mod2") - - - - elif alt2 == 6: - # XKBGrammar.g:168:4: 'Mod3' - self.match("Mod3") - - - - elif alt2 == 7: - # XKBGrammar.g:169:4: 'Mod4' - self.match("Mod4") - - - - elif alt2 == 8: - # XKBGrammar.g:170:4: 'Mod5' - self.match("Mod5") - - - - self._state.type = _type - self._state.channel = _channel - - finally: - - pass - - # $ANTLR end STATE - - - - # $ANTLR start OVERRIDE - def mOVERRIDE(self, ): - - try: - _type = OVERRIDE - _channel = DEFAULT_CHANNEL - - # XKBGrammar.g:174:2: ( 'override' ) - # XKBGrammar.g:174:4: 'override' - self.match("override") - - - - - self._state.type = _type - self._state.channel = _channel - - finally: - - pass - - # $ANTLR end OVERRIDE - - - - # $ANTLR start NAME - def mNAME(self, ): - - try: - _type = NAME - _channel = DEFAULT_CHANNEL - - # XKBGrammar.g:178:2: ( ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9' | '+' | '-' )* ) - # XKBGrammar.g:178:4: ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9' | '+' | '-' )* - # XKBGrammar.g:178:4: ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9' | '+' | '-' )* - while True: #loop3 - alt3 = 2 - LA3_0 = self.input.LA(1) - - if (LA3_0 == 43 or LA3_0 == 45 or (48 <= LA3_0 <= 57) or (65 <= LA3_0 <= 90) or LA3_0 == 95 or (97 <= LA3_0 <= 122)) : - alt3 = 1 - - - if alt3 == 1: - # XKBGrammar.g: - if self.input.LA(1) == 43 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) - raise mse - - - - else: - break #loop3 - - - - - - - self._state.type = _type - self._state.channel = _channel - - finally: - - pass - - # $ANTLR end NAME - - - - # $ANTLR start WS - def mWS(self, ): - - try: - _type = WS - _channel = DEFAULT_CHANNEL - - # XKBGrammar.g:182:2: ( ( ' ' | '\\r' | '\\t' | '\\u000C' | '\\n' ) ) - # XKBGrammar.g:183: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 - _channel=HIDDEN; - #action end - - - - - self._state.type = _type - self._state.channel = _channel - - finally: - - pass - - # $ANTLR end WS - - - - # $ANTLR start COMMENT - def mCOMMENT(self, ): - - try: - _type = COMMENT - _channel = DEFAULT_CHANNEL - - # XKBGrammar.g:188:6: ( '/*' ( . )* '*/' ) - # XKBGrammar.g:189:2: '/*' ( . )* '*/' - self.match("/*") - # XKBGrammar.g:189:7: ( . )* - while True: #loop4 - alt4 = 2 - LA4_0 = self.input.LA(1) - - if (LA4_0 == 42) : - LA4_1 = self.input.LA(2) - - if (LA4_1 == 47) : - alt4 = 2 - elif ((0 <= LA4_1 <= 46) or (48 <= LA4_1 <= 65534)) : - alt4 = 1 - - - elif ((0 <= LA4_0 <= 41) or (43 <= LA4_0 <= 65534)) : - alt4 = 1 - - - if alt4 == 1: - # XKBGrammar.g:189:7: . - self.matchAny() - - - - else: - break #loop4 - - - self.match("*/") - #action start - _channel=HIDDEN; - #action end - - - - - self._state.type = _type - self._state.channel = _channel - - finally: - - pass - - # $ANTLR end COMMENT - - - - # $ANTLR start LINE_COMMENT - def mLINE_COMMENT(self, ): - - try: - _type = LINE_COMMENT - _channel = DEFAULT_CHANNEL - - # XKBGrammar.g:193:6: ( ( '//' | '#' ) (~ ( '\\n' | '\\r' ) )* ( '\\r' )? '\\n' ) - # XKBGrammar.g:194:2: ( '//' | '#' ) (~ ( '\\n' | '\\r' ) )* ( '\\r' )? '\\n' - # XKBGrammar.g:194:2: ( '//' | '#' ) - alt5 = 2 - LA5_0 = self.input.LA(1) - - if (LA5_0 == 47) : - alt5 = 1 - elif (LA5_0 == 35) : - alt5 = 2 - else: - nvae = NoViableAltException("", 5, 0, self.input) - - raise nvae - - if alt5 == 1: - # XKBGrammar.g:194:3: '//' - self.match("//") - - - - elif alt5 == 2: - # XKBGrammar.g:194:10: '#' - self.match(35) - - - - - # XKBGrammar.g:194:16: (~ ( '\\n' | '\\r' ) )* - while True: #loop6 - alt6 = 2 - LA6_0 = self.input.LA(1) - - if ((0 <= LA6_0 <= 9) or (11 <= LA6_0 <= 12) or (14 <= LA6_0 <= 65534)) : - alt6 = 1 - - - if alt6 == 1: - # XKBGrammar.g:194:16: ~ ( '\\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) - raise mse - - - - - else: - break #loop6 - - - # XKBGrammar.g:194:32: ( '\\r' )? - alt7 = 2 - LA7_0 = self.input.LA(1) - - if (LA7_0 == 13) : - alt7 = 1 - if alt7 == 1: - # XKBGrammar.g:194:32: '\\r' - self.match(13) - - - - - self.match(10) - #action start - _channel=HIDDEN; - #action end - - - - - self._state.type = _type - self._state.channel = _channel - - finally: - - pass - - # $ANTLR end LINE_COMMENT - - - - # $ANTLR start DQSTRING - def mDQSTRING(self, ): - - try: - _type = DQSTRING - _channel = DEFAULT_CHANNEL - - # XKBGrammar.g:202:6: ( '\"' ( options {greedy=false; } : ~ ( '\"' ) )* '\"' ) - # XKBGrammar.g:202:10: '\"' ( options {greedy=false; } : ~ ( '\"' ) )* '\"' - self.match(34) - # XKBGrammar.g:202:14: ( options {greedy=false; } : ~ ( '\"' ) )* - while True: #loop8 - alt8 = 2 - LA8_0 = self.input.LA(1) - - if ((0 <= LA8_0 <= 33) or (35 <= LA8_0 <= 65534)) : - alt8 = 1 - elif (LA8_0 == 34) : - alt8 = 2 - - - if alt8 == 1: - # XKBGrammar.g:202:39: ~ ( '\"' ) - if (0 <= self.input.LA(1) <= 33) or (35 <= self.input.LA(1) <= 65534): - self.input.consume(); - else: - mse = MismatchedSetException(None, self.input) - self.recover(mse) - raise mse - - - - - else: - break #loop8 - - - self.match(34) - - - - - self._state.type = _type - self._state.channel = _channel - - finally: - - pass - - # $ANTLR end DQSTRING - - - - def mTokens(self): - # XKBGrammar.g:1:8: ( 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 | T__47 | T__48 | T__49 | T__50 | T__51 | MAPOPTS | STATE | OVERRIDE | NAME | WS | COMMENT | LINE_COMMENT | DQSTRING ) - alt9 = 26 - alt9 = self.dfa9.predict(self.input) - if alt9 == 1: - # XKBGrammar.g:1:10: T__34 - self.mT__34() - - - - elif alt9 == 2: - # XKBGrammar.g:1:16: T__35 - self.mT__35() - - - - elif alt9 == 3: - # XKBGrammar.g:1:22: T__36 - self.mT__36() - - - - elif alt9 == 4: - # XKBGrammar.g:1:28: T__37 - self.mT__37() - - - - elif alt9 == 5: - # XKBGrammar.g:1:34: T__38 - self.mT__38() - - - - elif alt9 == 6: - # XKBGrammar.g:1:40: T__39 - self.mT__39() - - - - elif alt9 == 7: - # XKBGrammar.g:1:46: T__40 - self.mT__40() - - - - elif alt9 == 8: - # XKBGrammar.g:1:52: T__41 - self.mT__41() - - - - elif alt9 == 9: - # XKBGrammar.g:1:58: T__42 - self.mT__42() - - - - elif alt9 == 10: - # XKBGrammar.g:1:64: T__43 - self.mT__43() - - - - elif alt9 == 11: - # XKBGrammar.g:1:70: T__44 - self.mT__44() - - - - elif alt9 == 12: - # XKBGrammar.g:1:76: T__45 - self.mT__45() - - - - elif alt9 == 13: - # XKBGrammar.g:1:82: T__46 - self.mT__46() - - - - elif alt9 == 14: - # XKBGrammar.g:1:88: T__47 - self.mT__47() - - - - elif alt9 == 15: - # XKBGrammar.g:1:94: T__48 - self.mT__48() - - - - elif alt9 == 16: - # XKBGrammar.g:1:100: T__49 - self.mT__49() - - - - elif alt9 == 17: - # XKBGrammar.g:1:106: T__50 - self.mT__50() - - - - elif alt9 == 18: - # XKBGrammar.g:1:112: T__51 - self.mT__51() - - - - elif alt9 == 19: - # XKBGrammar.g:1:118: MAPOPTS - self.mMAPOPTS() - - - - elif alt9 == 20: - # XKBGrammar.g:1:126: STATE - self.mSTATE() - - - - elif alt9 == 21: - # XKBGrammar.g:1:132: OVERRIDE - self.mOVERRIDE() - - - - elif alt9 == 22: - # XKBGrammar.g:1:141: NAME - self.mNAME() - - - - elif alt9 == 23: - # XKBGrammar.g:1:146: WS - self.mWS() - - - - elif alt9 == 24: - # XKBGrammar.g:1:149: COMMENT - self.mCOMMENT() - - - - elif alt9 == 25: - # XKBGrammar.g:1:157: LINE_COMMENT - self.mLINE_COMMENT() - - - - elif alt9 == 26: - # XKBGrammar.g:1:170: DQSTRING - self.mDQSTRING() - - - - - - - - - # lookup tables for DFA #1 - - DFA1_eot = DFA.unpack( - u"\14\uffff" - ) - - DFA1_eof = DFA.unpack( - u"\14\uffff" - ) - - DFA1_min = DFA.unpack( - u"\1\141\3\uffff\1\154\4\uffff\1\160\2\uffff" - ) - - DFA1_max = DFA.unpack( - u"\1\170\3\uffff\1\154\4\uffff\1\164\2\uffff" - ) - - DFA1_accept = DFA.unpack( - u"\1\uffff\1\1\1\2\1\3\1\uffff\1\5\1\6\1\7\1\11\1\uffff\1\4\1\10" - ) - - DFA1_special = DFA.unpack( - u"\14\uffff" - ) - - - DFA1_transition = [ - DFA.unpack(u"\1\4\2\uffff\1\1\1\uffff\1\6\1\uffff\1\2\2\uffff\1\5" - u"\1\uffff\1\7\2\uffff\1\3\7\uffff\1\10"), - DFA.unpack(u""), - DFA.unpack(u""), - DFA.unpack(u""), - DFA.unpack(u"\1\11"), - DFA.unpack(u""), - DFA.unpack(u""), - DFA.unpack(u""), - DFA.unpack(u""), - DFA.unpack(u"\1\12\3\uffff\1\13"), - DFA.unpack(u""), - DFA.unpack(u"") - ] - - # class definition for DFA #1 - - DFA1 = DFA - # lookup tables for DFA #2 - - DFA2_eot = DFA.unpack( - u"\14\uffff" - ) - - DFA2_eof = DFA.unpack( - u"\14\uffff" - ) - - DFA2_min = DFA.unpack( - u"\1\103\3\uffff\1\157\1\144\1\61\5\uffff" - ) - - DFA2_max = DFA.unpack( - u"\1\123\3\uffff\1\157\1\144\1\65\5\uffff" - ) - - DFA2_accept = DFA.unpack( - u"\1\uffff\1\1\1\2\1\3\3\uffff\1\4\1\5\1\6\1\7\1\10" - ) - - DFA2_special = DFA.unpack( - u"\14\uffff" - ) - - - DFA2_transition = [ - DFA.unpack(u"\1\2\10\uffff\1\3\1\4\5\uffff\1\1"), - DFA.unpack(u""), - DFA.unpack(u""), - DFA.unpack(u""), - DFA.unpack(u"\1\5"), - DFA.unpack(u"\1\6"), - DFA.unpack(u"\1\7\1\10\1\11\1\12\1\13"), - DFA.unpack(u""), - DFA.unpack(u""), - DFA.unpack(u""), - DFA.unpack(u""), - DFA.unpack(u"") - ] - - # class definition for DFA #2 - - DFA2 = DFA - # lookup tables for DFA #9 - - DFA9_eot = DFA.unpack( - u"\1\34\3\uffff\2\34\3\uffff\1\34\3\uffff\17\34\5\uffff\22\34\1\uffff" - u"\2\34\1\113\21\34\1\141\1\uffff\1\34\1\uffff\2\34\1\145\12\34\6" - u"\160\2\34\1\uffff\3\34\1\uffff\10\34\1\160\1\34\1\uffff\7\34\1" - u"\u0086\7\34\1\u008e\3\34\1\u0093\1\u0086\1\uffff\1\u0086\4\34\1" - u"\160\1\34\1\uffff\4\34\1\uffff\4\34\1\u00a1\10\34\1\uffff\11\34" - u"\1\u0086\3\34\1\u00b7\3\34\1\u0086\1\u00bb\2\34\1\uffff\3\34\1" - u"\uffff\1\u0086\3\34\1\u0086\5\34\1\u0086\2\34\1\u00cb\1\u0086\1" - u"\uffff" - ) - - DFA9_eof = DFA.unpack( - u"\u00cc\uffff" - ) - - DFA9_min = DFA.unpack( - u"\1\11\3\uffff\1\156\1\141\3\uffff\1\145\3\uffff\1\157\1\151\2\171" - u"\1\145\1\151\1\141\1\154\1\165\1\153\1\150\3\157\1\166\2\uffff" - u"\1\52\2\uffff\1\143\1\155\1\171\1\144\1\162\1\160\1\155\1\146\1" - u"\144\1\162\1\160\1\156\1\142\1\151\1\156\1\143\1\144\1\145\1\uffff" - u"\1\154\1\145\1\53\1\151\1\164\1\145\1\142\1\141\1\144\1\164\1\150" - u"\1\145\1\143\1\137\1\146\1\164\1\153\1\61\1\162\1\165\1\53\1\uffff" - u"\1\141\1\uffff\1\146\1\165\1\53\1\157\1\165\1\145\1\151\1\141\1" - u"\162\1\164\1\163\1\164\1\162\6\53\1\162\1\144\1\uffff\1\144\1\151" - u"\1\141\1\uffff\2\154\1\156\1\141\2\156\1\151\1\171\1\53\1\157\1" - u"\uffff\1\151\1\145\1\137\1\145\1\154\1\163\1\164\1\53\1\154\1\165" - u"\1\141\1\157\1\155\1\154\1\144\1\53\1\153\1\162\1\115\2\53\1\uffff" - u"\1\53\1\155\1\164\1\156\1\142\1\53\1\145\1\uffff\1\145\1\137\1" - u"\155\1\157\1\uffff\2\145\1\137\1\157\1\53\1\171\1\153\1\157\1\144" - u"\1\162\1\137\1\153\1\154\1\uffff\1\163\1\141\1\145\1\144\1\163" - u"\1\151\1\147\1\145\1\163\1\53\1\160\1\171\1\151\1\53\1\143\1\162" - u"\1\171\2\53\1\163\1\146\1\uffff\1\137\1\157\1\163\1\uffff\1\53" - u"\1\151\1\153\1\165\1\53\2\145\1\160\1\162\1\171\1\53\2\163\2\53" - u"\1\uffff" - ) - - DFA9_max = DFA.unpack( - u"\1\175\3\uffff\1\156\1\141\3\uffff\1\145\3\uffff\1\157\1\151\2" - u"\171\1\145\1\151\1\141\1\154\1\165\1\153\1\150\3\157\1\166\2\uffff" - u"\1\57\2\uffff\1\143\1\155\1\171\1\144\1\162\1\160\1\155\1\146\1" - u"\144\1\162\1\164\1\156\1\142\1\151\1\156\1\143\1\144\1\145\1\uffff" - u"\1\154\1\145\1\172\1\151\1\164\1\145\1\142\1\141\1\144\1\164\1" - u"\150\1\145\1\143\1\137\1\146\1\164\1\153\1\65\1\162\1\165\1\172" - u"\1\uffff\1\141\1\uffff\1\146\1\165\1\172\1\157\1\165\1\145\1\151" - u"\1\141\1\162\1\164\1\163\1\164\1\162\6\172\1\162\1\144\1\uffff" - u"\1\144\1\151\1\141\1\uffff\2\154\1\156\1\141\2\156\1\151\1\171" - u"\1\172\1\157\1\uffff\1\151\1\145\1\137\1\145\1\154\1\163\1\164" - u"\1\172\1\154\1\165\1\141\1\157\1\155\1\154\1\144\1\172\1\153\1" - u"\162\1\137\2\172\1\uffff\1\172\1\155\1\164\1\156\1\142\1\172\1" - u"\145\1\uffff\1\145\1\137\1\155\1\157\1\uffff\2\145\1\137\1\157" - u"\1\172\1\171\1\155\1\157\1\144\1\162\1\137\1\153\1\154\1\uffff" - u"\1\163\1\141\1\145\1\144\1\163\1\151\1\147\1\145\1\163\1\172\1" - u"\160\1\171\1\151\1\172\1\143\1\162\1\171\2\172\1\163\1\146\1\uffff" - u"\1\137\1\157\1\163\1\uffff\1\172\1\151\1\153\1\165\1\172\2\145" - u"\1\160\1\162\1\171\1\172\2\163\2\172\1\uffff" - ) - - DFA9_accept = DFA.unpack( - u"\1\uffff\1\1\1\2\1\3\2\uffff\1\6\1\7\1\10\1\uffff\1\13\1\14\1\15" - u"\17\uffff\1\26\1\27\1\uffff\1\31\1\32\22\uffff\1\30\25\uffff\1" - u"\11\1\uffff\1\12\25\uffff\1\5\3\uffff\1\20\12\uffff\1\24\25\uffff" - u"\1\23\7\uffff\1\4\4\uffff\1\21\15\uffff\1\25\25\uffff\1\22\3\uffff" - u"\1\16\17\uffff\1\17" - ) - - DFA9_special = DFA.unpack( - u"\u00cc\uffff" - ) - - - DFA9_transition = [ - DFA.unpack(u"\2\35\1\uffff\2\35\22\uffff\1\35\1\uffff\1\40\1\37\10" - u"\uffff\1\14\2\uffff\1\36\13\uffff\1\3\1\12\1\10\1\13\4\uffff\1" - u"\30\10\uffff\1\31\1\32\5\uffff\1\27\7\uffff\1\6\1\uffff\1\7\3\uffff" - u"\1\24\2\uffff\1\21\1\uffff\1\25\1\uffff\1\22\1\4\1\uffff\1\11\1" - u"\uffff\1\15\1\5\1\33\1\23\2\uffff\1\20\1\17\1\uffff\1\16\1\uffff" - u"\1\26\2\uffff\1\1\1\uffff\1\2"), - DFA.unpack(u""), - DFA.unpack(u""), - DFA.unpack(u""), - DFA.unpack(u"\1\41"), - DFA.unpack(u"\1\42"), - DFA.unpack(u""), - DFA.unpack(u""), - DFA.unpack(u""), - DFA.unpack(u"\1\43"), - DFA.unpack(u""), - DFA.unpack(u""), - DFA.unpack(u""), - DFA.unpack(u"\1\44"), - DFA.unpack(u"\1\45"), - DFA.unpack(u"\1\46"), - DFA.unpack(u"\1\47"), - DFA.unpack(u"\1\50"), - DFA.unpack(u"\1\51"), - DFA.unpack(u"\1\52"), - DFA.unpack(u"\1\53"), - DFA.unpack(u"\1\54"), - 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""), - DFA.unpack(u""), - DFA.unpack(u"\1\63\4\uffff\1\37"), - DFA.unpack(u""), - DFA.unpack(u""), - DFA.unpack(u"\1\64"), - 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"\1\74"), - DFA.unpack(u"\1\75"), - DFA.unpack(u"\1\76\3\uffff\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"\1\104"), - DFA.unpack(u"\1\105"), - DFA.unpack(u"\1\106"), - DFA.unpack(u""), - DFA.unpack(u"\1\107"), - DFA.unpack(u"\1\110"), - DFA.unpack(u"\1\34\1\uffff\1\34\1\111\1\uffff\12\34\7\uffff\32\34" - u"\4\uffff\1\34\1\uffff\17\34\1\112\12\34"), - DFA.unpack(u"\1\114"), - DFA.unpack(u"\1\115"), - DFA.unpack(u"\1\116"), - 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"\1\132\1\133\1\134\1\135\1\136"), - DFA.unpack(u"\1\137"), - DFA.unpack(u"\1\140"), - DFA.unpack(u"\1\34\1\uffff\1\34\2\uffff\12\34\7\uffff\32\34\4\uffff" - u"\1\34\1\uffff\32\34"), - DFA.unpack(u""), - DFA.unpack(u"\1\142"), - DFA.unpack(u""), - DFA.unpack(u"\1\143"), - DFA.unpack(u"\1\144"), - DFA.unpack(u"\1\34\1\uffff\1\34\2\uffff\12\34\7\uffff\32\34\4\uffff" - u"\1\34\1\uffff\32\34"), - DFA.unpack(u"\1\146"), - DFA.unpack(u"\1\147"), - DFA.unpack(u"\1\150"), - DFA.unpack(u"\1\151"), - DFA.unpack(u"\1\152"), - DFA.unpack(u"\1\153"), - DFA.unpack(u"\1\154"), - DFA.unpack(u"\1\155"), - DFA.unpack(u"\1\156"), - DFA.unpack(u"\1\157"), - DFA.unpack(u"\1\34\1\uffff\1\34\2\uffff\12\34\7\uffff\32\34\4\uffff" - u"\1\34\1\uffff\32\34"), - DFA.unpack(u"\1\34\1\uffff\1\34\2\uffff\12\34\7\uffff\32\34\4\uffff" - u"\1\34\1\uffff\32\34"), - DFA.unpack(u"\1\34\1\uffff\1\34\2\uffff\12\34\7\uffff\32\34\4\uffff" - u"\1\34\1\uffff\32\34"), - DFA.unpack(u"\1\34\1\uffff\1\34\2\uffff\12\34\7\uffff\32\34\4\uffff" - u"\1\34\1\uffff\32\34"), - DFA.unpack(u"\1\34\1\uffff\1\34\2\uffff\12\34\7\uffff\32\34\4\uffff" - u"\1\34\1\uffff\32\34"), - DFA.unpack(u"\1\34\1\uffff\1\34\2\uffff\12\34\7\uffff\32\34\4\uffff" - u"\1\34\1\uffff\32\34"), - DFA.unpack(u"\1\161"), - DFA.unpack(u"\1\162"), - DFA.unpack(u""), - DFA.unpack(u"\1\163"), - DFA.unpack(u"\1\164"), - DFA.unpack(u"\1\165"), - DFA.unpack(u""), - DFA.unpack(u"\1\166"), - DFA.unpack(u"\1\167"), - DFA.unpack(u"\1\170"), - DFA.unpack(u"\1\171"), - DFA.unpack(u"\1\172"), - DFA.unpack(u"\1\173"), - DFA.unpack(u"\1\174"), - DFA.unpack(u"\1\175"), - DFA.unpack(u"\1\34\1\uffff\1\34\2\uffff\12\34\7\uffff\32\34\4\uffff" - u"\1\34\1\uffff\32\34"), - DFA.unpack(u"\1\176"), - DFA.unpack(u""), - DFA.unpack(u"\1\177"), - DFA.unpack(u"\1\u0080"), - DFA.unpack(u"\1\u0081"), - DFA.unpack(u"\1\u0082"), - DFA.unpack(u"\1\u0083"), - DFA.unpack(u"\1\u0084"), - DFA.unpack(u"\1\u0085"), - DFA.unpack(u"\1\34\1\uffff\1\34\2\uffff\12\34\7\uffff\32\34\4\uffff" - u"\1\34\1\uffff\32\34"), - DFA.unpack(u"\1\u0087"), - DFA.unpack(u"\1\u0088"), - DFA.unpack(u"\1\u0089"), - DFA.unpack(u"\1\u008a"), - DFA.unpack(u"\1\u008b"), - DFA.unpack(u"\1\u008c"), - DFA.unpack(u"\1\u008d"), - DFA.unpack(u"\1\34\1\uffff\1\34\2\uffff\12\34\7\uffff\32\34\4\uffff" - u"\1\34\1\uffff\32\34"), - DFA.unpack(u"\1\u008f"), - DFA.unpack(u"\1\u0090"), - DFA.unpack(u"\1\u0092\21\uffff\1\u0091"), - DFA.unpack(u"\1\34\1\uffff\1\34\2\uffff\12\34\7\uffff\32\34\4\uffff" - u"\1\34\1\uffff\32\34"), - DFA.unpack(u"\1\34\1\uffff\1\34\2\uffff\12\34\7\uffff\32\34\4\uffff" - u"\1\34\1\uffff\32\34"), - DFA.unpack(u""), - DFA.unpack(u"\1\34\1\uffff\1\34\2\uffff\12\34\7\uffff\32\34\4\uffff" - u"\1\34\1\uffff\32\34"), - DFA.unpack(u"\1\u0094"), - DFA.unpack(u"\1\u0095"), - DFA.unpack(u"\1\u0096"), - DFA.unpack(u"\1\u0097"), - DFA.unpack(u"\1\34\1\uffff\1\34\2\uffff\12\34\7\uffff\32\34\4\uffff" - u"\1\34\1\uffff\32\34"), - DFA.unpack(u"\1\u0098"), - DFA.unpack(u""), - DFA.unpack(u"\1\u0099"), - DFA.unpack(u"\1\u009a"), - DFA.unpack(u"\1\u009b"), - DFA.unpack(u"\1\u009c"), - DFA.unpack(u""), - DFA.unpack(u"\1\u009d"), - DFA.unpack(u"\1\u009e"), - DFA.unpack(u"\1\u009f"), - DFA.unpack(u"\1\u00a0"), - DFA.unpack(u"\1\34\1\uffff\1\34\2\uffff\12\34\7\uffff\32\34\4\uffff" - u"\1\34\1\uffff\32\34"), - DFA.unpack(u"\1\u00a2"), - DFA.unpack(u"\1\u00a4\1\uffff\1\u00a3"), - DFA.unpack(u"\1\u00a5"), - DFA.unpack(u"\1\u00a6"), - DFA.unpack(u"\1\u00a7"), - DFA.unpack(u"\1\u00a8"), - DFA.unpack(u"\1\u00a9"), - DFA.unpack(u"\1\u00aa"), - DFA.unpack(u""), - DFA.unpack(u"\1\u00ab"), - DFA.unpack(u"\1\u00ac"), - DFA.unpack(u"\1\u00ad"), - DFA.unpack(u"\1\u00ae"), - DFA.unpack(u"\1\u00af"), - DFA.unpack(u"\1\u00b0"), - DFA.unpack(u"\1\u00b1"), - DFA.unpack(u"\1\u00b2"), - DFA.unpack(u"\1\u00b3"), - DFA.unpack(u"\1\34\1\uffff\1\34\2\uffff\12\34\7\uffff\32\34\4\uffff" - u"\1\34\1\uffff\32\34"), - DFA.unpack(u"\1\u00b4"), - DFA.unpack(u"\1\u00b5"), - DFA.unpack(u"\1\u00b6"), - DFA.unpack(u"\1\34\1\uffff\1\34\2\uffff\12\34\7\uffff\32\34\4\uffff" - u"\1\34\1\uffff\32\34"), - DFA.unpack(u"\1\u00b8"), - DFA.unpack(u"\1\u00b9"), - DFA.unpack(u"\1\u00ba"), - DFA.unpack(u"\1\34\1\uffff\1\34\2\uffff\12\34\7\uffff\32\34\4\uffff" - u"\1\34\1\uffff\32\34"), - DFA.unpack(u"\1\34\1\uffff\1\34\2\uffff\12\34\7\uffff\32\34\4\uffff" - u"\1\34\1\uffff\32\34"), - DFA.unpack(u"\1\u00bc"), - DFA.unpack(u"\1\u00bd"), - DFA.unpack(u""), - DFA.unpack(u"\1\u00be"), - DFA.unpack(u"\1\u00bf"), - DFA.unpack(u"\1\u00c0"), - DFA.unpack(u""), - DFA.unpack(u"\1\34\1\uffff\1\34\2\uffff\12\34\7\uffff\32\34\4\uffff" - u"\1\34\1\uffff\32\34"), - DFA.unpack(u"\1\u00c1"), - DFA.unpack(u"\1\u00c2"), - DFA.unpack(u"\1\u00c3"), - DFA.unpack(u"\1\34\1\uffff\1\34\2\uffff\12\34\7\uffff\32\34\4\uffff" - u"\1\34\1\uffff\32\34"), - DFA.unpack(u"\1\u00c4"), - DFA.unpack(u"\1\u00c5"), - DFA.unpack(u"\1\u00c6"), - DFA.unpack(u"\1\u00c7"), - DFA.unpack(u"\1\u00c8"), - DFA.unpack(u"\1\34\1\uffff\1\34\2\uffff\12\34\7\uffff\32\34\4\uffff" - u"\1\34\1\uffff\32\34"), - DFA.unpack(u"\1\u00c9"), - DFA.unpack(u"\1\u00ca"), - DFA.unpack(u"\1\34\1\uffff\1\34\2\uffff\12\34\7\uffff\32\34\4\uffff" - u"\1\34\1\uffff\32\34"), - DFA.unpack(u"\1\34\1\uffff\1\34\2\uffff\12\34\7\uffff\32\34\4\uffff" - u"\1\34\1\uffff\32\34"), - DFA.unpack(u"") - ] - - # class definition for DFA #9 - - DFA9 = 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,2396 +0,0 @@ -# $ANTLR 3.1b1 XKBGrammar.g 2008-06-20 23:20:19 - -import sys -from antlr3 import * -from antlr3.compat import set, frozenset - -from antlr3.tree import * - - - -# for convenience in actions -HIDDEN = BaseRecognizer.HIDDEN - -# token types -MAPOPTIONS=16 -OVERLAY=27 -TOKEN_INCLUDE=4 -ELEM_VIRTUALMODS=24 -ELEM_KEYSYMS=23 -TOKEN_MODIFIER_MAP=9 -EOF=-1 -TOKEN_TYPE=8 -MAPTYPE=14 -TOKEN_VIRTUAL_MODIFIERS=11 -NAME=30 -T__51=51 -MAPMATERIAL=17 -MAPOPTS=28 -COMMENT=32 -DQSTRING=29 -T__50=50 -T__42=42 -T__43=43 -T__40=40 -STATE=21 -T__41=41 -T__46=46 -T__47=47 -T__44=44 -T__45=45 -LINE_COMMENT=33 -KEYCODE=18 -T__48=48 -T__49=49 -TOKEN_NAME=6 -VALUE=20 -LAYOUT=12 -WS=31 -T__34=34 -T__35=35 -T__36=36 -T__37=37 -OVERRIDE=26 -T__38=38 -T__39=39 -TOKEN_SYMBOL=10 -ELEM_KEYSYMGROUP=22 -TOKEN_KEY=7 -MAPNAME=15 -SYMBOLS=13 -KEYELEMENTS=25 -TOKEN_KEY_TYPE=5 -KEYCODEX=19 - -# token names -tokenNames = [ - "<invalid>", "<EOR>", "<DOWN>", "<UP>", - "TOKEN_INCLUDE", "TOKEN_KEY_TYPE", "TOKEN_NAME", "TOKEN_KEY", "TOKEN_TYPE", - "TOKEN_MODIFIER_MAP", "TOKEN_SYMBOL", "TOKEN_VIRTUAL_MODIFIERS", "LAYOUT", - "SYMBOLS", "MAPTYPE", "MAPNAME", "MAPOPTIONS", "MAPMATERIAL", "KEYCODE", - "KEYCODEX", "VALUE", "STATE", "ELEM_KEYSYMGROUP", "ELEM_KEYSYMS", "ELEM_VIRTUALMODS", - "KEYELEMENTS", "OVERRIDE", "OVERLAY", "MAPOPTS", "DQSTRING", "NAME", - "WS", "COMMENT", "LINE_COMMENT", "'{'", "'}'", "';'", "'include'", "'name'", - "'['", "']'", "'='", "'key.type'", "'key'", "'<'", "'>'", "','", "'modifier_map'", - "'virtual_modifiers'", "'type'", "'symbols'", "'virtualMods'" -] - - - - -class XKBGrammarParser(Parser): - grammarFileName = "XKBGrammar.g" - tokenNames = tokenNames - - def __init__(self, input, state=None): - if state is None: - state = RecognizerSharedState() - - Parser.__init__(self, input, state) - - - - - - - - self.adaptor = CommonTreeAdaptor() - - - - - - - class layout_return(object): - def __init__(self): - self.start = None - self.stop = None - - self.tree = None - - - - - # $ANTLR start layout - # XKBGrammar.g:60:1: layout : ( symbols )+ EOF -> ^( LAYOUT ( symbols )+ ) ; - def layout(self, ): - - retval = self.layout_return() - retval.start = self.input.LT(1) - - root_0 = None - - EOF2 = None - symbols1 = None - - - EOF2_tree = None - stream_EOF = RewriteRuleTokenStream(self.adaptor, "token EOF") - stream_symbols = RewriteRuleSubtreeStream(self.adaptor, "rule symbols") - try: - try: - # XKBGrammar.g:61:2: ( ( symbols )+ EOF -> ^( LAYOUT ( symbols )+ ) ) - # XKBGrammar.g:61:4: ( symbols )+ EOF - # XKBGrammar.g:61:4: ( symbols )+ - cnt1 = 0 - while True: #loop1 - alt1 = 2 - LA1_0 = self.input.LA(1) - - if (LA1_0 == MAPOPTS) : - alt1 = 1 - - - if alt1 == 1: - # XKBGrammar.g:61:4: symbols - self._state.following.append(self.FOLLOW_symbols_in_layout161) - symbols1 = self.symbols() - - self._state.following.pop() - stream_symbols.add(symbols1.tree) - - - - else: - if cnt1 >= 1: - break #loop1 - - eee = EarlyExitException(1, self.input) - raise eee - - cnt1 += 1 - - - EOF2 = self.input.LT(1) - self.match(self.input, EOF, self.FOLLOW_EOF_in_layout164) - stream_EOF.add(EOF2) - # AST Rewrite - # elements: symbols - # token labels: - # rule labels: retval - # token list labels: - # rule list labels: - - retval.tree = root_0 - - if retval is not None: - stream_retval = RewriteRuleSubtreeStream(self.adaptor, "token retval", retval.tree) - else: - stream_retval = RewriteRuleSubtreeStream(self.adaptor, "token retval", None) - - - root_0 = self.adaptor.nil() - # 62:2: -> ^( LAYOUT ( symbols )+ ) - # XKBGrammar.g:62:5: ^( LAYOUT ( symbols )+ ) - root_1 = self.adaptor.nil() - root_1 = self.adaptor.becomeRoot(self.adaptor.createFromType(LAYOUT, "LAYOUT"), root_1) - - # XKBGrammar.g:62:14: ( symbols )+ - if not (stream_symbols.hasNext()): - raise RewriteEarlyExitException() - - while stream_symbols.hasNext(): - self.adaptor.addChild(root_1, stream_symbols.nextTree()) - - - stream_symbols.reset() - - self.adaptor.addChild(root_0, root_1) - - - - retval.tree = root_0 - - - - - retval.stop = self.input.LT(-1) - - - 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 - - return retval - - # $ANTLR end layout - - class symbols_return(object): - def __init__(self): - self.start = None - self.stop = None - - self.tree = None - - - - - # $ANTLR start symbols - # XKBGrammar.g:65:1: symbols : mapType '{' ( mapMaterial )+ '}' ';' -> ^( SYMBOLS mapType ^( MAPMATERIAL ( mapMaterial )+ ) ) ; - def symbols(self, ): - - retval = self.symbols_return() - retval.start = self.input.LT(1) - - root_0 = None - - char_literal4 = None - char_literal6 = None - char_literal7 = None - mapType3 = None - - mapMaterial5 = None - - - char_literal4_tree = None - char_literal6_tree = None - char_literal7_tree = None - stream_35 = RewriteRuleTokenStream(self.adaptor, "token 35") - stream_36 = RewriteRuleTokenStream(self.adaptor, "token 36") - stream_34 = RewriteRuleTokenStream(self.adaptor, "token 34") - stream_mapMaterial = RewriteRuleSubtreeStream(self.adaptor, "rule mapMaterial") - stream_mapType = RewriteRuleSubtreeStream(self.adaptor, "rule mapType") - try: - try: - # XKBGrammar.g:66:2: ( mapType '{' ( mapMaterial )+ '}' ';' -> ^( SYMBOLS mapType ^( MAPMATERIAL ( mapMaterial )+ ) ) ) - # XKBGrammar.g:66:4: mapType '{' ( mapMaterial )+ '}' ';' - self._state.following.append(self.FOLLOW_mapType_in_symbols187) - mapType3 = self.mapType() - - self._state.following.pop() - stream_mapType.add(mapType3.tree) - char_literal4 = self.input.LT(1) - self.match(self.input, 34, self.FOLLOW_34_in_symbols189) - stream_34.add(char_literal4) - # XKBGrammar.g:66:16: ( mapMaterial )+ - cnt2 = 0 - while True: #loop2 - alt2 = 2 - LA2_0 = self.input.LA(1) - - if (LA2_0 == OVERRIDE or (37 <= LA2_0 <= 38) or (42 <= LA2_0 <= 43) or (47 <= LA2_0 <= 48)) : - alt2 = 1 - - - if alt2 == 1: - # XKBGrammar.g:66:16: mapMaterial - self._state.following.append(self.FOLLOW_mapMaterial_in_symbols191) - mapMaterial5 = self.mapMaterial() - - self._state.following.pop() - stream_mapMaterial.add(mapMaterial5.tree) - - - - else: - if cnt2 >= 1: - break #loop2 - - eee = EarlyExitException(2, self.input) - raise eee - - cnt2 += 1 - - - char_literal6 = self.input.LT(1) - self.match(self.input, 35, self.FOLLOW_35_in_symbols194) - stream_35.add(char_literal6) - char_literal7 = self.input.LT(1) - self.match(self.input, 36, self.FOLLOW_36_in_symbols196) - stream_36.add(char_literal7) - # AST Rewrite - # elements: mapMaterial, mapType - # token labels: - # rule labels: retval - # token list labels: - # rule list labels: - - retval.tree = root_0 - - if retval is not None: - stream_retval = RewriteRuleSubtreeStream(self.adaptor, "token retval", retval.tree) - else: - stream_retval = RewriteRuleSubtreeStream(self.adaptor, "token retval", None) - - - root_0 = self.adaptor.nil() - # 67:2: -> ^( SYMBOLS mapType ^( MAPMATERIAL ( mapMaterial )+ ) ) - # XKBGrammar.g:67:5: ^( SYMBOLS mapType ^( MAPMATERIAL ( mapMaterial )+ ) ) - root_1 = self.adaptor.nil() - root_1 = self.adaptor.becomeRoot(self.adaptor.createFromType(SYMBOLS, "SYMBOLS"), root_1) - - self.adaptor.addChild(root_1, stream_mapType.nextTree()) - # XKBGrammar.g:67:23: ^( MAPMATERIAL ( mapMaterial )+ ) - root_2 = self.adaptor.nil() - root_2 = self.adaptor.becomeRoot(self.adaptor.createFromType(MAPMATERIAL, "MAPMATERIAL"), root_2) - - # XKBGrammar.g:67:37: ( mapMaterial )+ - if not (stream_mapMaterial.hasNext()): - raise RewriteEarlyExitException() - - while stream_mapMaterial.hasNext(): - self.adaptor.addChild(root_2, stream_mapMaterial.nextTree()) - - - stream_mapMaterial.reset() - - self.adaptor.addChild(root_1, root_2) - - self.adaptor.addChild(root_0, root_1) - - - - retval.tree = root_0 - - - - - retval.stop = self.input.LT(-1) - - - 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 - - return retval - - # $ANTLR end symbols - - class mapType_return(object): - def __init__(self): - self.start = None - self.stop = None - - self.tree = None - - - - - # $ANTLR start mapType - # XKBGrammar.g:70:1: mapType : ( MAPOPTS )+ DQSTRING -> ^( MAPTYPE ^( MAPOPTIONS ( MAPOPTS )+ ) ^( MAPNAME DQSTRING ) ) ; - def mapType(self, ): - - retval = self.mapType_return() - retval.start = self.input.LT(1) - - root_0 = None - - MAPOPTS8 = None - DQSTRING9 = None - - MAPOPTS8_tree = None - DQSTRING9_tree = None - stream_MAPOPTS = RewriteRuleTokenStream(self.adaptor, "token MAPOPTS") - stream_DQSTRING = RewriteRuleTokenStream(self.adaptor, "token DQSTRING") - - try: - try: - # XKBGrammar.g:71:2: ( ( MAPOPTS )+ DQSTRING -> ^( MAPTYPE ^( MAPOPTIONS ( MAPOPTS )+ ) ^( MAPNAME DQSTRING ) ) ) - # XKBGrammar.g:71:4: ( MAPOPTS )+ DQSTRING - # XKBGrammar.g:71:4: ( MAPOPTS )+ - cnt3 = 0 - while True: #loop3 - alt3 = 2 - LA3_0 = self.input.LA(1) - - if (LA3_0 == MAPOPTS) : - alt3 = 1 - - - if alt3 == 1: - # XKBGrammar.g:71:4: MAPOPTS - MAPOPTS8 = self.input.LT(1) - self.match(self.input, MAPOPTS, self.FOLLOW_MAPOPTS_in_mapType224) - stream_MAPOPTS.add(MAPOPTS8) - - - - else: - if cnt3 >= 1: - break #loop3 - - eee = EarlyExitException(3, self.input) - raise eee - - cnt3 += 1 - - - DQSTRING9 = self.input.LT(1) - self.match(self.input, DQSTRING, self.FOLLOW_DQSTRING_in_mapType227) - stream_DQSTRING.add(DQSTRING9) - # AST Rewrite - # elements: DQSTRING, MAPOPTS - # token labels: - # rule labels: retval - # token list labels: - # rule list labels: - - retval.tree = root_0 - - if retval is not None: - stream_retval = RewriteRuleSubtreeStream(self.adaptor, "token retval", retval.tree) - else: - stream_retval = RewriteRuleSubtreeStream(self.adaptor, "token retval", None) - - - root_0 = self.adaptor.nil() - # 72:2: -> ^( MAPTYPE ^( MAPOPTIONS ( MAPOPTS )+ ) ^( MAPNAME DQSTRING ) ) - # XKBGrammar.g:72:5: ^( MAPTYPE ^( MAPOPTIONS ( MAPOPTS )+ ) ^( MAPNAME DQSTRING ) ) - root_1 = self.adaptor.nil() - root_1 = self.adaptor.becomeRoot(self.adaptor.createFromType(MAPTYPE, "MAPTYPE"), root_1) - - # XKBGrammar.g:72:15: ^( MAPOPTIONS ( MAPOPTS )+ ) - root_2 = self.adaptor.nil() - root_2 = self.adaptor.becomeRoot(self.adaptor.createFromType(MAPOPTIONS, "MAPOPTIONS"), root_2) - - # XKBGrammar.g:72:28: ( MAPOPTS )+ - if not (stream_MAPOPTS.hasNext()): - raise RewriteEarlyExitException() - - while stream_MAPOPTS.hasNext(): - self.adaptor.addChild(root_2, stream_MAPOPTS.nextNode()) - - - stream_MAPOPTS.reset() - - self.adaptor.addChild(root_1, root_2) - # XKBGrammar.g:72:38: ^( MAPNAME DQSTRING ) - root_2 = self.adaptor.nil() - root_2 = self.adaptor.becomeRoot(self.adaptor.createFromType(MAPNAME, "MAPNAME"), root_2) - - self.adaptor.addChild(root_2, stream_DQSTRING.nextNode()) - - self.adaptor.addChild(root_1, root_2) - - self.adaptor.addChild(root_0, root_1) - - - - retval.tree = root_0 - - - - - retval.stop = self.input.LT(-1) - - - 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 - - return retval - - # $ANTLR end mapType - - class mapMaterial_return(object): - def __init__(self): - self.start = None - self.stop = None - - self.tree = None - - - - - # $ANTLR start mapMaterial - # XKBGrammar.g:75:1: mapMaterial : ( line_include | line_name ';' | line_keytype ';' | line_key ';' | line_modifier_map ';' | line_virtual_modifiers ';' ); - def mapMaterial(self, ): - - retval = self.mapMaterial_return() - retval.start = self.input.LT(1) - - root_0 = None - - char_literal12 = None - char_literal14 = None - char_literal16 = None - char_literal18 = None - char_literal20 = None - line_include10 = None - - line_name11 = None - - line_keytype13 = None - - line_key15 = None - - line_modifier_map17 = None - - line_virtual_modifiers19 = None - - - char_literal12_tree = None - char_literal14_tree = None - char_literal16_tree = None - char_literal18_tree = None - char_literal20_tree = None - - try: - try: - # XKBGrammar.g:76:2: ( line_include | line_name ';' | line_keytype ';' | line_key ';' | line_modifier_map ';' | line_virtual_modifiers ';' ) - alt4 = 6 - LA4 = self.input.LA(1) - if LA4 == 37: - alt4 = 1 - elif LA4 == 38: - alt4 = 2 - elif LA4 == 42: - alt4 = 3 - elif LA4 == OVERRIDE or LA4 == 43: - alt4 = 4 - elif LA4 == 47: - alt4 = 5 - elif LA4 == 48: - alt4 = 6 - else: - nvae = NoViableAltException("", 4, 0, self.input) - - raise nvae - - if alt4 == 1: - # XKBGrammar.g:76:4: line_include - root_0 = self.adaptor.nil() - - self._state.following.append(self.FOLLOW_line_include_in_mapMaterial259) - line_include10 = self.line_include() - - self._state.following.pop() - self.adaptor.addChild(root_0, line_include10.tree) - - - - elif alt4 == 2: - # XKBGrammar.g:77:4: line_name ';' - root_0 = self.adaptor.nil() - - self._state.following.append(self.FOLLOW_line_name_in_mapMaterial265) - line_name11 = self.line_name() - - self._state.following.pop() - self.adaptor.addChild(root_0, line_name11.tree) - char_literal12 = self.input.LT(1) - self.match(self.input, 36, self.FOLLOW_36_in_mapMaterial267) - - - - elif alt4 == 3: - # XKBGrammar.g:78:4: line_keytype ';' - root_0 = self.adaptor.nil() - - self._state.following.append(self.FOLLOW_line_keytype_in_mapMaterial273) - line_keytype13 = self.line_keytype() - - self._state.following.pop() - self.adaptor.addChild(root_0, line_keytype13.tree) - char_literal14 = self.input.LT(1) - self.match(self.input, 36, self.FOLLOW_36_in_mapMaterial275) - - - - elif alt4 == 4: - # XKBGrammar.g:79:4: line_key ';' - root_0 = self.adaptor.nil() - - self._state.following.append(self.FOLLOW_line_key_in_mapMaterial281) - line_key15 = self.line_key() - - self._state.following.pop() - self.adaptor.addChild(root_0, line_key15.tree) - char_literal16 = self.input.LT(1) - self.match(self.input, 36, self.FOLLOW_36_in_mapMaterial283) - - - - elif alt4 == 5: - # XKBGrammar.g:80:4: line_modifier_map ';' - root_0 = self.adaptor.nil() - - self._state.following.append(self.FOLLOW_line_modifier_map_in_mapMaterial289) - line_modifier_map17 = self.line_modifier_map() - - self._state.following.pop() - self.adaptor.addChild(root_0, line_modifier_map17.tree) - char_literal18 = self.input.LT(1) - self.match(self.input, 36, self.FOLLOW_36_in_mapMaterial291) - - - - elif alt4 == 6: - # XKBGrammar.g:81:4: line_virtual_modifiers ';' - root_0 = self.adaptor.nil() - - self._state.following.append(self.FOLLOW_line_virtual_modifiers_in_mapMaterial297) - line_virtual_modifiers19 = self.line_virtual_modifiers() - - self._state.following.pop() - self.adaptor.addChild(root_0, line_virtual_modifiers19.tree) - char_literal20 = self.input.LT(1) - self.match(self.input, 36, self.FOLLOW_36_in_mapMaterial299) - - - - retval.stop = self.input.LT(-1) - - - 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 - - return retval - - # $ANTLR end mapMaterial - - class line_include_return(object): - def __init__(self): - self.start = None - self.stop = None - - self.tree = None - - - - - # $ANTLR start line_include - # XKBGrammar.g:84:1: line_include : 'include' DQSTRING -> ^( TOKEN_INCLUDE DQSTRING ) ; - def line_include(self, ): - - retval = self.line_include_return() - retval.start = self.input.LT(1) - - root_0 = None - - string_literal21 = None - DQSTRING22 = None - - string_literal21_tree = None - DQSTRING22_tree = None - stream_DQSTRING = RewriteRuleTokenStream(self.adaptor, "token DQSTRING") - stream_37 = RewriteRuleTokenStream(self.adaptor, "token 37") - - try: - try: - # XKBGrammar.g:85:2: ( 'include' DQSTRING -> ^( TOKEN_INCLUDE DQSTRING ) ) - # XKBGrammar.g:85:4: 'include' DQSTRING - string_literal21 = self.input.LT(1) - self.match(self.input, 37, self.FOLLOW_37_in_line_include311) - stream_37.add(string_literal21) - DQSTRING22 = self.input.LT(1) - self.match(self.input, DQSTRING, self.FOLLOW_DQSTRING_in_line_include313) - stream_DQSTRING.add(DQSTRING22) - # AST Rewrite - # elements: DQSTRING - # token labels: - # rule labels: retval - # token list labels: - # rule list labels: - - retval.tree = root_0 - - if retval is not None: - stream_retval = RewriteRuleSubtreeStream(self.adaptor, "token retval", retval.tree) - else: - stream_retval = RewriteRuleSubtreeStream(self.adaptor, "token retval", None) - - - root_0 = self.adaptor.nil() - # 86:2: -> ^( TOKEN_INCLUDE DQSTRING ) - # XKBGrammar.g:86:5: ^( TOKEN_INCLUDE DQSTRING ) - 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_DQSTRING.nextNode()) - - self.adaptor.addChild(root_0, root_1) - - - - retval.tree = root_0 - - - - - retval.stop = self.input.LT(-1) - - - 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 - - return retval - - # $ANTLR end line_include - - class line_name_return(object): - def __init__(self): - self.start = None - self.stop = None - - self.tree = None - - - - - # $ANTLR start line_name - # XKBGrammar.g:89:1: line_name : 'name' ( '[' NAME ']' )? '=' DQSTRING -> ^( TOKEN_NAME DQSTRING ) ; - def line_name(self, ): - - retval = self.line_name_return() - retval.start = self.input.LT(1) - - root_0 = None - - string_literal23 = None - char_literal24 = None - NAME25 = None - char_literal26 = None - char_literal27 = None - DQSTRING28 = None - - string_literal23_tree = None - char_literal24_tree = None - NAME25_tree = None - char_literal26_tree = None - char_literal27_tree = None - DQSTRING28_tree = None - stream_NAME = RewriteRuleTokenStream(self.adaptor, "token NAME") - stream_41 = RewriteRuleTokenStream(self.adaptor, "token 41") - stream_40 = RewriteRuleTokenStream(self.adaptor, "token 40") - stream_DQSTRING = RewriteRuleTokenStream(self.adaptor, "token DQSTRING") - stream_39 = RewriteRuleTokenStream(self.adaptor, "token 39") - stream_38 = RewriteRuleTokenStream(self.adaptor, "token 38") - - try: - try: - # XKBGrammar.g:90:2: ( 'name' ( '[' NAME ']' )? '=' DQSTRING -> ^( TOKEN_NAME DQSTRING ) ) - # XKBGrammar.g:90:4: 'name' ( '[' NAME ']' )? '=' DQSTRING - string_literal23 = self.input.LT(1) - self.match(self.input, 38, self.FOLLOW_38_in_line_name333) - stream_38.add(string_literal23) - # XKBGrammar.g:90:11: ( '[' NAME ']' )? - alt5 = 2 - LA5_0 = self.input.LA(1) - - if (LA5_0 == 39) : - alt5 = 1 - if alt5 == 1: - # XKBGrammar.g:90:12: '[' NAME ']' - char_literal24 = self.input.LT(1) - self.match(self.input, 39, self.FOLLOW_39_in_line_name336) - stream_39.add(char_literal24) - NAME25 = self.input.LT(1) - self.match(self.input, NAME, self.FOLLOW_NAME_in_line_name338) - stream_NAME.add(NAME25) - char_literal26 = self.input.LT(1) - self.match(self.input, 40, self.FOLLOW_40_in_line_name340) - stream_40.add(char_literal26) - - - - - char_literal27 = self.input.LT(1) - self.match(self.input, 41, self.FOLLOW_41_in_line_name344) - stream_41.add(char_literal27) - DQSTRING28 = self.input.LT(1) - self.match(self.input, DQSTRING, self.FOLLOW_DQSTRING_in_line_name346) - stream_DQSTRING.add(DQSTRING28) - # AST Rewrite - # elements: DQSTRING - # token labels: - # rule labels: retval - # token list labels: - # rule list labels: - - retval.tree = root_0 - - if retval is not None: - stream_retval = RewriteRuleSubtreeStream(self.adaptor, "token retval", retval.tree) - else: - stream_retval = RewriteRuleSubtreeStream(self.adaptor, "token retval", None) - - - root_0 = self.adaptor.nil() - # 91:2: -> ^( TOKEN_NAME DQSTRING ) - # XKBGrammar.g:91:5: ^( TOKEN_NAME DQSTRING ) - 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_DQSTRING.nextNode()) - - self.adaptor.addChild(root_0, root_1) - - - - retval.tree = root_0 - - - - - retval.stop = self.input.LT(-1) - - - 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 - - return retval - - # $ANTLR end line_name - - class line_keytype_return(object): - def __init__(self): - self.start = None - self.stop = None - - self.tree = None - - - - - # $ANTLR start line_keytype - # XKBGrammar.g:94:1: line_keytype : 'key.type' ( '[' NAME ']' )? '=' DQSTRING -> ^( TOKEN_KEY_TYPE DQSTRING ) ; - def line_keytype(self, ): - - retval = self.line_keytype_return() - retval.start = self.input.LT(1) - - root_0 = None - - string_literal29 = None - char_literal30 = None - NAME31 = None - char_literal32 = None - char_literal33 = None - DQSTRING34 = None - - string_literal29_tree = None - char_literal30_tree = None - NAME31_tree = None - char_literal32_tree = None - char_literal33_tree = None - DQSTRING34_tree = None - stream_NAME = RewriteRuleTokenStream(self.adaptor, "token NAME") - stream_42 = RewriteRuleTokenStream(self.adaptor, "token 42") - stream_41 = RewriteRuleTokenStream(self.adaptor, "token 41") - stream_40 = RewriteRuleTokenStream(self.adaptor, "token 40") - stream_DQSTRING = RewriteRuleTokenStream(self.adaptor, "token DQSTRING") - stream_39 = RewriteRuleTokenStream(self.adaptor, "token 39") - - try: - try: - # XKBGrammar.g:95:2: ( 'key.type' ( '[' NAME ']' )? '=' DQSTRING -> ^( TOKEN_KEY_TYPE DQSTRING ) ) - # XKBGrammar.g:95:4: 'key.type' ( '[' NAME ']' )? '=' DQSTRING - string_literal29 = self.input.LT(1) - self.match(self.input, 42, self.FOLLOW_42_in_line_keytype366) - stream_42.add(string_literal29) - # XKBGrammar.g:95:15: ( '[' NAME ']' )? - alt6 = 2 - LA6_0 = self.input.LA(1) - - if (LA6_0 == 39) : - alt6 = 1 - if alt6 == 1: - # XKBGrammar.g:95:16: '[' NAME ']' - char_literal30 = self.input.LT(1) - self.match(self.input, 39, self.FOLLOW_39_in_line_keytype369) - stream_39.add(char_literal30) - NAME31 = self.input.LT(1) - self.match(self.input, NAME, self.FOLLOW_NAME_in_line_keytype371) - stream_NAME.add(NAME31) - char_literal32 = self.input.LT(1) - self.match(self.input, 40, self.FOLLOW_40_in_line_keytype373) - stream_40.add(char_literal32) - - - - - char_literal33 = self.input.LT(1) - self.match(self.input, 41, self.FOLLOW_41_in_line_keytype377) - stream_41.add(char_literal33) - DQSTRING34 = self.input.LT(1) - self.match(self.input, DQSTRING, self.FOLLOW_DQSTRING_in_line_keytype379) - stream_DQSTRING.add(DQSTRING34) - # AST Rewrite - # elements: DQSTRING - # token labels: - # rule labels: retval - # token list labels: - # rule list labels: - - retval.tree = root_0 - - if retval is not None: - stream_retval = RewriteRuleSubtreeStream(self.adaptor, "token retval", retval.tree) - else: - stream_retval = RewriteRuleSubtreeStream(self.adaptor, "token retval", None) - - - root_0 = self.adaptor.nil() - # 96:2: -> ^( TOKEN_KEY_TYPE DQSTRING ) - # XKBGrammar.g:96:5: ^( TOKEN_KEY_TYPE DQSTRING ) - 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_DQSTRING.nextNode()) - - self.adaptor.addChild(root_0, root_1) - - - - retval.tree = root_0 - - - - - retval.stop = self.input.LT(-1) - - - 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 - - return retval - - # $ANTLR end line_keytype - - class line_key_return(object): - def __init__(self): - self.start = None - self.stop = None - - self.tree = None - - - - - # $ANTLR start line_key - # 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() - retval.start = self.input.LT(1) - - root_0 = None - - OVERRIDE35 = None - string_literal36 = None - char_literal37 = None - NAME38 = None - char_literal39 = None - char_literal40 = None - char_literal42 = None - char_literal44 = None - keyelements41 = None - - keyelements43 = None - - - OVERRIDE35_tree = None - string_literal36_tree = None - char_literal37_tree = None - NAME38_tree = None - char_literal39_tree = None - char_literal40_tree = None - char_literal42_tree = None - char_literal44_tree = None - stream_NAME = RewriteRuleTokenStream(self.adaptor, "token NAME") - stream_45 = RewriteRuleTokenStream(self.adaptor, "token 45") - stream_43 = RewriteRuleTokenStream(self.adaptor, "token 43") - stream_44 = RewriteRuleTokenStream(self.adaptor, "token 44") - stream_46 = RewriteRuleTokenStream(self.adaptor, "token 46") - stream_35 = RewriteRuleTokenStream(self.adaptor, "token 35") - stream_OVERRIDE = RewriteRuleTokenStream(self.adaptor, "token OVERRIDE") - stream_34 = RewriteRuleTokenStream(self.adaptor, "token 34") - stream_keyelements = RewriteRuleSubtreeStream(self.adaptor, "rule keyelements") - try: - try: - # 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 - LA7_0 = self.input.LA(1) - - if (LA7_0 == OVERRIDE) : - alt7 = 1 - if alt7 == 1: - # XKBGrammar.g:100:4: OVERRIDE - OVERRIDE35 = self.input.LT(1) - self.match(self.input, OVERRIDE, self.FOLLOW_OVERRIDE_in_line_key399) - stream_OVERRIDE.add(OVERRIDE35) - - - - - string_literal36 = self.input.LT(1) - self.match(self.input, 43, self.FOLLOW_43_in_line_key402) - stream_43.add(string_literal36) - char_literal37 = self.input.LT(1) - self.match(self.input, 44, self.FOLLOW_44_in_line_key404) - stream_44.add(char_literal37) - NAME38 = self.input.LT(1) - self.match(self.input, NAME, self.FOLLOW_NAME_in_line_key406) - stream_NAME.add(NAME38) - char_literal39 = self.input.LT(1) - self.match(self.input, 45, self.FOLLOW_45_in_line_key408) - stream_45.add(char_literal39) - char_literal40 = self.input.LT(1) - self.match(self.input, 34, self.FOLLOW_34_in_line_key410) - stream_34.add(char_literal40) - self._state.following.append(self.FOLLOW_keyelements_in_line_key412) - keyelements41 = self.keyelements() - - self._state.following.pop() - stream_keyelements.add(keyelements41.tree) - # XKBGrammar.g:100:49: ( ',' keyelements )* - while True: #loop8 - alt8 = 2 - LA8_0 = self.input.LA(1) - - if (LA8_0 == 46) : - alt8 = 1 - - - if alt8 == 1: - # XKBGrammar.g:100:50: ',' keyelements - char_literal42 = self.input.LT(1) - self.match(self.input, 46, self.FOLLOW_46_in_line_key415) - stream_46.add(char_literal42) - self._state.following.append(self.FOLLOW_keyelements_in_line_key417) - keyelements43 = self.keyelements() - - self._state.following.pop() - stream_keyelements.add(keyelements43.tree) - - - - else: - break #loop8 - - - char_literal44 = self.input.LT(1) - self.match(self.input, 35, self.FOLLOW_35_in_line_key421) - stream_35.add(char_literal44) - # AST Rewrite - # elements: NAME, OVERRIDE, keyelements - # token labels: - # rule labels: retval - # token list labels: - # rule list labels: - - retval.tree = root_0 - - if retval is not None: - stream_retval = RewriteRuleSubtreeStream(self.adaptor, "token retval", retval.tree) - else: - stream_retval = RewriteRuleSubtreeStream(self.adaptor, "token retval", None) - - - root_0 = self.adaptor.nil() - # 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) - - # XKBGrammar.g:101:17: ( OVERRIDE )? - if stream_OVERRIDE.hasNext(): - self.adaptor.addChild(root_1, stream_OVERRIDE.nextNode()) - - - stream_OVERRIDE.reset(); - # 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() - - while stream_keyelements.hasNext(): - self.adaptor.addChild(root_1, stream_keyelements.nextTree()) - - - stream_keyelements.reset() - - self.adaptor.addChild(root_0, root_1) - - - - retval.tree = root_0 - - - - - retval.stop = self.input.LT(-1) - - - 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 - - return retval - - # $ANTLR end line_key - - class line_modifier_map_return(object): - def __init__(self): - self.start = None - self.stop = None - - self.tree = None - - - - - # $ANTLR start line_modifier_map - # XKBGrammar.g:104:1: line_modifier_map : 'modifier_map' STATE '{' keycode ( ',' keycode )* '}' -> ^( TOKEN_MODIFIER_MAP STATE ( keycode )+ ) ; - def line_modifier_map(self, ): - - retval = self.line_modifier_map_return() - retval.start = self.input.LT(1) - - root_0 = None - - string_literal45 = None - STATE46 = None - char_literal47 = None - char_literal49 = None - char_literal51 = None - keycode48 = None - - keycode50 = None - - - string_literal45_tree = None - STATE46_tree = None - char_literal47_tree = None - char_literal49_tree = None - char_literal51_tree = None - stream_STATE = RewriteRuleTokenStream(self.adaptor, "token STATE") - stream_47 = RewriteRuleTokenStream(self.adaptor, "token 47") - stream_46 = RewriteRuleTokenStream(self.adaptor, "token 46") - stream_35 = RewriteRuleTokenStream(self.adaptor, "token 35") - stream_34 = RewriteRuleTokenStream(self.adaptor, "token 34") - stream_keycode = RewriteRuleSubtreeStream(self.adaptor, "rule keycode") - try: - try: - # 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_map451) - stream_47.add(string_literal45) - STATE46 = self.input.LT(1) - 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_map455) - stream_34.add(char_literal47) - self._state.following.append(self.FOLLOW_keycode_in_line_modifier_map457) - keycode48 = self.keycode() - - self._state.following.pop() - stream_keycode.add(keycode48.tree) - # XKBGrammar.g:105:37: ( ',' keycode )* - while True: #loop9 - alt9 = 2 - LA9_0 = self.input.LA(1) - - if (LA9_0 == 46) : - alt9 = 1 - - - 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_map460) - stream_46.add(char_literal49) - self._state.following.append(self.FOLLOW_keycode_in_line_modifier_map462) - keycode50 = self.keycode() - - self._state.following.pop() - stream_keycode.add(keycode50.tree) - - - - else: - break #loop9 - - - char_literal51 = self.input.LT(1) - self.match(self.input, 35, self.FOLLOW_35_in_line_modifier_map466) - stream_35.add(char_literal51) - # AST Rewrite - # elements: keycode, STATE - # token labels: - # rule labels: retval - # token list labels: - # rule list labels: - - retval.tree = root_0 - - if retval is not None: - stream_retval = RewriteRuleSubtreeStream(self.adaptor, "token retval", retval.tree) - else: - stream_retval = RewriteRuleSubtreeStream(self.adaptor, "token retval", None) - - - root_0 = self.adaptor.nil() - # 106:2: -> ^( TOKEN_MODIFIER_MAP STATE ( keycode )+ ) - # XKBGrammar.g:106:5: ^( TOKEN_MODIFIER_MAP STATE ( keycode )+ ) - root_1 = self.adaptor.nil() - root_1 = self.adaptor.becomeRoot(self.adaptor.createFromType(TOKEN_MODIFIER_MAP, "TOKEN_MODIFIER_MAP"), root_1) - - self.adaptor.addChild(root_1, stream_STATE.nextNode()) - # XKBGrammar.g:106:32: ( keycode )+ - if not (stream_keycode.hasNext()): - raise RewriteEarlyExitException() - - while stream_keycode.hasNext(): - self.adaptor.addChild(root_1, stream_keycode.nextTree()) - - - stream_keycode.reset() - - self.adaptor.addChild(root_0, root_1) - - - - retval.tree = root_0 - - - - - retval.stop = self.input.LT(-1) - - - 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 - - return retval - - # $ANTLR end line_modifier_map - - class line_virtual_modifiers_return(object): - def __init__(self): - self.start = None - self.stop = None - - self.tree = None - - - - - # $ANTLR start line_virtual_modifiers - # XKBGrammar.g:109:1: line_virtual_modifiers : 'virtual_modifiers' NAME ( ',' NAME )* -> ^( TOKEN_VIRTUAL_MODIFIERS ( NAME )+ ) ; - def line_virtual_modifiers(self, ): - - retval = self.line_virtual_modifiers_return() - retval.start = self.input.LT(1) - - root_0 = None - - string_literal52 = None - NAME53 = None - char_literal54 = None - NAME55 = None - - string_literal52_tree = None - NAME53_tree = None - char_literal54_tree = None - NAME55_tree = None - stream_48 = RewriteRuleTokenStream(self.adaptor, "token 48") - stream_NAME = RewriteRuleTokenStream(self.adaptor, "token NAME") - stream_46 = RewriteRuleTokenStream(self.adaptor, "token 46") - - try: - try: - # 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_modifiers489) - stream_48.add(string_literal52) - NAME53 = self.input.LT(1) - self.match(self.input, NAME, self.FOLLOW_NAME_in_line_virtual_modifiers491) - stream_NAME.add(NAME53) - # XKBGrammar.g:110:29: ( ',' NAME )* - while True: #loop10 - alt10 = 2 - LA10_0 = self.input.LA(1) - - if (LA10_0 == 46) : - alt10 = 1 - - - 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_modifiers494) - stream_46.add(char_literal54) - NAME55 = self.input.LT(1) - self.match(self.input, NAME, self.FOLLOW_NAME_in_line_virtual_modifiers496) - stream_NAME.add(NAME55) - - - - else: - break #loop10 - - - # AST Rewrite - # elements: NAME - # token labels: - # rule labels: retval - # token list labels: - # rule list labels: - - retval.tree = root_0 - - if retval is not None: - stream_retval = RewriteRuleSubtreeStream(self.adaptor, "token retval", retval.tree) - else: - stream_retval = RewriteRuleSubtreeStream(self.adaptor, "token retval", None) - - - root_0 = self.adaptor.nil() - # 111:2: -> ^( TOKEN_VIRTUAL_MODIFIERS ( NAME )+ ) - # XKBGrammar.g:111:5: ^( TOKEN_VIRTUAL_MODIFIERS ( NAME )+ ) - root_1 = self.adaptor.nil() - root_1 = self.adaptor.becomeRoot(self.adaptor.createFromType(TOKEN_VIRTUAL_MODIFIERS, "TOKEN_VIRTUAL_MODIFIERS"), root_1) - - # XKBGrammar.g:111:31: ( NAME )+ - if not (stream_NAME.hasNext()): - raise RewriteEarlyExitException() - - while stream_NAME.hasNext(): - self.adaptor.addChild(root_1, stream_NAME.nextNode()) - - - stream_NAME.reset() - - self.adaptor.addChild(root_0, root_1) - - - - retval.tree = root_0 - - - - - retval.stop = self.input.LT(-1) - - - 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 - - return retval - - # $ANTLR end line_virtual_modifiers - - class keycode_return(object): - def __init__(self): - self.start = None - self.stop = None - - self.tree = None - - - - - # $ANTLR start keycode - # XKBGrammar.g:114:1: keycode : ( '<' NAME '>' -> ^( KEYCODEX NAME ) | NAME -> ^( KEYCODE NAME ) ); - def keycode(self, ): - - retval = self.keycode_return() - retval.start = self.input.LT(1) - - root_0 = None - - char_literal56 = None - NAME57 = None - char_literal58 = None - NAME59 = None - - char_literal56_tree = None - NAME57_tree = None - char_literal58_tree = None - NAME59_tree = None - stream_NAME = RewriteRuleTokenStream(self.adaptor, "token NAME") - stream_45 = RewriteRuleTokenStream(self.adaptor, "token 45") - stream_44 = RewriteRuleTokenStream(self.adaptor, "token 44") - - try: - try: - # XKBGrammar.g:115:2: ( '<' NAME '>' -> ^( KEYCODEX NAME ) | NAME -> ^( KEYCODE NAME ) ) - alt11 = 2 - LA11_0 = self.input.LA(1) - - if (LA11_0 == 44) : - alt11 = 1 - elif (LA11_0 == NAME) : - alt11 = 2 - else: - nvae = NoViableAltException("", 11, 0, self.input) - - raise nvae - - if alt11 == 1: - # XKBGrammar.g:115:4: '<' NAME '>' - char_literal56 = self.input.LT(1) - 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_keycode522) - stream_NAME.add(NAME57) - char_literal58 = self.input.LT(1) - self.match(self.input, 45, self.FOLLOW_45_in_keycode524) - stream_45.add(char_literal58) - # AST Rewrite - # elements: NAME - # token labels: - # rule labels: retval - # token list labels: - # rule list labels: - - retval.tree = root_0 - - if retval is not None: - stream_retval = RewriteRuleSubtreeStream(self.adaptor, "token retval", retval.tree) - else: - stream_retval = RewriteRuleSubtreeStream(self.adaptor, "token retval", None) - - - root_0 = self.adaptor.nil() - # 115:17: -> ^( KEYCODEX NAME ) - # XKBGrammar.g:115:20: ^( KEYCODEX NAME ) - root_1 = self.adaptor.nil() - root_1 = self.adaptor.becomeRoot(self.adaptor.createFromType(KEYCODEX, "KEYCODEX"), root_1) - - self.adaptor.addChild(root_1, stream_NAME.nextNode()) - - self.adaptor.addChild(root_0, root_1) - - - - retval.tree = root_0 - - - - elif alt11 == 2: - # XKBGrammar.g:116:4: NAME - NAME59 = self.input.LT(1) - self.match(self.input, NAME, self.FOLLOW_NAME_in_keycode537) - stream_NAME.add(NAME59) - # AST Rewrite - # elements: NAME - # token labels: - # rule labels: retval - # token list labels: - # rule list labels: - - retval.tree = root_0 - - if retval is not None: - stream_retval = RewriteRuleSubtreeStream(self.adaptor, "token retval", retval.tree) - else: - stream_retval = RewriteRuleSubtreeStream(self.adaptor, "token retval", None) - - - root_0 = self.adaptor.nil() - # 116:9: -> ^( KEYCODE NAME ) - # XKBGrammar.g:116:12: ^( 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.nextNode()) - - self.adaptor.addChild(root_0, root_1) - - - - retval.tree = root_0 - - - - retval.stop = self.input.LT(-1) - - - 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 - - return retval - - # $ANTLR end keycode - - class override_return(object): - def __init__(self): - self.start = None - self.stop = None - - self.tree = None - - - - - # $ANTLR start override - # XKBGrammar.g:119:1: override : 'override' ; - def override(self, ): - - retval = self.override_return() - retval.start = self.input.LT(1) - - root_0 = None - - string_literal60 = None - - string_literal60_tree = None - - try: - try: - # XKBGrammar.g:120:2: ( 'override' ) - # XKBGrammar.g:120:4: 'override' - root_0 = self.adaptor.nil() - - string_literal60 = self.input.LT(1) - 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) - - - - - - retval.stop = self.input.LT(-1) - - - 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 - - return retval - - # $ANTLR end override - - class keyelements_return(object): - def __init__(self): - self.start = None - self.stop = None - - self.tree = None - - - - - # $ANTLR start keyelements - # XKBGrammar.g:123:1: keyelements : ( elem_keysyms | elem_keysymgroup | elem_virtualmods | elem_overlay ); - def keyelements(self, ): - - retval = self.keyelements_return() - retval.start = self.input.LT(1) - - root_0 = None - - elem_keysyms61 = None - - elem_keysymgroup62 = None - - elem_virtualmods63 = None - - elem_overlay64 = None - - - - try: - try: - # XKBGrammar.g:124:2: ( elem_keysyms | elem_keysymgroup | elem_virtualmods | elem_overlay ) - alt12 = 4 - LA12 = self.input.LA(1) - if LA12 == 49: - alt12 = 1 - elif LA12 == 39 or LA12 == 50: - alt12 = 2 - elif LA12 == 51: - alt12 = 3 - elif LA12 == NAME: - alt12 = 4 - else: - nvae = NoViableAltException("", 12, 0, self.input) - - raise nvae - - if alt12 == 1: - # XKBGrammar.g:124:4: elem_keysyms - root_0 = self.adaptor.nil() - - self._state.following.append(self.FOLLOW_elem_keysyms_in_keyelements567) - elem_keysyms61 = self.elem_keysyms() - - self._state.following.pop() - self.adaptor.addChild(root_0, elem_keysyms61.tree) - - - - elif alt12 == 2: - # XKBGrammar.g:125:4: elem_keysymgroup - root_0 = self.adaptor.nil() - - self._state.following.append(self.FOLLOW_elem_keysymgroup_in_keyelements573) - elem_keysymgroup62 = self.elem_keysymgroup() - - self._state.following.pop() - self.adaptor.addChild(root_0, elem_keysymgroup62.tree) - - - - elif alt12 == 3: - # XKBGrammar.g:126:4: elem_virtualmods - root_0 = self.adaptor.nil() - - self._state.following.append(self.FOLLOW_elem_virtualmods_in_keyelements578) - elem_virtualmods63 = self.elem_virtualmods() - - self._state.following.pop() - self.adaptor.addChild(root_0, elem_virtualmods63.tree) - - - - elif alt12 == 4: - # XKBGrammar.g:127:4: elem_overlay - root_0 = self.adaptor.nil() - - self._state.following.append(self.FOLLOW_elem_overlay_in_keyelements583) - elem_overlay64 = self.elem_overlay() - - self._state.following.pop() - self.adaptor.addChild(root_0, elem_overlay64.tree) - - - - retval.stop = self.input.LT(-1) - - - 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 - - return retval - - # $ANTLR end keyelements - - class elem_keysyms_return(object): - def __init__(self): - self.start = None - self.stop = None - - self.tree = None - - - - - # $ANTLR start elem_keysyms - # XKBGrammar.g:130:1: elem_keysyms : 'type' ( '[' NAME ']' )? '=' DQSTRING -> ^( ELEM_KEYSYMS DQSTRING ) ; - def elem_keysyms(self, ): - - retval = self.elem_keysyms_return() - retval.start = self.input.LT(1) - - root_0 = None - - string_literal65 = None - char_literal66 = None - NAME67 = None - char_literal68 = None - char_literal69 = None - DQSTRING70 = None - - string_literal65_tree = None - char_literal66_tree = None - NAME67_tree = None - char_literal68_tree = None - char_literal69_tree = None - DQSTRING70_tree = None - stream_49 = RewriteRuleTokenStream(self.adaptor, "token 49") - stream_NAME = RewriteRuleTokenStream(self.adaptor, "token NAME") - stream_41 = RewriteRuleTokenStream(self.adaptor, "token 41") - stream_40 = RewriteRuleTokenStream(self.adaptor, "token 40") - stream_DQSTRING = RewriteRuleTokenStream(self.adaptor, "token DQSTRING") - stream_39 = RewriteRuleTokenStream(self.adaptor, "token 39") - - try: - try: - # 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_keysyms594) - stream_49.add(string_literal65) - # XKBGrammar.g:131:11: ( '[' NAME ']' )? - alt13 = 2 - LA13_0 = self.input.LA(1) - - if (LA13_0 == 39) : - alt13 = 1 - if alt13 == 1: - # XKBGrammar.g:131:12: '[' NAME ']' - char_literal66 = self.input.LT(1) - 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_keysyms599) - stream_NAME.add(NAME67) - char_literal68 = self.input.LT(1) - 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_keysyms605) - stream_41.add(char_literal69) - DQSTRING70 = self.input.LT(1) - self.match(self.input, DQSTRING, self.FOLLOW_DQSTRING_in_elem_keysyms607) - stream_DQSTRING.add(DQSTRING70) - # AST Rewrite - # elements: DQSTRING - # token labels: - # rule labels: retval - # token list labels: - # rule list labels: - - retval.tree = root_0 - - if retval is not None: - stream_retval = RewriteRuleSubtreeStream(self.adaptor, "token retval", retval.tree) - else: - stream_retval = RewriteRuleSubtreeStream(self.adaptor, "token retval", None) - - - root_0 = self.adaptor.nil() - # 132:2: -> ^( ELEM_KEYSYMS DQSTRING ) - # XKBGrammar.g:132:5: ^( ELEM_KEYSYMS DQSTRING ) - root_1 = self.adaptor.nil() - root_1 = self.adaptor.becomeRoot(self.adaptor.createFromType(ELEM_KEYSYMS, "ELEM_KEYSYMS"), root_1) - - self.adaptor.addChild(root_1, stream_DQSTRING.nextNode()) - - self.adaptor.addChild(root_0, root_1) - - - - retval.tree = root_0 - - - - - retval.stop = self.input.LT(-1) - - - 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 - - return retval - - # $ANTLR end elem_keysyms - - class elem_keysymgroup_return(object): - def __init__(self): - self.start = None - self.stop = None - - self.tree = None - - - - - # $ANTLR start elem_keysymgroup - # XKBGrammar.g:135:1: elem_keysymgroup : ( 'symbols' '[' NAME ']' '=' )? '[' keysym+= NAME ( ',' keysym+= NAME )* ']' -> ^( ELEM_KEYSYMGROUP ^( VALUE ( $keysym)+ ) ) ; - def elem_keysymgroup(self, ): - - retval = self.elem_keysymgroup_return() - retval.start = self.input.LT(1) - - root_0 = None - - string_literal71 = None - char_literal72 = None - NAME73 = None - char_literal74 = None - char_literal75 = None - char_literal76 = None - char_literal77 = None - char_literal78 = None - keysym = None - list_keysym = None - - string_literal71_tree = None - char_literal72_tree = None - NAME73_tree = None - char_literal74_tree = None - char_literal75_tree = None - char_literal76_tree = None - char_literal77_tree = None - char_literal78_tree = None - keysym_tree = None - stream_NAME = RewriteRuleTokenStream(self.adaptor, "token NAME") - stream_41 = RewriteRuleTokenStream(self.adaptor, "token 41") - stream_40 = RewriteRuleTokenStream(self.adaptor, "token 40") - stream_46 = RewriteRuleTokenStream(self.adaptor, "token 46") - stream_39 = RewriteRuleTokenStream(self.adaptor, "token 39") - stream_50 = RewriteRuleTokenStream(self.adaptor, "token 50") - - try: - try: - # XKBGrammar.g:136:2: ( ( 'symbols' '[' NAME ']' '=' )? '[' keysym+= NAME ( ',' keysym+= NAME )* ']' -> ^( ELEM_KEYSYMGROUP ^( VALUE ( $keysym)+ ) ) ) - # XKBGrammar.g:136:4: ( 'symbols' '[' NAME ']' '=' )? '[' keysym+= NAME ( ',' keysym+= NAME )* ']' - # XKBGrammar.g:136:4: ( 'symbols' '[' NAME ']' '=' )? - alt14 = 2 - LA14_0 = self.input.LA(1) - - if (LA14_0 == 50) : - alt14 = 1 - 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_keysymgroup628) - stream_50.add(string_literal71) - char_literal72 = self.input.LT(1) - 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_keysymgroup632) - stream_NAME.add(NAME73) - char_literal74 = self.input.LT(1) - 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_keysymgroup636) - stream_41.add(char_literal75) - - - - - char_literal76 = self.input.LT(1) - 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_keysymgroup644) - stream_NAME.add(keysym) - if list_keysym is None: - list_keysym = [] - list_keysym.append(keysym) - - # XKBGrammar.g:136:51: ( ',' keysym+= NAME )* - while True: #loop15 - alt15 = 2 - LA15_0 = self.input.LA(1) - - if (LA15_0 == 46) : - alt15 = 1 - - - 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_keysymgroup647) - stream_46.add(char_literal77) - keysym = self.input.LT(1) - self.match(self.input, NAME, self.FOLLOW_NAME_in_elem_keysymgroup651) - stream_NAME.add(keysym) - if list_keysym is None: - list_keysym = [] - list_keysym.append(keysym) - - - - - else: - break #loop15 - - - char_literal78 = self.input.LT(1) - self.match(self.input, 40, self.FOLLOW_40_in_elem_keysymgroup655) - stream_40.add(char_literal78) - # AST Rewrite - # elements: keysym - # token labels: - # rule labels: retval - # token list labels: keysym - # rule list labels: - - retval.tree = root_0 - stream_keysym = RewriteRuleTokenStream(self.adaptor, "token keysym", list_keysym) - - if retval is not None: - stream_retval = RewriteRuleSubtreeStream(self.adaptor, "token retval", retval.tree) - else: - stream_retval = RewriteRuleSubtreeStream(self.adaptor, "token retval", None) - - - root_0 = self.adaptor.nil() - # 137:2: -> ^( ELEM_KEYSYMGROUP ^( VALUE ( $keysym)+ ) ) - # XKBGrammar.g:137:5: ^( ELEM_KEYSYMGROUP ^( VALUE ( $keysym)+ ) ) - root_1 = self.adaptor.nil() - root_1 = self.adaptor.becomeRoot(self.adaptor.createFromType(ELEM_KEYSYMGROUP, "ELEM_KEYSYMGROUP"), root_1) - - # XKBGrammar.g:137:24: ^( VALUE ( $keysym)+ ) - root_2 = self.adaptor.nil() - root_2 = self.adaptor.becomeRoot(self.adaptor.createFromType(VALUE, "VALUE"), root_2) - - # XKBGrammar.g:137:32: ( $keysym)+ - if not (stream_keysym.hasNext()): - raise RewriteEarlyExitException() - - while stream_keysym.hasNext(): - self.adaptor.addChild(root_2, stream_keysym.nextNode()) - - - stream_keysym.reset() - - self.adaptor.addChild(root_1, root_2) - - self.adaptor.addChild(root_0, root_1) - - - - retval.tree = root_0 - - - - - retval.stop = self.input.LT(-1) - - - 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 - - return retval - - # $ANTLR end elem_keysymgroup - - class elem_virtualmods_return(object): - def __init__(self): - self.start = None - self.stop = None - - self.tree = None - - - - - # $ANTLR start elem_virtualmods - # XKBGrammar.g:140:1: elem_virtualmods : ( 'virtualMods' '=' NAME ) -> ^( ELEM_VIRTUALMODS NAME ) ; - def elem_virtualmods(self, ): - - retval = self.elem_virtualmods_return() - retval.start = self.input.LT(1) - - root_0 = None - - string_literal79 = None - char_literal80 = None - NAME81 = None - - string_literal79_tree = None - char_literal80_tree = None - NAME81_tree = None - stream_NAME = RewriteRuleTokenStream(self.adaptor, "token NAME") - stream_41 = RewriteRuleTokenStream(self.adaptor, "token 41") - stream_51 = RewriteRuleTokenStream(self.adaptor, "token 51") - - try: - try: - # XKBGrammar.g:141:2: ( ( 'virtualMods' '=' NAME ) -> ^( ELEM_VIRTUALMODS NAME ) ) - # XKBGrammar.g:141:4: ( 'virtualMods' '=' NAME ) - # 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_virtualmods683) - stream_51.add(string_literal79) - char_literal80 = self.input.LT(1) - 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_virtualmods687) - stream_NAME.add(NAME81) - - - - - # AST Rewrite - # elements: NAME - # token labels: - # rule labels: retval - # token list labels: - # rule list labels: - - retval.tree = root_0 - - if retval is not None: - stream_retval = RewriteRuleSubtreeStream(self.adaptor, "token retval", retval.tree) - else: - stream_retval = RewriteRuleSubtreeStream(self.adaptor, "token retval", None) - - - root_0 = self.adaptor.nil() - # 142:2: -> ^( ELEM_VIRTUALMODS NAME ) - # XKBGrammar.g:142:5: ^( ELEM_VIRTUALMODS NAME ) - root_1 = self.adaptor.nil() - root_1 = self.adaptor.becomeRoot(self.adaptor.createFromType(ELEM_VIRTUALMODS, "ELEM_VIRTUALMODS"), root_1) - - self.adaptor.addChild(root_1, stream_NAME.nextNode()) - - self.adaptor.addChild(root_0, root_1) - - - - retval.tree = root_0 - - - - - retval.stop = self.input.LT(-1) - - - 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 - - return retval - - # $ANTLR end elem_virtualmods - - class elem_overlay_return(object): - def __init__(self): - self.start = None - self.stop = None - - self.tree = None - - - - - # $ANTLR start elem_overlay - # XKBGrammar.g:145:1: elem_overlay : NAME '=' keycode -> ^( OVERLAY NAME keycode ) ; - def elem_overlay(self, ): - - retval = self.elem_overlay_return() - retval.start = self.input.LT(1) - - root_0 = None - - NAME82 = None - char_literal83 = None - keycode84 = None - - - NAME82_tree = None - char_literal83_tree = None - stream_NAME = RewriteRuleTokenStream(self.adaptor, "token NAME") - stream_41 = RewriteRuleTokenStream(self.adaptor, "token 41") - stream_keycode = RewriteRuleSubtreeStream(self.adaptor, "rule keycode") - try: - try: - # 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_overlay708) - stream_NAME.add(NAME82) - char_literal83 = self.input.LT(1) - 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_overlay712) - keycode84 = self.keycode() - - self._state.following.pop() - stream_keycode.add(keycode84.tree) - # AST Rewrite - # elements: keycode, NAME - # token labels: - # rule labels: retval - # token list labels: - # rule list labels: - - retval.tree = root_0 - - if retval is not None: - stream_retval = RewriteRuleSubtreeStream(self.adaptor, "token retval", retval.tree) - else: - stream_retval = RewriteRuleSubtreeStream(self.adaptor, "token retval", None) - - - root_0 = self.adaptor.nil() - # 147:2: -> ^( OVERLAY NAME keycode ) - # XKBGrammar.g:147:5: ^( OVERLAY NAME keycode ) - root_1 = self.adaptor.nil() - root_1 = self.adaptor.becomeRoot(self.adaptor.createFromType(OVERLAY, "OVERLAY"), root_1) - - self.adaptor.addChild(root_1, stream_NAME.nextNode()) - self.adaptor.addChild(root_1, stream_keycode.nextTree()) - - self.adaptor.addChild(root_0, root_1) - - - - retval.tree = root_0 - - - - - retval.stop = self.input.LT(-1) - - - 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 - - return retval - - # $ANTLR end elem_overlay - - - # Delegated rules - - - - - FOLLOW_symbols_in_layout161 = frozenset([28]) - FOLLOW_EOF_in_layout164 = frozenset([1]) - FOLLOW_mapType_in_symbols187 = frozenset([34]) - FOLLOW_34_in_symbols189 = frozenset([26, 37, 38, 42, 43, 47, 48]) - FOLLOW_mapMaterial_in_symbols191 = frozenset([26, 35, 37, 38, 42, 43, 47, 48]) - FOLLOW_35_in_symbols194 = frozenset([36]) - FOLLOW_36_in_symbols196 = frozenset([1]) - FOLLOW_MAPOPTS_in_mapType224 = frozenset([28, 29]) - FOLLOW_DQSTRING_in_mapType227 = frozenset([1]) - FOLLOW_line_include_in_mapMaterial259 = frozenset([1]) - FOLLOW_line_name_in_mapMaterial265 = frozenset([36]) - FOLLOW_36_in_mapMaterial267 = frozenset([1]) - FOLLOW_line_keytype_in_mapMaterial273 = frozenset([36]) - FOLLOW_36_in_mapMaterial275 = frozenset([1]) - FOLLOW_line_key_in_mapMaterial281 = frozenset([36]) - FOLLOW_36_in_mapMaterial283 = frozenset([1]) - FOLLOW_line_modifier_map_in_mapMaterial289 = frozenset([36]) - FOLLOW_36_in_mapMaterial291 = frozenset([1]) - FOLLOW_line_virtual_modifiers_in_mapMaterial297 = frozenset([36]) - FOLLOW_36_in_mapMaterial299 = frozenset([1]) - FOLLOW_37_in_line_include311 = frozenset([29]) - FOLLOW_DQSTRING_in_line_include313 = frozenset([1]) - FOLLOW_38_in_line_name333 = frozenset([39, 41]) - FOLLOW_39_in_line_name336 = frozenset([30]) - FOLLOW_NAME_in_line_name338 = frozenset([40]) - FOLLOW_40_in_line_name340 = frozenset([41]) - FOLLOW_41_in_line_name344 = frozenset([29]) - FOLLOW_DQSTRING_in_line_name346 = frozenset([1]) - FOLLOW_42_in_line_keytype366 = frozenset([39, 41]) - FOLLOW_39_in_line_keytype369 = frozenset([30]) - FOLLOW_NAME_in_line_keytype371 = frozenset([40]) - FOLLOW_40_in_line_keytype373 = frozenset([41]) - FOLLOW_41_in_line_keytype377 = frozenset([29]) - FOLLOW_DQSTRING_in_line_keytype379 = frozenset([1]) - FOLLOW_OVERRIDE_in_line_key399 = frozenset([43]) - FOLLOW_43_in_line_key402 = frozenset([44]) - FOLLOW_44_in_line_key404 = frozenset([30]) - FOLLOW_NAME_in_line_key406 = frozenset([45]) - FOLLOW_45_in_line_key408 = frozenset([34]) - FOLLOW_34_in_line_key410 = frozenset([30, 39, 49, 50, 51]) - FOLLOW_keyelements_in_line_key412 = frozenset([35, 46]) - 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_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]) - - - -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,58 +0,0 @@ -// XKB Grammar (X.org) -// Written by Simos Xenitellis <simos.lists@googlemail.com>, 2008. -// Version 0.8 - -tree grammar XKBGrammarWalker; - -options -{ - language = Python; - tokenVocab = XKBGrammar; - ASTLabelType = CommonTree; -} - -layout - : ^(LAYOUT symbols+) - ; - -symbols - : ^(SYMBOLS mapType ^(MAPMATERIAL mapMaterial+)) - ; - -mapType - : ^(MAPTYPE ^(MAPOPTIONS MAPOPTS+) ^(MAPNAME DQSTRING)) - ; - -mapMaterial - : ^(TOKEN_INCLUDE DQSTRING) - | ^(TOKEN_NAME DQSTRING) - | ^(TOKEN_KEY_TYPE NAME? ^(VALUE DQSTRING)) - | ^(TOKEN_KEY OVERRIDE? ^(KEYCODEX NAME) keyelements+) - | ^(TOKEN_MODIFIER_MAP STATE keycode+) - | ^(TOKEN_VIRTUAL_MODIFIERS NAME+) - ; - -keycode - : ^(KEYCODE NAME) - | ^(KEYCODEX NAME) - ; - -keyelements - : ^(ELEM_KEYSYMS DQSTRING) - | ^(ELEM_KEYSYMGROUP ^(VALUE NAME+)) - | ^(ELEM_VIRTUALMODS NAME) - | ^(ELEM_OVERLAY NAME keycode) - ; - -mapopts - : 'default' - | 'hidden' - | 'partial' - | 'alphanumeric_keys' - | 'keypad_keys' - | 'function_keys' - | 'modifier_keys' - | 'alternate_group' - | 'xkb_symbols' - ; - diff --git a/XKBGrammar/XKBGrammar__.g b/XKBGrammar/XKBGrammar__.g @@ -1,53 +0,0 @@ -lexer grammar XKBGrammar; -options { - language=Python; - -} - -T31 : '"' ; -T32 : '{' ; -T33 : ';' ; -T34 : '}' ; -T35 : 'include' ; -T36 : 'name' ; -T37 : '[' ; -T38 : ']' ; -T39 : '=' ; -T40 : 'key.type' ; -T41 : 'key' ; -T42 : '<' ; -T43 : '>' ; -T44 : ',' ; -T45 : 'default' ; -T46 : 'hidden' ; -T47 : 'partial' ; -T48 : 'alphanumeric_keys' ; -T49 : 'alternate_group' ; -T50 : 'xkb_symbols' ; - -// $ANTLR src "XKBGrammar.g" 123 -NAME - : ('a'..'z' | 'A'..'Z' | '_' | '-' | '(' | ')' | '0'..'9')* - ; - -// Comments are currently ignored. -// $ANTLR src "XKBGrammar.g" 128 -WS - : - ( ' ' | '\r' | '\t' | '\u000C' | '\n') - { $channel=HIDDEN; } - ; - -// $ANTLR src "XKBGrammar.g" 134 -COMMENT - : - '/*' .* '*/' {$channel=HIDDEN;} - ; - -// $ANTLR src "XKBGrammar.g" 139 -LINE_COMMENT - : - '//' ~('\n' | '\r')* '\r'? '\n' - { $channel=HIDDEN; } - ; - diff --git a/XKBGrammar/check_xkb.py b/XKBGrammar/check_xkb.py @@ -1,159 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -# Version 0.7 - -import sys -import pdb -import antlr3 -from XKBGrammarLexer import XKBGrammarLexer, SYMBOLS, MAPTYPE, MAPNAME, MAPOPTIONS, MAPMATERIAL, TOKEN_INCLUDE, TOKEN_NAME, TOKEN_KEY_TYPE, TOKEN_KEY, VALUE, KEYCODE, KEYCODEX, TOKEN_TYPE, OVERRIDE, ELEM_KEYSYMS, ELEM_KEYSYMGROUP -from XKBGrammarParser import XKBGrammarParser -from XKBGrammarWalker import XKBGrammarWalker - -# Helper function to iterate through all children of a given type -def getChildrenByType(tree, type_value): - for i in range(tree.getChildCount()): - child = tree.getChild(i) - if child.getType() == type_value: - yield child - -# Helper function to iterate through all children of a given type -def getChildrenListByType(tree, type_value): - list = [] - for i in range(tree.getChildCount()): - child = tree.getChild(i) - if child.getType() == type_value: - list.append(child) - return list - -def hasChildByType(tree, type_value): - has = False - for i in range(tree.getChildCount()): - child = tree.getChild(i) - if child.getType() == type_value: - has = True - break - return has - -xkbfilename = "gr" -if len(sys.argv) > 1: - xkbfilename = sys.argv[1] - -print "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", sys.argv[1] - -try: - xkbfile = open(xkbfilename, 'r') -except OSError: - print "Could not open file ", xkbfilename, ". Aborting..." - sys.exit(-1) - -xkbfile.close - -char_stream = antlr3.ANTLRFileStream(xkbfilename, encoding='utf-8') -lexer = XKBGrammarLexer(char_stream) -tokens = antlr3.CommonTokenStream(lexer) -parser = XKBGrammarParser(tokens) - -result = parser.layout() - -print "tree =", result.tree.toStringTree() - -nodes = antlr3.tree.CommonTreeNodeStream(result.tree) -nodes.setTokenStream(tokens) -walker = XKBGrammarWalker(nodes) -# walker.layout() - -for symbols in result.tree.getChildren(): - print "// Section" - for mapobject in symbols.getChildren(): - if mapobject.getType() == MAPTYPE: - for maptypesect in mapobject.getChildren(): - if maptypesect.getType() == MAPOPTIONS: - for mapoption in maptypesect.getChildren(): - print mapoption.getText(), - elif maptypesect.getType() == MAPNAME: - if maptypesect.getChildCount() == 1: - print '%(opt)s {' % { "opt": maptypesect.getChildren()[0].getText() } - else: - print "\t\t\tInternal error in mapoption" - else: - print "\t\tInternal error in maptypesect" - sys.exit(-2) - elif mapobject.getType() == MAPMATERIAL: - for name in getChildrenByType(mapobject, TOKEN_NAME): - nameText = name.getChild(0).getText() - for i in name.getChildren(): - if i.getType() == VALUE: - print '\tname[%(name)s] = %(val)s;' % { "name": nameText, "val": i.getChild(0).getText()} - for include in getChildrenByType(mapobject, TOKEN_INCLUDE): - print "\tinclude", include.getChild(0).getText() - for keytype in getChildrenByType(mapobject, TOKEN_KEY_TYPE): - keytypeText = keytype.getChild(0).getText() - for i in keytype.getChildren(): - if i.getType() == VALUE: - print '\tkey.type[%(kt)s] = %(val)s;' % { "kt": keytypeText, "val": i.getChild(0).getText() } - for keyset in getChildrenByType(mapobject, TOKEN_KEY): - keycode = getChildrenListByType(keyset, KEYCODE) - keycodex = getChildrenListByType(keyset, KEYCODEX) - keysyms = getChildrenByType(keyset, ELEM_KEYSYMS) - override = getChildrenListByType(keyset, OVERRIDE) - print '\t', - if len(override) == 1: - print 'override', - if len(keycode) == 1: - print 'key %(kc)s = { ' % { "kc": keycode[0].getChild(0).getText() }, - elif len(keycodex) == 1: - print 'key <%(kc)s> = { ' % { "kc": keycodex[0].getChild(0).getText() }, - else: - print "\tInternal error keycode/keycodex:", len(keycode), len(keycodex) - sys.exit(-1) - first_time = True - for ks in keysyms: - tokentype = getChildrenListByType(ks, TOKEN_TYPE) - keysymgroup = getChildrenListByType(ks, ELEM_KEYSYMGROUP) - if len(tokentype) == 1: - print 'type[%(t)s] = %(v)s,' % { "t": tokentype[0].getChild(0).getText(), "v": tokentype[0].getChild(1).getText() }, - elif len(tokentype) == 0: - pass - else: - print "Internal error" - sys.exit(-1) - ftg = True - for ksg in keysymgroup: - if ftg: - sys.stdout.write(' [ ') - ft = True - for lala in ksg.getChildren(): - if ft: - sys.stdout.write(lala.getText()) - ft = False - continue - sys.stdout.write(', ') - sys.stdout.write(lala.getText()) - sys.stdout.write(' ]') - ftg = False - continue - sys.stdout.write(', [') - ft = True - for lala in ksg.getChildren(): - if ft: - sys.stdout.write(lala.getText()) - ft = False - continue - sys.stdout.write(', ') - sys.stdout.write(lala.getText()) - sys.stdout.write(' ]') - # print "tokentype:", len(tokentype), tokentype[0].getText(), - # print "keysymgroup:", len(keysymgroup), keysymgroup[0], - # if len(tokentype) != 0: - # pass - #if len(keysymgroup) != 0: - # for ksg in keysymgroup: - # print ksg.getText(), - print " };" - else: - print "\tInternal error at map level,", mapobject.getText() - # sys.exit(-2) - print "};\n" - -#pdb.set_trace() diff --git a/XKBGrammar/gr b/XKBGrammar/gr @@ -1,17 +0,0 @@ -partial alphanumeric_keys alternate_group -xkb_symbols "extended" { - include "gr(basic)" - name[Group1] = "Greece-Extendedδφδ"; - key.type = "THREE_LEVEL"; // yeah, comment -// override key <AD01> { type[Group1] = "SEPARATE_CAPS_AND_SHIFT_ALPHABETIC", [ U1C9, U1C8], [ any, U1C7 ] }; // q -// override key <AD02> { [ U1CC, U1CB, any,U1CA ], type[Group1] = "SEPARATE_CAPS_AND_SHIFT_ALPHABETIC" }; // w -// key <BKSP> { -// type[Group1]="CTRL+ALT", -// symbols[Group1]= [ BackSpace, Terminate_Server ] -// }; -// key <BKSP> { virtualMods = AltGr, [ 1, 2 ] }; -// modifier_map Control { Control_L }; -// modifier_map Mod5 { <LVL3>, <MDSW> }; - key <BKSP> { [1, 2,3, 4] }; - -}; diff --git a/XKBGrammar/parse_xkb_to_xml.py b/XKBGrammar/parse_xkb_to_xml.py @@ -1,188 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -# Version 0.8 - -import sys -import os.path -import pdb -import antlr3 -from lxml import etree -from XKBGrammarLexer import XKBGrammarLexer -from XKBGrammarParser import XKBGrammarParser -from XKBGrammarWalker import XKBGrammarWalker, LAYOUT, SYMBOLS, MAPMATERIAL, MAPTYPE, MAPOPTIONS, MAPOPTS, MAPNAME, TOKEN_INCLUDE, TOKEN_NAME, TOKEN_KEY_TYPE, TOKEN_KEY, TOKEN_TYPE, TOKEN_MODIFIER_MAP, TOKEN_VIRTUAL_MODIFIERS, KEYCODE, KEYCODEX, ELEM_KEYSYMS, ELEM_KEYSYMGROUP, ELEM_VIRTUALMODS, OVERLAY, VALUE, STATE, NAME, DQSTRING, OVERRIDE - -# Helper function to iterate through all children of a given type -def getChildrenByType(tree, type_value): - for i in range(tree.getChildCount()): - child = tree.getChild(i) - if child.getType() == type_value: - yield child - -# Helper function to iterate through all children of a given type -def getChildrenByTypes(tree, type_value1, type_value2): - for i in range(tree.getChildCount()): - child = tree.getChild(i) - if child.getType() == type_value1 or child.getType() == type_value2: - yield child - -# Helper function to iterate through all children of a given type -def getChildrenListByType(tree, type_value): - list = [] - for i in range(tree.getChildCount()): - child = tree.getChild(i) - if child.getType() == type_value: - list.append(child) - return list - -# Helper function to iterate through all children of a given type -def getChildrenListByTypes(tree, type_value1, type_value2): - list = [] - for i in range(tree.getChildCount()): - child = tree.getChild(i) - if child.getType() == type_value1 or child.getType() == type_value2: - list.append(child) - return list - -def hasChildByType(tree, type_value): - has = False - for i in range(tree.getChildCount()): - child = tree.getChild(i) - if child.getType() == type_value: - has = True - break - return has - -xkbfilename = "gr" -if len(sys.argv) > 1: - xkbfilename = sys.argv[1] - -# print "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", sys.argv[1] - -try: - xkbfile = open(xkbfilename, 'r') -except OSError: - print "Could not open file ", xkbfilename, ". Aborting..." - sys.exit(-1) - -xkbfile.close - -char_stream = antlr3.ANTLRFileStream(xkbfilename, encoding='utf-8') -lexer = XKBGrammarLexer(char_stream) -tokens = antlr3.CommonTokenStream(lexer) -parser = XKBGrammarParser(tokens) - -result = parser.layout() - -print "tree =", result.tree.toStringTree() - -nodes = antlr3.tree.CommonTreeNodeStream(result.tree) -nodes.setTokenStream(tokens) -walker = XKBGrammarWalker(nodes) -# walker.layout() - -layout = etree.Element('layout') - -doc = etree.ElementTree(layout) - -layout.attrib['layoutname'] = os.path.basename(xkbfilename) - -print "Processing", os.path.basename(xkbfilename), "...", -for symbols in result.tree.getChildren(): - eSymbol = etree.SubElement(layout, 'symbols') - for mapobject in symbols.getChildren(): - if mapobject.getType() == MAPTYPE: - for maptypesect in mapobject.getChildren(): - if maptypesect.getType() == MAPOPTIONS: - for mapoption in maptypesect.getChildren(): - if mapoption.getText() == 'xkb_symbols' or mapoption.getText() == 'hidden': - eMapOption = etree.SubElement(eSymbol, 'mapoption') - eMapOption.text = mapoption.getText() - elif maptypesect.getType() == MAPNAME: - if maptypesect.getChildCount() == 1: - eMapName = etree.SubElement(eSymbol, 'mapname') - eMapName.text = maptypesect.getChildren()[0].getText()[1:-1] - else: - print "\t\t\tInternal error in mapoption" - else: - print "\t\tInternal error in maptypesect" - sys.exit(-2) - elif mapobject.getType() == MAPMATERIAL: - eMapMaterial = etree.SubElement(eSymbol, 'mapmaterial') - for name in getChildrenByType(mapobject, TOKEN_NAME): - nameText = name.getChild(0).getText()[1:-1] - eTokenName = etree.SubElement(eMapMaterial, 'tokenname', name=nameText ) - for include in getChildrenByType(mapobject, TOKEN_INCLUDE): - eInclude = etree.SubElement(eMapMaterial, 'tokeninclude') - eInclude.text = include.getChild(0).getText()[1:-1] - for keytype in getChildrenByType(mapobject, TOKEN_KEY_TYPE): - keytypeText = keytype.getChild(0).getText() - eKeyType = etree.SubElement(eMapMaterial, 'tokentype') - eKeyType.text = keytypeText[1:-1] - for modmap in getChildrenByType(mapobject, TOKEN_MODIFIER_MAP): - eModMap = etree.SubElement(eMapMaterial, 'tokenmodifiermap', state=modmap.getChild(0).getText()) - for modstate in getChildrenByTypes(modmap, KEYCODE, KEYCODEX): - if modstate.getType() == KEYCODE: - eModState = etree.SubElement(eModMap, "keycode", value=modstate.getChild(0).getText()) - elif modstate.getType() == KEYCODEX: - eModState = etree.SubElement(eModMap, "keycodex", value=modstate.getChild(0).getText()) - else: - print "Unexpected token encountered. Aborting...", modstate.getText() - sys.exit(-1) - for keyset in getChildrenByType(mapobject, TOKEN_KEY): - elem_keysymgroup = getChildrenByType(keyset, ELEM_KEYSYMGROUP) - elem_virtualmods = getChildrenByType(keyset, ELEM_VIRTUALMODS) - elem_overlay = getChildrenByType(keyset, OVERLAY) - override = getChildrenListByType(keyset, OVERRIDE) - eTokenKey = etree.SubElement(eMapMaterial, 'tokenkey') - eKeyCodeName = etree.SubElement(eTokenKey, 'keycodename') - 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: - eTokenKey.attrib['override'] = "False" - if len(getChildrenListByType(keyset, ELEM_KEYSYMGROUP)): - elem_keysyms = getChildrenListByType(keyset, ELEM_KEYSYMS) - eKeySymGroup = etree.SubElement(eTokenKey, 'keysymgroup') - keysymgroup_counter = len(getChildrenListByType(keyset, ELEM_KEYSYMGROUP)) - for elem in elem_keysymgroup: - eSymbolsGroup = etree.SubElement(eKeySymGroup, 'symbolsgroup') - for elem2 in elem.getChildren(): - for elem3 in elem2.getChildren(): - eSymbol = etree.SubElement(eSymbolsGroup, 'symbol') - eSymbol.text = elem3.getText() - if len(elem_keysyms) > 0: - if len(elem_keysyms) == 1: - ksname = elem_keysyms[0].getChild(0).getText() - eKeySyms = etree.SubElement(eKeySymGroup, 'typegroup', value=ksname[1:-1]) - else: - """ We are probably processing level3; we keep first item """ - ksname = elem_keysyms[0].getChild(0).getText() - eKeySyms = etree.SubElement(eKeySymGroup, 'typegroup', value=ksname[1:-1]) - print "Possibly processing level3" - if len(getChildrenListByType(keyset, ELEM_VIRTUALMODS)): - for vmods in elem_virtualmods: - etree.SubElement(eKeySymGroup, 'tokenvirtualmodifiers', value=vmods.getChild(0).getText()) - if len(getChildrenListByType(keyset, OVERLAY)): - for elem in elem_overlay: - for elem2 in getChildrenByType(elem, KEYCODEX): - pass - else: - print "\tInternal error at map level,", mapobject.getText() - # sys.exit(-2) - -fout = open(os.path.basename(xkbfilename) + ".xml", "w") -fout.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n") -# fout.write(" xmlns=\"http://relaxng.org/ns/structure/1.0\"\n") -# fout.write(" xmlns:xlink=\"http://www.w3.org/1999/xlink\"?>\n") -fout.write(etree.tostring(layout, pretty_print=True)) -fout.close() - -print " done." - -#pdb.set_trace() diff --git a/XKBGrammar/parse_xml_to_xkb.py b/XKBGrammar/parse_xml_to_xkb.py @@ -1,106 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -# Version 0.8 - -import sys -import os.path -import pdb -import antlr3 -from lxml import etree - -xmlfilename = "xkbsample.xml" -if len(sys.argv) > 1: - xmlfilename = sys.argv[1] - -try: - xmlfile = open(xmlfilename, 'r') - xmlfile.close -except OSError: - print "Could not open file ", xmlfilename, ". Aborting..." - sys.exit(-1) - - -doc = etree.parse(xmlfilename) - -# for elem in doc.getiterator(): -# print elem.tag, "has", len(elem), "children", elem.attrib, elem.text - -TABS="\t\t\t\t\t\t\t\t\t\t\t\t" - -xkbfilename = os.path.basename(xmlfilename)[:-4] -fout = open(xkbfilename, "w") - -def recurse_tree(node, depth): - if node.tag == "layout": - print "Parsing", node.attrib["layoutname"] - for n in node: - recurse_tree(n, depth+1) - elif node.tag == "symbols": - for k in node: - if k.tag == "mapoption": - fout.write(k.text) - fout.write(" ") - elif k.tag == "mapname": - fout.write("\"%(s)s\"\n{\n" % { "s": k.text }) - elif k.tag == "mapmaterial": - for t in k: - if t.tag == "tokenname": - fout.write("\tname = \"%(s)s\";\n" % { "s": t.attrib["name"] }) - elif t.tag == "tokeninclude": - fout.write("\tinclude \"%(s)s\"\n" % { "s": t.text }) - 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'] }) - count_mm = len(t) - for mm in t: - if mm.tag == "keycodex": - fout.write("<%(s)s>" % { "s": mm.attrib["value"] }) - elif mm.tag == "keycode": - fout.write("%(s)s" % { "s": mm.attrib["value"] }) - if count_mm > 1: - fout.write(", ") - count_mm -= 1 - fout.write(" };\n") - - elif t.tag == "tokenkey": - fout.write("\t") - if t.attrib["override"] == "True": - fout.write("override ") - for tk in t: - if tk.tag == "keycodename": - fout.write("key <%(s)s> { " % { "s": tk.text }) - elif tk.tag == "keysymgroup": - gotitem = False - for ks in tk: - if ks.tag == "typegroup": - if gotitem: - fout.write(", ") - fout.write("type = \"%(s)s\" " % { "s": ks.attrib["value"] }) - gotitem = True - elif ks.tag == "tokenvirtualmodifiers": - if gotitem: - fout.write(", ") - fout.write("virtualMods = %(s)s " % { "s": ks.attrib["value"] }) - elif ks.tag == "symbolsgroup": - if gotitem: - fout.write(", ") - gotitem = True - fout.write("[ ") - count_sg = len(ks) - for sg in ks: - if sg.tag == "symbol": - if count_sg > 1: - fout.write("%(s)s, " % { "s": sg.text }) - else: - fout.write("%(s)s " % { "s": sg.text }) - count_sg -= 1 - else: - print "ERROR" - sys.exit(-1) - fout.write("]") - fout.write(" };\n") - fout.write("};\n\n") - -recurse_tree(doc.getroot(), 0) diff --git a/XKBGrammar/print_tree.py b/XKBGrammar/print_tree.py @@ -1,70 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -# Version 0.7 - -import sys -import pdb -import antlr3 -from XKBGrammarLexer import XKBGrammarLexer, LAYOUT, SYMBOLS, MAPTYPE, MAPNAME, MAPOPTIONS, MAPMATERIAL, TOKEN_INCLUDE, TOKEN_NAME, TOKEN_KEY_TYPE, TOKEN_KEY, VALUE, KEYCODE, KEYCODEX -from XKBGrammarParser import XKBGrammarParser -from XKBGrammarWalker import XKBGrammarWalker - -# Helper function to iterate through all children of a given type -def getChildrenByType(tree, type_value): - for i in range(tree.getChildCount()): - child = tree.getChild(i) - if child.getType() == type_value: - yield child - -# Helper function to iterate through all children of a given type -def getChildrenListByType(tree, type_value): - list = [] - for i in range(tree.getChildCount()): - child = tree.getChild(i) - if child.getType() == type_value: - list.append(child) - return list - -xkbfilename = "gr" -if len(sys.argv) > 1: - xkbfilename = sys.argv[1] - -try: - xkbfile = open(xkbfilename, 'r') -except OSError: - print "Could not open file ", xkbfilename, ". Aborting..." - sys.exit(-1) - -xkbfile.close - -# char_stream = antlr3.ANTLRFileStream(xkbfilename, encoding='utf-8') -char_stream = antlr3.ANTLRFileStream(xkbfilename) -lexer = XKBGrammarLexer(char_stream) -tokens = antlr3.CommonTokenStream(lexer) -parser = XKBGrammarParser(tokens) - -result = parser.layout() - -print "XXXXXXXXXXXXXXXXXXXXXXX", xkbfilename -print "tree =", result.tree.toStringTree() - -nodes = antlr3.tree.CommonTreeNodeStream(result.tree) -nodes.setTokenStream(tokens) -walker = XKBGrammarWalker(nodes) -# walker.layout() - -MAX = 10 -TABS = "\t\t\t\t\t\t\t\t\t\t" - -def print_tree(node, depth): - if depth >= MAX: - return - for n in node.getChildren(): - print TABS[:depth], "===", n.getText(), "===" - print_tree(n, depth + 1) - - -print result.tree.getChild(0).getText() -print -print_tree(result.tree, 0) diff --git a/XKBGrammar/xkb.rng b/XKBGrammar/xkb.rng @@ -1,129 +0,0 @@ -<?xml version="1.0"?> -<grammar xmlns="http://relaxng.org/ns/structure/1.0" - xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" - xmlns:xlink="http://www.w3.org/1999/xlink" - datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"> - <start> - <element name="layout"> - <attribute name="layoutname"/> - <oneOrMore> - <element name="symbols"> - <oneOrMore> - <ref name="mapoptionContent"/> - </oneOrMore> - <element name="mapname"> - <text/> - </element> - <element name="mapmaterial"> - <ref name="mapContent"/> - </element> - </element> - </oneOrMore> - </element> - </start> - <define name="mapContent"> - <optional> - <element name="tokenname"> - <attribute name="name"/> - <text/> - </element> - </optional> - <optional> - <oneOrMore> - <element name="tokeninclude"> - <text/> - </element> - </oneOrMore> - </optional> - <optional> - <oneOrMore> - <element name="tokentype"> - <text/> - </element> - </oneOrMore> - </optional> - <optional> - <oneOrMore> - <element name="tokenmodifiermap"> - <attribute name="state"/> - <oneOrMore> - <optional> - <element name="keycode"> - <attribute name="value"/> - </element> - </optional> - <optional> - <element name="keycodex"> - <attribute name="value"/> - </element> - </optional> - </oneOrMore> - </element> - </oneOrMore> - </optional> - <optional> - <oneOrMore> - <element name="tokenvirtualmodifiers"> - <attribute name="value"/> - </element> - </oneOrMore> - </optional> - <optional> - <oneOrMore> - <ref name="tokenkeyContent"/> - </oneOrMore> - </optional> - </define> - <define name="tokenkeyContent"> - <element name="tokenkey"> - <attribute name="override"/> - <element name="keycodename"> - <text/> - </element> - <optional> - <element name="keysyms"> - <attribute name="tokenname"/> - <element name="value"> - <text/> - </element> - </element> - </optional> - <optional> - <element name="keysymgroup"> - <oneOrMore> - <element name="symbolsgroup"> - <oneOrMore> - <element name="symbol"> - <text/> - </element> - </oneOrMore> - </element> - </oneOrMore> - <optional> - <oneOrMore> - <element name="typegroup"> - <attribute name="value"/> - </element> - </oneOrMore> - </optional> - </element> - </optional> - <optional> - <element name="virtualMods"> - <attribute name="value"/> - </element> - </optional> - <optional> - <element name="overlay"> - <attribute name="ovname"/> - <attribute name="keycode"/> - </element> - </optional> - </element> - </define> - <define name="mapoptionContent"> - <element name="mapoption"> - <text/> - </element> - </define> -</grammar> diff --git a/XKBGrammar/xkbsample.xml b/XKBGrammar/xkbsample.xml @@ -1,118 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<layout layoutname="gr"> - <symbols> - <mapoption>default</mapoption> - <mapoption>partial</mapoption> - <mapoption>alphanumeric_keys</mapoption> - <mapoption>alternate_group</mapoption> - <mapoption>xkb_symbols</mapoption> - <mapname>basic</mapname> - <mapmaterial> - <tokenname name="Group1">Greece</tokenname> - <tokeninclude xlink:href="gr.xml" xlink:type="simple" xlink:title="bare"/> - <tokenkeytype>THREE_LEVEL</tokenkeytype> - <tokenkey override="False"> - <keycodename>TLDE</keycodename> - <keysymgroup> - <symbolsgroup> - <symbol>grave</symbol> - <symbol>asciitilde</symbol> - </symbolsgroup> - </keysymgroup> - </tokenkey> - <tokenkey override="False"> - <keycodename>AE01</keycodename> - <keysymgroup> - <symbolsgroup> - <symbol>1</symbol> - <symbol>exclam</symbol> - </symbolsgroup> - </keysymgroup> - </tokenkey> - </mapmaterial> - </symbols> - <symbols> - <mapoption>default</mapoption> - <mapoption>partial</mapoption> - <mapoption>alphanumeric_keys</mapoption> - <mapoption>hidden</mapoption> - <mapoption>xkb_symbols</mapoption> - <mapname>overlay1</mapname> - <mapmaterial> - <tokenkey override="False"> - <keycodename>TLDE</keycodename> - <keysymgroup> - <symbolsgroup> - <symbol>KP_Home</symbol> - </symbolsgroup> - </keysymgroup> - <overlay ovname="overlay1" keycode="K07"/> - </tokenkey> - <tokenkey override="False"> - <keycodename>AE01</keycodename> - <keysymgroup> - <symbolsgroup> - <symbol>1</symbol> - <symbol>exclam</symbol> - </symbolsgroup> - </keysymgroup> - </tokenkey> - </mapmaterial> - </symbols> - <symbols> - <mapoption>partial</mapoption> - <mapoption>alphanumeric_keys</mapoption> - <mapoption>xkb_symbols</mapoption> - <mapname>de_mac</mapname> - <mapmaterial> - <tokenname name="Group1">Switzerland - German (Macintosh)</tokenname> - <tokenkey override="False"> - <keycodename>AE01</keycodename> - <keysymgroup> - <symbolsgroup> - <symbol>1</symbol> - <symbol>plus</symbol> - <symbol>plusminus</symbol> - <symbol>infinity</symbol> - </symbolsgroup> - </keysymgroup> - </tokenkey> - <tokenkey override="True"> - <keycodename>AE02</keycodename> - <keysymgroup> - <symbolsgroup> - <symbol>2</symbol> - <symbol>quotedbl</symbol> - <symbol>leftquotedoublemark</symbol> - <symbol>rightquotedoublemark</symbol> - </symbolsgroup> - </keysymgroup> - </tokenkey> - </mapmaterial> - </symbols> - <symbols> - <mapoption>partial</mapoption> - <mapoption>modifier_keys</mapoption> - <mapoption>xkb_symbols</mapoption> - <mapname>ralt_alt</mapname> - <mapmaterial> - <tokenmodifiermap state="Mod1"> - <keycodex value="RALT"/> - <keycodex value="RALT"/> - <keycodex value="RALT"/> - </tokenmodifiermap> - <tokenvirtualmodifiers value="AltGr"/> - <tokenvirtualmodifiers value="LAlt"/> - <tokenkey override="False"> - <keycodename>RALT</keycodename> - <keysymgroup> - <typegroup value="TWO_LEVEL"/> - <symbolsgroup> - <symbol>Alt_R</symbol> - <symbol>Meta_R</symbol> - </symbolsgroup> - </keysymgroup> - </tokenkey> - </mapmaterial> - </symbols> -</layout> diff --git a/KeyboardLayoutEditor/src/XKBGrammarWalker.g b/XKBGrammarWalker.g diff --git a/KeyboardLayoutEditor/src/aliases b/aliases diff --git a/KeyboardLayoutEditor/src/evdev b/evdev diff --git a/KeyboardLayoutEditor/src/kle-icon.svg b/kle-icon.svg diff --git a/KeyboardLayoutEditor/src/kle-icon2.svg b/kle-icon2.svg diff --git a/KeyboardLayoutEditor/src/kle-icon3.svg b/kle-icon3.svg diff --git a/KeyboardLayoutEditor/src/kle-icon4.svg b/kle-icon4.svg diff --git a/KeyboardLayoutEditor/src/parse_xkb_to_xml.py b/parse_xkb_to_xml.py diff --git a/KeyboardLayoutEditor/src/parse_xml_to_xkb.py b/parse_xml_to_xkb.py diff --git a/KeyboardLayoutEditor/src/print_tree.py b/print_tree.py diff --git a/KeyboardLayoutEditor/src/utils/Keysyms.g b/utils/Keysyms.g diff --git a/KeyboardLayoutEditor/src/utils/KeysymsWalker.g b/utils/KeysymsWalker.g diff --git a/KeyboardLayoutEditor/src/utils/extract_keysymdefh.py b/utils/extract_keysymdefh.py diff --git a/KeyboardLayoutEditor/src/utils/extract_keysymstxt.py b/utils/extract_keysymstxt.py diff --git a/KeyboardLayoutEditor/src/utils/keysymdef.h b/utils/keysymdef.h diff --git a/KeyboardLayoutEditor/src/utils/keysyms.txt b/utils/keysyms.txt diff --git a/KeyboardLayoutEditor/src/xfree86 b/xfree86