Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.29 KB | None | 0 0
  1. css_grammar = {
  2. '<start>': [['<stylesheet>']],
  3. '<stylesheet>': [[
  4. '<[CHARSET_SYM_STRING_SEMI]-1>', ' ', '<[S_OR_CDO_OR_CDC]-1>', ' ',
  5. '<[import_CDO_S_OR_CDC_S]-1>', ' ', '<[stylesheet_closing_GROUPING]-1>'
  6. ]],
  7. '<[CHARSET_SYM_STRING_SEMI]>': [['<CHARSET_SYM>', ' ', '<STRING>', ' ;']],
  8. '<[S_OR_CDO_OR_CDC]>': [['<Sp>'], ['<CDO>'], ['<CDC>']],
  9. '<[import_CDO_S_OR_CDC_S]>': [['<import>', ' ', '<[CDO_S_OR_CDC_S]-1>']],
  10. '<[CDO_S_OR_CDC_S]>': [['<CDO>', ' ', '<Ss>'], ['<CDC>', ' ', '<Ss>']],
  11. '<[ruleset_OR_media_OR_page]>': [['<ruleset>'], ['<media>'], ['<page>']],
  12. '<[stylesheet_closing_GROUPING]>':
  13. [['<[ruleset_OR_media_OR_page]>', ' ', '<[CDO_S_OR_CDC_S]-2>']],
  14. '<import>': [[
  15. '<IMPORT_SYM>', ' ', '<Ss>', ' ', '<[STRING_OR_URI]>', ' ', '<Ss>',
  16. ' ', '<media_list-1>', ' ; ', '<Ss>'
  17. ]],
  18. '<[STRING_OR_URI]>': [['<STRING>'], ['<URI>']],
  19. '<media>': [[
  20. '<MEDIA_SYM>', ' ', '<Ss>', ' ', '<media_list>', ' { ', '<Ss>', ' ',
  21. '<ruleset-1>', ' } ', '<Ss>'
  22. ]],
  23. '<media_list>': [['<medium>', ' ', '<[COMMA_S_medium]-1>']],
  24. '<[COMMA_S_medium]>': [[', ', '<Ss>', ' ', '<medium>']],
  25. '<medium>': [['<IDENT>', ' ', '<Ss>']],
  26. '<page>': [[
  27. '<PAGE_SYM>', ' ', '<Ss>', ' ', '<pseudo_page-1>', ' { ', '<Ss>', ' ',
  28. '<declaration-1>', ' ', '<[SEMI_S_declaration]-1>', ' } ', '<Ss>'
  29. ]],
  30. '<[SEMI_S_declaration]>': [['; ', '<Ss>', ' ', '<declaration-2>']],
  31. '<pseudo_page>': [[': ', '<IDENT>', ' ', '<Ss>']],
  32. '<operator>': [['/ ', '<Ss>'], [', ', '<Ss>']],
  33. '<combinator>': [['+ ', '<Ss>'], ['> ', '<Ss>']],
  34. '<unary_operator>': [['-'], ['+']],
  35. '<property>': [['<IDENT>', ' ', '<Ss>']],
  36. '<ruleset>': [[
  37. '<selector>', ' ', '<COMMA_S_selector-1>', ' { ', '<Ss>', ' ',
  38. '<declaration-3>', ' ', '<[SEMI_S_declaration]-2>', ' } ', '<Ss>'
  39. ]],
  40. '<COMMA_S_selector>': [[', ', '<Ss>', ' selector']],
  41. '<selector>':
  42. [['<simple_selector>', ' ', '<[combinator_selector_OR_S]-1>']],
  43. '<[combinator_selector]>': [['<combinator-1>', ' ', '<selector>']],
  44. '<[combinator_selector_OR_S]>':
  45. [['<combinator>', ' ', '<selector>'],
  46. ['<Sp>', ' ', '<[combinator_selector]-1>']],
  47. '<simple_selector>':
  48. [['<element_name>', ' ', '<[HASH_OR_class_OR_attrib_OR_pseudo]-1>'],
  49. ['<[HASH_OR_class_OR_attrib_OR_pseudo]-2>']],
  50. '<[HASH_OR_class_OR_attrib_OR_pseudo]>': [['<HASH>'], ['<class>'],
  51. ['<attrib>'], ['<pseudo>']],
  52. '<class>': [['.', '<IDENT>']],
  53. '<element_name>': [['<IDENT>'], ['*']],
  54. '<attrib>': [[
  55. '[ ', '<Ss>', ' ', '<IDENT>', ' ', '<Ss>', ' ',
  56. '<[attrib_GROUPING]-1>', ' ]'
  57. ]],
  58. '<[EQUAL_OR_INCLUDES_OR_DASHMATCH]>': [['='], ['<INCLUDES>'],
  59. ['<DASHMATCH>']],
  60. '<[IDENT_OR_STRING]>': [['<IDENT>'], ['<STRING>']],
  61. '<[attrib_GROUPING]>': [[
  62. '<[EQUAL_OR_INCLUDES_OR_DASHMATCH]>', ' ', '<Ss>', ' ',
  63. '<[IDENT_OR_STRING]>', ' ', '<Ss>'
  64. ]],
  65. '<pseudo>': [[': ', '<[IDENT_OR_FUNCTION]>']],
  66. '<[IDENT_OR_FUNCTION]>':
  67. [['<IDENT>'], ['<FUNCTION>', ' ', '<Ss>', ' ', '<[IDENT_S]-1>', ' )']],
  68. '<[IDENT_S]>': [['<IDENT>', ' ', '<Ss>']],
  69. '<declaration>':
  70. [['<property>', ' : ', '<Ss>', ' ', '<expr>', ' ', '<prio-1>']],
  71. '<prio>': [['<IMPORT_SYM>', ' ', '<Ss>']],
  72. '<expr>': [['<term>', ' ', '<[operator_term]-1>']],
  73. '<[operator_term]>': [['<operator-1>', ' ', '<term>']],
  74. '<term>': [['<unary_operator-1>', ' ', '<[term_GROUPING]>'],
  75. ['<STRING>', ' ', '<Ss>'], ['<IDENT>', ' ', '<Ss>'],
  76. ['<URI>', ' ', '<Ss>'], ['<hexcolor>'], ['<function>']],
  77. '<[term_GROUPING]>': [['<NUMBER>', ' ', '<Ss>'],
  78. ['<PERCENTAGE>', ' ', '<Ss>'],
  79. ['<LENGTH>', ' ', '<Ss>'], ['<EMS>', ' ', '<Ss>'],
  80. ['<EXS>', ' ', '<Ss>'], ['<ANGLE>', ' ', '<Ss>'],
  81. ['<TIME>', ' ', '<Ss>'], ['<FREQ>', ' ', '<Ss>']],
  82. '<function>': [['<FUNCTION>', ' ', '<Ss>', ' ', '<expr>', ' ) ', '<Ss>']],
  83. '<hexcolor>': [['#', '<[three_char_HEX]>', ' ', '<Ss>'],
  84. ['#', '<[six_char_HEX]>', ' ', '<Ss>']],
  85. '<[three_char_HEX]>': [['<HEX_CHAR>', '<HEX_CHAR>', '<HEX_CHAR>']],
  86. '<[six_char_HEX]>': [[
  87. '<HEX_CHAR>', '<HEX_CHAR>', '<HEX_CHAR>', '<HEX_CHAR>', '<HEX_CHAR>',
  88. '<HEX_CHAR>'
  89. ]],
  90. '<HEX_CHAR>': [['0'], ['1'], ['2'], ['3'], ['4'], ['5'], ['6'], ['7'],
  91. ['8'], ['9'], ['a'], ['b'], ['c'], ['d'], ['e'], ['f']],
  92. '<Sp>': [['<WHITESPACE-1>']],
  93. '<Ss>': [['<WHITESPACE-2>']],
  94. '<So>': [[], ['<WHITESPACE>']],
  95. '<CDO>': [['<!--']],
  96. '<CDC>': [['-->']],
  97. '<INCLUDES>': [['~=']],
  98. '<DASHMATCH>': [['|=']],
  99. '<STRING>': [['<string1>'], ['<string2>']],
  100. '<IDENT>': [['<{ident}>']],
  101. '<HASH>': [['#', '<{name}>']],
  102. '<IMPORT_SYM>': [['@import']],
  103. '<PAGE_SYM>': [['@page']],
  104. '<MEDIA_SYM>': [['@media']],
  105. '<CHARSET_SYM>': [['@charset']],
  106. '<EMS>': [['<{num}>', 'em']],
  107. '<EXS>': [['<{num}>', 'ex']],
  108. '<LENGTH>': [['<{num}>', 'px'], ['<{num}>', 'cm'], ['<{num}>', 'mm'],
  109. ['<{num}>', 'in'], ['<{num}>', 'pt'], ['<{num}>', 'pc']],
  110. '<ANGLE>': [['<{num}>', 'deg'], ['<{num}>', 'rad'], ['<{num}>', 'grad']],
  111. '<TIME>': [['<{num}>', 'ms'], ['<{num}>', 's']],
  112. '<FREQ>': [['<{num}>', 'hz'], ['<{num}>', 'khz']],
  113. '<PERCENTAGE>': [['<{num}>', '%']],
  114. '<NUMBER>': [['<{num}>']],
  115. '<URI>': [['url("', '<So>', '<url>', '<So>', '")'],
  116. ['url("', '<So>', '<STRING>', '<So>', '")']],
  117. '<url>': [['<url_-1>']],
  118. '<url_>': [['!'], ['#'], ['$'], ['%'], ['&'], ['*'], ['-'], ['~'],
  119. ['<escape>']],
  120. '<FUNCTION>': [['<{ident}>', '(']],
  121. '<string1>': [['"', '<qmychars1-1>', '"']],
  122. '<string2>': [["'", '<qmychars2-1>', "'"]],
  123. '<qnonl1>': [['7'], ['Q'], ['J'], ['@'], ['2'], ['g'], ['\t'], ['X'],
  124. ['`'], ['G'], ['e'], ['['], ['?'], ['v'], ['$'], ['j'], ['K'],
  125. ['d'], ['A'], ['n'], ['h'], ['l'], ['4'], ['D'], ['a'], ['#'],
  126. ['f'], ['y'], ['B'], ['U'], ['P'], ['3'], ['O'], ['S'], [')'],
  127. [' '], ['W'], ['o'], ['b'], ['|'], ['q'], ['L'], [']'], ['V'],
  128. ['*'], ['z'], ['}'], ['6'], ['u'], ['^'], [','], ['N'], ['>'],
  129. ['+'], ['Y'], ['t'], ['k'], ['!'], ['p'], ['Z'], ['E'], ['('],
  130. ['\\'], ['<'], ['F'], ['%'], ['9'], ['0'], ['s'], [';'],
  131. ['&'], ['C'], ['T'], ['r'], ['5'], ['R'], ["'"], ['_'], ['.'],
  132. ['8'], ['H'], ['i'], ['/'], ['M'], ['~'], ['{'], [':'], ['c'],
  133. ['I'], ['-'], ['\x0b'], ['1'], ['w'], ['x'], ['m'], ['=']],
  134. '<qnonl2>': [['7'], ['Q'], ['J'], ['@'], ['2'], ['g'], ['\t'], ['X'],
  135. ['`'], ['G'], ['e'], ['['], ['?'], ['v'], ['$'], ['j'], ['K'],
  136. ['d'], ['A'], ['n'], ['h'], ['l'], ['4'], ['D'], ['a'], ['#'],
  137. ['f'], ['y'], ['B'], ['U'], ['P'], ['3'], ['O'], ['S'], [')'],
  138. [' '], ['W'], ['o'], ['b'], ['|'], ['q'], ['L'], [']'], ['V'],
  139. ['*'], ['z'], ['}'], ['6'], ['u'], ['^'], [','], ['N'], ['>'],
  140. ['+'], ['Y'], ['t'], ['k'], ['!'], ['p'], ['Z'], ['E'], ['('],
  141. ['\\'], ['<'], ['F'], ['%'], ['9'], ['0'], ['s'], [';'],
  142. ['&'], ['C'], ['T'], ['r'], ['5'], ['"'], ['R'], ['_'], ['.'],
  143. ['8'], ['H'], ['i'], ['/'], ['M'], ['~'], ['{'], [':'], ['c'],
  144. ['I'], ['-'], ['\x0b'], ['1'], ['w'], ['x'], ['m'], ['=']],
  145. '<qmychars1>': [['<qnonl1>'], ['\\', '<nl>'], ['<escape>']],
  146. '<qmychars2>': [['<qnonl2>'], ['\\', '<nl>'], ['<escape>']],
  147. '<nl>': [['\r'], ['\n'], ['\x0c'], ['\r\n']],
  148. '<escape>': [['\\', '<echar>']],
  149. '<echar>': [['Q'], ['J'], ['@'], ['g'], ['\t'], ['X'], ['`'], ['G'], ['['],
  150. ['?'], ['v'], ['$'], ['j'], ['K'], ['A'], ['n'], ['h'], ['l'],
  151. ['D'], ['#'], ['y'], ['B'], ['U'], ['P'], ['O'], ['S'], [')'],
  152. [' '], ['W'], ['o'], ['|'], ['q'], ['L'], [']'], ['V'], ['*'],
  153. ['z'], ['}'], ['u'], ['^'], [','], ['N'], ['>'], ['+'], ['Y'],
  154. ['t'], ['k'], ['!'], ['p'], ['Z'], ['E'], ['('], ['\\'], ['<'],
  155. ['F'], ['%'], ['s'], [';'], ['&'], ['C'], ['T'], ['r'], ['"'],
  156. ['R'], ["'"], ['_'], ['.'], ['H'], ['i'], ['/'], ['M'], ['~'],
  157. ['{'], [':'], ['I'], ['-'], ['\x0b'], ['w'], ['x'], ['m'],
  158. ['=']],
  159. '<{ident}>': [['<minus-1>', '<nmstart>', '<nmchar-1>']],
  160. '<nmstart>': [['a'], ['b'], ['c'], ['d'], ['e'], ['f'], ['g'], ['h'],
  161. ['i'], ['j'], ['k'], ['l'], ['m'], ['n'], ['o'], ['p'],
  162. ['q'], ['r'], ['s'], ['t'], ['u'], ['v'], ['w'], ['x'],
  163. ['y'], ['z'], ['<escape>'], ['_']],
  164. '<nmchar>': [['a'], ['b'], ['c'], ['d'], ['e'], ['f'], ['g'], ['h'], ['i'],
  165. ['j'], ['k'], ['l'], ['m'], ['n'], ['o'], ['p'], ['q'], ['r'],
  166. ['s'], ['t'], ['u'], ['v'], ['w'], ['x'], ['y'], ['z'], ['0'],
  167. ['1'], ['2'], ['3'], ['4'], ['5'], ['6'], ['7'], ['8'], ['9'],
  168. ['<escape>'], ['_'], ['-']],
  169. '<minus>': [['-']],
  170. '<{name}>': [['<nmchar-2>']],
  171. '<{num}>': [['<INTEGER>']],
  172. '<WHITESPACE>': [[' '], ['\t']],
  173. '<INTEGER>': [['<DIGIT>', '<INTEGER>'], ['<DIGIT>']],
  174. '<DIGIT>': [['0'], ['1'], ['2'], ['3'], ['4'], ['5'], ['6'], ['7'], ['8'],
  175. ['9']],
  176. '<[CHARSET_SYM_STRING_SEMI]-1>': [[], ['<[CHARSET_SYM_STRING_SEMI]>']],
  177. '<[S_OR_CDO_OR_CDC]-1>': [[],
  178. ['<[S_OR_CDO_OR_CDC]>',
  179. '<[S_OR_CDO_OR_CDC]-1>']],
  180. '<[import_CDO_S_OR_CDC_S]-1>':
  181. [[], ['<[import_CDO_S_OR_CDC_S]>', '<[import_CDO_S_OR_CDC_S]-1>']],
  182. '<[stylesheet_closing_GROUPING]-1>':
  183. [[],
  184. ['<[stylesheet_closing_GROUPING]>', '<[stylesheet_closing_GROUPING]-1>']],
  185. '<[CDO_S_OR_CDC_S]-1>': [[],
  186. ['<[CDO_S_OR_CDC_S]>', '<[CDO_S_OR_CDC_S]-1>']],
  187. '<[CDO_S_OR_CDC_S]-2>': [[],
  188. ['<[CDO_S_OR_CDC_S]>', '<[CDO_S_OR_CDC_S]-2>']],
  189. '<media_list-1>': [[], ['<media_list>']],
  190. '<ruleset-1>': [[], ['<ruleset>', '<ruleset-1>']],
  191. '<[COMMA_S_medium]-1>': [[],
  192. ['<[COMMA_S_medium]>', '<[COMMA_S_medium]-1>']],
  193. '<pseudo_page-1>': [[], ['<pseudo_page>']],
  194. '<declaration-1>': [[], ['<declaration>']],
  195. '<[SEMI_S_declaration]-1>':
  196. [[], ['<[SEMI_S_declaration]>', '<[SEMI_S_declaration]-1>']],
  197. '<declaration-2>': [[], ['<declaration>']],
  198. '<COMMA_S_selector-1>': [[],
  199. ['<COMMA_S_selector>', '<COMMA_S_selector-1>']],
  200. '<declaration-3>': [[], ['<declaration>']],
  201. '<[SEMI_S_declaration]-2>':
  202. [[], ['<[SEMI_S_declaration]>', '<[SEMI_S_declaration]-2>']],
  203. '<[combinator_selector_OR_S]-1>': [[], ['<[combinator_selector_OR_S]>']],
  204. '<combinator-1>': [[], ['<combinator>']],
  205. '<[combinator_selector]-1>': [[], ['<[combinator_selector]>']],
  206. '<[HASH_OR_class_OR_attrib_OR_pseudo]-1>':
  207. [[],
  208. [
  209. '<[HASH_OR_class_OR_attrib_OR_pseudo]>',
  210. '<[HASH_OR_class_OR_attrib_OR_pseudo]-1>'
  211. ]],
  212. '<[HASH_OR_class_OR_attrib_OR_pseudo]-2>':
  213. [['<[HASH_OR_class_OR_attrib_OR_pseudo]>'],
  214. [
  215. '<[HASH_OR_class_OR_attrib_OR_pseudo]>',
  216. '<[HASH_OR_class_OR_attrib_OR_pseudo]-2>'
  217. ]],
  218. '<[attrib_GROUPING]-1>': [[], ['<[attrib_GROUPING]>']],
  219. '<[IDENT_S]-1>': [[], ['<[IDENT_S]>']],
  220. '<prio-1>': [[], ['<prio>']],
  221. '<[operator_term]-1>': [[], ['<[operator_term]>', '<[operator_term]-1>']],
  222. '<operator-1>': [[], ['<operator>']],
  223. '<unary_operator-1>': [[], ['<unary_operator>']],
  224. '<WHITESPACE-1>': [['<WHITESPACE>'], ['<WHITESPACE>', '<WHITESPACE-1>']],
  225. '<WHITESPACE-2>': [[], ['<WHITESPACE>', '<WHITESPACE-2>']],
  226. '<url_-1>': [[], ['<url_>', '<url_-1>']],
  227. '<qmychars1-1>': [[], ['<qmychars1>', '<qmychars1-1>']],
  228. '<qmychars2-1>': [[], ['<qmychars2>', '<qmychars2-1>']],
  229. '<minus-1>': [[], ['<minus>']],
  230. '<nmchar-1>': [[], ['<nmchar>', '<nmchar-1>']],
  231. '<nmchar-2>': [['<nmchar>'], ['<nmchar>', '<nmchar-2>']]
  232. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement