How to implement a programming language in JavaScript
lisperator.net
How to implement a programming language in JavaScript
1–10 of 39 posts
Re: How to implement a programming language in JavaScript
#2Re: How to implement a programming language in JavaScript
#3Re: How to implement a programming language in JavaScript
#4Just wondering if it is true that most of the modern language parsers are written in C?
Re: How to implement a programming language in JavaScript
#5I've done a really hacky version of something this where a user would input a succinct, high-level description of a sequence of colored lighting, and my program would parse* that and build the tedious, low-level JSON representation of that sequence for yet another program to perform. Is there a fancy or unfancy name for that?
*Ok really it was a little bit of munging and then eval.
Re: How to implement a programming language in JavaScript
#6Re: How to implement a programming language in JavaScript
#7Is there such a thing as a language that compiles to a value rather than an executable program? I've done a really hacky version of something this where a user would input a succinct, high-level description of a sequence of colored lighting, and my program would parse* that and build the tedious, low-level JSON representation of that sequence for yet another program to perform. Is there a fancy or unfancy name for th…
There's a continuum between this and what we think of as a "value" in programming terms (eg. an int or a string), but the boundary is fuzzy. It was pretty common at Google to write DSLs that compiled to a protobuf that'd be loaded into the server as configuration, for example. CUDA compiles programs into a buffer that is then sent to the GPU. HTML compiles into the DOM, which is a value that can be manipulated with Javascript.
Re: How to implement a programming language in JavaScript
#8Just wondering if it is true that most of the modern language parsers are written in C?
Probably true, but only because the implementation language for them is also C . Some of them also frequently use a mix of the implementation language and grammar specification DSL like yacc.
consider:
input: /* empty string */
| input line
;
line: '\n'
| exp '\n' { printf ("\t%.10g\n", $1); }
;
exp: NUM { $$ = $1; }
| exp '+' exp { $$ = $1 + $3; }
| exp '-' exp { $$ = $1 - $3; }
| exp '*' exp { $$ = $1 * $3; }
| exp '/' exp { $$ = $1 / $3; }
| '-' exp %prec NEG { $$ = -$2; }
| exp '^' exp { $$ = pow ($1, $3); }
| '(' exp ')' { $$ = $2; }
;
http://dinosaur.compilertools.net/bison/bison_5.html#SEC27Re: How to implement a programming language in JavaScript
#9Just wondering if it is true that most of the modern language parsers are written in C?