Hello,

I'm trying to implement something like gmail-search where the user can
enter key:word or key:"more than one word" -> where the multiple words
are enclosed in double quotes (would like to remove that constraint if
possible, but I don't know enough of ANTLR to do that yet)

So far I have the following which correctly matches `description:"something"`:

    grammar Search;

    options {
        language=Python;
    }

    main
        : k=WORD ':' v=PHRASE { print $k.text, '=', $v.text }
        ;

    PHRASE
        : '"' WORD '"' { $text = $WORD.text }
        ;

    WORD
        : ( 'a'..'z' | 'A'..'Z' | '.' )+
        ;

    WHITESPACE
        :   (' '|'\t'|'\n'|'\r')+ { self.skip() }
        ;


The problem is that I'm unable to proceed from here. If I put

    PHRASE
        : '"' w=WORD+ '"' { $text = $w.text }
        ;


Then I get the following error:

    ANTLR Parser Generator  Version 3.1.1
    line 1:22 mismatched character u' ' expecting u'"'
    line 1:28 required (...)+ loop did not match anything at character '<EOF>'
    line 1:23 missing PHRASE at u'todo'
    description = <missing PHRASE>


I am not sure how to match a phrase as multiple words.

Any help would be greatly appreciated. Please be gentle on a newbie :-)

Regards,
Swaroop

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to