Tayra

Template. Script. Distribute

parser – LALR parser grammar

Parser grammer for Tayra Template Language. Parser is defined using PLY.

Module contents

class tayra.parser.TTLParser(compiler)[source]

Bases: builtins.object

Parser class for tayra template language. This class is initialized with tayra.compiler.TTLCompiler instance, and configuration options like, optimize, lex_debug, lextab, yacc_debug, yacctab, yacc_outputdir.

It might be a costly operation to create a TTLParser instance every time, and to avoid that use _initialize() method before starting off with a new template.

p_body(p)[source]

body : BODY NEWLINES

p_commentblock(p)[source]

commentblock : COMMENTOPEN COMMENTTEXT COMMENTCLOSE NEWLINES | COMMENTOPEN COMMENTCLOSE NEWLINES

p_commentline(p)[source]

commentline : COMMENTLINE NEWLINES

p_docytpe(p)[source]

doctype : DOCTYPE NEWLINES

p_elifblock_1(p)[source]

elifblock : ELIF NEWLINES INDENT script DEDENT

p_elifblock_2(p)[source]

elifblock : ELIF NEWLINES INDENT DEDENT

p_elseblock_1(p)[source]

elseblock : ELSE NEWLINES INDENT script DEDENT

p_elseblock_2(p)[source]

elseblock : ELSE NEWLINES INDENT DEDENT

p_filterblock_1(p)[source]

filterblock : FILTEROPEN NEWLINES filtertext FILTERCLOSE NEWLINES

p_filterblock_2(p)[source]

filterblock : FILTEROPEN NEWLINES FILTERCLOSE NEWLINES

p_filtertext(p)[source]

filtertext : FILTERTEXT NEWLINES | filtertext FILTERTEXT NEWLINES

p_forblock_1(p)[source]

forblock : FOR NEWLINES INDENT script DEDENT

p_forblock_2(p)[source]

forblock : FOR NEWLINES INDENT DEDENT

p_functionblock_1(p)[source]

functionblock : DECORATOR NEWLINES FUNCTION NEWLINES INDENT script DEDENT

p_functionblock_2(p)[source]

functionblock : DECORATOR NEWLINES FUNCTION NEWLINES INDENT DEDENT

p_functionblock_3(p)[source]

functionblock : FUNCTION NEWLINES INDENT script DEDENT

p_functionblock_4(p)[source]

functionblock : FUNCTION NEWLINES INDENT DEDENT

p_ifblock_1(p)[source]

ifblock : IF NEWLINES INDENT script DEDENT

p_ifblock_2(p)[source]

ifblock : IF NEWLINES INDENT DEDENT

p_ifelfiblock_1(p)[source]

ifelfiblock : ifblock

p_ifelfiblock_2(p)[source]

ifelfiblock : ifelfiblock elifblock

p_ifelfiblock_3(p)[source]

ifelfiblock : ifelfiblock elseblock

p_implement(p)[source]

implement : IMPLEMENT NEWLINES

p_importas(p)[source]

importas : IMPORT NEWLINES

p_inherit(p)[source]

inherit : INHERIT NEWLINES

p_interfaceblock_1(p)[source]

interfaceblock : INTERFACE NEWLINES INDENT script DEDENT

p_interfaceblock_2(p)[source]

interfaceblock : INTERFACE NEWLINES INDENT DEDENT

p_script_1(p)[source]

script : doctype | body | importas | inherit | implement | use | statement | tagline | commentline | tagblock | commentblock | textblock | textspan | filterblock | functionblock | interfaceblock | ifelfiblock | forblock | whileblock

p_script_2(p)[source]

script : script doctype | script body | script importas | script inherit | script implement | script use | script statement | script tagline | script commentline | script tagblock | script commentblock | script textblock | script textspan | script filterblock | script functionblock | script interfaceblock | script ifelfiblock | script forblock | script whileblock

p_statement(p)[source]

statement : STATEMENT NEWLINES

p_tagblock_1(p)[source]

tagblock : tagline INDENT script DEDENT

p_tagblock_2(p)[source]

tagblock : tagline INDENT DEDENT

p_tagline(p)[source]

tagline : tagspans NEWLINES

p_tagspans_1(p)[source]

tagspans : TAGBEGIN | TAGBEGIN text

p_tagspans_2(p)[source]

tagspans : tagspans TAGBEGIN | tagspans TAGBEGIN text

p_template_1(p)[source]

template : script

p_template_2(p)[source]

template :

p_text(p)[source]

text : TEXT | text TEXT

p_textblock_1(p)[source]

textblock : text NEWLINES

p_textblock_2(p)[source]

textblock : textblock text NEWLINES

p_textblock_3(p)[source]

textblock : textblock INDENT script DEDENT

p_textblock_4(p)[source]

textblock : textblock INDENT DEDENT

p_textspan(p)[source]

textspan : text tagspans NEWLINES

p_use(p)[source]

use : USE NEWLINES

p_whileblock_1(p)[source]

whileblock : WHILE NEWLINES INDENT script DEDENT

p_whileblock_2(p)[source]

whileblock : WHILE NEWLINES INDENT DEDENT

parse(text, ttlfile=None, debuglevel=0)[source]

Parse tayra templage text, text and return an AST tree. AST tree starts with a root node tayra.ast.Template. Every time the parser is invoked the lexer, yaccer, app options will be reused.

ttlfile
Name of the file being parsed (for meaningful error messages)
debuglevel
Debug level to yacc

Table Of Contents

Related Topics

This Page