Code Monkey home page Code Monkey logo

Comments (2)

ztellman avatar ztellman commented on August 25, 2024

The checkpoint is mostly for internal use, but maybe this example will be a bit more illuminating:

user> (def foo (a/compile 
          (a/or [:d :d]
                [:d :d :g :h])))
#'user/foo
user>  (a/greedy-find foo nil [:d :d :g])
#automat.compiler.core.CompiledAutomatonState{:accepted? false, :checkpoint #automat.compiler.core.CompiledAutomatonState{:accepted? true, :checkpoint nil, :state-index 2, :start-index 0, :stream-index 2, :value nil}, :state-index 3, :start-index 0, :stream-index 3, :value nil}
user>  (a/greedy-find foo *1 [:z])
#automat.compiler.core.CompiledAutomatonState{:accepted? true, :checkpoint nil, :state-index 2, :start-index 0, :stream-index 2, :value nil}

All of your examples were accepted states, so they don't need to have a reference back to the previous accepted state. In this example, we're halfway between one accepted state and maybe a greedier one. Once we get something other than :h in the last input, it simply returns the checkpointed state.

The documentation could certainly be clearly here, but does that make sense?

from automat.

osfameron avatar osfameron commented on August 25, 2024

Aha, yes, thanks for the reply! I think that's clear, so basically my misunderstandings were:

  • the checkpoint is not created for accepted? states
  • if created, the checkpoint would contain another state value

In any case, as it turns out those semantics aren't useful to my use-case*, I suspect I need to roll something up with direct use of (a/advance) instead, so I'll play with that :-)

(* for example, I was musing on a key-binding parser. If the user types "dd", should we process the :first action, or wait a little longer to see if they go on to type a "g"?)

from automat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.