News for hackers. Stuff that matters.
Re:Things That Turbo Pascal is Smaller Than by tluyben2 on Sunday October 30, 2011 @08:33PM (#3175863)
There are a billion Lisp parsers in a few lines of Python, C, Lisp, etc. Any Pascal ones like that?

Edit; not meant sarcastic, I would really like to see such a simple parser as was implied.

Re:Things That Turbo Pascal is Smaller Than by colanderman on Sunday October 30, 2011 @08:51PM (#3175902)
"parsed and codegenned" he said. Any Lisp compilers like that?
Re:Things That Turbo Pascal is Smaller Than by ajross on Sunday October 30, 2011 @11:08PM (#3176203)
No, but only by definition. Passing through an s-expression representation is a requirement for a lisp compiler, because the tree to be compiled might have been built at runtime. Certainly lisp's grammar is no more complicated than pascal's.

Nor, frankly, is K&R C, which is is also a very simple representation. The ANSI process added some edge cases that complicated it, but really it's pretty simple.

Re:Things That Turbo Pascal is Smaller Than by rayiner on Sunday October 30, 2011 @11:55PM (#3176306)
I don't know any practical algorithm for handling closures that'll let you code-gen Lisp in one pass, but in general writing Lisp compilers is frightfully easy: http://scheme2006.cs.uchicago.edu/11-ghuloum.pdf
Re:Things That Turbo Pascal is Smaller Than by groovy2shoes on Sunday October 30, 2011 @10:29PM (#3176128)
I believe that's how the Clojurescript compiler currently works (though I haven't looked at the code in detail). Compilers that don't do it that way usually have optimizations going on in between the parse and codegen phases, not because it's impossible to do with Lisp syntax.
Re:Things That Turbo Pascal is Smaller Than by xyzzyz on Monday October 31, 2011 @07:05AM (#3176995)
"because it's impossible to do with Lisp syntax."

The problem is not with Lisp syntax. The problem is with Lisp's semantics, which makes it much more difficult (if at all possible) to compile in one pass. Things like closures, conditions or macros are absent in Pascal.

Re:Things That Turbo Pascal is Smaller Than by fogus on Monday October 31, 2011 @07:02AM (#3176988)
ClojureScript has a two-pass compiler; more if you consider GClosure a step.
Re:Things That Turbo Pascal is Smaller Than by silentbicycle on Monday October 31, 2011 @09:31AM (#3177283)
No, but Lua works that way.
Re:Things That Turbo Pascal is Smaller Than by barrkel on Monday October 31, 2011 @10:01AM (#3177368)
It's easy to write very small interpreters, even ones that JIT code. So much so that some approaches to shrinking software have historically been to write a little VM interpreter, and compile the source code to target that rather than the actual CPU. A compiler that produces code that no longer requires a runtime (in the VM sense - inverted control) is slightly more work.

Turbo Pascal's code generation was simple and naive. It had little optimization. It literally output the machine code as it parsed. There was no AST, not even an expression tree.

(I have the source code to the final version of the Turbo Pascal compiler on my disk. It was used for Delphi 1.)

Re:Things That Turbo Pascal is Smaller Than by outworlder on Monday October 31, 2011 @10:51AM (#3177523)
>(I have the source code to the final version of the Turbo Pascal compiler on my disk. It was used for Delphi 1.)

Is that still under copyright? And chance it could be released?

Re:Things That Turbo Pascal is Smaller Than by barrkel on Monday October 31, 2011 @11:33AM (#3177714)
As far as I know it is still under copyright. Anders Hejlsberg's name is in the comment headers; it was largely rewritten in 1986 and 1987 for TP4. I believe it belongs to Embarcadero, the company I work for, after they bought the developer tools division from Borland.

I have no idea about releasing it. I'm entirely the wrong end of the company to ask about it.

Re:Things That Turbo Pascal is Smaller Than by groovy2shoes on Sunday October 30, 2011 @10:37PM (#3176143)
Those billion Lisp implementations primarily exist because Lisp is fashionable; Pascal is not. In the past, toy Pascal compilers have actually been a popular project (especially in introductory compiler courses).
Re:Things That Turbo Pascal is Smaller Than by 4ad on Monday October 31, 2011 @05:38AM (#3176858)
Go can be parsed in one pass without a symbol table.
Re:Things That Turbo Pascal is Smaller Than by sjs on Sunday October 30, 2011 @09:36PM (#3176015)
Here's a Pascal-ish parser: http://compilers.iecc.com/crenshaw/