org.silence.smushcode
Class SmushcodeDefines

java.lang.Object
  |
  +--org.silence.smushcode.SmushcodeDefines

public final class SmushcodeDefines
extends java.lang.Object

SmushcodeDefines controls most of the SMUSHcode75 parser's behavior. It is here that all of the "magic values" are defined - what character sequence defines a comment, what character starts a string literal, etc. All of these things are kept separate so they will be easy to change if the need ever arises. This entire class is nothing but public static final Strings and public static final chars, basically the Java equivalent of a collection of constants. No SmushcodeDefines object should ever be instantiated - values should simply be read right out of the class.

The EBNF specification for SMUSHcode75 is shown below:

 EBNF specifications use the following tokens:
   a | b         Indicates that either a or b is allowed.
   [ a ]         Indicates that a is optional.
   { a }         Indicates that 0 or more instances of a are allowed.
   x{ a }        Indicates that x instances of a are required, and may be
                 followed by 0 or more instances of a.
   "a"           Indicates that the lower-case letter a is required.
   <a>           Indicates that a is an EBNF object defined elsewhere.
   a ... b       Indicates both a and b as well as everything between them
                 in a logical progression (used primarily for lists of letters
                 and numbers).
 
 expression:
         <literal> | <compound-expression> | <function>
 
 literal:
         <numeric-literal> | <string-literal> |
         <empty-literal>
 
 numeric-literal:
         [ "+" | "-" ] 1{ "0" | "1" | ... | "9" } [ "." 1{ "0" | "1" | ... | 
         "9" } ] [ "E" 1{ "0" | "1" | ... | "9" } ]
 
 string-literal:
         "`" { "a" | "b" | ... | "z" | "0" | "1" | ... | "9" | "!" | "@" | "#" |
         "$" | "%" | "^" | "&" | "*" | "(" | ")" | "-" | "_" | "=" | "+" | "[" |
         "{" | "]" | "}" | "|" | ";" | ":" | "'" | """ | "," | "<" | "." | ">" |
         "/" | "?" | "~" | " " | "\\" | "\`" | "\b" | "\t" | "\n" | "\r" } "`"

 empty-literal:

 
 compound-expression:
         "{" [ <expression> { ";" <expression> } ] "}"
 
 function:
         <function-identifier> "(" [ <expression> { "," <expression> } ] ")"
 
 function-identifier:
         <mathematical-function> | <numeric-function> | <string-function> |
         <looping-function> | <decision-function> | <variable-function> |
         <logic-function> | <subroutine-function>

 mathematical-function:
         "add" | "sub" | "mul" | "div" | "mod" | "exp" | "abs"

 numeric-function:
         "trunc" | "round" | "lt" | "gt" | "eq"

 string-function:
         "null" | "perror" | "strlen"

 looping-function:
         "preloop" | "postloop"

 decision-function:
         "if" | "select"

 variable-function:
         "store" | "vstore" | "v"

 subroutine-function:
         "u" | "eval" | "p" | "pnum"

 logic-function:
         "and" | "or" | "not" | "true" |
 
Note that the EBNF specifications only dictate what SMUSHcode75 is required to do in order to be called SMUSHcode75. It is quite possible that any given implementation may exceed the stated requirements (an example of this would be a string literal accepting more characters than are listed).

The EBNF specifications also say nothing about the functional meanings of any of the above constructs. For that type of interpretation, some sort of SMUSHcode75 programmer's manual is needed.

Version:
org.silence.smushcode v1.0
Author:
Sam Clippinger (samc (at) silence (dot) org)

Field Summary
static java.lang.String badFunctionErrorText
          Defines the full text that accompanies a parse error in a SMUSHcode75 statement.
static java.lang.String badNumericArgumentErrorText
          Defines the full text that accompanies a SMUSHcode75 function error, specifically an error resulting from an invalid numberic argument being supplied to a function.
static java.lang.String baseFalse
          Defines the value that is returned when a boolean SMUSHcode75 function returns "false".
static java.lang.String baseTrue
          Defines the value that is returned when a boolean SMUSHcode75 function returns "true".
static java.lang.String commentEnd
          Defines what character sequence ends a comment in a SMUSHcode75.
static java.lang.String commentStart
          Defines what character sequence begins a comment in a SMUSHcode75.
static char compoundEnd
          Defines the character that ends a compound expression in SMUSHcode75.
static char compoundSeparator
          Defines the character that separates expressions within a SMUSHcode75 compound expression.
static char compoundStart
          Defines the character that starts a compound expression in SMUSHcode75.
static java.lang.String debugSeparator
          Defines the string that separates a SMUSHcode75's source expression from its output during a call to traceExec().
static char delimitedBackspace
          Defines the character that, when preceded by specialDelimiter, signals a backspace character.
static char delimitedCarriageReturn
          Defines the character that, when preceded by specialDelimiter, signals a carriage return.
static char delimitedNewline
          Defines the character that, when preceded by specialDelimiter, signals a newline.
static char delimitedTab
          Defines the character that, when preceded by specialDelimiter, signals a tab character.
static java.lang.String errorPattern
          Defines the text that surrounds a SMUSHcode75 function error to make it more noticable.
static char functionEnd
          Defines the character that marks the end of a SMUSHcode75 function's parameter list.
static java.lang.String functionErrorHeader
          Defines the text that precedes an error message from a SMUSHcode75 function.
static char functionSeparator
          Defines the character that separates the parameters in a SMUSHcode75 function's parameter list.
static char functionStart
          Defines the character that marks the beginning of a SMUSHcode75 function's parameter list.
static java.lang.String illegalNumberFormatErrorText
          Defines the full text that accompanies a parse error in a SMUSHcode75 statement.
static int indexExec
          Defines which element in the array of Vectors used by the evaluate() functions contains the output of the SMUSHcode75 statements.
static int indexNoExec
          Defines which element in the array of Vectors used by the evaluate() functions contains the original SMUSHcode75 statements.
static java.lang.String invalidExpressionErrorText
          Defines the text that precedes a SMUSHcode75 function error, specifically an error message resulting from an attempt to evaluate an invalid user-defined expression.
static java.lang.String misplacedStringEndErrorText
          Defines the full text that accompanies a parse error in a SMUSHcode75 statement.
static java.lang.String misplacedStringStartErrorText
          Defines the full text that accompanies a parse error in a SMUSHcode75 statement.
static java.lang.String missingCommentEndErrorText
          Defines the full text that accompanies a parse error in a SMUSHcode75 statement.
static java.lang.String missingCompoundEndErrorText
          Defines the full text that accompanies a parse error in a SMUSHcode75 statement.
static java.lang.String missingCompoundStartErrorText
          Defines the full text that accompanies a parse error in a SMUSHcode75 statement.
static java.lang.String missingFunctionEndErrorText
          Defines the full text that accompanies a parse error in a SMUSHcode75 statement.
static java.lang.String missingFunctionStartErrorText
          Defines the full text that accompanies a parse error in a SMUSHcode75 statement.
static java.lang.String missingStringEndErrorText
          Defines the full text that accompanies a parse error in a SMUSHcode75 statement.
static java.lang.String missingStringStartErrorText
          Defines the full text that accompanies a parse error in a SMUSHcode75 statement.
static java.lang.String parseErrorHeader
          Defines the start of the error text that accompanies a parse error in a SMUSHcode75 statement.
static char realBackspace
          Defines the character that is printed when the sequence specialDelimiter-delimitedBackspace is encountered.
static char realCarriageReturn
          Defines the character that is printed when the sequence specialDelimiter-delimitedCarriageReturn is encountered.
static char realNewline
          Defines the character that is printed when the sequence specialDelimiter-delimitedNewline is encountered.
static char realTab
          Defines the character that is printed when the sequence specialDelimiter-delimitedTab is encountered.
static int recursionLimit
          Defines the maximum size of the runtime execution stack.
static java.lang.String recursionLimitExceededErrorText
          Defines the text that precedes a SMUSHcode75 function error, specifically an error message resulting from too many levels being added to the runtime stack.
static char specialDelimiter
          Defines the "special delimiter" that offsets special characters in SMUSHcode75 statements.
static char stringEnd
          Defines the character that ends a string literal.
static char stringStart
          Defines the character that begins a string literal.
static java.lang.String tooFewArgumentsErrorText
          Defines the full text that accompanies a SMUSHcode75 function error, specifically an error resulting from too few arguments being supplied to a function.
static java.lang.String tooManyArgumentsErrorText
          Defines the full text that accompanies a SMUSHcode75 function error, specifically an error resulting from too many arguments being supplied to a function.
static java.lang.String whiteSpace
          Defines what is taken to be whitespace in a SMUSHcode75 statement.
 
Constructor Summary
SmushcodeDefines()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

whiteSpace

public static final java.lang.String whiteSpace
Defines what is taken to be whitespace in a SMUSHcode75 statement. This is significant because all whitespace is removed (except within string literals) prior to execution.

This is set to a space, a tab, a newline and a carriage return.

See Also:
Constant Field Values

commentStart

public static final java.lang.String commentStart
Defines what character sequence begins a comment in a SMUSHcode75. All comments are completely ignored during execution. Comments can occur anywhere in SMUSHcode75 statements, even in the middle of keywords and in the middle of string literals.

This is set to "[*".

See Also:
Constant Field Values

commentEnd

public static final java.lang.String commentEnd
Defines what character sequence ends a comment in a SMUSHcode75. All comments are completely ignored during execution. Comments can occur anywhere in SMUSHcode75 statements, even in the middle of keywords and in the middle of string literals.

This is set to "*]".

See Also:
Constant Field Values

baseTrue

public static final java.lang.String baseTrue
Defines the value that is returned when a boolean SMUSHcode75 function returns "true".

This is set to "1".

See Also:
Constant Field Values

baseFalse

public static final java.lang.String baseFalse
Defines the value that is returned when a boolean SMUSHcode75 function returns "false". This is also the value that Expression.logic(ExpressionCaller) looks for when determining a statement's "falseness".

This is set to "0".

See Also:
Expression.logic(org.silence.smushcode.ExpressionCaller), Constant Field Values

parseErrorHeader

public static final java.lang.String parseErrorHeader
Defines the start of the error text that accompanies a parse error in a SMUSHcode75 statement.

This is set to "Parse error: ".

See Also:
Constant Field Values

missingFunctionStartErrorText

public static final java.lang.String missingFunctionStartErrorText
Defines the full text that accompanies a parse error in a SMUSHcode75 statement. Specifically, this text is used when the delimiter to mark the start of a function's parameter list cannot be found.

This is set to parseErrorHeader + "Expected function begin delimiter not found."

See Also:
Constant Field Values

missingFunctionEndErrorText

public static final java.lang.String missingFunctionEndErrorText
Defines the full text that accompanies a parse error in a SMUSHcode75 statement. Specifically, this text is used when the delimiter to mark the end of a function's parameter list cannot be found.

This is set to parseErrorHeader + "Expected function end delimiter not found."

See Also:
Constant Field Values

misplacedStringStartErrorText

public static final java.lang.String misplacedStringStartErrorText
Defines the full text that accompanies a parse error in a SMUSHcode75 statement. Specifically, this text is used when the delimiter to mark the start of a string is found in an unexpected place.

This is set to parseErrorHeader + "String start delimiter found within string."

See Also:
Constant Field Values

misplacedStringEndErrorText

public static final java.lang.String misplacedStringEndErrorText
Defines the full text that accompanies a parse error in a SMUSHcode75 statement. Specifically, this text is used when the delimiter to mark the end of a string is found in an unexpected place.

This is set to parseErrorHeader + "String end delimiter found outside string."

See Also:
Constant Field Values

missingStringStartErrorText

public static final java.lang.String missingStringStartErrorText
Defines the full text that accompanies a parse error in a SMUSHcode75 statement. Specifically, this text is used when the delimiter to mark the start of a string is not found.

This is set to parseErrorHeader + "String start delimiter not found."

See Also:
Constant Field Values

missingStringEndErrorText

public static final java.lang.String missingStringEndErrorText
Defines the full text that accompanies a parse error in a SMUSHcode75 statement. Specifically, this text is used when the delimiter to mark the end of a string is not found.

This is set to parseErrorHeader + "String end delimiter not found."

See Also:
Constant Field Values

missingCommentEndErrorText

public static final java.lang.String missingCommentEndErrorText
Defines the full text that accompanies a parse error in a SMUSHcode75 statement. Specifically, this text is used when the delimiter to mark the end of a comment is not found.

This is set to parseErrorHeader + "Comment end delimiter not found."

See Also:
Constant Field Values

illegalNumberFormatErrorText

public static final java.lang.String illegalNumberFormatErrorText
Defines the full text that accompanies a parse error in a SMUSHcode75 statement. Specifically, this text is used when a numeric literal has a format that Double.valueOf().doubleValue() cannot parse.

This is set to parseErrorHeader + "Illegal number format."

See Also:
Constant Field Values

badFunctionErrorText

public static final java.lang.String badFunctionErrorText
Defines the full text that accompanies a parse error in a SMUSHcode75 statement. Specifically, this text is used when an expression references a function name that is undefined.

This is set to parseErrorHeader + "Unknown SMUSHcode75 function reference."

See Also:
Constant Field Values

missingCompoundStartErrorText

public static final java.lang.String missingCompoundStartErrorText
Defines the full text that accompanies a parse error in a SMUSHcode75 statement. Specifically, this text is used when a compound expression does not begin with the proper delimiter.

This is set to parseErrorHeader + "Expected compound expression start delimiter not found."

See Also:
Constant Field Values

missingCompoundEndErrorText

public static final java.lang.String missingCompoundEndErrorText
Defines the full text that accompanies a parse error in a SMUSHcode75 statement. Specifically, this text is used when a compound expression does not end with the proper delimiter.

This is set to parseErrorHeader + "Expected compound expression end delimiter not found."

See Also:
Constant Field Values

errorPattern

public static final java.lang.String errorPattern
Defines the text that surrounds a SMUSHcode75 function error to make it more noticable.

This is set to "###".

See Also:
Constant Field Values

functionErrorHeader

public static final java.lang.String functionErrorHeader
Defines the text that precedes an error message from a SMUSHcode75 function.

This is set to "ERROR:".

See Also:
Constant Field Values

tooFewArgumentsErrorText

public static final java.lang.String tooFewArgumentsErrorText
Defines the full text that accompanies a SMUSHcode75 function error, specifically an error resulting from too few arguments being supplied to a function.

This is set to functionErrorHeader + "Not enough arguments given." + errorPattern

See Also:
Constant Field Values

tooManyArgumentsErrorText

public static final java.lang.String tooManyArgumentsErrorText
Defines the full text that accompanies a SMUSHcode75 function error, specifically an error resulting from too many arguments being supplied to a function.

This is set to functionErrorHeader + "Too many arguments given." + errorPattern

See Also:
Constant Field Values

badNumericArgumentErrorText

public static final java.lang.String badNumericArgumentErrorText
Defines the full text that accompanies a SMUSHcode75 function error, specifically an error resulting from an invalid numberic argument being supplied to a function.

This is set to functionErrorHeader + "Invalid numeric literal in argument." + errorPattern

See Also:
Constant Field Values

invalidExpressionErrorText

public static final java.lang.String invalidExpressionErrorText
Defines the text that precedes a SMUSHcode75 function error, specifically an error message resulting from an attempt to evaluate an invalid user-defined expression.

This is set to functionErrorHeader + "Invalid SMUSHcode75 expression in evaluation: "

See Also:
Constant Field Values

recursionLimitExceededErrorText

public static final java.lang.String recursionLimitExceededErrorText
Defines the text that precedes a SMUSHcode75 function error, specifically an error message resulting from too many levels being added to the runtime stack.

This is set to functionErrorHeader + "Recursion limit exceeded." + errorPattern

See Also:
Constant Field Values

stringStart

public static final char stringStart
Defines the character that begins a string literal.

This is set to '`'.

See Also:
Constant Field Values

stringEnd

public static final char stringEnd
Defines the character that ends a string literal.

This is set to '`'.

See Also:
Constant Field Values

specialDelimiter

public static final char specialDelimiter
Defines the "special delimiter" that offsets special characters in SMUSHcode75 statements. The use of this delimiter is typically confined to generating unique characters in strings such as newlines, carriage returns and tabs.

This is set to '\'.

See Also:
Constant Field Values

compoundStart

public static final char compoundStart
Defines the character that starts a compound expression in SMUSHcode75. This is set to '{'.

See Also:
Constant Field Values

compoundEnd

public static final char compoundEnd
Defines the character that ends a compound expression in SMUSHcode75. This is set to '}'.

See Also:
Constant Field Values

compoundSeparator

public static final char compoundSeparator
Defines the character that separates expressions within a SMUSHcode75 compound expression. This is set to ';'.

See Also:
Constant Field Values

functionStart

public static final char functionStart
Defines the character that marks the beginning of a SMUSHcode75 function's parameter list. This is set to '('.

See Also:
Constant Field Values

functionEnd

public static final char functionEnd
Defines the character that marks the end of a SMUSHcode75 function's parameter list. This is set to ')'.

See Also:
Constant Field Values

functionSeparator

public static final char functionSeparator
Defines the character that separates the parameters in a SMUSHcode75 function's parameter list. This is set to ','.

See Also:
Constant Field Values

delimitedTab

public static final char delimitedTab
Defines the character that, when preceded by specialDelimiter, signals a tab character. This is set to 't'.

See Also:
Constant Field Values

realTab

public static final char realTab
Defines the character that is printed when the sequence specialDelimiter-delimitedTab is encountered. This is set to '\t' (tab).

See Also:
Constant Field Values

delimitedBackspace

public static final char delimitedBackspace
Defines the character that, when preceded by specialDelimiter, signals a backspace character. This is set to 'b'.

See Also:
Constant Field Values

realBackspace

public static final char realBackspace
Defines the character that is printed when the sequence specialDelimiter-delimitedBackspace is encountered. This is set to '\b' (backspace).

See Also:
Constant Field Values

delimitedNewline

public static final char delimitedNewline
Defines the character that, when preceded by specialDelimiter, signals a newline. This is set to 'n'.

See Also:
Constant Field Values

realNewline

public static final char realNewline
Defines the character that is printed when the sequence specialDelimiter-delimitedNewline is encountered. This is set to '\n' (newline).

See Also:
Constant Field Values

delimitedCarriageReturn

public static final char delimitedCarriageReturn
Defines the character that, when preceded by specialDelimiter, signals a carriage return. This is set to 'r'.

See Also:
Constant Field Values

realCarriageReturn

public static final char realCarriageReturn
Defines the character that is printed when the sequence specialDelimiter-delimitedCarriageReturn is encountered. This is set to '\r' (carriage return).

See Also:
Constant Field Values

debugSeparator

public static final java.lang.String debugSeparator
Defines the string that separates a SMUSHcode75's source expression from its output during a call to traceExec(). This is set to " => ".

See Also:
Expression.traceExec(org.silence.smushcode.ExpressionCaller), Constant Field Values

indexExec

public static final int indexExec
Defines which element in the array of Vectors used by the evaluate() functions contains the output of the SMUSHcode75 statements. This is set to 0.

See Also:
Expression.evaluate(org.silence.smushcode.ExpressionCaller), Constant Field Values

indexNoExec

public static final int indexNoExec
Defines which element in the array of Vectors used by the evaluate() functions contains the original SMUSHcode75 statements. This is set to 1.

See Also:
Expression.evaluate(org.silence.smushcode.ExpressionCaller), Constant Field Values

recursionLimit

public static final int recursionLimit
Defines the maximum size of the runtime execution stack. This is primarily used to keep recursive functions from running amok and crashing the interpreter. This is set to 40.

See Also:
Constant Field Values
Constructor Detail

SmushcodeDefines

public SmushcodeDefines()