Package frege.prelude.PreludeBase

Examples of frege.prelude.PreludeBase.TTuple2


   * run a {@link frege.prelude.PreludeBase.TState} action and return the new TGlobal state
   * @return the new state
   */
  public static TGlobal runSTG(Lazy action, TGlobal g) {
    Lambda stg = Delayed.<Lambda>forced(action);        // State (g -> (a, g))
    TTuple2 r = TState.run(stg, g).<TTuple2>forced();
    return Delayed.<TGlobal>forced( r.mem2 );
  }
View Full Code Here


   * The state must not be changed by the action.
   * @return the result
   */
  public static Object funSTG(Lazy action, TGlobal g) {
    Lambda stg = action.<Lambda>forced();        // State (g -> (a, g))
    TTuple2 r = TState.run(stg, g).<TTuple2>forced();
    return r.mem1;
  }
View Full Code Here

   * @return the new state
   */
  public static TGlobal runSTIO(Lazy action, TGlobal g) {
    Lambda stg = Delayed.<Lambda>forced(action);        // StateT (g -> IO (a, g))
    Lambda r   = Delayed.<Lambda>forced( TStateT.run(stg, g));
    TTuple2 t  = r.apply(42).result().<TTuple2>forced();
    return Delayed.<TGlobal>forced(t.mem2);
  }
View Full Code Here

   * @return the result
   */
  public static Object funSTIO(Lazy action, TGlobal g) {
    Lambda stg = Delayed.<Lambda>forced(action);        // StateT (g -> IO (a, g))
    Lambda r   = Delayed.<Lambda>forced( TStateT.run(stg, g));
    TTuple2 t  = r.apply(42).result().<TTuple2>forced();
    return t.mem1;
  }
View Full Code Here

          && errors(global) == 0
          && index < 2) {    // do lexer and parser synchronized
        t1 = System.nanoTime();
        index++;
        passes = pass.mem2.<TList>forced();
        final TTuple2 adx = Delayed.<TTuple2>forced( pass.mem1 );
        final Lazy action = index == 1 ? Main.lexPassIDE(contents) : Delayed.delayed(adx.mem1);
        final String   desc   = Delayed.<String>forced(adx.mem2);
        final TGlobal g = runSTIO(action, global);
        te = System.nanoTime();
        System.err.println(desc + " took "
          + (te-t1)/1000000 + "ms, cumulative "
          + (te-t0)/1000000 + "ms");
       
        monitor.worked(1);
        global = runSTG(Utilities.passDone, g);
      }
      if (achievement(global) >= achievement(goodglobal))
        goodglobal = global;      // when opening a file with errors
      else {
        // update token array in goodglobal
        TToken[] toks = TSubSt.toks(TGlobal.sub(global));
        goodglobal = TGlobal.upd$sub(goodglobal, TSubSt.upd$toks(
            TGlobal.sub(goodglobal), toks));
      }
//      Array gtoks = TSubSt.toks(TGlobal.sub(global));
//      System.err.println("global.toks==good.toks is " + (toks == gtoks));
    }
   
    int needed = (int) ((te-t0) / 1000000);
       
    if (scanOnly && timeout - needed > 0 && errors(global) == 0 && !monitor.isCanceled())
      try { Thread.sleep(timeout - needed); } catch (InterruptedException e) {}
    t0 = System.nanoTime() - (te-t0);

   
    while (!monitor.isCanceled()
          && errors(global) == 0
          && (pass = passes._Cons()) != null) {      // do the rest unsynchronized
        t1 = System.nanoTime();
        passes = pass.mem2.<TList>forced();
        index++;
        final TTuple2 adx = Delayed.<TTuple2>forced( pass.mem1 );
        final Lazy action = Delayed.delayed(adx.mem1);
        final String   desc   = Delayed.<String>forced(adx.mem2);
        final TGlobal g = runSTIO(action, global);
        te = System.nanoTime();
        System.err.println(desc + " took "
View Full Code Here

TOP

Related Classes of frege.prelude.PreludeBase.TTuple2

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.