Difference between revisions of "LavishScript:Syntax"

From Lavish Software Wiki
Jump to navigation Jump to search
Line 46: Line 46:
 
*<tt><Pipeline>;<Pipeline></tt>
 
*<tt><Pipeline>;<Pipeline></tt>
 
Command lists are interpreted from left to right
 
Command lists are interpreted from left to right
 +
 +
== Escape Sequences ==
 +
Escape sequences are character sequences that have their own special meaning. 
 +
 +
Escape sequences consist of a backslash (<tt>\</tt>) and a following character:
 +
*<tt>/<character></tt>
 +
 +
Recognized characters and their meanings are as follows:
 +
*a: Character 7, the ASCII beep
 +
*e: Character 27, the ESC character (useful for terminal color/control/etc sequences)
 +
*n: Character 10, Line feed
 +
*r: Character 13, Carriage return
 +
*t: Character 9, Horizontal tab
 +
;All other characters following the escape character are treated as that character, and the escape character is removed.  For example, \" is a quote, and \\ is a backslash.
 +
 +
Often times it is necessary to prevent characters from having the special meanings as described in other sections.  For example, one way to use a comma inside a dimension in an Index is to enclose the entire dimension in quotes.  Similarly, to use <, |, or > in mathematical formulae, your expression also needs to be enclosed in quotes.  However, escape sequences can also be used for this purpose.  By escaping a comma, it will not be treated as a dimension separator in an index.  By escaping a |, it will not be treated as a command pipe.

Revision as of 19:43, 27 April 2005

Simple Command

A Simple Command is made up of a Command Name, and any Parameters given to it. Parameters are optional.

Possible forms are as follows

  • <Command Name>
  • <Command Name> [Parameters]

Examples

LSVersion

In this example, "LSVersion" is the Command Name

DeclareVariable MyBool bool local false

In this example, "DeclareVariable" is the Command Name, and "MyBool bool local false" are the parameters

Command Name

A command name is a single word. The only "special" character that has any effect in a command name is [, which will be used as an Index, for use with data methods. Quotes do not have an effect on spaces, as they would with parameters or indices, but will be stripped if they surround the single word. Data are not processed as part of the command name.

If the command name is found to contain a :, the command name is assumed to be that of a data method. In such cases, any parameters following the command are ignored, and the command is considered successful, whether or not the method is successfully processed.

If the command name is not assumed to be a method, it will first be checked for a matching alias, and then for an actual command. Aliases must match completely, though actual commands can be shortened and will resolve to the first matching command alphabetically.

Parameters

Parameters are words separated by spaces. If an individual parameter must itself include a space, or certain special characters should not be interpreted as part of a complex command, double quotes (") should be used around the parameter. Data are valid in any parameter, and will be processed (potentially becoming multiple parameters) unless the command name indicates a command that instructs otherwise (in which case the data will be treated as a single word). If data are processed, they will be replaced with the "return" (also referred to as "To String") value of the final resulting object.

Data

Data begin with ${ and end with }. Inside this, possible forms are as follows:

  • <Object>
  • <Object>.<Member>
  • <Object>:<Method>
  • <Object>(cast)
  • <Object>[Index]

These forms are recursive. Every Member, Method, or cast results in an Object for which the form can be continued. Indices have special rules, as described below.

Indices

Indices begin with [ and end with ]. Inside this, each dimension is described and separated by a comma. If a comma or ] must be used within a single dimension, double quotes (") are used around the dimension. Dimensions are interpreted as dimensions for arrays, or individual parameters where applicable. Data are processed in indices (possibly becoming multiple dimensions if the result contains a comma), unless used in a parameter to a command that instructs otherwise (in which case the data will be processed as a term in a single dimension). If data are processed, they will be replaced with the "return" (also referred to as "To String") value of the final resulting object. Indices are not limited to numerical values, they are the same as parameters, but delimited by commas.

Complex Command

Complex commands are commands and their parameters, with other special possibilities such as command lists, "pipelining" and input and output redirection.

A Pipeline has the following possible forms:

  • <Simple Command>
  • <Simple Command> < file.txt
  • <Simple Command> > file.txt
  • <Simple Command> >> file.txt
  • <Simple Command>|<Simple Command>

(or any mix of < > >> and | forms, which will be interpreted left to right) A Command List is described as follows:

  • <Pipeline>;<Pipeline>

Command lists are interpreted from left to right

Escape Sequences

Escape sequences are character sequences that have their own special meaning.

Escape sequences consist of a backslash (\) and a following character:

  • /<character>

Recognized characters and their meanings are as follows:

  • a: Character 7, the ASCII beep
  • e: Character 27, the ESC character (useful for terminal color/control/etc sequences)
  • n: Character 10, Line feed
  • r: Character 13, Carriage return
  • t: Character 9, Horizontal tab
All other characters following the escape character are treated as that character, and the escape character is removed. For example, \" is a quote, and \\ is a backslash.

Often times it is necessary to prevent characters from having the special meanings as described in other sections. For example, one way to use a comma inside a dimension in an Index is to enclose the entire dimension in quotes. Similarly, to use <, |, or > in mathematical formulae, your expression also needs to be enclosed in quotes. However, escape sequences can also be used for this purpose. By escaping a comma, it will not be treated as a dimension separator in an index. By escaping a |, it will not be treated as a command pipe.