Giter Club home page Giter Club logo

arborist's People

Contributors

davidkellis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

arborist's Issues

Feedback

Hey ๐Ÿ‘‹

thanks for your lib! I'm using it to parse Lisp (Clojure-like) syntax. Here is some feedback (want to share some thoughts with you).

It would be nice to have error object which would contain 1 message (as a string) with line and column. For now I use print_match_failure_error.

For example:

Malformed input fragment on line 1 char 5 ; at position 5 (character index 4):
(1 2
----^
Expected one of the following expressions to match on line 1 char 5 ; at position 5 (character index 4):
number
  1. term(".")
     0 - expression_or_comment
     0 - expression
     0 - list
     3 - expression_or_comment
     3 - expression
     3 - number
comment
  1. term(";")
     0 - expression_or_comment
     0 - expression
     0 - list
     3 - expression_or_comment
     4 - comment
list
  1. term(")")
     0 - expression_or_comment
     0 - expression
     0 - list

In the given example I would expect:

Expected ")" on line 1 at position 5 instead got end of file

Adding ; or . would not fix the sitaution.

I didn't find a good way to skip Lisp-comments, instead I return nil and later check for it:

eval.on("expression_or_comment") do |ctx|
  if ctx.captures["expression"]?
    ctx.capture("expression").visit(eval)
  else
    # return nil to skip
    nil
  end
end

eval.on("list") do |ctx|
  list = Mal::List.new
  if ctx.captures.first_value?
    ctx.captures.first_value.each do |e|
      val = e.visit(eval)
      if val # check if not a comment
        list << val
      end
    end
  end
  Mal::Type.new list
end

I also want to implement Python-like syntax (which would be transformed to s-expressions). I wonder what it would take to implement :python mode?

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.