Below is an extracted ANTLR description of sweet-expressions.  "n_expr_first" 
is an n-expression that doesn't match an abbreviation followed by a horizontal 
space (hspace, aka space or tab).  See the "devel" branch for the whole thing.

Thoughts? Comments?  It's like to have some errors, and certainly has some 
omissions.

I'm not sure how to handle #|...|# at top level when nothing else on line - it 
needs to be skipped and completely ignored.  Suggestions welcome.


--- David A. Wheeler

=======================================================


abbrevh                 :       APOSH | QUASIQUOTEH | UNQUOTE_SPLICEH | 
UNQUOTEH;
abbrev_noh              : APOS | QUASIQUOTE | UNQUOTE_SPLICE | UNQUOTE ;
abbrev_all              : abbrevh | abbrev_noh;
splice  :       GROUP;  // Use this synonym to make its purpose clearer.
sublist :       DOLLAR; // Use this synonym to make its purpose clearer.

// Whitespace & indentation names
ichar   : SPACE | TAB | BANG ; // indent char
hspace  : SPACE | TAB ;        // horizontal space

wspace  : hspace;  // or eolchars

// Read in ;comment (if exists), followed by EOL.  On a non-tokeninzing parser,
// this may reset indent as part of EOL processing.
eol_comment_lines : LCOMMENT? EOL;

// The "head" is the production for 1+ n-expressions on one line; it will
// return the list of n-expressions on the line.

head    :       n_expr_first hspace* rest;

// The "rest" production reads the rest of the expressions on a line ("rest of 
the head"),
// after the first expression of the line.

rest    : PERIOD hspace+ n_expr hspace* /* improper list.  Error if n_expr at 
this point */
        | BLOCK_COMMENT hspace* rest
        | DATUM_COMMENT_START hspace* n_expr hspace* rest  // Ignore the next 
datum
        | n_expr hspace* rest
        | /* empty: ; eol */;

// body handles the sequence of 1+ child lines in an i_expr.

body    :        i_expr (SAME body | DEDENT);

i_expr : head ( splice hspace* (i_expr | eol_comment_lines (INDENT body)?)
              | DOLLAR hspace* (i_expr | eol_comment_lines (INDENT body)?)
              | eol_comment_lines (INDENT body)?
              ) // child lines
         | (GROUP | BLOCK_COMMENT) hspace* (i_expr | eol_comment_lines INDENT 
body)
         | DOLLAR hspace* (i_expr | eol_comment_lines INDENT body)
         | abbrevh hspace* i_expr;

t_expr  : i_expr
        | eol_comment_lines t_expr
        | hspace+ (n_expr /* indent processing disabled */
                   | eol_comment_lines t_expr /* try again */
                   | BANG /* error */)
        | BANG /* error */
        | EOF;



------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
Readable-discuss mailing list
Readable-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/readable-discuss

Reply via email to