News for hackers. Stuff that matters.
Re:Writing Your Own Programming Language by protomikron on Thursday November 10, 2016 @01:01PM (#12922636)
Why is it so often stated, that Scheme doesn't need a parser? I mean the AST is simpler then in other languages, but at the end of the day, you have to parse SEXPs, don't you?

I mean let's say you evaluate

  > (+ 2 3)
You have to parse the string "(+ 2 3)" and will then evaluate it to 5?
Re:Writing Your Own Programming Language by richard_todd on Thursday November 10, 2016 @01:38PM (#12922952)
... reading sexp's is technically parsing but it is so far removed from something like a C parser that it's really not the same animal. I mean, you can write a function to build a list from a sexp in a few minutes, while even a basic hand-written C parser will take days/weeks/months depending on your familiarity.

So, that's a reason why it is said. (edit: also, if the course implements scheme IN scheme, then you don't need a parser because the host scheme can do it for you.)

Re:Writing Your Own Programming Language by protomikron on Thursday November 10, 2016 @01:51PM (#12923078)
> ... reading sexp's is technically parsing but it is so far removed from something like a C parser that it's really not the same animal.

Yeah it is obviously a lot easier to parse than traditional, imperative languages like C. I just do not like the phrase, as it gives this "magic" vibe to Scheme. I mean its syntax is beautiful and simple, but there is definitely no magic there.

Re:Writing Your Own Programming Language by nickpsecurity on Thursday November 10, 2016 @09:15PM (#12926846)
McCarthy's basic evaluator for LISP in a page or two in a high-level language (esp LISP). That's not magic but good design gets plenty close. ;)
Re:Writing Your Own Programming Language by mncharity on Thursday November 10, 2016 @11:37PM (#12927890)
"It's easy to parse scheme" is one of those pretty stories that is often repeated but untrue. A similar one is "it's easy to implement scheme in scheme".

It is true for toy compilers of language subsets, and those are often done. And few people ever explore real scheme compiler internals.

The readers in real scheme compilers are generally a large pile of ugly code. A decade or so ago, I recall Bigloo's was the cleanest I'd found, with a regular expression based parser framework. I can't quickly find the files to link. But after wading through many other implementations, it was a breath of fresh air. But not simple, and not small.

Here's a quick quote from a Chicken changelog: "2.7 Fix several bugs (expt, integer?, rational?, <=, >=, eqv?, -) found by importing the number tests from Gauche and writing an extensive test for number syntax edge cases. Complete rewrite of number parser (it should fully conform to the R7RS superset of R5RS number syntax now)."

Re:Writing Your Own Programming Language by acchow on Thursday November 10, 2016 @04:22PM (#12924497)
we mean it doesn't need a parser in the traditional sense of a LR or LL grammar (or more complicated) with generated table or even a hand-rolled parser with lookahead.

Sure, it needs a "parser" in the sense of a FSA + a stack.

Re:Writing Your Own Programming Language by DonaldFisk on Thursday November 10, 2016 @01:13PM (#12922720)
The read function the parser.