Exemplo n.º 1
0
    def _syn():
        """parsing synonyms"""
        def p(tok):
            tok.value in ['/', '/-'] or c.can_wordify(tok)

        synlist = Parse.next_token().if_test(p).plus()
        return c.comma_nonempty_list(synlist)
Exemplo n.º 2
0
 def f(item):
     item1 = Parse.next_token().process(item)
     result = item1.tok
     if result.type == 'INTEGER' or result.type == 'WORD':
         tok = copy.copy(result)
         if tok.type == 'WORD':
             tok.value = c.synonymize(tok.value)
         tok.type = 'ATOMIC_IDENTIFIER'
         return (tok, item1)
     if result.type == 'ATOMIC_IDENTIFIER':
         return result
     raise ParseError(item)
Exemplo n.º 3
0
    def instruction():
        """parsing and processing of synonyms and other instructions"""
        def treat_syn(acc):
            for ac in acc:
                vs = [t.value for t in ac]
                v_expand = Instruction._expand_slashdash(vs)
                c.synonym_add(v_expand)
                return ()

        def treat_instruct(acc):
            keyword, ls = acc
            instruct[keyword.value] = Instruction._param_value(ls)
            return ()

        keyword_instruct = (first_word("""exit timelimit printgoal dump 
                         ontored read library error warning""") +
                            Parse.next_token().possibly())
        return (c.bracket(
            next_word('synonym') + Instruction._syn().treat(treat_syn)
            | c.bracket(keyword_instruct.treat(treat_instruct))))
Exemplo n.º 4
0
 def id():
     def f(acc):
         return (acc.type,acc.value)
     return Parse.next_token().if_types(['TY','ID']).treat(f)
Exemplo n.º 5
0
def var():
    """parser for a single variable.
    Accepts a single token that is a variable."""
    return Parse.next_token().if_type(['VAR']).expect('var')
Exemplo n.º 6
0
 def this_directive_pred():
     return c.andcomma_nonempty_list(Parse.next_token().if_test(adjective))
Exemplo n.º 7
0
def hierarchical_identifier():
    """parser for hierarchical identifiers.
    Parser output is a single token."""
    return Parse.next_token().if_type(['HIERARCHICAL_IDENTIFIER'])