20 years of code generation led here. The YAML 1.2 spec has 211 grammar productions. I converted them from the Haskell reference implementation to s-expressions, wrote a projector in Common Lisp, and generated spec-compliant parsers in 18 languages. All pass 308/308 YAML Test Suite tests. Adding a new language is a 300-line target spec. The projector does the rest in seconds.
Comments
amno•2h ago
I have read through your pdf and I think you make a best case for Lisp I have read in last few years.
We could just imagine who programming languages would look like if we abandoned the specialized notations like Haskell or C++, of which C++ really starts to show up that such notations are probably a dead-end. Or if B. Eich was allowed to use Scheme as the built-in scripting language for Netscape. Perhaps we would not need XML and/or Json even Yaml as machine interchange and description formats?
Anyway, I am not familiar with Futamura and yaml spec, your texts in the repo, and your project is the first time I see this. I did a webserach and have read through the Wikipedia page on Partial evaluation which talks about Futamura projections. But can you please ELI5-me about your project: is this a yaml parser generator or is this a DSL/PL language parser generator? Can I specify few rules in a language of my choice, say C, and it will generate a yaml parser and test suite in C language? Or does it mean I can specify a parser for a programming language, say C or a DSL, as yaml production rules in language of my choice, say Common Lisp, and it will generate a parser for C or that DSL in Common Lisp? Or do I understand this completely wrongly? :)
How does this project compares to something like tree-sitter? This AST you build, I have just glanced over it thus far, or use under the hood, could that be exposed somehow, or is it already, to the application? For example, could we build a server in Common Lisp, that reads this various language specs, builds an AST and gives us answers on questions like: is this position in a code for a function definition, or in a comment, and similar? In other words, could we use it for a tool that gives information about meta-data from the source code so we could use it to build tools like LSP servers, indentation servers, syntax highlight and such? Just a curious question, forgive me if I misunderstand what this does.
amno•2h ago
We could just imagine who programming languages would look like if we abandoned the specialized notations like Haskell or C++, of which C++ really starts to show up that such notations are probably a dead-end. Or if B. Eich was allowed to use Scheme as the built-in scripting language for Netscape. Perhaps we would not need XML and/or Json even Yaml as machine interchange and description formats?
Anyway, I am not familiar with Futamura and yaml spec, your texts in the repo, and your project is the first time I see this. I did a webserach and have read through the Wikipedia page on Partial evaluation which talks about Futamura projections. But can you please ELI5-me about your project: is this a yaml parser generator or is this a DSL/PL language parser generator? Can I specify few rules in a language of my choice, say C, and it will generate a yaml parser and test suite in C language? Or does it mean I can specify a parser for a programming language, say C or a DSL, as yaml production rules in language of my choice, say Common Lisp, and it will generate a parser for C or that DSL in Common Lisp? Or do I understand this completely wrongly? :)
How does this project compares to something like tree-sitter? This AST you build, I have just glanced over it thus far, or use under the hood, could that be exposed somehow, or is it already, to the application? For example, could we build a server in Common Lisp, that reads this various language specs, builds an AST and gives us answers on questions like: is this position in a code for a function definition, or in a comment, and similar? In other words, could we use it for a tool that gives information about meta-data from the source code so we could use it to build tools like LSP servers, indentation servers, syntax highlight and such? Just a curious question, forgive me if I misunderstand what this does.
Edit: was looking a bit around and found a nice intro into Futamura projections: https://www.youtube.com/watch?v=RZe8ojn7goo.
This is awesome :). Thanks.