help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Matching multiple rules


From: gnudev
Subject: Matching multiple rules
Date: Sat, 22 Sep 2001 15:09:02 +1000

Hi,

I am trying to write a grammar for an HTML-tag based programming tool, like
ColdFusion. ColdFusion tags look like this, for example the database query
tag:

<CFQUERY NAME="thequery" DATASOURCE="some_db">
SELECT * FROM some_tbl
ORDER BY id DESC
</CFQUERY>

I would like to write a grammar that allows a mixture of the "programming"
tags and ordinary HTML, plus other stuff, called "content."

How do I specify that there can be multiple tags?

For example, I have an echo tag which looks like this:

<!--#echo "text to echo">

And a tag that prints the date and time:

<!--#servertime>

I have a rule which says that a tag is a programming tag, or an HTML tag or
content. I have lumped HTML in with "content."

tag:    echo_tag
        | servertime_tag
        | content
    ;

I want a rule which says that an HTML file can be any number of these
"tags."

html_page:    tag                // one or more, no limit. How???
                ;

tag:    echo_tag
        | servertime_tag
        | content
    ;

I also have another problem. I need to be able to accumulate "content" into
a buffer, for example:

<!--#query name="thequery" datasource="somedb">
SELECT * FROM table
</query>


>From the way I have written the lexer, the "content" comes into the parser
one character at a time. How do I get it all in the same buffer, for example
with this rule:

query_tag:    OPENTAG NAMETAG '=' QUOTED_STR DATASOURCE '=' QUOTED_STR
                        CLOSETAG
                    {
                            // mumble
                    }
                    content
                    {
                            // get the SQL, send it to the database
                    }
                    CLOSEQUERY_TAG
                ;

Thanks!

James





reply via email to

[Prev in Thread] Current Thread [Next in Thread]