Module containing Terminal and Non-terminal definitions.
The AST tree is constructed according to the parser-grammar defined in tayra.parser. From the root non-terminal use the children() method on every node to walk through the tree.
Bases: builtins.object
Base class for all Terminal and Non-terminal nodes. Initialize parent object on the node.
Bubble up value value to the root node and save that as its attribute attrname
Same as bubbleup(), but instead of assigning the value to attrname, it is appended to the list.
Return a tuple of children for this node in the same order as parsed by the grammar rule. Must always be overriden by the deriving class.
Simply dump the contents of this node and its children node and return the same.
Code generation phase. The result must be an executable python script
Strip the leftmost chars from the Terminal nodes. Each terminal node must return remaining characters. In case of the Non-terminal node, call all the children node’s lstrip() method, until the caller recieves a non-empty return value.
Immediate non-terminal parent node.
tayra.parser.TTLParser instance.
Strip the rightmost chars from the Terminal nodes. Each terminal node must return remaining characters. In case of the Non-terminal node, call all the children node’s rstrip() method, until the caller recieves a non-empty return value.
Pretty print the Node and all its attributes and children (recursively) to a buffer.
Bases: tayra.ast.Node
Abstract base class for all terminal nodes. Initialize terminal attribute
Simply dump the contents of this node and its children node and return the same.
Line number reference where the node starts in the text. Useful in debug mode.
Strip off the leftmost characters from the terminal string. Return the remaining characters.
Strip off the rightmost characters from the terminal string. Return the remaining characters.
Pretty print the Node and all its attributes and children (recursively) to a buffer.
Terminal’s token String.
Bases: tayra.ast.Node
Abstract base class for all non-terminalnodes. Initialize _terms and _nonterms
List of NonTerminal nodes under this node.
Instead of recursing through left-recursive grammar, flatten them into sequential list for looping on them later.
Generate control blocks, if-elif-else, for and while loops.
Generate function block for @def and @interface.
class to handle doctype grammar. Note that DTDs are deprecated in HTML5. We will have to wait and see how it evolves under HTML5.
ttl doctype name | Transted to html |
---|---|
html4.01transitional | <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd“> |
html4.01strict | <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd“> |
html4.01frameset | <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Frameset//EN” “http://www.w3.org/TR/html4/frameset.dtd“> |
xhtml1.0transitional | <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/ xhtml1-transitional.dtd”> |
xhtml1.0strict | <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/ xhtml1-strict.dtd”> |
xhtml1.0frameset | <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Frameset//EN” “http://www.w3.org/TR/xhtml1/DTD/ xhtml1-frameset.dtd”> |
xhtml1.1 | <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.1//EN” “http://www.w3.org/TR/xhtml11/DTD/
|
xhtml1.1basic | <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML Basic 1.1//EN” “http://www.w3.org/TR/xhtml-basic/ xhtml-basic11.dtd”> |
xhtml1.1mobile | <!DOCTYPE html PUBLIC “-//WAPFORUM//DTD XHTML Mobile 1.2//EN” “http://www.openmobilealliance.org/tech/DTD/ xhtml-mobile12.dtd”> |
xhtml+rdfa1.0 | <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML+RDFa 1.0//EN” “http://www.w3.org/MarkUp/DTD/ xhtml-rdfa-1.dtd”> |
html | <!DOCTYPE html> |