| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 | 2 |
| 3 # Copyright 2014 The Chromium Authors. All rights reserved. | 3 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 import in_generator | 7 import in_generator |
| 8 import sys | 8 import sys |
| 9 import os | 9 import os |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 const MediaQueryTokenizer::CodePoint MediaQueryTokenizer::codePoints[{array_size
}] = {{ | 21 const MediaQueryTokenizer::CodePoint MediaQueryTokenizer::codePoints[{array_size
}] = {{ |
| 22 {token_lines} | 22 {token_lines} |
| 23 }}; | 23 }}; |
| 24 const unsigned codePointsNumber = {array_size}; | 24 const unsigned codePointsNumber = {array_size}; |
| 25 """ | 25 """ |
| 26 | 26 |
| 27 | 27 |
| 28 def token_type(i): | 28 def token_type(i): |
| 29 codepoints = {'(': 'leftParenthesis', | 29 codepoints = {'(': 'leftParenthesis', |
| 30 ')': 'rightParenthesis', | 30 ')': 'rightParenthesis', |
| 31 '[': 'leftBracket', |
| 32 ']': 'rightBracket', |
| 33 '{': 'leftBrace', |
| 34 '}': 'rightBrace', |
| 31 '+': 'plusOrFullStop', | 35 '+': 'plusOrFullStop', |
| 32 '.': 'plusOrFullStop', | 36 '.': 'plusOrFullStop', |
| 33 '-': 'hyphenMinus', | 37 '-': 'hyphenMinus', |
| 34 ',': 'comma', | 38 ',': 'comma', |
| 35 '/': 'solidus', | 39 '/': 'solidus', |
| 36 '\\': 'reverseSolidus', | 40 '\\': 'reverseSolidus', |
| 37 ':': 'colon', | 41 ':': 'colon', |
| 38 ';': 'semiColon', | 42 ';': 'semiColon', |
| 39 } | 43 } |
| 40 whitespace = '\n\r\t\f ' | 44 whitespace = '\n\r\t\f ' |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 | 80 |
| 77 def generate(self): | 81 def generate(self): |
| 78 array_size = 128 # SCHAR_MAX + 1 | 82 array_size = 128 # SCHAR_MAX + 1 |
| 79 token_lines = [' &MediaQueryTokenizer::%s,' % token_type(i) | 83 token_lines = [' &MediaQueryTokenizer::%s,' % token_type(i) |
| 80 if token_type(i) else ' 0,' | 84 if token_type(i) else ' 0,' |
| 81 for i in range(array_size)] | 85 for i in range(array_size)] |
| 82 return CPP_TEMPLATE.format(array_size=array_size, token_lines='\n'.join(
token_lines), module_pyname=module_pyname) | 86 return CPP_TEMPLATE.format(array_size=array_size, token_lines='\n'.join(
token_lines), module_pyname=module_pyname) |
| 83 | 87 |
| 84 if __name__ == '__main__': | 88 if __name__ == '__main__': |
| 85 in_generator.Maker(MakeMediaQueryTokenizerCodePointsWriter).main(sys.argv) | 89 in_generator.Maker(MakeMediaQueryTokenizerCodePointsWriter).main(sys.argv) |
| OLD | NEW |