Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
libuavcan_dsdl_compiler.pyratemp.Parser Class Reference
Inheritance diagram for libuavcan_dsdl_compiler.pyratemp.Parser:
Inheritance graph
[legend]

Public Member Functions

def __init__ (self, loadfunc=None, testexpr=None, escape=HTML)
 
def parse (self, template)
 

Public Attributes

 escape
 

Private Member Functions

def _errpos (self, fpos)
 
def _parse (self, template, fpos=0)
 
def _parse_sub (self, parsetree, text, fpos=0)
 
def _testexpr (self, expr, fpos=0)
 

Private Attributes

 _includestack
 
 _load
 
 _testexprfunc
 

Static Private Attributes

string _block_end = ")-->"
 
string _block_start = "<!--("
 
string _comment_end = "!#"
 
string _comment_start = "#!"
 
 _e = re.escape(_block_end)
 
 _reBlock = re.compile(_strBlock, re.X|re.M)
 
 _reComment = re.compile(_strComment, re.M)
 
 _reForParam = re.compile(_strForParam)
 
 _reMacroParam = re.compile()
 
 _reSubstitution = re.compile(_strSubstitution, re.X|re.M)
 
 _s = re.escape(_block_start)
 
string _strBlock
 
string _strComment = r"""%s(?P<content>.*?)(?P<end>%s|\n|$)""" \
 
string _strForParam = r"""^(?P<names>\w+(?:\s*,\s*\w+)*)\s+in\s+(?P<iter>.+)$"""
 
string _strSubstitution
 
string _sub_end = "!$"
 
string _sub_start = "$!"
 
string _subesc_end = "!@"
 
string _subesc_start = "@!"
 

Detailed Description

Parse a template into a parse-tree.

Includes a syntax-check, an optional expression-check and verbose
error-messages.

See documentation for a description of the parse-tree.

Definition at line 432 of file pyratemp.py.

Constructor & Destructor Documentation

◆ __init__()

def libuavcan_dsdl_compiler.pyratemp.Parser.__init__ (   self,
  loadfunc = None,
  testexpr = None,
  escape = HTML 
)
Init the parser.

:Parameters:
    - `loadfunc`: function to load included templates
      (i.e. ``LoaderFile(...).load``)
    - `testexpr`: function to test if a template-expressions is valid
      (i.e. ``EvalPseudoSandbox().compile``)
    - `escape`:   default-escaping (may be modified by the template)
:Exceptions:
    - `ValueError`: if `testexpr` or `escape` is invalid.

Definition at line 510 of file pyratemp.py.

Member Function Documentation

◆ _errpos()

def libuavcan_dsdl_compiler.pyratemp.Parser._errpos (   self,
  fpos 
)
private
Convert `fpos` to ``(filename,row,column)`` for error-messages.

Definition at line 555 of file pyratemp.py.

◆ _parse()

def libuavcan_dsdl_compiler.pyratemp.Parser._parse (   self,
  template,
  fpos = 0 
)
private
Recursive part of `parse()`.

:Parameters:
    - template
    - fpos: position of ``template`` in the complete template (for error-messages)

Definition at line 599 of file pyratemp.py.

◆ _parse_sub()

def libuavcan_dsdl_compiler.pyratemp.Parser._parse_sub (   self,
  parsetree,
  text,
  fpos = 0 
)
private
Parse substitutions, and append them to the parse-tree.

Additionally, remove comments.

Definition at line 567 of file pyratemp.py.

◆ _testexpr()

def libuavcan_dsdl_compiler.pyratemp.Parser._testexpr (   self,
  expr,
  fpos = 0 
)
private
Test a template-expression to detect errors.

Definition at line 560 of file pyratemp.py.

◆ parse()

def libuavcan_dsdl_compiler.pyratemp.Parser.parse (   self,
  template 
)
Parse a template.

:Parameters:
    - `template`: template-unicode-string
:Returns:         the resulting parse-tree
:Exceptions:
    - `TemplateSyntaxError`: for template-syntax-errors
    - `TemplateIncludeError`: if template-inclusion failed
    - `TemplateException`

Definition at line 541 of file pyratemp.py.

Member Data Documentation

◆ _block_end

string libuavcan_dsdl_compiler.pyratemp.Parser._block_end = ")-->"
staticprivate

Definition at line 448 of file pyratemp.py.

◆ _block_start

string libuavcan_dsdl_compiler.pyratemp.Parser._block_start = "<!--("
staticprivate

Definition at line 447 of file pyratemp.py.

◆ _comment_end

string libuavcan_dsdl_compiler.pyratemp.Parser._comment_end = "!#"
staticprivate

Definition at line 442 of file pyratemp.py.

◆ _comment_start

string libuavcan_dsdl_compiler.pyratemp.Parser._comment_start = "#!"
staticprivate

Definition at line 441 of file pyratemp.py.

◆ _e

libuavcan_dsdl_compiler.pyratemp.Parser._e = re.escape(_block_end)
staticprivate

Definition at line 480 of file pyratemp.py.

◆ _includestack

libuavcan_dsdl_compiler.pyratemp.Parser._includestack
private

Definition at line 539 of file pyratemp.py.

◆ _load

libuavcan_dsdl_compiler.pyratemp.Parser._load
private

Definition at line 523 of file pyratemp.py.

◆ _reBlock

libuavcan_dsdl_compiler.pyratemp.Parser._reBlock = re.compile(_strBlock, re.X|re.M)
staticprivate

Definition at line 500 of file pyratemp.py.

◆ _reComment

libuavcan_dsdl_compiler.pyratemp.Parser._reComment = re.compile(_strComment, re.M)
staticprivate

Definition at line 455 of file pyratemp.py.

◆ _reForParam

libuavcan_dsdl_compiler.pyratemp.Parser._reForParam = re.compile(_strForParam)
staticprivate

Definition at line 504 of file pyratemp.py.

◆ _reMacroParam

libuavcan_dsdl_compiler.pyratemp.Parser._reMacroParam = re.compile()
staticprivate

Definition at line 507 of file pyratemp.py.

◆ _reSubstitution

libuavcan_dsdl_compiler.pyratemp.Parser._reSubstitution = re.compile(_strSubstitution, re.X|re.M)
staticprivate

Definition at line 467 of file pyratemp.py.

◆ _s

libuavcan_dsdl_compiler.pyratemp.Parser._s = re.escape(_block_start)
staticprivate

Definition at line 479 of file pyratemp.py.

◆ _strBlock

string libuavcan_dsdl_compiler.pyratemp.Parser._strBlock
staticprivate
Initial value:
= r"""
^(?P<mEnd>[ \t]*)%send%s(?P<meIgnored>.*)\r?\n? # multi-line end (^ <!--(end)-->IGNORED_TEXT\n)
|
(?P<sEnd>)%send%s # single-line end (<!--(end)-->)
|
(?P<sSpace>[ \t]*) # single-line tag (no nesting)
%s(?P<sKeyw>\w+)[ \t]*(?P<sParam>.*?)%s
(?P<sContent>.*?)
(?=(?:%s.*?%s.*?)??%send%s) # (match until end or i.e. <!--(elif/else...)-->)
|
# multi-line tag, nested by whitespace indentation
^(?P<indent>[ \t]*) # save indentation of start tag
%s(?P<mKeyw>\w+)\s*(?P<mParam>.*?)%s(?P<mIgnored>.*)\r?\n
(?P<mContent>(?:.*\n)*?)
(?=(?P=indent)%s(?:.|\s)*?%s) # match indentation
""" % (_s, _e,
_s, _e,
_s, _e, _s, _e, _s, _e,
_s, _e, _s, _e)

Definition at line 481 of file pyratemp.py.

◆ _strComment

string libuavcan_dsdl_compiler.pyratemp.Parser._strComment = r"""%s(?P<content>.*?)(?P<end>%s|\n|$)""" \
staticprivate

Definition at line 453 of file pyratemp.py.

◆ _strForParam

string libuavcan_dsdl_compiler.pyratemp.Parser._strForParam = r"""^(?P<names>\w+(?:\s*,\s*\w+)*)\s+in\s+(?P<iter>.+)$"""
staticprivate

Definition at line 503 of file pyratemp.py.

◆ _strSubstitution

string libuavcan_dsdl_compiler.pyratemp.Parser._strSubstitution
staticprivate
Initial value:
= r"""
(
%s\s*(?P<sub>.*?)\s*(?P<end>%s|$) #substitution
|
%s\s*(?P<escsub>.*?)\s*(?P<escend>%s|$) #escaped substitution
)
""" % (re.escape(_sub_start), re.escape(_sub_end),
re.escape(_subesc_start), re.escape(_subesc_end))

Definition at line 459 of file pyratemp.py.

◆ _sub_end

string libuavcan_dsdl_compiler.pyratemp.Parser._sub_end = "!$"
staticprivate

Definition at line 444 of file pyratemp.py.

◆ _sub_start

string libuavcan_dsdl_compiler.pyratemp.Parser._sub_start = "$!"
staticprivate

Definition at line 443 of file pyratemp.py.

◆ _subesc_end

string libuavcan_dsdl_compiler.pyratemp.Parser._subesc_end = "!@"
staticprivate

Definition at line 446 of file pyratemp.py.

◆ _subesc_start

string libuavcan_dsdl_compiler.pyratemp.Parser._subesc_start = "@!"
staticprivate

Definition at line 445 of file pyratemp.py.

◆ _testexprfunc

libuavcan_dsdl_compiler.pyratemp.Parser._testexprfunc
private

Definition at line 528 of file pyratemp.py.

◆ escape

libuavcan_dsdl_compiler.pyratemp.Parser.escape

Definition at line 538 of file pyratemp.py.


The documentation for this class was generated from the following file:


uavcan_communicator
Author(s):
autogenerated on Fri Dec 13 2024 03:10:04