Exemplo n.º 1
0
def _mult_expand(start, end, context):
    
    start.connect(fork(
                       tn(MULT_ZERO_TO_ONE, 'mult-1'),
                       tn(MULT_ZERO_TO_MANY, 'mult-2'),
                       tn(MULT_ONE_TO_MANY, 'mult-3'),
                       )).connect(end)
Exemplo n.º 2
0
def _enable_expand(start, end, context):
    
    start\
    .connect(tn(ENABLE))\
    .connect(tn(FULL_BACKTRACKING))\
    .connect(tn(SEMICOLON))\
    .connect(end)
Exemplo n.º 3
0
def _group_expand(start, end, context):
    
    start\
    .connect(tn(PAR_OPEN))\
    .connect(_BranchRule('branch'))\
    .connect(zeroToMany(sequence(tn(OR), _BranchRule('branch'))))\
    .connect(tn(PAR_CLOSE))\
    .connect(end)
Exemplo n.º 4
0
def _rule_expand(start, end, context):
    
    branch = _BranchRule('branch')
    
    start\
    .connect(zeroToOne(tn(GRAMMAR_ANNOTATION, 'is-grammar')))\
    .connect(tn(RULE_ID, 'rule-id'))\
    .connect(tn(ASSIGN))\
    .connect(branch)\
    .connect(zeroToMany(sequence(tn(OR), branch)))\
    .connect(tn(SEMICOLON))\
    .connect(end)
Exemplo n.º 5
0
 def expand(self, start, end, context):
     
     end_ = connector()
     
     start\
     .connect(tn(self._token_type))\
     .connect(tn(TOKEN_ID, "id"))\
     .connect(end_)
     
     if not self._token_type in [LITERAL, TEXT_BLOCK]:
         end_ = end_.connect(tn(TOKEN_VALUE, "value"))
     
     if self._token_type in [KEYWORD, WORD, PREFIX, POSTFIX, SEPARATOR]:
         end_.connect(_PropsRule('properties')).connect(end)
     
     end_.connect(tn(SEMICOLON)).connect(end)
Exemplo n.º 6
0
def _comment_expand(start, end, context):

    start\
    .connect(tn(LINE_COMMENT_STYLE, 'line'))\
    .connect(tn(COMMENT_VALUE, 'begin'))\
    .connect(tn(SEMICOLON))\
    .connect(end)

    start\
    .connect(tn(BLOCK_COMMENT_STYLE, 'block'))\
    .connect(tn(COMMENT_VALUE, 'begin'))\
    .connect(tn(COMMENT_VALUE, 'end'))\
    .connect(tn(SEMICOLON))\
    .connect(end)
Exemplo n.º 7
0
def _branch_elem_expand(start, end, context):
    
    token = sequence(zeroToOne(sequence(tn(ID, 'id'), tn(ASSIGN))), 
                     tn(TOKEN_ID, 'token'),
                     zeroToOne(_MultRule('mult'))
                     )
    keyword = sequence(zeroToOne(sequence(tn(ID, 'id'), tn(ASSIGN))), 
                       tn(KEYWORD_NAME, 'keyword'),
                       zeroToOne(_MultRule('mult'))
                       )

    rule = sequence(zeroToOne(sequence(tn(ID, 'id'), tn(ASSIGN))), 
                    tn(RULE_ID, 'rule'),
                    zeroToOne(_MultRule('mult'))
                    )
    
    group = sequence(zeroToOne(sequence(tn(ID, 'id'), tn(ASSIGN))),
                    _GroupRule('group'),
                    zeroToOne(_MultRule('mult')) 
                    )
    
    start.connect(fork(
                       token,
                       keyword,
                       rule,
                       group
                       )).connect(end)
Exemplo n.º 8
0
def _props_expand(start, end, context):
    
    tt = context[ENVVAR_TOKEN_TYPE]
    
    start_ = connector()
    end_ = connector()
    hlp = connector()
    prop_end = connector()       
    
    start\
    .connect(tn(BRACE_OPEN))\
    .connect(start_)
    
    is_flag = True
    
    if tt == KEYWORD:
        start_.connect(tn(CASE_SENSITIVE, 'case-sensitive')).connect(hlp)
    elif tt == WORD:
        is_flag = False
        start_\
        .connect(tn(FILTER_CB, 'filter-callback'))\
        .connect(tn(COLON))\
        .connect(tn(ID, 'filter-callback-name'))\
        .connect(prop_end)
    elif tt == PREFIX:
        start_.connect(tn(ESCAPE, 'escape')).connect(hlp)
    elif tt == POSTFIX:
        start_.connect(tn(ESCAPE, 'escape')).connect(hlp)
    elif tt == SEPARATOR:
        start_.connect(tn(IS_PATTERN, 'pattern')).connect(hlp)
        start_.connect(tn(WS_ALLOWED, 'ws-allowed')).connect(hlp)
        start_.connect(tn(ESCAPE, 'escape')).connect(hlp)
    else:
        raise Exception("Unknown property target")
    
    if is_flag:
    
        hlp\
        .connect(tn(COLON))\
        .connect(tn(TRUE, 'true'))\
        .connect(prop_end)
    
        hlp\
        .connect(tn(COLON))\
        .connect(tn(FALSE, 'false'))\
        .connect(prop_end)
    
    prop_end.connect(tn(COMMA)).connect(start_)
    prop_end.connect(end_)
        
    end_\
    .connect(tn(BRACE_CLOSE))\
    .connect(end)