nikodemus / esrap

OLD REPOSITORY: Please go to:
https://github.com/scymtym/esrap
81 stars 25 forks source link

Added &position START END syntax to :lambda and :destructure #10

Closed scymtym closed 12 years ago

scymtym commented 12 years ago

The change allows bodies of :lambda and :destructure transforms to receive the bounds of the matching substring in two variables. The respective syntax is:

(:lambda (ARG &position START END)
  BODY)
(:destructure (LAMBDA-LIST-ELEMENTS &position START END)
  BODY)

Modified example which includes substring bounds in parse result:

(defrule sexp (and (? whitespace) (or magic list atom))
  (:destructure (w s &position start end)
    (declare (ignore w))
    (list s (cons start end))))
nikodemus commented 12 years ago

I like this. Notes:

scymtym commented 12 years ago

Thanks for the feedback. I will update the patch accordingly.

scymtym commented 12 years ago

I tried to incorporate the suggested improvements.

nikodemus commented 12 years ago

Thanks. Can you squash those and write a single cohesive commit message, or do you want me to do that?

scymtym commented 12 years ago

Please do. I'm not sufficiently familiar with git yet.

nikodemus commented 12 years ago

Done, thanks!