Package com.stuffwithstuff.magpie.parser

Examples of com.stuffwithstuff.magpie.parser.MagpieParser


      String source = right.asString();
     
      boolean canParse = true;
     
      try {
        MagpieParser parser = new MagpieParser(new StringReader("", source));

        while (true) {
          Expr expr = parser.parseStatement();
          if (expr == null) break;
        }
      } catch (ParseException e) {
        canParse = false;
      }
View Full Code Here


  public void finishInitialization() {
    mInitializingCount--;
  }
 
  private void evaluateModule(Module module) {
    MagpieParser parser = new MagpieParser(module.readSource());
   
    mLoadingModules.push(module);
    try {
      // Copy the base stuff in first.
      if (module != mBaseModule) {
        Scope scope = module.getScope();
        for (String name : mBaseModule.getExportedNames()) {
          scope.importName(name, name, mBaseModule, false);
        }
      }
     
      // Evaluate the module.
      try {
        List<Expr> exprs = parser.parseModule();
        for (Expr expr : exprs) {
          evaluate(expr, module, module.getScope());
        }
      } catch (ParseException e) {
        String message = String.format("Syntax error at %s: %s",
View Full Code Here

  public Repl createRepl() {
    return new Repl(mInterpreter);
  }
 
  public void defineMethod(String signature, String doc, Method method) {
    MagpieParser parser = new MagpieParser(signature);
    Pair<String, Pattern> parsed = parser.parseSignature();

    String name = parsed.getKey();
    Pattern pattern = parsed.getValue();
   
    Scope scope = mInterpreter.getBaseModule().getScope();
View Full Code Here

  Repl(Interpreter interpreter) {
    mInterpreter = interpreter;
  }
 
  public ReplResult readAndEvaluate(SourceReader reader) {
    MagpieParser parser = new MagpieParser(reader);

    try {
      Expr expr = parser.parseStatement();
      parser.consume(TokenType.LINE);
     
      Obj result = mInterpreter.interpret(expr);
      String resultText;
      if (result == mInterpreter.nothing()) {
        resultText = null;
View Full Code Here

 
  private static Pair<String, Pattern> parseSignature(String text) {
    try {
      // Process the annotation to get the method's Magpie name and type
      // signature.
      MagpieParser parser = new MagpieParser(text);
      return parser.parseSignature();
    } catch (ParseException e) {
      // TODO(bob): Hack. Better error handling.
      System.out.println("Could not parse built-in signature \"" +
          text + "\".");
    }
View Full Code Here

TOP

Related Classes of com.stuffwithstuff.magpie.parser.MagpieParser

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.