Working on a child of s-exp

  • 6 Replies
  • 2831 Views
*

Zero

  • Eve
  • ***********
  • 1287
Working on a child of s-exp
« on: August 27, 2018, 03:57:29 pm »

I know I know, s-exp are god, but I find some constructions hard to read, like those where the car are lists, like this:

Code
(((alpha a b c) are letters) is a fact)

So, if you just put the car outside of the parentheses, you get something more readable, like:

Code
alpha(a b c)(are letters)(is a fact)

The syntax would be

Code
document = element*
element = word | structure
structure = element "(" element* ")"

but this is a case of left recursion. So I managed to find a small workaround. Here is a PEGjs syntax for it:

Code
doc
= element*


element
= _ head:word body:block* _ {

var result = head;
   
    for (var b of body)
    result = { head: result, body: b };
       
    return result;
}


word
= c:[a-zA-Z0-9]+ { return c.join(''); }


block
= "(" e:element* ")" { return e; }


_
= [ \t\r\n]*

When given this:

Code
one two(foo) three(foo)(bar)

The parser yields this:

Code
[
   "one",
   {
      "head": "two",
      "body": [
         "foo"
      ]
   },
   {
      "head": {
         "head": "three",
         "body": [
            "foo"
         ]
      },
      "body": [
         "bar"
      ]
   }
]

Which is the result we want.

I think a decent minimalist programming language wouldn't need blocks at all, except to express data structures.

Here is a little html:

Code
<div id="here" class="stuff">foo bar</div>

It turns into this:

Code
div( id(here) class(stuff) )(foo bar)

Not bad IMO./

*

LOCKSUIT

  • Emerged from nothing
  • Trusty Member
  • *******************
  • Prometheus
  • *
  • 4659
  • First it wiggles, then it is rewarded.
    • Main Project Thread
Re: Working on a child of s-exp
« Reply #1 on: August 27, 2018, 04:46:17 pm »
(((alpha a b c) are letters) is a fact)

What is that? Are you Building there?? And what do you use that Build for?
Emergent          https://openai.com/blog/

*

ivan.moony

  • Trusty Member
  • ************
  • Bishop
  • *
  • 1729
    • mind-child
Re: Working on a child of s-exp
« Reply #2 on: August 27, 2018, 05:07:24 pm »
If we have `one two three`, how do we know if it is `one (two three)`, or `(one two) three`? And how do we tell apart trees from lists?

Nevertheless, I salute an attempt to introduce a key value over flat lists. I had some tries in that direction, but I gave up after having troubles with second order trees. I'll need a replacement for HTML in some point, so I'm curious about what your experiment will turn into.
« Last Edit: August 27, 2018, 05:55:46 pm by ivan.moony »

*

Zero

  • Eve
  • ***********
  • 1287
Re: Working on a child of s-exp
« Reply #3 on: August 27, 2018, 05:44:32 pm »
If we have `one two three`, how do we know is it `one (two three)`, or `(one two) three`?


Nevertheless, I salute an attempt to introduce a key value over flat lists.

a b c = a b c
(a b c) = a(b c)
(a b) c = a(b) c
((a b) c) = a(b)(c)

Do you still see an ambiguity?

(((alpha a b c) are letters) is a fact)

What is that? Are you Building there?? And what do you use that Build for?

The content is just blah blah, what matters here is the structure of the container.

*

ivan.moony

  • Trusty Member
  • ************
  • Bishop
  • *
  • 1729
    • mind-child
Re: Working on a child of s-exp
« Reply #4 on: August 27, 2018, 06:05:39 pm »
If I understood correctly, we just pull the first element out of braces to the left? Sounds like a simple consistent rule, but somehow I can't get used to it. Maybe I need some more time and examples to process it.

*

LOCKSUIT

  • Emerged from nothing
  • Trusty Member
  • *******************
  • Prometheus
  • *
  • 4659
  • First it wiggles, then it is rewarded.
    • Main Project Thread
Re: Working on a child of s-exp
« Reply #5 on: August 27, 2018, 06:15:00 pm »
(   ((I) (am))   (letters)   )

Here we combine I and am......then I am and letters
Emergent          https://openai.com/blog/

*

Zero

  • Eve
  • ***********
  • 1287
Re: Working on a child of s-exp
« Reply #6 on: August 28, 2018, 01:41:14 pm »
You understood correctly. Here is the translation:

Code

( ((I) (am)) (letters) )

I()( am() )( letters() )

« Last Edit: August 28, 2018, 02:10:41 pm by Zero »

 


Requirements for functional equivalence to conscious processing?
by DaltonG (General AI Discussion)
November 19, 2024, 11:56:05 am
Will LLMs ever learn what is ... is?
by HS (Future of AI)
November 10, 2024, 06:28:10 pm
Who's the AI?
by frankinstien (Future of AI)
November 04, 2024, 05:45:05 am
Project Acuitas
by WriterOfMinds (General Project Discussion)
October 27, 2024, 09:17:10 pm
Ai improving AI
by infurl (AI Programming)
October 19, 2024, 03:43:29 am
Atronach's Eye
by WriterOfMinds (Home Made Robots)
October 13, 2024, 09:52:42 pm
Running local AI models
by spydaz (AI Programming)
October 07, 2024, 09:00:53 am
Hi IM BAA---AAACK!!
by MagnusWootton (Home Made Robots)
September 16, 2024, 09:49:10 pm
LLaMA2 Meta's chatbot released
by spydaz (AI News )
August 24, 2024, 02:58:36 pm
ollama and llama3
by spydaz (AI News )
August 24, 2024, 02:55:13 pm
AI controlled F-16, for real!
by frankinstien (AI News )
June 15, 2024, 05:40:28 am
Open AI GPT-4o - audio, vision, text combined reasoning
by MikeB (AI News )
May 14, 2024, 05:46:48 am
OpenAI Speech-to-Speech Reasoning Demo
by MikeB (AI News )
March 31, 2024, 01:00:53 pm
Say good-bye to GPUs...
by MikeB (AI News )
March 23, 2024, 09:23:52 am
Google Bard report
by ivan.moony (AI News )
February 14, 2024, 04:42:23 pm
Elon Musk's xAI Grok Chatbot
by MikeB (AI News )
December 11, 2023, 06:26:33 am

Users Online

297 Guests, 0 Users

Most Online Today: 491. Most Online Ever: 2369 (November 21, 2020, 04:08:13 pm)

Articles