Hello,

I have this grammar file:

grammar VCard;

@members {
    public static void main(String[] args) throws Exception {
        VCardLexer lex = new VCardLexer(new ANTLRFileStream(args[0]));
        CommonTokenStream tokens = new CommonTokenStream(lex);

        VCardParser parser = new VCardParser(tokens);

        try {
            parser.line();
        } catch (RecognitionException e)  {
            e.printStackTrace();
        }
    }
}

line
        : property=TOKEN subtoken=SUBTOKEN* DPOINT attribute=TOKEN
        {
                System.out.println ("Property: " + $property.text);
                System.out.println ("Attribute: " + $attribute.text);
                System.out.println ("Subtoken: " + $subtoken.text);

        }
        ;

TOKEN
        : (ALPHA | DIGIT)+
        ;
        
SUBTOKEN
        : SEMI TOKEN
        ;
        
WS      
        : ('\n' | ' ' | '\t')* {$channel=HIDDEN;}
        ;       

fragment DIGIT          
        : '0'..'9'
        ;
        
fragment ALPHA
        : 'a'..'z' | 'A'..'Z'
        ;
        
DPOINT
        : ':'
        ;
        
SEMI
        : ';'
        ;
        

And this input:

a;b;c;2:3a3bcde

This is the output:

Property: a
Attribute: 3a3bcde
Subtoken: ;2

What I like to get is:

Property: a
Subtoken: b
Subtoken: c
Subtoken: 2
Attribute: 3a3bcde

I couldn't find in the docs how to match multiple tokens that I get
from a * or + parser.

A second question is how to not include the ';' in the match.

I tried it for some time now, but I find no way. Could someone give me
an hint.

regards
Andreas

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