Arc Forumnew | comments | leaders | submitlogin
Compiler/translator using Arc?
2 points by adm 5424 days ago | 5 comments
I'm thinking of writing a translator for a custom language for inhouse use. Target language will be VBscript. I'm novice to compilers and translators. so far I gathered that there are two options a) tweak existing syntax: e.q. in ruby taking advantage of blocks and closures, design new domain specific constructs, wherein I won't have to do syntax parsing and evaluation, just a code generation b) new syntax and translator for it(it won't be a lisp like syntax).

How difficult it is to write a translator in lisp? Can you please point me to references for writing those using lisp/scheme. I think if I go by option-b it will give me chance to learn and write using Arc. (It'll be my side project.) thanks.



2 points by twilightsentry 5424 days ago | link

Have you looked at _Essentials of Programming Languages_? It focuses on interpreters rather than compilers, but its a good place to start if you're not clear about how to lower some construct (eg, closures) that your syntax defines but which don't directly correspond to something in vbs.

On a side note, is there any particular reason you wouldn't want to use a lispey syntax? You get a lexer for free, and could implement whatever domain-specific constructs you like as macros.

-----

1 point by shader 5424 days ago | link

As the syntax will not be lisp-like, it will not nearly as easy to write a translator as it would be otherwise, but lisps such as arc are still very concise languages, and macros give you a lot of power.

Which would you rather do? It will probably be challenging either way.

-----

1 point by adm 5424 days ago | link

option-b. Any advantages of using lisp for this than other languages?

-----

1 point by shader 5424 days ago | link

Advantages of arc:

1) powerful macros 2) functional and imperative programing 3) strong tree handling functions

Disadvantages:

1) arc is somewhat slow. 2) arc has few libraries

There might be more, but lisp is just a programming language like everything else. It might be somewhat better, but odds are it won't be a "silver bullet".

-----

1 point by Adlai 5424 days ago | link

I think that Lisp can support good quality syntax parsers. An example of this, although it's not a full fledged language, is CatDancer's JSON parser built on top of a general-purpose parser library: http://hacks.catdancer.ws/parser-combinator-approach-to-json... (it's a long article, the relevant parts are the ones about the parser-combinator approach).

Also, it seems as though your in-house language isn't completely specified yet. One area where Lisp excels is implementing unspecified things, and changing them with great flexibility on-the-fly.

Shader mentioned that Arc is slow, and this does seem to be the case. If you really want to use a Lisp, and Arc is too slow, it's probably worth looking at a few other Lisps before turning to Option A -- there are very fast implementations of both Common Lisp and Scheme.

-----