Package Martel :: Module Generate
[hide private]
[frames] | no frames]

Module Generate

source code

Classes [hide private]
  GeneratorState
  SetGroupValue
  HandleRepeatCount
  _call_calltag
  _call_call
  print_debug
Print debug information
  CheckAssertNot
  CheckAssert
  CheckGroupRef
  print_info
Print information after each expression match
Functions [hide private]
 
generate_alt(expression, genstate) source code
 
generate_seq(expression, genstate) source code
 
generate_literal(expression, genstate) source code
 
generate_str(expression, genstate) source code
 
generate_any(expression, genstate) source code
 
generate_group(expression, genstate) source code
 
generate_named_max_repeat(expression, genstate) source code
 
generate_max_repeat(expression, genstate) source code
 
generate_null_op(expression, genstate) source code
 
generate_debug(expression, genstate) source code
 
check_at_beginning(text, x, end) source code
 
generate_at_beginning(expression, genstate) source code
 
generate_at_end(expression, genstate) source code
 
generate_dot(expression, genstate) source code
 
generate_eol(expression, genstate) source code
 
check_assert_not(text, x, end, tagtable) source code
 
check_assert(text, x, end, tag_words) source code
 
generate_assert(expression, genstate) source code
 
generate_groupref(expression, genstate) source code
 
generate_pass_through(expression, genstate) source code
 
track_position(text, x, end)
store the start position of the farthest successful match
source code
 
_generate(expression, genstate) source code
 
generate(expression, debug_level=0)
expression -> Parser for the Expression tree
source code
 
generate_parser(expression, debug_level=0) source code
 
_find_wanted_groupref_names(expression)
expression -> dict of group names wanted by elements of the tree
source code
Variables [hide private]
  supports_lookahead = True
  _generate_count = 0
  generate_table = {Expression.Alt: generate_alt, Expression.Any...
  _position = -1
Function Details [hide private]

track_position(text, x, end)

source code 

store the start position of the farthest successful match

This value is more useful than mxTextTools' default, which only points out the last text region successfully tagged at the top level. This value is the last region successfully tagged anywhere.

Uses a global variable so this is SINGLE THREADED!

_find_wanted_groupref_names(expression)

source code 

expression -> dict of group names wanted by elements of the tree

The dict is used to during tagtable generation to specify which groups need to save their match text. There's match-time overhead for doing that, and the code isn't thread safe, so the intent is to save only those groups that are needed.

The dict value is 1 if the group name is needed, else there is no entry in the dict.

XXX need to make this a method!


Variables Details [hide private]

generate_table

Value:
{Expression.Alt: generate_alt, Expression.Any: generate_any, Expressio\
n.Assert: generate_assert, Expression.AtBeginning: generate_at_beginni\
ng, Expression.AtEnd: generate_at_end, Expression.Debug: generate_debu\
g, Expression.Dot: generate_dot, Expression.AnyEol: generate_eol, Expr\
ession.Group: generate_group, Expression.GroupRef: generate_groupref, \
Expression.Literal: generate_literal, Expression.MaxRepeat: generate_m\
ax_repeat, Expression.NullOp: generate_null_op, Expression.Seq: genera\
te_seq, Expression.Str: generate_str,}