parcon.railroad
index
/home/jcp/github/parcon/parcon/railroad/__init__.py

This module provides various classes for specifying what a particular syntax
diagram (a.k.a. railroad diagram) should look like.
 
The actual drawing of diagrams created with classes in this module is left up
to other modules included with Parcon in order to allow railroad diagrams that
look different to be created. The main one of these is the submodule raildraw,
which is a from-scratch railroad diagram drawing engine that can take a
railroad diagram as specified by classes in this module and convert it to a PNG
image.
 
Here's a really simple example that uses raildraw to draw a syntax diagram:
 
from parcon import First
# Create a parser to draw
some_parser = "Hello, " + First("world", "all you people")
Then draw a diagram of it.
some_parser.draw_railroad_to_png({}, "test.png")

 
Package Contents
       
raildraw
regex

 
Classes
       
__builtin__.object
Component
Bullet
Loop
Nothing
Or
Then
Token
Railroadable

 
class Bullet(Component)
    
Method resolution order:
Bullet
Component
__builtin__.object

Methods defined here:
__str__(self)
copy(self)

Methods inherited from Component:
__repr__(self)
optimize(self)

Data descriptors inherited from Component:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class Component(__builtin__.object)
     Methods defined here:
__repr__(self)
copy(self)
optimize(self)

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class Loop(Component)
    
Method resolution order:
Loop
Component
__builtin__.object

Methods defined here:
__init__(self, component, delimiter)
__str__(self)
copy(self)
optimize(self)

Methods inherited from Component:
__repr__(self)

Data descriptors inherited from Component:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class Nothing(Component)
    
Method resolution order:
Nothing
Component
__builtin__.object

Methods defined here:
__str__(self)
copy(self)

Methods inherited from Component:
__repr__(self)
optimize(self)

Data descriptors inherited from Component:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class Or(Component)
    
Method resolution order:
Or
Component
__builtin__.object

Methods defined here:
__init__(self, *constructs)
__str__(self)
copy(self)
optimize(self)

Methods inherited from Component:
__repr__(self)

Data descriptors inherited from Component:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class Railroadable(__builtin__.object)
    A class representing an object that can be drawn as a railroad diagram.
Most Parcon parsers subclass this class in addition to parcon.Parser.
 
  Methods defined here:
create_railroad(self, options)
draw_productions_to_png(self, options, filename, tail=[])
draw_railroad_to_png(self, options, filename)
Draws a syntax diagram for this object to the specified .png image file
using the specified options. For now, just pass {} (i.e. an empty
dictionary) as options; I'll document what this actually does at a
later date.
get_productions(self)

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Data and other attributes defined here:
railroad_children = []
railroad_production_delegate = None
railroad_production_name = None

 
class Then(Component)
    
Method resolution order:
Then
Component
__builtin__.object

Methods defined here:
__init__(self, *constructs)
__str__(self)
copy(self)
optimize(self)

Methods inherited from Component:
__repr__(self)

Data descriptors inherited from Component:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class Token(Component)
    
Method resolution order:
Token
Component
__builtin__.object

Methods defined here:
__init__(self, type, text)
__str__(self)
copy(self)

Methods inherited from Component:
__repr__(self)
optimize(self)

Data descriptors inherited from Component:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
Functions
       
create_railroad(value, options)
ensure_railroadable(value)

 
Data
        ANYCASE = 3
DESCRIPTION = 4
PRODUCTION = 1
TEXT = 2