Nu Syntax
Nu has a very simple syntax. On the surface, this may seem strict and conservative, but in many important ways it allows Nu to be liberal and permissive.
Elements
The basic elements of Nu are symbols, numbers, strings, characters, regular expressions, and punctuation.
Symbols
Symbols are sequences of characters that exclude punctuation and whitespace. Symbols are used as names for values. Names may be assigned values using the set operator.
Anything that can be parsed as a number is not a symbol. Numbers may not be assigned values; by definition, a number is its own value.
Symbols may include the colon character (':'), but only as the last character of the symbol. A symbol that ends with a colon is called a label. A colon forces the parser to end the current symbol and begin scanning something new. This allows us to write label:value pairs without having to include a space between the label and its associated value.
Numbers
Anything that looks like a number is a number. If a token can be converted to a long with strtol(), it's an integer, and if it can be converted to a double with strtod() then it's a floating point number. Both integer and floating point values are represented with instances of NSNumber.
Strings
Strings are represented with instances of NSString. They can be defined in two ways and have one special feature.
Double-quoted strings
Sequences of characters enclosed in double quotes are treated as strings. Double-quoted strings must be defined on a single line; these strings may not contain newlines. These strings also may not contain double quotes. Here is an example, which also illustrates the use of the set operator:
(set author "Isaac Asimov")
Here strings
Multiline strings and strings containing double quotes can be created using Nu's "here string" notation. A here string declaration begins with the three characters "<<-" or "<<+" immediately followed by an identifier that will be used to mark the end of the string. This identifier ends at a newline, after which follows the definition of the string. Here is an example.
(set poem
| Web Proxy Viewer | New URL | Original Page |