Exemple #1
0
 def parse_group(self):
     while True:
         token = self.required([self.NAME, self.STRING, self.INTEGER, self.LBRACE, self.RBRACE])
         if token.pattern is self.LBRACE:
             yield FunctionLiteral(list(self.parse_group()))
         elif token.pattern is self.RBRACE:
             break
         else:
             yield self.LITERAL_TYPES[token.pattern](token.value)
Exemple #2
0
   Identifier(u':='),
   Integer(2),
   QuotedVar(u'after.sentence'),
   Identifier(u':='),
   Integer(3),
   QuotedVar(u'after.block'),
   Identifier(u':=')]],
 [u'STRINGS', [Identifier(u's'), Identifier(u't')]],
 [u'FUNCTION',
  [Identifier(u'output.nonnull')],
  [QuotedVar(u's'),
   Identifier(u':='),
   Identifier(u'output.state'),
   Identifier(u'mid.sentence'),
   Identifier(u'='),
   FunctionLiteral([String(u', '), Identifier(u'*'), Identifier(u'write$')]),
   FunctionLiteral([Identifier(u'output.state'), Identifier(u'after.block'), Identifier(u'='), FunctionLiteral([Identifier(u'add.period$'), Identifier(u'write$'), Identifier(u'newline$'), String(u'\\newblock '), Identifier(u'write$')]), FunctionLiteral([Identifier(u'output.state'), Identifier(u'before.all'), Identifier(u'='), QuotedVar(u'write$'), FunctionLiteral([Identifier(u'add.period$'), String(u' '), Identifier(u'*'), Identifier(u'write$')]), Identifier(u'if$')]), Identifier(u'if$'), Identifier(u'mid.sentence'), QuotedVar(u'output.state'), Identifier(u':=')]),
   Identifier(u'if$'),
   Identifier(u's')]],
 [u'FUNCTION',
  [Identifier(u'output')],
  [Identifier(u'duplicate$'),
   Identifier(u'empty$'),
   QuotedVar(u'pop$'),
   QuotedVar(u'output.nonnull'),
   Identifier(u'if$')]],
 [u'FUNCTION',
  [Identifier(u'output.check')],
  [QuotedVar(u't'),
   Identifier(u':='),
   Identifier(u'duplicate$'),
Exemple #3
0
def process_function(toks):
    return FunctionLiteral(toks[0])