ll.ul4c provides templating for XML/HTML as well as any other text-based
format. A template defines placeholders for data output and basic logic (like
loops and conditional blocks), that define how the final rendered output will
look.
ll.ul4c compiles a template to a bytecode format, which makes it possible
to implement template renderers in multiple programming languages.
class Location(object):
A Location object contains information about the location of a
template tag.
def __init__(self, source, name, type, starttag, endtag, startcode, endcode):
selfCreate a new Location object. The arguments have the following
meaning:
sourceThe complete source string
nameThe name of the template the location belongs to.
typeThe tag type (i.e.
"for","if", etc. orNonefor literal text)starttagThe start position of the start delimiter.
endtagThe end position of the end delimiter.
startcodeThe start position of the tag code.
endcodeThe end position of the tag code.
def __getitem__(self, key):
selfproperty code:
def __get__(self):
property tag:
def __get__(self):
def __repr__(self):
selfdef pos(self):
selfdef __str__(self):
selfclass Error(Exception):
Exception class that wraps another exception and provides a location.
def __init__(self, location):
selfdef __repr__(self):
selfdef __str__(self):
selfclass LexicalError(Exception):
def __init__(self, start, end, input):
selfdef __str__(self):
selfclass SyntaxError(Exception):
def __init__(self, token):
selfdef __str__(self):
selfclass UnterminatedStringError(Exception):
Exception that is raised by the parser when a string constant is not terminated.
def __str__(self):
selfclass BlockError(Exception):
Exception that is raised by the compiler when an illegal block structure is
detected (e.g. an endif without a previous if).
def __init__(self, message):
selfdef __str__(self):
selfclass UnknownFunctionError(Exception):
Exception that is raised by the renderer if the function to be executed by
the callfunc0, callfunc1, callfunc2, callfunc3 or
callfunc4 opcodes is unknown.
def __init__(self, funcname):
selfdef __str__(self):
selfclass UnknownMethodError(Exception):
Exception that is raised by the renderer if the method to be executed by the
callmeth0, callmeth1, callmeth2 or callmeth3 opcodes is
unknown.
def __init__(self, methname):
selfdef __str__(self):
selfclass UnknownOpcodeError(Exception):
Exception that is raised when an unknown opcode is encountered by the renderer.
def __init__(self, opcode):
selfdef __str__(self):
selfclass OutOfRegistersError(Exception):
Exception that is raised by the compiler when there are no more free registers. This might happen with complex expressions in tag code.
def __str__(self):
selfclass Opcode(object):
An Opcode stores an opcode. An Opcode object has the
following attributes:
code(string orNone)The opcode type (see below for a list).
r1,r2,r3,r4,r5(integer orNone)Register specifications (for the sources or the target of the opcode)
arg(string orNone)Used if the opcode requires an additional argument (like a variable name or the value of a constant).
location(Locationobject)The location of the tag to which this opcode belongs.
The following opcode types are available:
None:Print text. The text is available from
location.code."print":Print the content of register
r1. (If the object in the register is not a string, it will be converted to a string first.)"loadnone":Load the constant
Noneinto registerr1."loadfalse":Load the constant
Falseinto registerr1."loadtrue":Load the constant
Trueinto registerr1."loadstr":Load the string
arginto registerr1."loadint":Load the integer value
arginto registerr1."loadfloat":Load the float value
arginto registerr1."loaddate":Load the date value
arginto registerr1.argmust be in ISO format (e.g.2008-07-02T11:05:55.460464)."loadcolor":Load the color value
arginto registerr1.argmust be in the formatrrggbbaa)."buildlist":Load an empty list into register
r1."builddict":Load an empty dictionary into register
r1."addlist"Append the object in register
r2to the list in registerr1."adddict"Add a new entry to the dictionary in register
r1. The object inr2is the key and the object in registerr3is the value."updatedict"Update the dictionary in register
r1with the items from the dictionary inr2."loadvar":Load the variable named
arginto the registerr1."storevar":Store the content of register
r1in the variable namedarg."addvar":Add the content of register
r1to the variable namedarg."for":Start a loop over the object in the register
r2and store the object from each loop iteration in the registerr1."endfor":End the innermost running
forloop."break":Breaks the innermost running
forloop."continue":Continues the innermost running
forloop (i.e. jumps back to the start of the loop body)."if":Start a conditional block. If the objects in the register
r1is true the block will be executed. The "block" consists of all opcodes after theifupto the matchingelseorendifopcode."else":Start the else branch of the previous
if."endif":End a conditional block.
"getattr":Get the attribute named
argfrom the object in registerr2and store it in registerr1."getitem":Get an item from the object in register
r2. If this object is a list or string the object in registerr3will be used as the index. If it is a dictionaryr3will be used as the key. The result will be stored in registerr1."getslice12":Get an slice from the object in register
r2. The object in registerr3(which must be anintorNone) specifies the start index, the object in registerr4specifies the end index. The result will be stored in registerr1."getslice1":Similar to
getslice12except that the end index is always the length of the object."getslice2":Similar to
getslice12except that the start index is always 0 and the end index is in registerr3."not":Invert the truth value of the object in register
r2and stores the resulting bool in the registerr1."eq":Compare the objects in register
r2andr3and storeTruein the registerr1if they are equal,Falseotherwise."ne":Compare the objects in register
r2andr3and storeFalsein the registerr1if they are equal,Trueotherwise."lt":Does a "<" comparison of the objects in register
r2andr3and stores the result in registerr1."le":Does a "<=" comparison of the objects in register
r2andr3and stores the result in registerr1."gt":Does a ">" comparison of the objects in register
r2andr3and stores the result in registerr1."ge":Does a ">=" comparison of the objects in register
r2andr3and stores the result in registerr1."contains":Test whether the object in register
r3contains the object in registerr2(either as a key ifr3is a dictionary or as an item if it's a list or as a substring if it's a string) and storeTrueinto the registerr1if it does,Falseotherwise."notcontains":Test whether the object in register
r3contains the object in registerr2(either as a key ifr3is a dictionary or as an item if it's a list or as a substring if it's a string) and storeFalseinto the registerr1if it does,Trueotherwise."or":Check the truth value of the two objects in registers
r2andr3and storer2in the registerr1if it is true,r3otherwise)."and":Check the truth value of the two objects in registers
r2andr3and storer3in the registerr1ifr2is true,r3otherwise)."mod":Does a modulo operation: Calculates
r2modulor3and stores the result in registerr1."callfunc0":Call the function named
argwithout any arguments and store the return value in registerr1."callfunc1":Call the function named
argwith the content of registerr2as an argument and store the return value in registerr1."callfunc2":Call the function named
argwith the contents of registerr2andr3as the two arguments and store the return value in registerr1."callfunc3":Call the function named
argwith the contents of registerr2,r3andr4as the three arguments and store the return value in registerr1."callfunc4":Call the function named
argwith the contents of registerr2,r3,r4andr5as the four arguments and store the return value in registerr1."callmeth0":Call the method named
argon the object in registerr2and store the return value in registerr1."callmeth1":Call the method named
argon the object in registerr2using the object in registerr3as the only argument and store the return value in registerr1."callmeth2":Call the method named
argon the object in registerr2using the objects in registerr3andr4as arguments and store the return value in registerr1."callmeth3":Call the method named
argon the object in registerr2using the objects in registerr3,r4andr5as arguments and store the return value in registerr1."render":Render the template in the attribute
r1. The content of registerr2(which must be a dictionary) will be passed to the template as the variable dictionary."def"Begin the definition of a local template. The template will be stored in the variable named
arg."enddef"End the definition of a local template.
def __init__(self, code, r1=None, r2=None, r3=None, r4=None, r5=None, arg=None, location=None):
selfdef __getitem__(self, key):
selfdef __repr__(self):
selfdef __str__(self):
selfclass Template(object):
A template object is normally creating by passing the template source to the
constructor. It can also be loaded from the compiled format via the class
methods load (from a stream) or loads (from a string).
The compiled format can be generated with the methods dump (which
dumps the format to a stream) or dumps (which returns a string with
the compiled format).
Rendering the template can be done with the methods render (which
is a generator) or renders (which returns a string).
def __init__(self, source=None, name='unnamed', startdelim='<?', enddelim='?>'):
selfCreate a Template object. If source is None, the
Template remains uninitialized, otherwise source will be
compiled (using startdelim and enddelim as the tag
delimiters). name is the name of the template. It will be used in
exception messages and should be a valid Python identifier.
def __getitem__(self, key):
selfdef loads(cls, data):
clsThe class method loads loads the template from string data.
data must contain the template in compiled format.
def load(cls, stream):
clsThe class method load loads the template from the stream
stream. The stream must contain the template in compiled format.
def iterdump(self):
selfThis generator outputs the template in compiled format.
def dump(self, stream):
selfdump dumps the template in compiled format to the stream
stream.
def dumps(self):
selfdumps returns the template in compiled format (as a string).
def render(self, **variables):
selfRender the template iteratively (i.e. this is a generator).
variables contains the top level variables available to the
template code.
def renders(self, **variables):
selfRender the template as a string. variables contains the top level
variables available to the template code.
def pythonfunction(self):
selfReturn a Python generator that can be called to render the template. The
argument signature of the function will be **variables.
def __call__(self, **variables):
selfdef pythonsource(self, *args, **kwargs):
selfReturn the template as Python source code. All arguments in args
and kwargs will be passed on to the PythonSource object
which creates the sourcecode. See its constructor for more info.
def jssource(self):
selfReturn the template as the source code of a Javascript function. A
JavascriptSource object will be used to generated the sourcecode.
def javasource(self, *args, **kwargs):
selfReturn the template as Java source code. All arguments in args
and kwargs will be passed on to the JavaSource object
which creates the sourcecode. See its constructor for more info.
def format(self, indent='\t'):
selfFormat the list of opcodes. This is a generator yielding lines to be output
(but without trailing newlines). indent can be used to specify how
to indent blocks (defaulting to "\t").
def _tokenize(self, source, name, startdelim, enddelim):
selfTokenize the template source code source into tags and non-tag
text. startdelim and enddelim are used as the tag delimiters.
This is a generator which produces Location objects for each tag
or non-tag text. It will be called by _compile internally.
def _allocreg(self):
selfAllocates a free register from the pool of available registers.
def _freereg(self, register):
selfReturns the register register to the pool of available registers.
def opcode(self, code, r1=None, r2=None, r3=None, r4=None, r5=None, arg=None):
selfCreates an Opcode object and appends it to selfs list of
opcodes.
def _compile(self, source, name, startdelim, enddelim):
selfCompile the template source code source into opcodes.
startdelim and enddelim are used as the tag delimiters.
def __str__(self):
selfdef __unicode__(self):
selfdef __repr__(self):
selfclass PythonSource(object):
A PythonSource object generates Python sourcecode from a UL4
template.
def __init__(self, template):
selfCreate a PythonSource object. template is the
Template object.
def __unicode__(self):
selfReturn the Python sourcecode for the Template object passed to
the constructor.
def _line(self, location, line):
selfdef _dispatch_None(self, opcode):
selfdef _dispatch_loadstr(self, opcode):
selfdef _dispatch_loadint(self, opcode):
selfdef _dispatch_loadfloat(self, opcode):
selfdef _dispatch_loadnone(self, opcode):
selfdef _dispatch_loadfalse(self, opcode):
selfdef _dispatch_loadtrue(self, opcode):
selfdef _dispatch_loaddate(self, opcode):
selfdef _dispatch_loadcolor(self, opcode):
selfdef _dispatch_buildlist(self, opcode):
selfdef _dispatch_builddict(self, opcode):
selfdef _dispatch_addlist(self, opcode):
selfdef _dispatch_adddict(self, opcode):
selfdef _dispatch_updatedict(self, opcode):
selfdef _dispatch_loadvar(self, opcode):
selfdef _dispatch_storevar(self, opcode):
selfdef _dispatch_addvar(self, opcode):
selfdef _dispatch_subvar(self, opcode):
selfdef _dispatch_mulvar(self, opcode):
selfdef _dispatch_truedivvar(self, opcode):
selfdef _dispatch_floordivvar(self, opcode):
selfdef _dispatch_modvar(self, opcode):
selfdef _dispatch_delvar(self, opcode):
selfdef _dispatch_getattr(self, opcode):
selfdef _dispatch_getitem(self, opcode):
selfdef _dispatch_getslice12(self, opcode):
selfdef _dispatch_getslice1(self, opcode):
selfdef _dispatch_getslice2(self, opcode):
selfdef _dispatch_print(self, opcode):
selfdef _dispatch_printx(self, opcode):
selfdef _dispatch_for(self, opcode):
selfdef _dispatch_endfor(self, opcode):
selfdef _dispatch_break(self, opcode):
selfdef _dispatch_continue(self, opcode):
selfdef _dispatch_not(self, opcode):
selfdef _dispatch_neg(self, opcode):
selfdef _dispatch_contains(self, opcode):
selfdef _dispatch_notcontains(self, opcode):
selfdef _dispatch_eq(self, opcode):
selfdef _dispatch_ne(self, opcode):
selfdef _dispatch_lt(self, opcode):
selfdef _dispatch_le(self, opcode):
selfdef _dispatch_gt(self, opcode):
selfdef _dispatch_ge(self, opcode):
selfdef _dispatch_add(self, opcode):
selfdef _dispatch_sub(self, opcode):
selfdef _dispatch_mul(self, opcode):
selfdef _dispatch_floordiv(self, opcode):
selfdef _dispatch_truediv(self, opcode):
selfdef _dispatch_and(self, opcode):
selfdef _dispatch_or(self, opcode):
selfdef _dispatch_mod(self, opcode):
selfdef _dispatch_callfunc0(self, opcode):
selfdef _dispatch_callfunc1(self, opcode):
selfdef _dispatch_callfunc2(self, opcode):
selfdef _dispatch_callfunc3(self, opcode):
selfdef _dispatch_callfunc4(self, opcode):
selfdef _dispatch_callmeth0(self, opcode):
selfdef _dispatch_callmeth1(self, opcode):
selfdef _dispatch_callmeth2(self, opcode):
selfdef _dispatch_callmeth3(self, opcode):
selfdef _dispatch_callmethkw(self, opcode):
selfdef _dispatch_if(self, opcode):
selfdef _dispatch_else(self, opcode):
selfdef _dispatch_endif(self, opcode):
selfdef _dispatch_def(self, opcode):
selfdef _dispatch_enddef(self, opcode):
selfdef _dispatch_render(self, opcode):
selfdef _dispatch_callfunc0_now(self, opcode):
selfdef _dispatch_callfunc0_utcnow(self, opcode):
selfdef _dispatch_callfunc0_vars(self, opcode):
selfdef _dispatch_callfunc0_random(self, opcode):
selfdef _dispatch_callfunc1_xmlescape(self, opcode):
selfdef _dispatch_callfunc1_csv(self, opcode):
selfdef _dispatch_callfunc1_json(self, opcode):
selfdef _dispatch_callfunc1_str(self, opcode):
selfdef _dispatch_callfunc1_int(self, opcode):
selfdef _dispatch_callfunc1_float(self, opcode):
selfdef _dispatch_callfunc1_bool(self, opcode):
selfdef _dispatch_callfunc1_len(self, opcode):
selfdef _dispatch_callfunc1_abs(self, opcode):
selfdef _dispatch_callfunc1_enumerate(self, opcode):
selfdef _dispatch_callfunc1_isnone(self, opcode):
selfdef _dispatch_callfunc1_isstr(self, opcode):
selfdef _dispatch_callfunc1_isint(self, opcode):
selfdef _dispatch_callfunc1_isfloat(self, opcode):
selfdef _dispatch_callfunc1_isbool(self, opcode):
selfdef _dispatch_callfunc1_isdate(self, opcode):
selfdef _dispatch_callfunc1_islist(self, opcode):
selfdef _dispatch_callfunc1_isdict(self, opcode):
selfdef _dispatch_callfunc1_istemplate(self, opcode):
selfdef _dispatch_callfunc1_iscolor(self, opcode):
selfdef _dispatch_callfunc1_repr(self, opcode):
selfdef _dispatch_callfunc1_get(self, opcode):
selfdef _dispatch_callfunc1_chr(self, opcode):
selfdef _dispatch_callfunc1_ord(self, opcode):
selfdef _dispatch_callfunc1_hex(self, opcode):
selfdef _dispatch_callfunc1_oct(self, opcode):
selfdef _dispatch_callfunc1_bin(self, opcode):
selfdef _dispatch_callfunc1_sorted(self, opcode):
selfdef _dispatch_callfunc1_range(self, opcode):
selfdef _dispatch_callfunc1_type(self, opcode):
selfdef _dispatch_callfunc1_reversed(self, opcode):
selfdef _dispatch_callfunc1_randrange(self, opcode):
selfdef _dispatch_callfunc1_randchoice(self, opcode):
selfdef _dispatch_callfunc2_format(self, opcode):
selfdef _dispatch_callfunc2_range(self, opcode):
selfdef _dispatch_callfunc2_get(self, opcode):
selfdef _dispatch_callfunc2_zip(self, opcode):
selfdef _dispatch_callfunc2_int(self, opcode):
selfdef _dispatch_callfunc2_randrange(self, opcode):
selfdef _dispatch_callfunc3_range(self, opcode):
selfdef _dispatch_callfunc3_zip(self, opcode):
selfdef _dispatch_callfunc3_rgb(self, opcode):
selfdef _dispatch_callfunc3_hls(self, opcode):
selfdef _dispatch_callfunc3_hsv(self, opcode):
selfdef _dispatch_callfunc3_randrange(self, opcode):
selfdef _dispatch_callfunc4_rgb(self, opcode):
selfdef _dispatch_callfunc4_hls(self, opcode):
selfdef _dispatch_callfunc4_hsv(self, opcode):
selfclass JavascriptSource(object):
A JavascriptSource object generates javascript sourcecode from a UL4
template.
The signature of the generated Javascript function will be function(vars),
i.e. all template variables will be attributes of the object vars.
Note that the generated code will require the ul4 Javascript support
library.
def __init__(self, template):
selfCreate a JavascriptSource object. template is the
Template object.
def __unicode__(self):
selfReturn the Javascript sourcecode for the Template object passed
to the constructor.
def _line(self, line):
selfdef _dispatch_None(self, opcode):
selfdef _dispatch_loadstr(self, opcode):
selfdef _dispatch_loadint(self, opcode):
selfdef _dispatch_loadfloat(self, opcode):
selfdef _dispatch_loadnone(self, opcode):
selfdef _dispatch_loadfalse(self, opcode):
selfdef _dispatch_loadtrue(self, opcode):
selfdef _dispatch_loaddate(self, opcode):
selfdef _dispatch_loadcolor(self, opcode):
selfdef _dispatch_buildlist(self, opcode):
selfdef _dispatch_builddict(self, opcode):
selfdef _dispatch_addlist(self, opcode):
selfdef _dispatch_adddict(self, opcode):
selfdef _dispatch_updatedict(self, opcode):
selfdef _dispatch_loadvar(self, opcode):
selfdef _dispatch_storevar(self, opcode):
selfdef _dispatch_addvar(self, opcode):
selfdef _dispatch_subvar(self, opcode):
selfdef _dispatch_mulvar(self, opcode):
selfdef _dispatch_truedivvar(self, opcode):
selfdef _dispatch_floordivvar(self, opcode):
selfdef _dispatch_modvar(self, opcode):
selfdef _dispatch_delvar(self, opcode):
selfdef _dispatch_getattr(self, opcode):
selfdef _dispatch_getitem(self, opcode):
selfdef _dispatch_getslice12(self, opcode):
selfdef _dispatch_getslice1(self, opcode):
selfdef _dispatch_getslice2(self, opcode):
selfdef _dispatch_print(self, opcode):
selfdef _dispatch_printx(self, opcode):
selfdef _dispatch_for(self, opcode):
selfdef _dispatch_endfor(self, opcode):
selfdef _dispatch_def(self, opcode):
selfdef _dispatch_enddef(self, opcode):
selfdef _dispatch_break(self, opcode):
selfdef _dispatch_continue(self, opcode):
selfdef _dispatch_not(self, opcode):
selfdef _dispatch_neg(self, opcode):
selfdef _dispatch_contains(self, opcode):
selfdef _dispatch_notcontains(self, opcode):
selfdef _dispatch_eq(self, opcode):
selfdef _dispatch_ne(self, opcode):
selfdef _dispatch_lt(self, opcode):
selfdef _dispatch_le(self, opcode):
selfdef _dispatch_gt(self, opcode):
selfdef _dispatch_ge(self, opcode):
selfdef _dispatch_add(self, opcode):
selfdef _dispatch_sub(self, opcode):
selfdef _dispatch_mul(self, opcode):
selfdef _dispatch_floordiv(self, opcode):
selfdef _dispatch_truediv(self, opcode):
selfdef _dispatch_and(self, opcode):
selfdef _dispatch_or(self, opcode):
selfdef _dispatch_mod(self, opcode):
selfdef _dispatch_callfunc0(self, opcode):
selfdef _dispatch_callfunc1(self, opcode):
selfdef _dispatch_callfunc2(self, opcode):
selfdef _dispatch_callfunc3(self, opcode):
selfdef _dispatch_callfunc4(self, opcode):
selfdef _dispatch_callmeth0(self, opcode):
selfdef _dispatch_callmeth1(self, opcode):
selfdef _dispatch_callmeth2(self, opcode):
selfdef _dispatch_callmeth3(self, opcode):
selfdef _dispatch_callmethkw(self, opcode):
selfdef _dispatch_if(self, opcode):
selfdef _dispatch_else(self, opcode):
selfdef _dispatch_endif(self, opcode):
selfdef _dispatch_render(self, opcode):
selfclass _JavaTemplateLevel(object):
def __init__(self, variables, name=None):
selfclass JavaSource(object):
A JavaSource object generates Java sourcecode from a UL4
template.
The code produced requires the UL4 Java package.
def __init__(self, template, indent=2, variables='variables'):
selfCreate a JavaSource object. template is the
Template object.
indent is the current indent level (defaulting to 2 for normal
method source code).
variables is the variable name of a Map object containing the
template variables.
def __unicode__(self):
selfReturn the Java sourcecode for the Template object passed to
the constructor.
def output(self, expression):
selfReturn a statement for outputting the Java expression expression.
This uses out.write() (for JSP etc.) but can be overwritten in
subclasses.
def _usereg(self, r):
selfdef _do(self, line):
selfdef _dispatch_None(self, opcode):
selfdef _dispatch_loadstr(self, opcode):
selfdef _dispatch_loadint(self, opcode):
selfdef _dispatch_loadfloat(self, opcode):
selfdef _dispatch_loadnone(self, opcode):
selfdef _dispatch_loadfalse(self, opcode):
selfdef _dispatch_loadtrue(self, opcode):
selfdef _dispatch_loaddate(self, opcode):
selfdef _dispatch_loadcolor(self, opcode):
selfdef _dispatch_buildlist(self, opcode):
selfdef _dispatch_builddict(self, opcode):
selfdef _dispatch_addlist(self, opcode):
selfdef _dispatch_adddict(self, opcode):
selfdef _dispatch_updatedict(self, opcode):
selfdef _dispatch_loadvar(self, opcode):
selfdef _dispatch_storevar(self, opcode):
selfdef _dispatch_addvar(self, opcode):
selfdef _dispatch_subvar(self, opcode):
selfdef _dispatch_mulvar(self, opcode):
selfdef _dispatch_truedivvar(self, opcode):
selfdef _dispatch_floordivvar(self, opcode):
selfdef _dispatch_modvar(self, opcode):
selfdef _dispatch_delvar(self, opcode):
selfdef _dispatch_getattr(self, opcode):
selfdef _dispatch_getitem(self, opcode):
selfdef _dispatch_getslice12(self, opcode):
selfdef _dispatch_getslice1(self, opcode):
selfdef _dispatch_getslice2(self, opcode):
selfdef _dispatch_print(self, opcode):
selfdef _dispatch_printx(self, opcode):
selfdef _dispatch_for(self, opcode):
selfdef _dispatch_endfor(self, opcode):
selfdef _dispatch_def(self, opcode):
selfdef _dispatch_enddef(self, opcode):
selfdef _dispatch_break(self, opcode):
selfdef _dispatch_continue(self, opcode):
selfdef _dispatch_not(self, opcode):
selfdef _dispatch_neg(self, opcode):
selfdef _dispatch_contains(self, opcode):
selfdef _dispatch_notcontains(self, opcode):
selfdef _dispatch_eq(self, opcode):
selfdef _dispatch_ne(self, opcode):
selfdef _dispatch_lt(self, opcode):
selfdef _dispatch_le(self, opcode):
selfdef _dispatch_gt(self, opcode):
selfdef _dispatch_ge(self, opcode):
selfdef _dispatch_add(self, opcode):
selfdef _dispatch_sub(self, opcode):
selfdef _dispatch_mul(self, opcode):
selfdef _dispatch_floordiv(self, opcode):
selfdef _dispatch_truediv(self, opcode):
selfdef _dispatch_and(self, opcode):
selfdef _dispatch_or(self, opcode):
selfdef _dispatch_mod(self, opcode):
selfdef _dispatch_callfunc0(self, opcode):
selfdef _dispatch_callfunc1(self, opcode):
selfdef _dispatch_callfunc2(self, opcode):
selfdef _dispatch_callfunc3(self, opcode):
selfdef _dispatch_callfunc4(self, opcode):
selfdef _dispatch_callmeth0(self, opcode):
selfdef _dispatch_callmeth1(self, opcode):
selfdef _dispatch_callmeth2(self, opcode):
selfdef _dispatch_callmeth3(self, opcode):
selfdef _dispatch_callmethkw(self, opcode):
selfdef _dispatch_if(self, opcode):
selfdef _dispatch_else(self, opcode):
selfdef _dispatch_endif(self, opcode):
selfdef _dispatch_render(self, opcode):
selfclass Token(object):
def __init__(self, start, end, type):
selfdef __repr__(self):
selfdef __str__(self):
selfclass AST(object):
Baseclass for all syntax tree nodes.
def __init__(self, start, end):
selfclass Const(AST):
Common baseclass for all constants (used for type testing in constant folding)
def __repr__(self):
selfdef compile(self, template):
selfclass None_(Const):
class True_(Const):
class False_(Const):
class Value(Const):
def __init__(self, start, end, value):
selfdef __repr__(self):
selfdef compile(self, template):
selfclass Int(Value):
class Float(Value):
def compile(self, template):
selfclass Str(Value):
class Date(Value):
def compile(self, template):
selfclass Color(Value):
def compile(self, template):
selfclass List(AST):
def __init__(self, start, end, *items):
selfdef __repr__(self):
selfdef compile(self, template):
selfclass Dict(AST):
def __init__(self, start, end, *items):
selfdef __repr__(self):
selfdef compile(self, template):
selfclass Name(AST):
def __init__(self, start, end, name):
selfdef __repr__(self):
selfdef compile(self, template):
selfclass For(AST):
def __init__(self, start, end, iter, cont):
selfdef __repr__(self):
selfdef compile(self, template):
selfclass GetAttr(AST):
def __init__(self, start, end, obj, attr):
selfdef __repr__(self):
selfdef compile(self, template):
selfclass GetSlice12(AST):
def __init__(self, start, end, obj, index1, index2):
selfdef __repr__(self):
selfdef compile(self, template):
selfclass Unary(AST):
def __init__(self, start, end, obj):
selfdef __repr__(self):
selfdef compile(self, template):
selfclass Not(Unary):
class Neg(Unary):
class Binary(AST):
def __init__(self, start, end, obj1, obj2):
selfdef __repr__(self):
selfdef compile(self, template):
selfclass GetItem(Binary):
class GetSlice1(Binary):
class GetSlice2(Binary):
class EQ(Binary):
class NE(Binary):
class LT(Binary):
class LE(Binary):
class GT(Binary):
class GE(Binary):
class Contains(Binary):
class NotContains(Binary):
class Add(Binary):
class Sub(Binary):
class Mul(Binary):
class FloorDiv(Binary):
class TrueDiv(Binary):
class Or(Binary):
class And(Binary):
class Mod(Binary):
class ChangeVar(AST):
def __init__(self, start, end, name, value):
selfdef __repr__(self):
selfdef compile(self, template):
selfclass StoreVar(ChangeVar):
class AddVar(ChangeVar):
class SubVar(ChangeVar):
class MulVar(ChangeVar):
class TrueDivVar(ChangeVar):
class FloorDivVar(ChangeVar):
class ModVar(ChangeVar):
class DelVar(AST):
def __init__(self, start, end, name):
selfdef __repr__(self):
selfdef compile(self, template):
selfclass CallFunc(AST):
def __init__(self, start, end, name, args):
selfdef __repr__(self):
selfdef compile(self, template):
selfclass CallMeth(AST):
def __init__(self, start, end, name, obj, args):
selfdef __repr__(self):
selfdef compile(self, template):
selfclass CallMethKeywords(AST):
def __init__(self, start, end, name, obj, args):
selfdef __repr__(self):
selfdef compile(self, template):
selfclass Render(AST):
def __init__(self, start, end, template, *variables):
selfdef __repr__(self):
selfdef compile(self, template):
selfclass Scanner(ll.spark.Scanner):
def tokenize(self, location):
selfdef color8(self, start, end, s):
selfdef color6(self, start, end, s):
selfdef color4(self, start, end, s):
selfdef color3(self, start, end, s):
selfdef date(self, start, end, s):
selfdef token(self, start, end, s):
selfdef name(self, start, end, s):
selfdef float(self, start, end, s):
selfdef hexint(self, start, end, s):
selfdef octint(self, start, end, s):
selfdef binint(self, start, end, s):
selfdef int(self, start, end, s):
selfdef beginstr1(self, start, end, s):
selfdef beginstr2(self, start, end, s):
selfdef endstr(self, start, end, s):
selfdef whitespace(self, start, end, s):
selfdef escapedbackslash(self, start, end, s):
selfdef escapedapos(self, start, end, s):
selfdef escapedquot(self, start, end, s):
selfdef escapedbell(self, start, end, s):
selfdef escapedbackspace(self, start, end, s):
selfdef escapedformfeed(self, start, end, s):
selfdef escapedlinefeed(self, start, end, s):
selfdef escapedcarriagereturn(self, start, end, s):
selfdef escapedtab(self, start, end, s):
selfdef escapedverticaltab(self, start, end, s):
selfdef escapedescape(self, start, end, s):
selfdef escaped8bitchar(self, start, end, s):
selfdef escaped16bitchar(self, start, end, s):
selfdef text(self, start, end, s):
selfdef default(self, start, end, s):
selfdef error(self, start, end, s):
selfclass ExprParser(ll.spark.Parser):
def __init__(self, scanner):
selfdef compile(self, template):
selfdef typestring(self, token):
selfdef error(self, token):
selfdef makeconst(self, start, end, value):
selfdef expr_atom(self, atom):
selfdef expr_emptylist(self, _0, _1):
selfdef expr_buildlist(self, _0, expr):
selfdef expr_addlist(self, list, _0, expr):
selfdef expr_finishlist(self, list, _0):
selfdef expr_finishlist1(self, list, _0, _1):
selfdef expr_emptydict(self, _0, _1):
selfdef expr_builddict(self, _0, exprkey, _1, exprvalue):
selfdef expr_builddictupdate(self, _0, _1, expr):
selfdef expr_adddict(self, dict, _0, exprkey, _1, exprvalue):
selfdef expr_updatedict(self, dict, _0, _1, expr):
selfdef expr_finishdict(self, dict, _0):
selfdef expr_finishdict1(self, dict, _0, _1):
selfdef expr_bracket(self, _0, expr, _1):
selfdef expr_callfunc0(self, name, _0, _1):
selfdef expr_callfunc1(self, name, _0, arg0, _1):
selfdef expr_callfunc2(self, name, _0, arg0, _1, arg1, _2):
selfdef expr_callfunc3(self, name, _0, arg0, _1, arg1, _2, arg2, _3):
selfdef expr_callfunc4(self, name, _0, arg0, _1, arg1, _2, arg2, _3, arg3, _4):
selfdef expr_getattr(self, expr, _0, name):
selfdef expr_callmeth0(self, expr, _0, name, _1, _2):
selfdef expr_callmeth1(self, expr, _0, name, _1, arg1, _2):
selfdef expr_callmeth2(self, expr, _0, name, _1, arg1, _2, arg2, _3):
selfdef expr_callmeth3(self, expr, _0, name, _1, arg1, _2, arg2, _3, arg3, _4):
selfdef methkw_startname(self, expr, _0, methname, _1, argname, _2, argvalue):
selfdef methkw_startdict(self, expr, _0, methname, _1, _2, argvalue):
selfdef methkw_buildname(self, call, _0, argname, _1, argvalue):
selfdef methkw_builddict(self, call, _0, _1, argvalue):
selfdef methkw_finish(self, call, _0):
selfdef expr_getitem(self, expr, _0, key, _1):
selfdef expr_getslice12(self, expr, _0, index1, _1, index2, _2):
selfdef expr_getslice1(self, expr, _0, index1, _1, _2):
selfdef expr_getslice2(self, expr, _0, _1, index2, _2):
selfdef expr_neg(self, _0, expr):
selfdef expr_mul(self, obj1, _0, obj2):
selfdef expr_floordiv(self, obj1, _0, obj2):
selfdef expr_truediv(self, obj1, _0, obj2):
selfdef expr_mod(self, obj1, _0, obj2):
selfdef expr_add(self, obj1, _0, obj2):
selfdef expr_sub(self, obj1, _0, obj2):
selfdef expr_eq(self, obj1, _0, obj2):
selfdef expr_ne(self, obj1, _0, obj2):
selfdef expr_lt(self, obj1, _0, obj2):
selfdef expr_le(self, obj1, _0, obj2):
selfdef expr_gt(self, obj1, _0, obj2):
selfdef expr_ge(self, obj1, _0, obj2):
selfdef expr_contains(self, obj, _0, container):
selfdef expr_notcontains(self, obj, _0, _1, container):
selfdef expr_not(self, _0, expr):
selfdef expr_and(self, obj1, _0, obj2):
selfdef expr_or(self, obj1, _0, obj2):
selfdef expr_dropprecedence(self, expr):
selfclass ForParser(ExprParser):
def for0(self, iter, _0, cont):
selfdef for1(self, _0, iter, _1, _2, _3, cont):
selfdef for2a(self, _0, iter1, _1, iter2, _2, _3, cont):
selfdef for2b(self, _0, iter1, _1, iter2, _2, _3, _4, cont):
selfdef for3a(self, _0, iter1, _1, iter2, _2, iter3, _3, _4, cont):
selfdef for3b(self, _0, iter1, _1, iter2, _2, iter3, _3, _4, _5, cont):
selfclass StmtParser(ExprParser):
def stmt_assign(self, name, _0, value):
selfdef stmt_iadd(self, name, _0, value):
selfdef stmt_isub(self, name, _0, value):
selfdef stmt_imul(self, name, _0, value):
selfdef stmt_itruediv(self, name, _0, value):
selfdef stmt_ifloordiv(self, name, _0, value):
selfdef stmt_imod(self, name, _0, value):
selfdef stmt_del(self, _0, name):
selfclass RenderParser(ExprParser):
def emptyrender(self, template, _0, _1):
selfdef startrender(self, template, _0, argname, _1, argvalue):
selfdef startrenderupdate(self, template, _0, _1, arg):
selfdef buildrender(self, render, _0, argname, _1, argvalue):
selfdef buildrenderupdate(self, render, _0, _1, arg):
selfdef finishrender(self, render, _0):
selfdef finishrender1(self, render, _0, _1):
selfdef _repr(obj):
Helper for the repr function.
def _json(obj):
Helper for the json function.
def _oct(value):
Helper for the oct function.
def _csv(obj):
Helper for the csv function.
def _type(obj):
Helper for the type function.
def _mimeformat(obj):
Helper for the mimeformat method.
def _yearday(obj):
Helper for the yearday method.
def _isoformat(obj):
Helper for the isoformat method.