|Runtime syntax Dhruva.Krishnamurthy@in.bosch.com (Dhruva Krishnamurthy) (2004-12-25)|
|Re: Runtime syntax email@example.com (Dmitry A. Kazakov) (2004-12-29)|
|Re: Runtime syntax firstname.lastname@example.org (2004-12-29)|
|Runtime Syntax email@example.com (2004-12-29)|
|From:||firstname.lastname@example.org (Cedric LEMAIRE)|
|Date:||29 Dec 2004 01:40:33 -0500|
|Posted-Date:||29 Dec 2004 01:40:33 EST|
> We are trying to support text parsers for slightly differing
> syntax. I was looking at developing an engine where we can supply the
> grammar at runtime. I know Yacc/Bison is at compile time, is there
> some project/working proof of concept to achieve this? Any help is
If you are working in C++, you can use the C++ runtime library of
CodeWorker (distributed under LGPL and available at
"http://www.codeworker.org"). It is both a parser interpretor and a
source code generator. The extended-BNF parse scripts can be changed
If you just have to select a grammar amongst some already written and
frozen, the selection depending on a pre-analysis of the text for
instance, and the grammars being almost the same, you can:
- isolate the common BNF rules in a CW parse script, and then
include them in each grammar, which will then add their specific
specific_rule_1 ::= ...;
- overload some of the common BNF rules ('
// in "common-rules.cwp", somewhere:
procedure_call // a non-terminal
assignment // another non-terminal
// important part of this rule:
// read an identifier and put it into the
// variable 'sKeyword'
// call of a template-like rule:
// if sKeyword is worth 'while', the BNF rule
// statement_keyword<"while"> should have been defined
// in one of the particular grammars:
// add of a new statement, the C-like 'for'
'(' expression ';' expression ';' expression ')'
If you want to improve the speed of parsing, you can translate the CW
parse scripts to C++, using the switch '-c++' on the command line, and
then link them with a C++ applicaton.
I have already applied these features for recognizing short Financial
news: each time a new sentence template was appearing, its BNF
expression was added to the grammar in charge of detecting interesting
news. The improvements were applied dynamically: the grammar was
changing at runtime, which isn't what you are looking for, but which
is implemented similarly in the BNF scripts. The parse tree was just
holding the semantic data resulting of the sentence analysis.
But why to rewrite a new engine? If CodeWorker doesn't suit you, I'm
sure it exists some other tools that should answer your needs.
Return to the
Search the comp.compilers archives again.