예제 #1
0
파일: grammar.py 프로젝트: crazydreamer/css
def style_sheet(rule):
    rule | ([charset], star(import_), star(section))
    rule.astAttrs = {
            'charset': charset,
            'imports': [import_],
            'sections': [section],
        }
예제 #2
0
def style_sheet(rule):
    rule | ([charset], star(import_), star(section))
    rule.astAttrs = {
        'charset': charset,
        'imports': [import_],
        'sections': [section],
    }
예제 #3
0
def media(rule):
    rule | (no_ignore('@', 'media'), commas(cssid,
                                            False), '{', star(ruleset), '}')
    rule.astAttrs = {
        'media': [cssid],
        'rulesets': [ruleset],
    }
예제 #4
0
파일: grammar.py 프로젝트: scooterman/j2cpp
def primary(rule):
	rule | parExpression \
    |   ('this', star('.', Identifier), [identifierSuffix]) \
    |   ('super', superSuffix) \
    |   literal \
    |   ('new', creator) \
    |   (Identifier, star('.' ,Identifier), [identifierSuffix]) \
    |   (primitiveType, star('[', ']'), '.', 'class') \
    |   ('void', '.', 'class')

	rule.astAttrs = { 'parExpression' : parExpression, 
					  'superSuffix' : superSuffix, 
					  'literal' : literal, 
					  'creator' : creator,
					  'id' : [Identifier],
					  'primitive' : primitiveType,
					  'suffix' : identifierSuffix } 
예제 #5
0
def declare(rule):
    rule | (selectors, '{', star(attr), '}')
    rule.astAttrs = {
        'selectors': {
            'type': selectors,
            'single': True
        },
        'body': attr
    }
예제 #6
0
파일: grammar.py 프로젝트: crazydreamer/css
def simple_selector(rule):
    postops = hash, class_, attrib, pseudo
    rule | (_or(NODE_NAME, '*'), star(_or(postops)))
    rule | plus(_or(postops))
    rule.dont_ignore = True
    rule.astAttrs = {
        'node': NODE_NAME,
        'post': postops,
    }
예제 #7
0
def simple_selector(rule):
    postops = hash, class_, attrib, pseudo
    rule | (_or(NODE_NAME, '*'), star(_or(postops)))
    rule | plus(_or(postops))
    rule.dont_ignore = True
    rule.astAttrs = {
        'node': NODE_NAME,
        'post': postops,
    }
예제 #8
0
def atomic(rule):
    rule | (literal, star(_or(post_attr, post_subs, post_call)))
    rule.astAttrs = {
        'literal': {
            'type': literal,
            'single': True
        },
        'posts': (post_attr, post_subs, post_call)
    }
예제 #9
0
파일: grammar.py 프로젝트: scooterman/j2cpp
def compilationUnit(rule):
	rule | (annotations, 
			_or(
				(
					packageDeclaration,
					star(importDeclaration),
					star(typeDeclaration)
				) ,
				(
					classOrInterfaceDeclaration, star(typeDeclaration)
				)
			)
		) | (
			[packageDeclaration], 
			star(importDeclaration), 
			star(typeDeclaration)
		    )	

	rule.astAttrs = { 'packageDeclaration' : packageDeclaration , 'imports' : [importDeclaration] , 'typeDeclarations' : [classOrInterfaceDeclaration] + [typeDeclaration] }
예제 #10
0
def mul_ex(rule):
    rule | (atomic, star(_or(*'*/'), atomic))
    rule.astAttrs = {
        'left': {
            'type': atomic,
            'single': True
        },
        'ops': SYMBOL,
        'values': {
            'type': atomic,
            'start': 1
        }
    }
예제 #11
0
 def meta(rule):
     rule | (next, star(_or(*ops), next))
     rule.astAttrs = {
         'left': {
             'type': next,
             'single': True
         },
         'ops': SYMBOL,
         'values': {
             'type': next,
             'start': 1
         }
     }
예제 #12
0
def expression(rule):
    rule | (mul_ex, star(_or(*'-+'), mul_ex))
    rule.astAttrs = {
        'left': {
            'type': mul_ex,
            'single': True
        },
        'ops': SYMBOL,
        'values': {
            'type': mul_ex,
            'start': 1
        }
    }
예제 #13
0
def units(rule):
    rule | plus(star(NEWLINE), [unit], star(NEWLINE))
    rule.astAttrs = {"units": [unit]}
예제 #14
0
 def meta(rule):
     rule | (next, star(_or(*ops), next))
     rule.astAttrs = {'left': {'type':next, 'single':True}, 'ops': SYMBOL, 'values': {'type':next, 'start':1}}
예제 #15
0
def mul_ex(rule):
    rule | (atomic, star(_or(*'*/'), atomic))
    rule.astAttrs = {'left': {'type':atomic, 'single':True}, 'ops': SYMBOL, 'values': {'type':atomic, 'start':1}}
예제 #16
0
def value(rule):
    rule | (ID, star('-', _or(INT, ID)))
    rule.dont_ignore = True
예제 #17
0
파일: grammar.py 프로젝트: scooterman/j2cpp
def typeBound(rule):
	rule | ( _type, star('&', _type))
예제 #18
0
파일: lithon.py 프로젝트: pheuter/Lithon
def anon(rule):
  rule | ('(','lambda','(',star(ID),')',expression,')')
  rule.astAttrs = {'args': [ID], 'body': expression}
예제 #19
0
def declaration_end(rule):
    rule | (cssid, ':', plus(value), [important], '}')
    rule | (plus(_not(_or(';', '}'))), '}')
    rule.astAttrs = {
        'property': cssid,
        'values': [value],
        'important': important,
    }
    rule.keep_tree = True


declaration_end.astName = 'Declaration'


def important(rule):
    rule | ('!', 'important')
    rule.dont_ignore = True


from values import value, uri

block = '{', star(declaration), _or(declaration_end, '}')

grammar = Grammar(start=style_sheet,
                  tokens=the_tokens,
                  ignore=[WHITE, CMCOMMENT, NEWLINE],
                  ast_tokens=[COLOR, HEXCOLOR, STRING, SSTRING])

# vim: et sw=4 sts=4
예제 #20
0
def section(rule):
    rule | (head, star(_or(define, NEWLINE)))
    rule.astAttrs = {'head':head, 'body':[define]}
예제 #21
0
def value(rule):
    rule | (star(_or(*not_newline)), _or(EOF, (NEWLINE, [INDENT, star(star(_or(*not_newline)), _or(NEWLINE, EOF)), _or(DEDENT, EOF)])))
    rule.astAttrs = {'text':list(not_newline)+[NEWLINE]}
예제 #22
0
파일: grammar.py 프로젝트: scooterman/j2cpp
def interfaceBody(rule):
	rule | ('{', star(interfaceBodyDeclaration), '}')
예제 #23
0
def value(rule):
    rule | (ID, star('-', _or(INT, ID)))
    rule.dont_ignore = True
예제 #24
0
파일: grammar.py 프로젝트: scooterman/j2cpp
def classBody(rule):
	rule | ('{', star(classBodyDeclaration), '}')
	rule.astAttrs = { 'decl' : [classBodyDeclaration] }
예제 #25
0
파일: grammar.py 프로젝트: scooterman/j2cpp
def enumBodyDeclarations(rule):
	rule | (';', star(classBodyDeclaration))
예제 #26
0
파일: grammar.py 프로젝트: scooterman/j2cpp
def enumConstants(rule):
	rule | (enumConstant, star(',', enumConstant))
예제 #27
0
def start_four(rule):
    rule | star(four_sub)
예제 #28
0
def start(rule):
    rule | star(_or(section, NEWLINE))
    rule.astAttrs = {'sections':[section]}
예제 #29
0
파일: grammar.py 프로젝트: scooterman/j2cpp
def arrayCreatorRest(rule):
    rule | ('[', _or((']', star('[',']'), arrayInitializer) ,(expression, ']', star('[', expression, ']'), star('[' , ']'))))
예제 #30
0
def start(rule):
    rule | (star(_or(statement, NEWLINE)))
    rule.astAttrs = {'body': statement}
예제 #31
0
파일: lithon.py 프로젝트: pheuter/Lithon
def sexp(rule):
  rule | ('(',ID,star(expression),')') | ('(',star(expression),')')
  rule.astAttrs = {'function': ID, 'args': [expression]}
예제 #32
0
def selector(rule):
    rule | (simple_selector, star([_or('+', '>')], simple_selector))
    rule.astAttrs = {
        'parts': [simple_selector, SYMBOL],
    }
예제 #33
0
def start(rule):
    rule | star(declare)
    rule.astAttrs = {'body': declare}
예제 #34
0
def start(rule):
    rule | (RESERVED, star(ID, RESERVED))
예제 #35
0
def cssid(rule):
    ids = ID, COLOR, NODE_NAME, UNIT
    rule | plus('-', _or(*ids)) | (_or(*ids), star('-', _or(*ids)))
    rule.dont_ignore = True
    rule.astAttrs = {'parts': (SYMBOL, ) + ids}
예제 #36
0
파일: grammar.py 프로젝트: scooterman/j2cpp
def primaryExpression(rule):
	rule | (primary, star(selector), [_or(('+','+'),('-','-'))])
	rule.astAttrs = { 'primary' : primary, 'selector' : [selector], 'op' : [SYMBOL] }
예제 #37
0
def start_four(rule):
    rule | star(four_sub)
예제 #38
0
def at(rule):
    rule | (no_ignore('@', ID), _or(STRING, SSTRING, star(_not(_or(';','}')))), ';')
    rule | star(_not(_or(';','}')))
예제 #39
0
def start(rule):
    rule | (star(_or(statement, NEWLINE)))
    rule.astAttrs = {'body': statement}
예제 #40
0
def start_one(rule):
    rule | star(ID)
예제 #41
0
def atomic(rule):
    rule | (literal, star(_or(post_attr, post_subs, post_call)))
    rule.astAttrs = {'literal':{'type':literal, 'single':True}, 'posts':(post_attr, post_subs, post_call)}
예제 #42
0
파일: lithon.py 프로젝트: pheuter/Lithon
def program(rule):
  rule | (star(_or(expression,NEWLINE)),EOF)
  rule.astAttrs = {'body': [expression]}
예제 #43
0
def expression(rule):
    rule | (mul_ex, star(_or(*'-+'), mul_ex))
    rule.astAttrs = {'left': {'type':mul_ex, 'single':True}, 'ops': SYMBOL, 'values': {'type':mul_ex, 'start':1}}
예제 #44
0
파일: lithon.py 프로젝트: pheuter/Lithon
def quote(rule):
  rule | ('\'','(',star(expression),')')
  rule.astAttrs = {'values':[expression]}
예제 #45
0
def start_one(rule):
    rule | star(ID)
예제 #46
0
파일: lithon.py 프로젝트: pheuter/Lithon
def define(rule):
  rule | ('(','define','(',ID,star(ID),')',plus(expression),')')
  rule.astAttrs = {'args': [ID], 'body': [expression]}
예제 #47
0
def units(rule):
    rule | plus(star(NEWLINE), [unit], star(NEWLINE))
    rule.astAttrs = {"units": [unit]}
예제 #48
0
파일: grammar.py 프로젝트: scooterman/j2cpp
def typeParameters(rule):
	rule | ('<', typeParameter, star(',', typeParameter), '>')
예제 #49
0
def at(rule):
    rule | (no_ignore('@', ID), _or(STRING, SSTRING, star(_not(_or(';','}')))), ';')
    rule | star(_not(_or(';','}')))
예제 #50
0
파일: values.py 프로젝트: yishh/css
def uri_contents(rule):
    rule | star(_not(')'))
    rule.dont_ignore = True
    rule.astAttrs = {
        'items':the_tokens,
        }