com.io7m.jsx 3.0.0-SNAPSHOT
com.io7m.jsx 3.0.0-SNAPSHOT Documentation
Package Information
Orientation
Overview
The com.io7m.jsx package implements an S-expression parser.
Installation
Source compilation
The project can be compiled and installed with Maven:
$ mvn -C clean install
Maven
Regular releases are made to the Central Repository, so it's possible to use the com.io7m.jsx package in your projects with the following Maven dependency:
<dependency>
  <groupId>com.io7m.jsx</groupId>
  <artifactId>com.io7m.jsx-core</artifactId>
  <version>3.0.0-SNAPSHOT</version>
</dependency>
All io7m.com packages use Semantic Versioning [0], which implies that it is always safe to use version ranges with an exclusive upper bound equal to the next major version - the API of the package will not change in a backwards-incompatible manner before the next major version.
Platform Specific Issues
There are currently no known platform-specific issues.
License
All files distributed with the com.io7m.jsx package are placed under the following license:
Copyright © 2015 <code@io7m.com> http://io7m.com

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
      
Expression Language
Notational Conventions
Unicode
The specification makes reference to the Unicode character set which, at the time of writing, is at version 6.2.0. The specification often references specific Unicode characters, and does so using the standard notation U+NNNN, where N represents a hexadecimal digit. For example, U+03BB corresponds to the lowercase lambda symbol λ.
EBNF
The specification gives grammar definitions in ISO/IEC 14977:1996 Extended Backus-Naur form.
Language
The language understood by the com.io7m.jsx package can be defined by the following grammar:
expression =
    symbol
  | quoted_string
  | "(" , { expression } , ")" ;

expression_squares =
    symbol
  | quoted_string
  | "[" , { expression_squares } , "]"
  | "(" , { expression_squares } , ")" ;
The com.io7m.jsx lexer recognizes the sequences U+000D U+000A and U+000A as line terminators for the purposes of tracking line and column numbers for diagnostic messages. The lexer does not permit bare U+000D characters to appear outside of quoted strings.
Many systems that parse S-expressions allow for the use of square brackets to increase readability. For example:
(: map (→ (→ a b) (→ (list a) (list b))))

(: map (→ [→ a b] [→ (list a) (list b)]))
Note that the second version that uses square brackets is slightly easier to understand due to the square brackets more clearly indicating which of the nested lists are being terminated. The com.io7m.jsx lexer can optionally treat U+005B [ and U+005D ] as tokens, and the parser ensures that the use of the brackets is balanced with respect to ordinary parentheses as part of the grammar above. If square brackets are enabled, the language understood by the com.io7m.jsx package is defined by expression_squares. Otherwise, the language is defined by expression.
The terminals of the language are given by:
symbol_character =
  ? not (")" | "(" | U+0022 | WHITESPACE) ? ;

symbol_character_squares =
  ? not (")" | "(" | "[" | "]" | U+0022 | WHITESPACE) ? ;

symbol =
  symbol_character , { symbol_character } ;

quoted_character =
  ? not U+0022 ? ;

quoted_string =
  (quoted_character | escape) , { (quoted_character | escape) } ;

escape =
    escape_carriage
  | escape_newline
  | escape_tab
  | escape_quote
  | escape_unicode4
  | escape_unicode8 ;

escape_carriage =
  "\r" ;

escape_newline =
  "\n" ;

escape_quote =
  "\" , U+0022 ;

escape_tab =
  "\t" ;

escape_unicode4 =
  "\u" ,
  hex_digit , hex_digit , hex_digit , hex_digit ;
  
escape_unicode8 =
  "\u" ,
  hex_digit , hex_digit , hex_digit , hex_digit ,
  hex_digit , hex_digit , hex_digit , hex_digit ;

hex_digit =
  "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "0" |
  "a" | "A" | "b" | "B" | "c" | "C" | "d" | "D" | "e" | "E" | "f" | "F" ;
Due to limitations in the EBNF format, the definitions for symbol_character and quoted_character cannot be expressed directly.
Informally, the symbol_character rule should be understood to specify any Unicode character that is not whitespace, is not U+0028 (, is not U+0029 ), and is not U+0022 ".
If square brackets are enabled, the symbol_character_squares rule should be understood to replace the symbol_character rule.
The quoted_character rule should be understood to specify any character that is not not U+0022 ".
Quoted strings may contain escape codes that are transformed to specific characters during lexing.
CodeResulting CharacterComment
\"U+0022Double quote
\\U+005CBackslash
\rU+000DCarriage return
\nU+000ALine feed
\tU+0009Horizontal tab
\uNNNNU+NNNNUnicode character NNNN (where N is a hexadecimal digit)
\UNNNNNNNNU+NNNNNNNNUnicode character NNNNNNNN (where N is a hexadecimal digit)
API Reference
Javadoc
API documentation for the package is provided via the included Javadoc.