[antlr-interest] With apologies for the list-spam, here's another question
    Terence Parr 
    parrt at cs.usfca.edu
       
    Mon Mar  1 10:48:59 PST 2004
    
    
  
On Feb 29, 2004, at 7:50 PM, offline314159 wrote:
> (note that this was foolishly asked in my other thread, little was i
> thinking -- since most people wisely skip the "thanks, d00d" messages.
>  I apologize to all the people who DID read it, and thank you all for
> your patience, which i won't try anymore:  on with the message!)
>
> The input for my parser may consist of "folded" text - basically, some
> lines that are beyond a reasonable length will be wrapped with leading
> whitespace indicating that their values are to be unfolded and treated
> as all one piece.
>
> So how do i look for that? I was originally handling it by filtering
> the input, but that was messing with my linefeeds and CRs, so i'd like
> to handle it in the parser. Essentially what i want is to return a
> single token, call it VALUE, that takes everything from the first ":"
> on a line to the first ENDL character that is not followed by some
> whitespace.
>
> Can this even be done?
Sure.  What's the indicator that you've gone beyond a "reasonable 
length"?  Just add code to the NEWLINE rule:
NEWLINE
     :   '\n' {newline();}
         ( {getColumn()>MAX}? (' '|'\t')+ {$setType(Token.SKIP);})?
     ;
This will ignore newline followed by whitespace if newline is beyond 
MAX column. :)
Ter		
--
Professor Comp. Sci., University of San Francisco
Creator, ANTLR Parser Generator, http://www.antlr.org
Cofounder, http://www.jguru.com
Cofounder, http://www.knowspam.net enjoy email again!
Cofounder, http://www.peerscope.com pure link sharing
 
Yahoo! Groups Links
<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
     antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/
 
    
    
More information about the antlr-interest
mailing list