4. Lexical syntax

Larceny's default lexical syntax extends the lexical syntax required by the R5RS, R6RS, and ERR5RS standards.

The R6RS forbids most lexical extensions, however, so Larceny provides several mechanisms for turning its lexical extensions on and off.

4.1. Flags

By default, Larceny recognizes several Larceny-specific flags of the form permitted by the R6RS. The flag you are most likely to encounter represents one of Larceny's unspecified values:

    #!unspecified

Certain other flags have special meanings to Larceny's read and get-datum procedures. They are described below.

4.2. Case-sensitivity

By default, Larceny is case-sensitive. This global default can be overridden by specifying —foldcase or —nofoldcase on Larceny's command line, or by changing the value of Larceny's case-sensitive? parameter.

The case-sensitivity of a particular textual input port is affected by reading one of the following flags from the port using the read or get-datum procedures:

    #!fold-case
    #!no-fold-case

The #!fold-case flag enables case-folding on data read from the port by the read and get-datum procedures, while the #!no-fold-case flag disables case-folding. The behavior established by one of these flags extends to the next flag read from the port by read or get-datum.

Both #!fold-case and #!no-fold-case evaluate to an unspecified value. To obtain the effect of one of these flags while treating it as a comment, place #; in front of the flag.

4.3. Lexical extensions

When a port is first opened, the Larceny-specific lexical extensions that are accepted on the port are determined by Larceny's lexical parameters.

The following flags change the case-sensitivity and lexical extensions on the specific port from which they are read:

    #!r6rs         ; implies #!no-fold-case, negates other flags
    #!r5rs         ; implies #!fold-case, #!err5rs
    #!err5rs       ; allows Larceny-specific extensions
    #!larceny      ; implies #!no-fold-case, #!err5rs

The #!r6rs flag is a comment, while all of Larceny's other flags evaluate to an unspecified value. To obtain the effect of a flag other than #!r6rs while treating it as a comment, place #; in front of the flag.

Warning

The R6RS requires implementations to treat #!r6rs as a comment; it is the only flag that implementations of the R6RS are required to treat as a comment. Since the #!r6rs flag behaves differently from all other flags, it is deprecated.

4.4. Lexical parameters

When given no argument, these parameters return the current default for some aspect of the lexical syntax that will be accepted on newly created ports. When given an argument, these procedures change the default as specified by the argument.

Procedure case-sensitive?

(case-sensitive? ) => boolean

(case-sensitive? boolean)

Determines whether newly created textual ports default to case-sensitive.

Procedure read-larceny-weirdness?

(read-larceny-weirdness? ) => boolean

(read-larceny-weirdness? boolean)

Determines whether newly created textual ports allow Larceny's usual extensions to R5RS lexical syntax. This parameter also determines whether newly created ports allow # as an insignificant digit; this is required by the R5RS, but disallowed by the R6RS.

Procedure read-traditional-weirdness?

(read-traditional-weirdness? ) => boolean

(read-traditional-weirdness? boolean)

Determines whether newly created textual ports allow certain lexical extensions that are deprecated in Larceny. These extensions include symbols enclosed by vertical bars and read-time evaluation.

For the current semantics of these parameters, please consult the Larceny developers' web page that describes Larceny's lexical syntax.