Package org.jatha.read

Examples of org.jatha.read.LispParser


    initConstants2();

    COMPILER     = new LispCompiler(this);
    MACHINE      = new SECDMachine(this);
    PARSER       = new LispParser(this, new InputStreamReader(System.in));


    // Need to allow *TOP-LEVEL-PROMPT* to change this.
    prompt = makeString("Jatha> ");

View Full Code Here


   * </ul>
   */
  public LispValue parse(String s, int caseSensitivity)
    throws EOFException
  {
    return new LispParser(this, s, caseSensitivity).parse();
  }
View Full Code Here

  {
    // System.err.println("Loading: verbose is " + verbose);

    BufferedReader buff = new BufferedReader(in);

    LispParser fileparser = new LispParser(this, buff);
    LispValue  input, code;
    boolean    atLeastOneResult = false;

    LispPackage oldPackage = (LispPackage)PACKAGE_SYMBOL.symbol_value();
    // Read and Eval stream until EOF.
    try {
      while (true)
      {
        input = fileparser.parse();

        code  = COMPILER.compile(MACHINE, input, NIL);

        LispValue value = MACHINE.Execute(code, NIL);
        atLeastOneResult = true;
View Full Code Here

    else if (obj instanceof String)
      return new StandardLispString(this, (String) obj);

    try
    {
      return (new LispParser(this, obj.toString(), LispParser.PRESERVE)).parse();
    } catch (Exception e)
    {
      System.err.println("Error in Jatha.toLisp(" + obj + ")");
    }
    return NIL;
View Full Code Here

    assertFalse(f_Package.basic_macrop());
    assertFalse(f_Real.basic_macrop());
    assertFalse(f_String.basic_macrop());
    assertFalse(f_Symbol.basic_macrop());

    LispParser parser = new LispParser(f_lisp, "(defmacro aaa (x) `(+ ,x 15)) ");
    LispValue macro = f_lisp.NIL;
    LispValue value = f_lisp.NIL;
    try {
      macro = parser.parse();
      assertFalse(macro.basic_null());
      value = f_lisp.eval(macro);
      assertFalse(value.basic_null());
    } catch (Exception e) {
      fail("Can't create macro: " + e.getMessage());
    }


    parser = new LispParser(f_lisp, "(aaa 42)");
    try {
      macro = parser.parse();
      assertFalse(macro.basic_null());
      value = f_lisp.eval(macro);
      assertTrue(value.equalNumeric(f_lisp.makeInteger(57)) == f_lisp.T);
    } catch (Exception e2) {
      fail("Can't evaluate macro: " + e2.getMessage());
View Full Code Here

    else if (obj instanceof String)
      return new StandardLispString(lisp, (String)obj);

    try {
      return (new LispParser(lisp, obj.toString(), LispParser.PRESERVE)).parse();
    } catch (Exception e) {
      System.err.println("Error in LispValueFactory.toLisp(" + obj + ")");
    }
    return lisp.NIL;
  }
View Full Code Here

  throws IOException
  {
//System.err.println( "loadLispSource '"+name+"' --> "+f );

    FileReader      fr;
    LispParser      parser;
    PushbackReader    pbr;
    LispValue      codeFragment, result;
    boolean        verbose = classPrefs.getBoolean( KEY_VERBOSE, false );
   
    fr        = new FileReader( f )// throws FileNotFoundException
    try {
      pbr      = new PushbackReader( fr, 32 );
      initJatha()// XXX we should remove all user variables and functions
      prefsHash.setf_gethash( jatha.makeString( "BASEDIRECTORY" ),
        jatha.makeString( f.getParent() ));
//System.err.println( "initJatha() done." );
      parser    = jatha.PARSER;    // XXX ? Jatha.getParser();
      parser.setInputReader( pbr );
      parser.setCaseSensitivity( LispParser.UPCASE );
      try {
        while( true ) {
//System.err.println( "reading a line from the file..." );
          codeFragment  = parser.read()// consecutively parse all expressions in the file
//System.err.println( "evaluating..." );
          result      = jatha.eval( codeFragment );
          if( verbose ) {
            System.out.println( result );
          }
View Full Code Here

TOP

Related Classes of org.jatha.read.LispParser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.