Rational Rose ".ptl" file parsing?
Mike C. Fletcher
mcfletch at rogers.com
Mon Jun 16 14:44:06 EDT 2003
Well, the "lisp.py" example from simpleparse seems to parse it fine, but
all you get out is a set of "name", "string", "list" and "number"
records (in a tree) (i.e. the parser's just giving you what lisp
structures were found). You'd have to interpret the results yourself
regarding what each name is *meaning*.
The grammar is pretty simple from what you've shown, you could probably
hand-code it as easily as using a parser.
Enjoy yourself,
Mike
Here's what you get on a small sample string (note that everything below
"float" is ignorable in most cases):
success '(object Design "Logical View"\n is_unit \tTRUE\n
is_loaded \t(test this 2.3456))' 86
'list' : '(object Design "Logical View"\n is_unit \tTRUE\n
i... (0, 86)
| 'name' : 'object' (1, 7)
| 'name' : 'Design' (8, 14)
| 'string_double_quote... : '"Logical View"' (15, 29)
| | 'char_no_quote' : 'Logical View' (16, 28)
| 'name' : 'is_unit' (34, 41)
| 'name' : 'TRUE' (46, 50)
| 'name' : 'is_loaded' (55, 64)
| 'list' : '(test this 2.3456)' (67, 85)
| | 'name' : 'test' (68, 72)
| | 'name' : 'this' (73, 77)
| | 'number_expr' : '2.3456' (78, 84)
| | | 'number' : '2.3456' (78, 84)
| | | | 'float' : '2.3456' (78, 84)
| | | | | 'explicit_base' : '2.3456' (78, 84)
| | | | | | 'int_unsigned' : '2' (78, 79)
| | | | | | 'decimal_fraction' : '.3456' (79, 84)
| | | | | | | 'int_unsigned' : '3456' (80, 84)
Harry George wrote:
>Anyone have a handy parser for the RatRose .ptl file format? Want to
>get it into an object tree reasonable naming convetions. Iwas going
>to do this with shlex, but I'd go with anything already working. It
>occurs to me that this is fairly lispish, so "readlisp.py" is another
>candidate.
>
>
...
_______________________________________
Mike C. Fletcher
Designer, VR Plumber, Coder
http://members.rogers.com/mcfletch/
More information about the Python-list
mailing list