Questions tagged [s-expression]

S-expressions are a notation for nested list or tree-structured data, popularized by the Lisp programming language.

In computing, s-expressions, sexprs or sexps (for "symbolic expression") are a notation for nested list (tree-structured) data, invented for and popularized by the programming language which uses them for source code as well as data.

Source: Wikipedia

138 questions
4
votes
2 answers

S-Expressions parsing

I ran into this question earlier today: Example Input: I ran into Joe and Jill and then we went shopping Example Output: [TOP [S [S [NP [PRP I]] [VP [VBD ran] [PP [IN into] [NP [NNP Joe] [CC and] [NNP Jill]]]]] [CC and] [S [ADVP [RB then]] [NP…
Benjamin Gruenbaum
  • 270,886
  • 87
  • 504
  • 504
4
votes
1 answer

OCaml sexplib, how to define custom to_sexplib function?

I'm using with sexp syntax to generate s-exp functions automagically. The problem is data structures I'm printing with sexplib have some recursive pointers and printing will end up with stack overflow. So I need to override a to_sexp function and…
sinan
  • 6,809
  • 6
  • 38
  • 67
4
votes
5 answers

Flat evaluation of Lisp s-expressions

I'm trying to figure out how I could implement Lisp evaluation non-recursive. My C based evaluator is Minimal Lisp file l1.c. However several functions there recurse into eval again: eval, apply, evargs, evlist and also the Lisp Ops defineFunc,…
Konrad Eisele
  • 3,088
  • 20
  • 35
3
votes
2 answers

Parsing S-expressions with arbitrary delimiters in LISP

(I'm new enough to Lisp not to know how to do this, but familiar enough to know there just must be a simple way.) I was intrigued by an article that I read recently which advocated storing log files as Lisp-style S-expressions, so that the log files…
chimeracoder
  • 20,648
  • 21
  • 60
  • 60
3
votes
3 answers

S-expression idioms

I am interested in S-expressions, but I still don't have the right idioms in mind. Imagine a VLSI component, characterized by a name and a list of typed ports. What is preferable : (component name (p1 float) (p2 float)) or (component name ((p1…
JCLL
  • 5,379
  • 5
  • 44
  • 64
3
votes
2 answers

With clojure read/read-string function, how do i read in a .clj file to a list of objects

As titled, If I do (read-string (slurp "somefile")) This will only give me the first object in the file, meaning if "somefile" is as below: (a obj) (b obj) Then I only get (a obj) as the result. How do i get a list of all objects, like this? ((a…
andy
  • 71
  • 1
  • 3
3
votes
1 answer

Fast lookup of tree with placeholders?

For an application I'm considering, there would be a large (100,000+) 'database' of trees (think expressions in a programming language, or S-expressions), and I would need to query that database for expressions that match a specific given…
3
votes
3 answers

What tools exist for parsing Javascript and reading the results in Javascript or Ruby?

I'd like to do some code-analysis of Javascript. I'd prefer to operate on ASTs or S-Expressions. It's certainly possible that the V8 engine builds this, though I can't seem to find any documentation on how to access this information from a…
James A. Rosen
  • 64,193
  • 61
  • 179
  • 261
3
votes
2 answers

Recursive list analysis in Erlang

I'm playing with Erlang and trying to write an S-expression parser. I find it to be an easy task in Python using stacks and loops, but it's non-trivial for me as a beginner in immutable variables and Erlang data structures. I need to transform a…
asyndrige
  • 572
  • 6
  • 23
3
votes
3 answers

Parsing s-expressions in Go

Here's a link to lis.py if you're unfamiliar: http://norvig.com/lispy.html I'm trying to implement a tiny lisp interpreter in Go. I've been inspired by Peter Norvig's Lis.py lisp implementation in Python. My problem is I can't think of a single…
Francis
  • 99
  • 2
3
votes
6 answers

Parsing Lisp S-Expressions with known schema in C#

I'm working with a service that provides data as a Lisp-like S-Expression string. This data is arriving thick and fast, and I want to churn through it as quickly as possible, ideally directly on the byte stream (it's only single-byte characters)…
Drew Noakes
  • 300,895
  • 165
  • 679
  • 742
3
votes
1 answer

How can I process the LISP style tree generated by Antlr 4?

I parsed an SQL query using an Antlr 4 grammar. The result of tree.toStringTree() is this: ([] ([845] SELECT ([878 845] ([1473 878 845] ([1129 1473 878 845] ([1700 1129 1473 878 845] col1))) as ([1477 878 845] a)) FROM ([887 845] ([1487 887 845]…
user3898179
  • 211
  • 5
  • 13
3
votes
1 answer

How to reverse a list in VB?

I am working with LISP expressions in my computer programming (visual basic) course and I have a minor question. How would I go about reversing a list in vb.net? For example, if I were to input: '(H J K L) I would return an output of: '(L K J H)
Augment
  • 29
  • 1
  • 2
3
votes
2 answers

Get outermost list from the current point

From the point current position inside an Emacs buffer, how can I get the outermost list/s-expression which contains that point ? Follows a few examples in order to illustrate what I want to achieve: Example 1: (defun xpto(arg) (+ 2…
utxeee
  • 953
  • 1
  • 12
  • 24
3
votes
2 answers

Emacs: bulletproof up-list?

I'm getting up-list: Scan error: "Unbalanced parentheses" from this position: (foo "bar|") Snippet from up-list doc: This command assumes point is not in a string or comment. So this is the expected behavior. But I don't care. I just want to go…
abo-abo
  • 20,038
  • 3
  • 50
  • 71