[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: SEUL: Parsely announcements: Draft 1
Here are some comments; I hope you find them useful. Unquoted (>) text
indicates either modifications or questions. I hope to write more in the
next day or so.
Very neat project, by the way. :)
> Hello, all. Here are the first drafts of some announcements I want to
> send out about my project, Parsely. (See http://parsely.seul.org/).
> If you have time, I'd like feedback about the announcements. I'm
> aiming and hackers and developers here -- I want them as interested as
> I've also got some specific questions about specific parts of the
> announcements. I've marked them with "***", and put them on separate
> Many thanks,
> ================================================================1 Line
> Parsely: A tool for writing configuration tools
> Parsely: A cross-language tool for parsing and file manipulation
> Parsely: A cross-language tool for configuration file parsing and
> ***Which, if any, is best?
Parsely: A programmer's tool for parsing and manipulating configuration
Parsely is a general framework for writing configuration tools.
It exposes programmer-friendly interfaces to nearly any text-based file
format, so workable applications can be rapidly made by providing the
front-ends. Parsely manipulates configuration files without disturbing
whitespace or formatting.
Python/pcre/SPARK support is complete, alpha-tested and ready for a
public beta. C/flex/Bison support is 50% done, and should be available
for testing by the end of May.
Although Parsely is not a complete configuration tool by itself, it makes
the development of effective general configuration programs a real
possibility. Current configuration format grammars include C, flex and
Bison, although many others are possible.
> Finally, I want to mention that it's cross-language and
> cross-scanner, and cross-parser. This also eludes me.]
[I am unclear as to what "cross-scanner" and "cross-parser" mean.]
> ***Which details are gratuitous? [Perhaps the pcre/SPARK/flex/Bison
> stuff... but I want people to know it isn't a new parser, but
> an interface to all the old parsers.]
> ***How can I make the right people want to hack this?
> ANNOUNCEMENT: Parsely 0.1.0
Parsely is a general framework for programmers writing configuration
tools. It exposes programmer-friendly interfaces to various file
formats, so that all you need to write are the front-end.
> Here's how it works:
> 1. You, the programmer, decide you want to write a tool that
> manipulates a given file format.
> 2. You write a grammar file describing the file format. For a set
> of extremely simple examples, look in tests/*.ply.
> 3. Parsely reads the grammar file, and writes a scanner/parser for
> you in the language of your choice. (Python support is
> complete; C support is about 50% done. C++ and perl are down
> the pipe.)
> 4. Later, your program can use the generated scanner to parse
> files into an easily-manipulated tree structure. It can examine
> and modify the tree structure, and later write its changes back
> out to disk, preserving all comments and formatting.
> Parsely doesn't try to reinvent the wheel; it interfaces with scanner-
> and parser- generators like flex and bison, rather than trying to
> generate efficient C scanners and parsers itself.
> Parsely is written and documented. You can download Parsely or browse
> its documentation at http://parsely.seul.org
> Please be aware that this is a hackers-only release: you'll probably
> need to know a fair amount about Python to get it to work.
> ***I should write a feature list here. Which features from the web page/
> documentation seem most interesting to you?
> ***Should this section be here? Is it enabling or intimidating?
Examples are good, IMO./
> Suppose you want to write an interface to files that look like this:
> # (save this file as 'kvl.example')
> # Comment
> Key2 = "A string"
> Key3= val2
> # and so on....
> You start by writing a file description. (The format is explained
> more fully in the documentation.)
> # (save this file as 'kvl.ply')
> # First, you list all the tokens you care about.
> token '[';
> token ']';
> token '\n';
> token '=';
> token Word = m/\w+/; # We proudly support Perl's regular expressions!
> token String = m/"([^"]|\\")*"/;
> # Next, you list the kinds of space that appear in the file.
> space /\s+/;
> space /#.*$/; # Comments count as space too.
> default space ''; # By default, don't insert space.
> # Last, you write a grammar for the file as a whole:
> start File;
> File = Section *;
> Section = OptNewlines '[' Word:name ']' Newlines Lines:body ;
> Lines = Line * ;
> Line = Word:key '=' Word:val Newlines |
> Word:key '=' String:val Newlines ;
> Newlines = '\n' +;
> OptNewlines = '\n' *;
> Once you've written the file description, you can use Python to parse
> and manipulate this kind of files. In reality, you'd want to do this
> behind a GUI, but we'll do a small example below:
> import parsely
> # Load the file format.
> kvl_format = parsely.loadFormat('kvl')
> # Read the example file
> file = kvl_format.parseFile('kvl.example')
> # Change the name of the second section
> file.name = 'NewName'
> # Insert a new entry into the first section
> ('NewKey', '=', 'NewVal', '\n'), ''))
Is this staggered spacing intended?
> # Change the value of the first entry
> file.body.val = 'modifiedvalue'
> # Write the file back to disk
> Once you're done, the new file will reflect your changes, but be
> otherwise identical:
> # Comment
> Key2 = "A string"
> Key3= val2
> # and so on....
> PENDING TASKS and CALL FOR HACKERS:
> Parsely is alpha software! I'm trying to finish my Master's thesis
> now, but I should have a few hours here and there to hack on
> Parsely. These are the tasks I hope to accomplish first.
> * There needs to be a real build and install process. Right now,
> this tool is hackers-only.
> * The documentation could use fleshing out.
> * We need more examples.
> * File includes need to work properly.
> * There needs to be C support.
> * I need testers to help push me towards a stable release.
> Most of all, I need good GUI hackers to help write graphical frontends
> for the backends Parsely provides. Give Parsely a try in your own
> configuration project! If you can't get it working yourself, drop me a
> line, and I'll help you write the .ply files and the the syntax
> manipulation code.
> Parsely has the flexibility to handle everything from simple Key-value
> files to XF86Config to bash and tcsh configurations. It can probably
> help with your project too.
> (In fact, it wouldn't be too hard to write a module to parse
> sendmail.cf, if only I knew what to do with it...)
> FOR MORE INFORMATION:
> Please feel free to email me at email@example.com, or see the Parsely web
> page at <http://www.parsely.org/> for screenshots, documentation, and
> a mailinglist.
> *** What else do I need to say?
Pete St. Onge