codesimian
Class StringLang

java.lang.Object
  extended by codesimian.StringLang

public class StringLang
extends java.lang.Object


Field Summary
static char calcExecPrefix
          operatorName$myFuel#nameOfCS( ...params...
static java.lang.String lexerFileName
          11/9/04: The CodeSimian language syntax might LATER be defined by a java file created by an external lexer, probably JFlex.
static char namePrefix
          operatorName$myFuel#nameOfCS( ...params...
 
Constructor Summary
StringLang()
           
 
Method Summary
 CS compile(CS[] csTokens)
          input CSs in order as if they were tokens that a lexer returned to a parser
 CS compile(java.lang.String code)
          Converts a string of CodeSimian code, like "&c =# sqrt(a*a + b*b)", to a tree or graph of CSs.
 void DForProxy(java.lang.String code)
           
 CS stringToOneCS(java.lang.String oneCS)
          Returns a new CS (with no parameters, add them!) described by the String.
Examples: "3.45" "sin" "*" "+$4".
Not allowed: "+$4(3.45 sine(7))" "3.45 +$4 sine(7)" because its multiple CSs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lexerFileName

public static java.lang.String lexerFileName
11/9/04: The CodeSimian language syntax might LATER be defined by a java file created by an external lexer, probably JFlex.


calcExecPrefix

public static char calcExecPrefix
operatorName$myFuel#nameOfCS( ...params... ). Default: '$'


namePrefix

public static char namePrefix
operatorName$myFuel#nameOfCS( ...params... ). Default: '#'

Constructor Detail

StringLang

public StringLang()
Method Detail

DForProxy

public void DForProxy(java.lang.String code)

stringToOneCS

public CS stringToOneCS(java.lang.String oneCS)
Returns a new CS (with no parameters, add them!) described by the String.
Examples: "3.45" "sin" "*" "+$4".
Not allowed: "+$4(3.45 sine(7))" "3.45 +$4 sine(7)" because its multiple CSs.


compile

public CS compile(java.lang.String code)
           throws java.text.ParseException
Converts a string of CodeSimian code, like "&c =# sqrt(a*a + b*b)", to a tree or graph of CSs.
a * b + c * - d
( (a * b) + (c * (- d)) )
//. is top of parse stack. down is left. Priority + < * < -
a . * b + c * - d
a * . b + c * - d
a * b . + c * - d //shift/reduce conflict
(a*b) + . c * - d //+ has less parse priority than *, so reduce a*b to *: make a and b be *'s childs. (a*b) + c . * - d //dont know what c will become... shift
(a*b) + c * . - d
(a*b) + c * - . d //- higher than *
(a*b) + c * - d . //end of string should have less priority than d, so reduce
(a*b) + c * (- d) //reduce again
(a*b) + (c * (- d)) //reduce again
( (a*b) + (c * (- d)) )

x highPriorityOp y

Throws:
java.text.ParseException

compile

public CS compile(CS[] csTokens)
input CSs in order as if they were tokens that a lexer returned to a parser