Skip to content

Commit

Permalink
Added lexical syntax for immutable texts (ticket #788).
Browse files Browse the repository at this point in the history
  • Loading branch information
WillClinger committed Jul 26, 2017
1 parent 57f30dc commit bbe33ff
Show file tree
Hide file tree
Showing 6 changed files with 1,259 additions and 1,046 deletions.
4 changes: 2 additions & 2 deletions src/Lib/Common/larceny.pg
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ boolean
number
character
string
text
lparen
rparen
lbracket
Expand Down Expand Up @@ -61,6 +62,7 @@ xstring
::= xfaslc #makeCompnum
::= xfaslf #makeFlonum
::= character #makeChar
::= text #makeText
::= string #makeString
::= xstring #makeXString
::= id #makeSym
Expand All @@ -72,8 +74,6 @@ xstring
<structured> ::= <list> #identity
::= <vector> #identity
::= <bytevector> #identity
<string> ::= string #makeString
::= xstring #makeXString
<symbol> ::= id #makeSym
<list> ::= lparen <list2> #identity
::= lbracket <blst2> #identity
Expand Down
46 changes: 35 additions & 11 deletions src/Lib/Common/larcenyTokens.sch
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,6 @@
(lambda (c)
(and (char? c)
(char<=? c (integer->char 127)))))
(isAsciiNotVbar
(lambda (c)
(and (char? c)
(char<=? c (integer->char 127))
(not (char=? c #\|)))))
(isAsciiNotDoublequote
(lambda (c)
(and (char? c)
(char<=? c (integer->char 127))
(not (char=? c #\")))))
(isNotNewline
(lambda (c)
(and (char? c)
Expand All @@ -70,6 +60,23 @@
(and (char? c)
(not (char=? c #\|))
(not (char=? c #\\)))))
(isLeftDoubleAngleQuote
(lambda (c)
(and (char? c)
(char=? c (integer->char #x00ab)))))
(isRightDoubleAngleQuote
(lambda (c)
(and (char? c)
(char=? c (integer->char #x00bb)))))
(isNotRightDoubleAngleQuote
(lambda (c)
(and (char? c)
(not (char=? c (integer->char #x00bb))))))
(isNotDoublequote
(lambda (c)
(and (char? c)
(char<=? c (integer->char 127))
(not (char=? c #\")))))
(isZsZlZp
(lambda (c)
(and (char? c) (char-whitespace? c))))
Expand Down Expand Up @@ -622,15 +629,32 @@
(* (! (! #\linefeed #\return (#\return #\linefeed)
isNel (#\return isNel) isLS)
(#\\ (! #\a #\b #\t #\n #\v #\f #\r #\" #\\
isLeftDoubleAngleQuote isRightDoubleAngleQuote
(! #\linefeed #\return (#\return #\linefeed)
isNel (#\return isNel) isLS)
#\space
(#\x (! %0..9 %a..f %A..F)
(* (! %0..9 %a..f %A..F)))
isChar)) ; anything can be escaped
isChar))
isNotDoubleQuote))
#\"))

; Same as string except for opening and closing quotes.

(text (isLeftDoubleAngleQuote
(* (! (! #\linefeed #\return (#\return #\linefeed)
isNel (#\return isNel) isLS)
(#\\ (! #\a #\b #\t #\n #\v #\f #\r #\" #\\
isLeftDoubleAngleQuote isRightDoubleAngleQuote
(! #\linefeed #\return (#\return #\linefeed)
isNel (#\return isNel) isLS)
#\space
(#\x (! %0..9 %a..f %A..F)
(* (! %0..9 %a..f %A..F)))
isChar)) ; anything can be escaped
isNotRightDoubleAngleQuote))
isRightDoubleAngleQuote))

; #^B #^C #^F #^G #^P (used in .fasl files)

(xfaslb (#\# isCtrlB)) ; #^B"..."
Expand Down
2 changes: 2 additions & 0 deletions src/Lib/Common/print.sch
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@
(let ((sv (char->integer c)))
(or (<= 32 sv 126)
(and (<= 128 sv)
(not (= sv #x00ab)) ; left double angle quote
(not (= sv #x00bb)) ; right double angle quote
(not (memq (char-general-category c)
'(Zs Zl Zp Cc Cf Cs Co Cn)))))))

Expand Down
Loading

0 comments on commit bbe33ff

Please sign in to comment.