The parser below has the following positions on the recent discussions
(as the discussions are not yet final at this writing, any position
below is not final):
1. "any expression can be postfixed with () [] {}" - accept this proposal
2. ". as indentation whitespace LAWLZ TROLL3D U" - reject this proposal
3. "GROUP / SPLICE / ENLIST semantics and syntax" - merge GROUP and
SPLICE meanings, use "\" for SPLICE, reject current SPLICE rule 1
(SPLICE-at-the-eol), accept current SPLICE rules 2 (SPLICE-inline) and
3 (SPLICE-at-the-start), reject ENLIST.
4. Err this is the parser spec
5. "QUOTE WHITESPACE as abbreviation for quote symbol" - reject this proposal
6. "empty lines as expression delimiter" - disallow empty lines
inside top-level expressions, allow comment lines of any indentation
inside top-level expressions.
7. "top-level expression not at left edge" - DISABLE indentation
processing for next expression.
any-space -> SPACE | TAB | VTAB | FORMFEED | CR | LF | comment
; the core implementations here need to be
; factored out, as the sweet-expr parser needs
; to do similar processing when differentating
; between QUOTE SPACE and the QUOTE mdn-expr
; case.
mdn-expr -> QUOTE any-space* mdn-expr
(list 'quote $3)
mdn-expr -> QUASIQUOTE any-space* mdn-expr
(list 'quasiquote $3)
mdn-expr -> UNQUOTE any-space* mdn-expr
(list 'unquote $3)
mdn-expr -> UNQUOTE-SPLICING any-space* mdn-expr
(list 'unquote-splicing $3)
mdn-expr -> mdn-expr-post-quote
$1
mdn-expr-post-quote -> base-expr post-mdn-expr
($2 $1)
mdn-expr-post-quote -> base-expr
$1
post-mdn-expr -> post-mdn-expr-1 post-mdn-expr
(lambda (e) ($2 ($1 e)))
post-mdn-expr -> post-mdn-expr-1
$1
post-mdn-expr-1 -> list-notation
(lambda (e) (cons e $1))
post-mdn-expr-1 -> LBRACKET list-content RBRACKET
(lambda (e) (cons 'bracketaccess (cons e $2)))
post-mdn-expr-1 -> curly-infix
(lambda (e) (list e $1))
list-notation -> LPARENS list-content RPARENS
$2
; CONS = . i.e. the dotted-pair operator
list-content -> any-space* CONS any-space+ mdn-expr any-space*
$4
list-content -> any-space* mdn-expr list-content
(cons $2 $3)
list-content -> any-space*
'()
base-expr -> list-notation
$1
base-expr -> bracket-notation
$1
base-expr -> curly-infix
$1
; basically, these cases involve calling
; the built-in reader.
base-expr -> STRING
$1
base-expr -> NUMBER
$1
base-expr -> OTHER ; i.e. for #x reader
$1
base-expr -> SYMBOL
$1
; hook for language-specific bracket meanings
bracket-notation -> bracket-notation-scheme
$1
bracket-notation-scheme -> LBRACKET list-content RBRACKET
$2
bracket-notation-arc -> LBRACKET list-content RBRACKET
(list 'lambda (list '_) $2)
; ignore completely empty and comment lines at start of
; sweet expressions
swt-expr -> empty-line* swt-expr-core
$2
; some simple utility parsers
empty-line -> comment-or-hspace* eol
comment -> COMMENT-MARKER (not eol)*
comment-line -> hspace* comment eol
eol -> CR | LF
hspace -> SPACE | TAB | FORMFEED | VTAB
comment-or-hspace -> hspace | comment
; for exact indentation
; this part is tricky
(initial-indent ()) -> ; empty
(initial-indent ($1 . l)) -> (initial-indent l) hspace
; implements "whitespace at top-level
; DISABLES I-expressions"
swt-expr-core -> hspace+ mdn-expr
$2
; I-expressions must start at
; indent 0. Sorry dwheeler.
; Most consistent seems
; too complex or has other
; problems.
swt-expr-core -> (i-expr ())
$1
; implements dwheeler's spec fix.
(i-expr lvl) -> QUOTE hspace+ (i-expr lvl)
(list 'quote $3)
(i-expr lvl) -> QUASIQUOTE hspace+ (i-expr lvl)
(list 'quasiquote $3)
(i-expr lvl) -> UNQUOTE hspace+ (i-expr lvl)
(list 'unquote $3)
(i-expr lvl) -> UNQUOTE-SPLICING hspace+ (i-expr lvl)
(list 'unquote-splicing $3)
; NB: because of the hspace requirement,
; implementing the above means that we
; must take over some of mdn-expr's
; work; if after finding QUOTE et al.
; we DON'T find hspace, recurse into
; mdn-expr and add to the current head.
; merge of GROUP and SPLICE character.
(i-expr lvl) -> SPLICE head eol-comment-lines (body inlvl), if {lvl
perfect-tail-sublist-of inlvl}
(append $2 $4)
(i-expr lvl) -> SPLICE eol-comment-lines (body inlvl), if {lvl
perfect-tail-sublist-of inlvl}
$3
(i-expr lvl) -> SPLICE head eol-comment-lines
(if (= (length $2) 1)
(car $2)
$2)
(i-expr lvl) -> head eol-comment-lines (body inlvl), if {lvl
perfect-tail-sublist-of inlvl}
(append $1 $3)
(i-expr lvl) -> head eol-comment-lines
(if (= (length $1) 1)
(car $1)
$1)
; another simple utility parser
eol-comment-lines -> comment-or-hspace* eol comment-line*
head -> mdn-expr hspace* head
(cons $1 $3)
head -> mdn-expr
(list $1)
; body handles the final part of the
; new "splice" concept, viz., splice
; on same line
; NB: in the implementation, we expect body to ALSO return
; the indentation that initial-indent failed at, because of
; the one-char lookahead. Also in the implementation
; initial-indent probably returns the initial indent, not
; accept it as a parameter.
(body lvl) -> (initial-indent lvl) (sub-body lvl)
$2
(body lvl) -> ; empty
'()
(sub-body lvl) -> (i-expr lvl) hspace* SPLICE hspace* (sub-body lvl)
(cons $1 $5)
(sub-body lvl) -> (i-expr lvl) eol-comment-lines (body lvl)
(cons $1 $3)
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Readable-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/readable-discuss