KLL Compiler
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

kll.py 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  1. #!/usr/bin/env python3
  2. # KLL Compiler
  3. # Keyboard Layout Langauge
  4. #
  5. # Copyright (C) 2014 by Jacob Alexander
  6. #
  7. # This file is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation, either version 3 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This file is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this file. If not, see <http://www.gnu.org/licenses/>.
  19. ### Imports ###
  20. import argparse
  21. import io
  22. import os
  23. import re
  24. import sys
  25. import token
  26. import importlib
  27. from tokenize import generate_tokens
  28. from re import VERBOSE
  29. from pprint import pformat
  30. from kll_lib.hid_dict import *
  31. from kll_lib.containers import *
  32. from funcparserlib.lexer import make_tokenizer, Token, LexerError
  33. from funcparserlib.parser import (some, a, many, oneplus, skip, finished, maybe, skip, forward_decl, NoParseError)
  34. ### Decorators ###
  35. ## Print Decorator Variables
  36. ERROR = '\033[5;1;31mERROR\033[0m:'
  37. ## Python Text Formatting Fixer...
  38. ## Because the creators of Python are averse to proper capitalization.
  39. textFormatter_lookup = {
  40. "usage: " : "Usage: ",
  41. "optional arguments" : "Optional Arguments",
  42. }
  43. def textFormatter_gettext( s ):
  44. return textFormatter_lookup.get( s, s )
  45. argparse._ = textFormatter_gettext
  46. ### Argument Parsing ###
  47. def checkFileExists( filename ):
  48. if not os.path.isfile( filename ):
  49. print ( "{0} {1} does not exist...".format( ERROR, filename ) )
  50. sys.exit( 1 )
  51. def processCommandLineArgs():
  52. # Setup argument processor
  53. pArgs = argparse.ArgumentParser(
  54. usage="%(prog)s [options] <file1>...",
  55. description="Generates .h file state tables and pointer indices from KLL .kll files.",
  56. epilog="Example: {0} mykeyboard.kll -d colemak.kll -p hhkbpro2.kll -p symbols.kll".format( os.path.basename( sys.argv[0] ) ),
  57. formatter_class=argparse.RawTextHelpFormatter,
  58. add_help=False,
  59. )
  60. # Positional Arguments
  61. pArgs.add_argument( 'files', type=str, nargs='+',
  62. help=argparse.SUPPRESS ) # Suppressed help output, because Python output is verbosely ugly
  63. # Optional Arguments
  64. pArgs.add_argument( '-b', '--backend', type=str, default="kiibohd",
  65. help="Specify target backend for the KLL compiler.\n"
  66. "Default: kiibohd" )
  67. pArgs.add_argument( '-d', '--default', type=str, nargs='+',
  68. help="Specify .kll files to layer on top of the default map to create a combined map." )
  69. pArgs.add_argument( '-p', '--partial', type=str, nargs='+', action='append',
  70. help="Specify .kll files to generate partial map, multiple files per flag.\n"
  71. "Each -p defines another partial map.\n"
  72. "Base .kll files (that define the scan code maps) must be defined for each partial map." )
  73. pArgs.add_argument( '-t', '--template', type=str, default="templates/kiibohdKeymap.h",
  74. help="Specify template used to generate the keymap.\n"
  75. "Default: templates/kiibohdKeymap.h" )
  76. pArgs.add_argument( '-o', '--output', type=str, default="templateKeymap.h",
  77. help="Specify output file. Writes to current working directory by default.\n"
  78. "Default: generatedKeymap.h" )
  79. pArgs.add_argument( '-h', '--help', action="help",
  80. help="This message." )
  81. # Process Arguments
  82. args = pArgs.parse_args()
  83. # Parameters
  84. baseFiles = args.files
  85. defaultFiles = args.default
  86. partialFileSets = args.partial
  87. if defaultFiles is None:
  88. defaultFiles = []
  89. if partialFileSets is None:
  90. partialFileSets = [[]]
  91. # Check file existance
  92. for filename in baseFiles:
  93. checkFileExists( filename )
  94. for filename in defaultFiles:
  95. checkFileExists( filename )
  96. for partial in partialFileSets:
  97. for filename in partial:
  98. checkFileExists( filename )
  99. return (baseFiles, defaultFiles, partialFileSets, args.backend, args.template, args.output)
  100. ### Tokenizer ###
  101. def tokenize( string ):
  102. """str -> Sequence(Token)"""
  103. # Basic Tokens Spec
  104. specs = [
  105. ( 'Comment', ( r' *#.*', ) ),
  106. ( 'Space', ( r'[ \t\r\n]+', ) ),
  107. ( 'USBCode', ( r'U(("[^"]+")|(0x[0-9a-fA-F]+)|([0-9]+))', ) ),
  108. ( 'USBCodeStart', ( r'U\[', ) ),
  109. ( 'ScanCode', ( r'S((0x[0-9a-fA-F]+)|([0-9]+))', ) ),
  110. ( 'ScanCodeStart', ( r'S\[', ) ),
  111. ( 'CodeEnd', ( r'\]', ) ),
  112. ( 'String', ( r'"[^"]*"', VERBOSE ) ),
  113. ( 'SequenceString', ( r"'[^']*'", ) ),
  114. ( 'Operator', ( r'=>|:\+|:-|:|=', ) ),
  115. ( 'Comma', ( r',', ) ),
  116. ( 'Dash', ( r'-', ) ),
  117. ( 'Plus', ( r'\+', ) ),
  118. ( 'Parenthesis', ( r'\(|\)', ) ),
  119. ( 'Number', ( r'-?(0x[0-9a-fA-F]+)|(0|([1-9][0-9]*))', VERBOSE ) ),
  120. ( 'Name', ( r'[A-Za-z_][A-Za-z_0-9]*', ) ),
  121. ( 'VariableContents', ( r'''[^"' ;:=>()]+''', ) ),
  122. ( 'EndOfLine', ( r';', ) ),
  123. ]
  124. # Tokens to filter out of the token stream
  125. useless = ['Space', 'Comment']
  126. tokens = make_tokenizer( specs )
  127. return [x for x in tokens( string ) if x.type not in useless]
  128. ### Parsing ###
  129. ## Map Arrays
  130. macros_map = Macros()
  131. variable_dict = dict()
  132. capabilities_dict = Capabilities()
  133. ## Parsing Functions
  134. def make_scanCode( token ):
  135. scanCode = int( token[1:], 0 )
  136. # Check size, to make sure it's valid
  137. if scanCode > 0xFF:
  138. print ( "{0} ScanCode value {1} is larger than 255".format( ERROR, scanCode ) )
  139. raise
  140. return scanCode
  141. def make_usbCode( token ):
  142. # If first character is a U, strip
  143. if token[0] == "U":
  144. token = token[1:]
  145. # If using string representation of USB Code, do lookup, case-insensitive
  146. if '"' in token:
  147. try:
  148. usbCode = kll_hid_lookup_dictionary[ token[1:-1].upper() ]
  149. except LookupError as err:
  150. print ( "{0} {1} is an invalid USB Code Lookup...".format( ERROR, err ) )
  151. raise
  152. else:
  153. usbCode = int( token, 0 )
  154. # Check size, to make sure it's valid
  155. if usbCode > 0xFF:
  156. print ( "{0} USBCode value {1} is larger than 255".format( ERROR, usbCode ) )
  157. raise
  158. return usbCode
  159. def make_seqString( token ):
  160. # Shifted Characters, and amount to move by to get non-shifted version
  161. # US ANSI
  162. shiftCharacters = (
  163. ( "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 0x20 ),
  164. ( "+", 0x12 ),
  165. ( "&(", 0x11 ),
  166. ( "!#$%<>", 0x10 ),
  167. ( "*", 0x0E ),
  168. ( ")", 0x07 ),
  169. ( '"', 0x05 ),
  170. ( ":", 0x01 ),
  171. ( "^", -0x10 ),
  172. ( "_", -0x18 ),
  173. ( "{}|", -0x1E ),
  174. ( "~", -0x20 ),
  175. ( "@", -0x32 ),
  176. ( "?", -0x38 ),
  177. )
  178. listOfLists = []
  179. shiftKey = kll_hid_lookup_dictionary["SHIFT"]
  180. # Creates a list of USB codes from the string: sequence (list) of combos (lists)
  181. for char in token[1:-1]:
  182. processedChar = char
  183. # Whether or not to create a combo for this sequence with a shift
  184. shiftCombo = False
  185. # Depending on the ASCII character, convert to single character or Shift + character
  186. for pair in shiftCharacters:
  187. if char in pair[0]:
  188. shiftCombo = True
  189. processedChar = chr( ord( char ) + pair[1] )
  190. break
  191. # Do KLL HID Lookup on non-shifted character
  192. # NOTE: Case-insensitive, which is why the shift must be pre-computed
  193. usbCode = kll_hid_lookup_dictionary[ processedChar.upper() ]
  194. # Create Combo for this character, add shift key if shifted
  195. charCombo = []
  196. if shiftCombo:
  197. charCombo = [ [ shiftKey ] ]
  198. charCombo.append( [ usbCode ] )
  199. # Add to list of lists
  200. listOfLists.append( charCombo )
  201. return listOfLists
  202. def make_string( token ):
  203. return token[1:-1]
  204. def make_number( token ):
  205. return int( token, 0 )
  206. # Range can go from high to low or low to high
  207. def make_scanCode_range( rangeVals ):
  208. start = rangeVals[0]
  209. end = rangeVals[1]
  210. # Swap start, end if start is greater than end
  211. if start > end:
  212. start, end = end, start
  213. # Iterate from start to end, and generate the range
  214. return list( range( start, end + 1 ) )
  215. # Range can go from high to low or low to high
  216. # Warn on 0-9 (as this does not do what one would expect) TODO
  217. # Lookup USB HID tags and convert to a number
  218. def make_usbCode_range( rangeVals ):
  219. # Check if already integers
  220. if isinstance( rangeVals[0], int ):
  221. start = rangeVals[0]
  222. else:
  223. start = make_usbCode( rangeVals[0] )
  224. if isinstance( rangeVals[1], int ):
  225. end = rangeVals[1]
  226. else:
  227. end = make_usbCode( rangeVals[1] )
  228. # Swap start, end if start is greater than end
  229. if start > end:
  230. start, end = end, start
  231. # Iterate from start to end, and generate the range
  232. return list( range( start, end + 1 ) )
  233. pass
  234. ## Base Rules
  235. const = lambda x: lambda _: x
  236. unarg = lambda f: lambda x: f(*x)
  237. flatten = lambda list: sum( list, [] )
  238. tokenValue = lambda x: x.value
  239. tokenType = lambda t: some( lambda x: x.type == t ) >> tokenValue
  240. operator = lambda s: a( Token( 'Operator', s ) ) >> tokenValue
  241. parenthesis = lambda s: a( Token( 'Parenthesis', s ) ) >> tokenValue
  242. eol = a( Token( 'EndOfLine', ';' ) )
  243. def listElem( item ):
  244. return [ item ]
  245. def listToTuple( items ):
  246. return tuple( items )
  247. # Flatten only the top layer (list of lists of ...)
  248. def oneLayerFlatten( items ):
  249. mainList = []
  250. for sublist in items:
  251. for item in sublist:
  252. mainList.append( item )
  253. return mainList
  254. # Capability arguments may need to be expanded (e.g. 1 16 bit argument needs to be 2 8 bit arguments for the state machine)
  255. def capArgExpander( items ):
  256. newArgs = []
  257. # For each defined argument in the capability definition
  258. for arg in range( 0, len( capabilities_dict[ items[0] ][1] ) ):
  259. argLen = capabilities_dict[ items[0] ][1][ arg ][1]
  260. num = items[1][ arg ]
  261. byteForm = num.to_bytes( argLen, byteorder='little' ) # XXX Yes, little endian from how the uC structs work
  262. # For each sub-argument, split into byte-sized chunks
  263. for byte in range( 0, argLen ):
  264. newArgs.append( byteForm[ byte ] )
  265. return tuple( [ items[0], tuple( newArgs ) ] )
  266. # Expand ranges of values in the 3rd dimension of the list, to a list of 2nd lists
  267. # i.e. [ sequence, [ combo, [ range ] ] ] --> [ [ sequence, [ combo ] ], <option 2>, <option 3> ]
  268. def optionExpansion( sequences ):
  269. expandedSequences = []
  270. # Total number of combinations of the sequence of combos that needs to be generated
  271. totalCombinations = 1
  272. # List of leaf lists, with number of leaves
  273. maxLeafList = []
  274. # Traverse to the leaf nodes, and count the items in each leaf list
  275. for sequence in sequences:
  276. for combo in sequence:
  277. rangeLen = len( combo )
  278. totalCombinations *= rangeLen
  279. maxLeafList.append( rangeLen )
  280. # Counter list to keep track of which combination is being generated
  281. curLeafList = [0] * len( maxLeafList )
  282. # Generate a list of permuations of the sequence of combos
  283. for count in range( 0, totalCombinations ):
  284. expandedSequences.append( [] ) # Prepare list for adding the new combination
  285. position = 0
  286. # Traverse sequence of combos to generate permuation
  287. for sequence in sequences:
  288. expandedSequences[ -1 ].append( [] )
  289. for combo in sequence:
  290. expandedSequences[ -1 ][ -1 ].append( combo[ curLeafList[ position ] ] )
  291. position += 1
  292. # Increment combination tracker
  293. for leaf in range( 0, len( curLeafList ) ):
  294. curLeafList[ leaf ] += 1
  295. # Reset this position, increment next position (if it exists), then stop
  296. if curLeafList[ leaf ] >= maxLeafList[ leaf ]:
  297. curLeafList[ leaf ] = 0
  298. if leaf + 1 < len( curLeafList ):
  299. curLeafList[ leaf + 1 ] += 1
  300. break
  301. return expandedSequences
  302. # Converts USB Codes into Capabilities
  303. def usbCodeToCapability( items ):
  304. # Items already converted to variants using optionExpansion
  305. for variant in range( 0, len( items ) ):
  306. # Sequence of Combos
  307. for sequence in range( 0, len( items[ variant ] ) ):
  308. for combo in range( 0, len( items[ variant ][ sequence ] ) ):
  309. # Only convert if an integer, otherwise USB Code doesn't need converting
  310. if isinstance( items[ variant ][ sequence ][ combo ], int ):
  311. # Use backend capability name and a single argument
  312. items[ variant ][ sequence ][ combo ] = tuple( [ backend.usbCodeCapability(), tuple( [ items[ variant ][ sequence ][ combo ] ] ) ] )
  313. return items
  314. ## Evaluation Rules
  315. def eval_scanCode( triggers, operator, results ):
  316. # Convert to lists of lists of lists to tuples of tuples of tuples
  317. # Tuples are non-mutable, and can be used has index items
  318. triggers = tuple( tuple( tuple( sequence ) for sequence in variant ) for variant in triggers )
  319. results = tuple( tuple( tuple( sequence ) for sequence in variant ) for variant in results )
  320. # Iterate over all combinations of triggers and results
  321. for trigger in triggers:
  322. for result in results:
  323. # Append Case
  324. if operator == ":+":
  325. macros_map.appendScanCode( trigger, result )
  326. # Remove Case
  327. elif operator == ":-":
  328. macros_map.removeScanCode( trigger, result )
  329. # Replace Case
  330. elif operator == ":":
  331. macros_map.replaceScanCode( trigger, result )
  332. def eval_usbCode( triggers, operator, results ):
  333. # Convert to lists of lists of lists to tuples of tuples of tuples
  334. # Tuples are non-mutable, and can be used has index items
  335. triggers = tuple( tuple( tuple( sequence ) for sequence in variant ) for variant in triggers )
  336. results = tuple( tuple( tuple( sequence ) for sequence in variant ) for variant in results )
  337. # Iterate over all combinations of triggers and results
  338. for trigger in triggers:
  339. scanCodes = macros_map.lookupUSBCodes( trigger )
  340. for scanCode in scanCodes:
  341. for result in results:
  342. # Cache assignment until file finishes processing
  343. macros_map.cacheAssignment( operator, scanCode, result )
  344. def eval_variable( name, content ):
  345. # Content might be a concatenation of multiple data types, convert everything into a single string
  346. assigned_content = ""
  347. for item in content:
  348. assigned_content += str( item )
  349. variable_dict[ name ] = assigned_content
  350. def eval_capability( name, function, args ):
  351. capabilities_dict[ name ] = [ function, args ]
  352. map_scanCode = unarg( eval_scanCode )
  353. map_usbCode = unarg( eval_usbCode )
  354. set_variable = unarg( eval_variable )
  355. set_capability = unarg( eval_capability )
  356. ## Sub Rules
  357. usbCode = tokenType('USBCode') >> make_usbCode
  358. scanCode = tokenType('ScanCode') >> make_scanCode
  359. name = tokenType('Name')
  360. number = tokenType('Number') >> make_number
  361. comma = tokenType('Comma')
  362. dash = tokenType('Dash')
  363. plus = tokenType('Plus')
  364. content = tokenType('VariableContents')
  365. string = tokenType('String') >> make_string
  366. unString = tokenType('String') # When the double quotes are still needed for internal processing
  367. seqString = tokenType('SequenceString') >> make_seqString
  368. # Code variants
  369. code_end = tokenType('CodeEnd')
  370. # Scan Codes
  371. scanCode_start = tokenType('ScanCodeStart')
  372. scanCode_range = number + skip( dash ) + number >> make_scanCode_range
  373. scanCode_listElem = number >> listElem
  374. scanCode_innerList = oneplus( ( scanCode_range | scanCode_listElem ) + skip( maybe( comma ) ) ) >> flatten
  375. scanCode_expanded = skip( scanCode_start ) + scanCode_innerList + skip( code_end )
  376. scanCode_elem = scanCode >> listElem
  377. scanCode_combo = oneplus( ( scanCode_expanded | scanCode_elem ) + skip( maybe( plus ) ) )
  378. scanCode_sequence = oneplus( scanCode_combo + skip( maybe( comma ) ) )
  379. # USB Codes
  380. usbCode_start = tokenType('USBCodeStart')
  381. usbCode_range = ( number | unString ) + skip( dash ) + ( number | unString ) >> make_usbCode_range
  382. usbCode_listElemTag = unString >> make_usbCode
  383. usbCode_listElem = ( number | usbCode_listElemTag ) >> listElem
  384. usbCode_innerList = oneplus( ( usbCode_range | usbCode_listElem ) + skip( maybe( comma ) ) ) >> flatten
  385. usbCode_expanded = skip( usbCode_start ) + usbCode_innerList + skip( code_end )
  386. usbCode_elem = usbCode >> listElem
  387. usbCode_combo = oneplus( ( usbCode_expanded | usbCode_elem ) + skip( maybe( plus ) ) ) >> listElem
  388. usbCode_sequence = oneplus( ( usbCode_combo | seqString ) + skip( maybe( comma ) ) ) >> oneLayerFlatten
  389. # Capabilities
  390. capFunc_arguments = many( number + skip( maybe( comma ) ) ) >> listToTuple
  391. capFunc_elem = name + skip( parenthesis('(') ) + capFunc_arguments + skip( parenthesis(')') ) >> capArgExpander >> listElem
  392. capFunc_combo = oneplus( ( usbCode_expanded | usbCode_elem | capFunc_elem ) + skip( maybe( plus ) ) ) >> listElem
  393. capFunc_sequence = oneplus( ( capFunc_combo | seqString ) + skip( maybe( comma ) ) ) >> oneLayerFlatten
  394. # Trigger / Result Codes
  395. triggerCode_outerList = scanCode_sequence >> optionExpansion
  396. triggerUSBCode_outerList = usbCode_sequence >> optionExpansion >> usbCodeToCapability
  397. resultCode_outerList = capFunc_sequence >> optionExpansion >> usbCodeToCapability
  398. ## Main Rules
  399. #| <variable> = <variable contents>;
  400. variable_contents = name | content | string | number | comma | dash
  401. variable_expression = name + skip( operator('=') ) + oneplus( variable_contents ) + skip( eol ) >> set_variable
  402. #| <capability name> => <c function>;
  403. capability_arguments = name + skip( operator(':') ) + number + skip( maybe( comma ) )
  404. capability_expression = name + skip( operator('=>') ) + name + skip( parenthesis('(') ) + many( capability_arguments ) + skip( parenthesis(')') ) + skip( eol ) >> set_capability
  405. #| <trigger> : <result>;
  406. operatorTriggerResult = operator(':') | operator(':+') | operator(':-')
  407. scanCode_expression = triggerCode_outerList + operatorTriggerResult + resultCode_outerList + skip( eol ) >> map_scanCode
  408. usbCode_expression = triggerUSBCode_outerList + operatorTriggerResult + resultCode_outerList + skip( eol ) >> map_usbCode
  409. def parse( tokenSequence ):
  410. """Sequence(Token) -> object"""
  411. # Top-level Parser
  412. expression = scanCode_expression | usbCode_expression | variable_expression | capability_expression
  413. kll_text = many( expression )
  414. kll_file = maybe( kll_text ) + skip( finished )
  415. return kll_file.parse( tokenSequence )
  416. def processKLLFile( filename ):
  417. with open( filename ) as file:
  418. data = file.read()
  419. tokenSequence = tokenize( data )
  420. #print ( pformat( tokenSequence ) ) # Display tokenization
  421. tree = parse( tokenSequence )
  422. ### Main Entry Point ###
  423. if __name__ == '__main__':
  424. (baseFiles, defaultFiles, partialFileSets, backend_name, template, output) = processCommandLineArgs()
  425. # Load backend module
  426. global backend
  427. backend_import = importlib.import_module( "backends.{0}".format( backend_name ) )
  428. backend = backend_import.Backend( template )
  429. # Process base layout files
  430. for filename in baseFiles:
  431. processKLLFile( filename )
  432. macros_map.completeBaseLayout() # Indicates to macros_map that the base layout is complete
  433. # Default combined layer
  434. for filename in defaultFiles:
  435. processKLLFile( filename )
  436. # Apply assignment cache, see 5.1.2 USB Codes for why this is necessary
  437. macros_map.replayCachedAssignments()
  438. # Iterate through additional layers
  439. for partial in partialFileSets:
  440. # Increment layer for each -p option
  441. macros_map.addLayer()
  442. # Iterate and process each of the file in the layer
  443. for filename in partial:
  444. processKLLFile( filename )
  445. # Apply assignment cache, see 5.1.2 USB Codes for why this is necessary
  446. macros_map.replayCachedAssignments()
  447. # Remove un-marked keys to complete the partial layer
  448. macros_map.removeUnmarked()
  449. # Do macro correlation and transformation
  450. macros_map.generate()
  451. # Process needed templating variables using backend
  452. backend.process( capabilities_dict, macros_map )
  453. # Generate output file using template and backend
  454. backend.generate( output )
  455. # Successful Execution
  456. sys.exit( 0 )