Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

SEXP-parser in LISP

Name: Anonymous 2010-12-27 20:55


parseWS xs -> all \Space xs
parseNumber [@xs] -> if (all digit? xs) then asBase 10 xs
parseSymbol [@xs] -> if (all alpha? xs) then asSymbol xs
parseRest x -> x.{[] => 'nil; [@!WS] => 'nil
                  [\Space @!WS e:!Sexp es:!Rest] => if es=='nil [e] [e@es]}
parseList xs -> parseRest [\Space @xs]
parseSexp x -> x.{[e:!Number]=>e; [e:!Symbol]=>e
                  [\( @!WS es:!List \)] => e}

Name: SEXP-parser in LISP/Scheme 2010-12-27 21:19

(read)

It is portable.

Name: Anonymous 2010-12-27 21:34

>>2
How about parsing Scheme from CL?

Name: Anonymous 2010-12-27 21:39

>>3
The implementation is left as exercise for the reader.

Name: Anonymous 2010-12-28 5:44

Your language isn't really Lisp, please give it a real name instead as you've already invented enough syntax for it. At a glance it looks like a cross between Haskell, ML and CL.

Name: Anonymous 2010-12-28 7:39

>>5
>you've already invented enough syntax
If you call reader macros syntax

cross between Haskell, ML
I will consider such comparison as an insult. Haskell/ML symbolizes everything I hate in programming. Static math-wannabe Algol descendants with BDSM syntax.

Name: Anonymous 2010-12-28 8:20

The Haskell/ML comparison comes from the syntax and overall style used, not the static nature of the language.

Name: Anonymous 2010-12-28 10:44

>>6
an insult
->
xs

IHBT

Name: Anonymous 2010-12-28 13:38

>>6
If you call reader macros syntax
I'm quite sure you could write a Pascal interpreter using that.

Name: Anonymous 2010-12-28 15:31

>>6
If you call reader macros syntax
I call syntax syntax. I suppose next you'll claim your language doesn't have a grammar either, you lower-class bum.

Name: Anonymous 2010-12-28 20:22

>>9
>I'm quite sure you could write a Pascal interpreter using that.
No. I couldnt, because implementing Pascal requires BNF gammars, not SEXPs.


>next you'll claim your language doesn't have a grammar either
Sorry, cant find grammars anywhere. Probably lost together with design document :-(

Name: Anonymous 2010-12-28 20:25

>>8
Whats wrong with `xs`? I've seen some schemers used `xs` and `ys` as a general name for lists.

Name: Anonymous 2010-12-28 20:55

Lisp is a copyrighted trademark. OP will be sued.

Name: Anonymous 2010-12-28 21:03

OP is a copyrighted trademark. Lisp will be sued.

Name: Anonymous 2010-12-28 21:14

Trademark is a copyrighted Lisp. OP will be sued.

Name: LISPPER 2010-12-28 21:14

Lisp is a Lisped Lisp. Lisp will be Lisped.

LISP

Name: Anonymous 2010-12-29 0:33

>>12
I use xs in scheme, but I've also implemented nomads

Name: Anonymous 2010-12-29 2:43

XS is a copyrighted trademark. >>17 will be sued.

Name: Anonymous 2010-12-29 2:58

Whenever i see ``xs'', especially when used in pattern matching like x::xs to denote an element and the rest of the list, I think of it like: the CAR is x, REST are xs (plural of ``x'').

Name: Anonymous 2010-12-29 3:06

>>19
Too bad if your code implements driving simulator and there is a bunch of `car` vars.

Name: Anonymous 2010-12-29 3:12

when used in pattern matching like x::xs
If Haskell had real pattern matching, it would be possible to match things like

parseEnglish [v:!verb o:@Object as:@Adverbs] -> [[v as] o]

but no, Haskell forces you to monkey code everything, just like C/C++.

Name: Anonymous 2010-12-29 3:36

>>19
You mean the CDR (cudder) is xs. (plural of ``x'', but cdr is singular)

Name: Anonymous 2010-12-29 3:37

>>21
But do you have monads, haskell monads?

Name: Anonymous 2010-12-29 3:43

>>21
Not related to Haskell, but natural language parsing is pretty difficult as most of them evolved naturally, and to truly be able to obtain the true meaning of a sentence in an unmbiguous way requires "understanding" and "context". There's some promising statistical methods for dealing with this, but they're still quite imperfect. I think the best solution is to just aim at creating a human-level intelligence general AI and teach it human languages (such an AI could be based on a high-level model of our brain or a more low-level model such as a huge neural net that tries to model the neocortex and other related structures. Too bad such projects are still quite expensive these days).

Name: Anonymous 2010-12-29 3:56

>>20
nice.

Name: Anonymous 2010-12-29 3:56

>>20
I lol'd

Name: Anonymous 2010-12-29 4:09

>>24
With a simple pattern matching you still can easily parse well-formed sentences of a language, like of the form:

verb adjectives object adverbs

of course you will need separate hash tables for classifying words.

Name: Anonymous 2010-12-29 4:14

>>27
Also, these simple sentences could be used to train more robust fuzzy AI, but one still have to parse them somehow, lol.

Name: Anonymous 2010-12-29 6:54

>>24
>true meaning of a sentence
Try reading Bible, then explain to us "true meaning" of word "God". The truth is that there is no truth.

Name: Anonymous 2010-12-29 6:58

>>29
The truth is that there is no truth.
That's kind of self-contradicting, atheistfag

Name: Anonymous 2010-12-29 7:11

>>30
Truth is much too complicated to allow anything but approximations. -- John von Neumann

Name: Anonymous 2010-12-29 7:21

>>31
Apparently it was too hard for von Neumann to place program code and data in different memory, which led to all this clusterfuck of security problems and technologies designed specifically to protect corruptable stacks and heaps. I wouldn't trust this guy in anything.

Name: >>24 2010-12-29 8:20

>>29
That would be explaining the meaning of one definition of one word. In your example, it would be difficult as the concept is self-contradictory and I don't see how logically fallacious concepts can exist (at least if you take the entire book as true).

What I actually meant about my "true meaning" part was more about a human mind being able to resolve ambiguity in human language by integrating context. While in some cases resolving ambiguity and getting to more raw "truths" may be needed, I meant something more casual in my example.

Name: Anonymous 2010-12-29 8:28

>>33
>human mind being able to resolve ambiguity in human language by integrating context
Judging from all those people, who "believe" in "God" or supreme truth or that their program doesnt have bugs, I can hardly agree with you.

Name: Anonymous 2010-12-29 8:29

/prog/ - Philosophy

Name: Anonymous 2010-12-29 8:53

>>34
The human mind is a feeble and fallible thing. It takes a certain mindset to be able to approach things in a rational manner. Some humans are just fine with living with contradictions and try to put them away in their mind, but I can't imagine it'd feel good or healthy ( http://en.wikipedia.org/wiki/Cognitive_dissonance ).

Name: Anonymous 2010-12-29 14:10

>>34
I believe in God and supreme truth, but I'm certain my programs are filled with bugs.

Don't change these.
Name: Email:
Entire Thread Thread List