コード例 #1
0
def colon_annotation(prs):  #was opt_colon_type, opt_colon_sort
    """Parser for ': A', discarding the colon. 
    A is parsed by prs.
    Parser returns an empty list if there is no annotation."""
    #def trt1(toks):
    #    if len(toks)==0:
    #        return toks
    #    return prs.process(toks)
    prs1 = (next_value(':') + post_colon_balanced()).treat(
        lib.snd).possibly().treat(lib.fflatten)
    return prs1.reparse(prs)
コード例 #2
0
ファイル: inner.py プロジェクト: formalabstracts/CNL-CIC
 def top_level():
     def f(acc):
         (((a,b),c),p) = acc
         return {'finished':bool(p),'nonterminal':a,'production':b,'annotated':c}
     return (Inner.nontermprod() + Inner.annotated().plus() + next_value('$').possibly()).treat(f)
コード例 #3
0
ファイル: inner.py プロジェクト: formalabstracts/CNL-CIC
 def opt():
     def f(acc):
         ((_,a),_) = acc
         return ('OPT',a)
     return (next_type('(') + Inner.annotated().plus(next_value('|')) + next_type(')')).treat(f).name('opt')
コード例 #4
0
def assign_expr():
    """parser for := followed by an expression
    The output is the expression
    """
    return (next_value(':=') + expr()).treat(lib.snd)
コード例 #5
0
 def identifier_pattern():
     ##XX
     return (lit('a') + identifier().if_test(p)) | next_value('_')
コード例 #6
0
 def function_copula():
     return (Macro.copula() | opt_colon_type() + next_value(':='))
コード例 #7
0
 def copula():
     """Parser for copula in macro declarations.
     """
     return ((lit('is') + lit('defined-as').possibly()) | (next_value(':='))
             | (lit('denote')))
コード例 #8
0
 def var_multisubsect_pattern():
     return ((Pattern._var() + next_value(',') + Pattern._var())
             | c.paren(Pattern._var() + next_value(',') + Pattern._var() +
                       opt_colon_type_meta()))
コード例 #9
0
def var_or_atomic_or_blank():
    """parser for var or atomic or _.
    The parser output is a single token that is one of those types."""
    return var_or_atomic() | next_value('_')
コード例 #10
0
            return (Parse.word('we').possibly() +
                    first_word('record register') +
                    Parse.word('identification').possibly() +
                    Parse.word('that').possibly())
        if s == 'doc':
            return lit['document'] | lit['end-document']
        if s == 'location':
            return Parse.first(
                [lit_dict['document'], lit_dict['theorem'], lit_dict['axiom']])
    return lit_dict[s]


#others:
#label = atomic

period = next_value('.').clear_history()
comma = next_value(',')
semicolon = next_value(';')
colon = next_value(':')

#renamed map -> call

# instructions do nothing except store for now

instruct = {}


class Instruction:
    def _param_value(ls):
        if ls == []:
            return ''