I agree with Russell. lex/yacc is the way to go. If you don't feel like learning those tools, writing a parser by hand really isn't hard, especially for such a simple grammar. I know all the textbooks say it's a no-no, but a recursive parser is way easier to write than a Finite State Machine, and should be sufficient for your needs, unless you're planning on using this for data serialization as opposed to user input.
On Wed, Jan 2, 2013 at 3:04 PM, Jim Bromer <[email protected]> wrote: > I don't see how that could be a difficult problem but I don't > really understand what it is that you are saying. What is the problem that > you think would give you trouble? How would integrating it into the > database be troublesome? > > On Tue, Jan 1, 2013 at 3:53 PM, Piaget Modeler > <[email protected]>wrote: > >> Hello all, >> I'm attempting to create parse trees for user input to the following >> simple grammar: >> *term := number | moment | string | symbol | scheme | collection* >> *number := #nnnn.nnn -- where n is a >> digit.* >> *moment := @nnnnnnnnnnnnnnnn -- where n is a digit* >> *string := $[ccccccc] -- where c >> is a character* >> *symbol := cccccccc -- where c >> is a character* >> *slot := ccccccccc ** -- >> where c is a character* >> *scheme := positional | slotted * >> *positional := symbol( term* ) -- where term **is >> zero or more & slot** * >> *slotted := symbol(slot:term* ) -- where slot & >> term pair is one or more.* >> *collection := sequence | concurrence | choice | cycle* >> *sequence := [ term* ] -- where [ ] >> are delimiters* >> *concurrence := ( term* ) -- where ( ) >> are delimiters* >> *choice := { term* } -- where { >> } are delimiters* >> *cycle := < term* > -- where < >> > are delimiters* >> >> After an input expression is parsed and a parse tree is generated, I'd >> like to be able to: >> (1) query the parse tree against a database >> (2) merge the parse tree into the database. >> Other requirements: The parse itself should be on the order of >> milliseconds. >> Your thoughts on approaches or tools is appreciated? >> ~PM >> >> ------------------------------------------------------------------------------------------------------------------------------------------------ >> *Confidential *- *This message is meant solely for the intended >> recipient. Please do not copy or forward this message without * >> *the consent of the sender. If you have received this message in error, >> please delete the message and notify the sender.* >> *AGI* | Archives <https://www.listbox.com/member/archive/303/=now> >> <https://www.listbox.com/member/archive/rss/303/10561250-470149cf> | >> Modify <https://www.listbox.com/member/?&> Your Subscription >> <http://www.listbox.com> >> > > *AGI* | Archives <https://www.listbox.com/member/archive/303/=now> > <https://www.listbox.com/member/archive/rss/303/23050605-2da819ff> | > Modify<https://www.listbox.com/member/?&>Your Subscription > <http://www.listbox.com> > ------------------------------------------- AGI Archives: https://www.listbox.com/member/archive/303/=now RSS Feed: https://www.listbox.com/member/archive/rss/303/21088071-f452e424 Modify Your Subscription: https://www.listbox.com/member/?member_id=21088071&id_secret=21088071-58d57657 Powered by Listbox: http://www.listbox.com
