GitHub - Chubek/ZephyrASDL: An implementation of Zephyr ASDL in C, targeting C
github.com
external-link
An implementation of Zephyr ASDL in C, targeting C - Chubek/ZephyrASDL

You can use ASDL to describe the tree grammar of your language. After doing that, translate the code to C by running it through my program. Now you have a C file that contains a bunch of constructors, type defs, macros, etc ,that describe the AST of your language. Two examples, a basic one, and one for regex, has been provided. There’s an e simple one for m4 in the man page.

Some people may need further explanations so let’s go ahead and do it:

When you pass a program to the compiler or the interpreter, or another application does that for you, it first gets ‘lexed’, that is, every token is scanned and categorized. Then, these tokens are used to ‘parse’ the program. That is, the chunks of token are used to define the structure of your program, based on a pre-conceived grammar. For example, in my ASDL implementation, you can view the grammar for ASDL in both Yacc format and in EBNF format (in companions/GRAMMAR.ebnf).

Now, the parser takes ‘semantic’ actions whenever it successfully parses a chunk of code. In the early days of computing, people just printed Assembly code! But now, with optimizing compilers and stuff like that, there was need to represent the language in form of a tree. The parser tree was first used. But parser trees are dense, so ‘abstract’ form it was used, which is what this program makes. You can see the abstract structures that represent ASDL itself, in absyn.c.

After you translate your code to AST, you can translate it to DAGs ,or Directed Acyclic Graphs, to get the flow of the program. Then a control flow graph. If your language is interpeted, you can translate it to your VM bytecode.

So this is what ASDL is. A tool for constructing compilers and interpeters, and other DSLs perhaps?

I explained why I created this. Basically, the original implementation was useless.

Thanks.

Nobody even said anything.

Create a post

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person’s post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you’re posting long videos try to add in some form of tldr for those who don’t want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



  • 1 user online
  • 1 user / day
  • 1 user / week
  • 1 user / month
  • 1 user / 6 months
  • 1 subscriber
  • 1.21K Posts
  • 17.8K Comments
  • Modlog