Re: [Datadraw-user] BNF in 42
Brought to you by:
smilindog2000
From: Richard P. <rdp...@gm...> - 2008-12-28 16:29:46
|
Your are far more experienced then me regarding complex language parsing. I take your words for granted blindly. * I allow strings in the grammar rules to be lex-style regular expressions. What do you think?* That is what I wished. I was reading about LALR and it seems feasible. Is your example part of the same syntax of defining relationship and classes or a different syntax on a different file type? The good point about the previous was cleanness based on indentation... Although, I don't have anything wonderful to propose. Regards Richard On Sun, Dec 28, 2008 at 5:41 AM, Bill Cox <bi...@bi...> wrote: > Hi, Richard. > > I've written a ton of lex/yacc flex/bison based parsers. Here's one > thing I've found. Most formats are context sensitive. You just can't > parse them the easy way, but have to build a parse tree and then > traverse it manually to extract data. Icky, but true. This is > massively true for VHDL, even thought the Preface of the VHDL Language > Reference says it's not. It's even true for Verilog. Simple formats, > like Synopsys Liberty format, are massively context dependent. > > In 42, I figured I'd give up on allowing generic code to execute for > each matched rule, and just go ahead and build a parse tree for the > user. That separates all the application specific code from the grammar > definition, and should help make the grammars more reusable and easier > to read. > > I allow strings in the grammar rules to be lex-style regular > expressions. What do you think? > > The attached file is a grammar that I currently parse to build a parser > rule database. Then, I'm planning to write a BNF interpreter and > re-parse this file using the rules defined in the file. Once that > works, I was planning to start writing the rest of the core 42 parser in > 42 directly, and then start on the interpreter for it. When the > interpreter is running, I can start writing libraries to compile more > advanced 42 constructs into simpler code which can be directly written > out in C. Anyway, that's the plan... too bad the holidays wont last > forever - I'll probably have to get too focused on real work to make > much progress come January. > > Regards, > Bill > > Regards, > Bill > > > ------------------------------------------------------------------------------ > > _______________________________________________ > Datadraw-user mailing list > Dat...@li... > https://lists.sourceforge.net/lists/listinfo/datadraw-user > > |