2

I have no idea how to build S-exp. I want to do it, because I need to build AST for my langauge. At the beginning I used RubyParser to parse it to sexp then code gen. But it must be ruby's subset I think.I cant define the language what I want. Now I need to implement parser for my language.
So anyone could recommend any ruby tool that building AST for S-expression ?

Thanks!

user997948
  • 157
  • 1
  • 7

3 Answers3

2

You might try the sxp-ruby gem at http://github.com/bendiken/sxp-ruby. I use it for SPARQL S-Expressions (SSE) and similar methods for managing Abstract Syntax Trees in Ruby.

Gregg Kellogg
  • 1,831
  • 12
  • 8
2

It is not very clear from your question what exactly do you need, but simple Google search gives some interesting links to check. Maybe after checking these links, if they are not the answer to your question, you can edit question and make it more precise and concrete.

http://thingsaaronmade.com/blog/writing-an-s-expression-parser-in-ruby.html https://github.com/aarongough/sexpistol

ivanjovanovic
  • 511
  • 4
  • 9
0

Maybe you could have a look at this gem named Astrapi.

This is just an experiment :

  • describe your language elements (concepts) in a "mm" file (abstract syntax)
  • run astrapi on this file
  • astrapi generates a parser that is able to fill up your AST, from your input source expressed in s-expression (concrete syntax of your concepts).

I have put a modest documentation here.

JCLL
  • 5,379
  • 5
  • 44
  • 64