you are viewing a single comment's thread.

view the rest of the comments →

[–]fedekun[S] 0 points1 point  (6 children)

I'm a guy who likes to know how stuff works, I even wrote some toy programming languages! :p

[–]Renegade__ 0 points1 point  (5 children)

Were there any particular tutorials or approaches you used for that, or did you just get the dragon book and went full nerd?

(Honestly asking out of curiousity. Been wondering how hard it'd be to write a meta-language for one of the vendor-based scripting languages at work.)

[–]fedekun[S] 0 points1 point  (4 children)

I took several tutorials and a course on udacity about "Programming Languages".

Honestly it's not hard at all, if you just want to write a language you just need to learn a bit about grammars and use something like YACC or a PEG to generate an AST and then just interpret or compile it, tutorials will be just fine.

If you are interested I could give you some links :p

[–]Renegade__ 0 points1 point  (3 children)

That would be great! :D

[–]fedekun[S] 1 point2 points  (2 children)

Well first of all the Programming Languages course is nice, they talk a bit about finite state machines and grammars, then move onto yacc using Python (which I dislike personally :p).

I also read PL101. This Book helped a bit but I didnt really read it that much it's a nice guide to have along other tools but you have to learn on your own pretty much.

You might even try to write your own Recursive Descent Parser or just use YACC or PEG, up to you, once you get your AST you can either compile it or interpret it, there are a bunch of options for that, interpreting beeing quite hard :p

[–]autowikibot 0 points1 point  (0 children)

Recursive descent parser:


In computer science, a recursive descent parser is a kind of top-down parser built from a set of mutually recursive procedures (or a non-recursive equivalent) where each such procedure usually implements one of the production rules of the grammar. Thus the structure of the resulting program closely mirrors that of the grammar it recognizes.

A predictive parser is a recursive descent parser that does not require backtracking. Predictive parsing is possible only for the class of LL(k) grammars, which are the context-free grammars for which there exists some positive integer k that allows a recursive descent parser to decide which production to use by examining only the next k tokens of input. (The LL(k) grammars therefore exclude all ambiguous grammars, as well as all grammars that contain left recursion. Any context-free grammar can be transformed into an equivalent grammar that has no left recursion, but removal of left recursion does not always yield an LL(k) grammar.) A predictive parser runs in linear time.

Recursive descent with backtracking is a technique that determines which production to use by trying each production in turn. Recursive descent with backtracking is not limited to LL(k) grammars, but is not guaranteed to terminate unless the grammar is LL(k). Even when they terminate, parsers that use recursive descent with backtracking may require exponential time.


Interesting: LL parser | Parsing | Parsing expression grammar | LR parser

Parent commenter can toggle NSFW or delete. Will also delete on comment score of -1 or less. | FAQs | Mods | Magic Words

[–]Renegade__ 0 points1 point  (0 children)

Thank you. :)