[antlr-interest] File spec grammar
jbb at acm.org
jbb at acm.org
Sat Apr 10 16:04:03 PDT 2004
Mr. Lischke :-
You asked:
>Does anybody have an ANTLR grammar to fully parse a file name? I
>tried several approaches but either got ambiguities or had to
>simplify the grammar so much that I cannot differentiate anymore
>between path parts and file names. Is it at all possible to parse a
>file name using EBNF?
I haven't actually tried this using Antlr but how about:
filename :
( '/' | "./" | "../" | "~/" )? name ( '/' name )*
;
name :
( character | '.' ) ( character | '.' )*
;
character : LETTER | DIGIT | SPECIAL ;
LETTER : 'a' .. 'z' | 'A' .. 'Z' ;
DIGIT : '0' .. '9' ;
SPECIAL : '_' | '~' | ',' | ' ' | '+' | '-' ; // and probably more here...
and you did mean unix filenames, right?
hope this helps...
-jbb
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