Package loop.ast.script

Examples of loop.ast.script.Unit.declare()


  public Unit script(String file) {
    Unit unit = new Unit(file, ModuleDecl.DEFAULT);
    Node parse = parse();
    for (Node child : parse.children()) {
      if (child instanceof FunctionDecl)
        unit.declare((FunctionDecl) child);
      else
        unit.addToInitializer(child);
    }

    return unit;
View Full Code Here


          addError("Duplicate module import: " + require.toSymbol(),
              require.sourceLine, require.sourceColumn);
          throw new LoopCompileException();
        }

        unit.declare(require);
      }
    } while (require != null);

    FunctionDecl function;
    ClassDecl classDecl = null;
View Full Code Here

              function.sourceLine,
              function.sourceColumn);
          throw new LoopCompileException();
        }

        unit.declare(function);
      } else if (null != classDecl) {
        if (unit.getType(classDecl.name) != null) {
          addError("Duplicate type definition: " + classDecl.name,
              classDecl.sourceLine, classDecl.sourceColumn);
          throw new LoopCompileException();
View Full Code Here

          addError("Duplicate type definition: " + classDecl.name,
              classDecl.sourceLine, classDecl.sourceColumn);
          throw new LoopCompileException();
        }

        unit.declare(classDecl);
      }

    } while (function != null || classDecl != null);

    // Now slurp up any freeform expressions into the module initializer.
View Full Code Here

      reader.setExpandEvents(false);
      reader.addCompleter(new MetaCommandCompleter());

      Unit shellScope = new Unit(null, ModuleDecl.SHELL);
      FunctionDecl main = new FunctionDecl("main", null);
      shellScope.declare(main);
      shellContext = new HashMap<String, Object>();

      boolean inFunction = false;

      // Used to build up multiline statement blocks (like functions)
View Full Code Here

        if (line.isEmpty())
          continue;

        // Add a require import.
        if (line.startsWith("require ")) {
          shellScope.declare(new LexprParser(new Tokenizer(line + '\n').tokenize()).require());
          shellScope.loadDeps("<shell>");
          continue;
        }

        if (line.startsWith(":q") || line.startsWith(":quit")) {
View Full Code Here

        if (line.startsWith(":r") || line.startsWith(":reset")) {
          System.out.println("Context reset.");
          shellScope = new Unit(null, ModuleDecl.SHELL);
          main = new FunctionDecl("main", null);
          shellScope.declare(main);
          shellContext = new HashMap<String, Object>();
          continue;
        }
        if (line.startsWith(":i") || line.startsWith(":imports")) {
          for (RequireDecl requireDecl : shellScope.imports()) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.