r/Compilers • u/Commercial-Drawer881 • Jul 07 '26
Building a Parser Generator!
Hi, I am creating a Parser Generator. It will have it's own unique syntax for grammar definition. This is what I am working on currently. I am sharing a draft of the syntax and asking if anyone is interested in sharing their feedbacks in the comments.
Is this syntax:
- easy to read?
- easy to understand?
- sparks interest in you?
- what stands out?
- do you suggests any changes or additions?
UPDATED
I am settling on a syntax for the language. Here is a snippet:
# BASIC LANG
# ---------
# A 100
# B 25
parser {
# action -> ast: (parent(children))
(name number) -> (name(number)); # generate name with number as child of name
(spc | nl) -> (); # no AST generated
}
name = <A:Z>+; # character sequence
number = <0> | <1:9> <0:9>+; # character sequence
# spc is built-in rule for space
# nl is built-in rule for nl
Full syntax is being worked on here: https://github.com/Algodal/Algodal_Text_Parser_Generator_Manual
I will be streaming code implementation of the parser generator on youtube: https://www.youtube.com/@RevnantRicko
View all comments
Show parent comment
-1
u/Commercial-Drawer881 Jul 07 '26
Thank you for your feedback!
Mixes Lexer and Parser? Yes, it does. It can be challenging dealing with multiple files and ensuring changes are consistent between them. I believe using a single file is the best approach, and the parser generator compiler will be able to give you proper compile messages across the entire pipeline. However, do note that the parser part (Syntactic Analysis) is completely optional. If you want to write only a token generator, that works just fine.
Doesn't resemble EBNF? I understand that it can be challenging to adopt something new that doesn't follow the de facto standard of EBNF. I believe that as long as I design the syntax to be simple and clear enough, and the parser generator provides significant benefits and fixes known pain points, people will be willing to give it a try.