Custom Language Tutorial with C Style Language

I really like the custom language tutorial and I understand most of it, but I'm having trouble with the bnf and flex lexer concepts. I would love to see a basic flex and bnf grammar kit tutorial with a c style language. Just real simple with keyword support and matching braces and perhaps strings. I think this would really tie the concepts together for me if I had something that could go step by step through the thought process of writing these files. The properties file example is nice, but it would be great to have something that is presented with a c-style language since there are so many of them.

3 comments
Comment actions Permalink

Actually a tutorial reimplementing this logic in GrammarKit would be amazing. None of the UI, but how to write a BNF and Lexer to accomplish all the settings provided here. That would be a great foundation to build from.
Screen Shot 2015-07-13 at 10.01.07 PM.png

0
Comment actions Permalink

Custom file type highlighting is provided entirely by a lexer; there is no parser, grammar or BNF involved. A BNF becomes necessary when you have a code construct that consists of multiple tokens (for example, an if statement consists of an "if" keyword token, an open parenthesis token, an expression, a close parenthesis token and so on). Custom file type highlighting does not use any such constructs.

0
Comment actions Permalink

Thanks for the explanation Dimitry. I'm still trying to wrap my head around grammars, lexers and parsers, but they seem to be the key to writing a custom language beyond simple highlighting. I was thinking that might be a good place to start. In theory when I read the simple plugin tutorial the properties file example of the bnf, flex lexer make sense, but it doesn't go far enough for me to apply the same logic to something a bit more complex. After that section of the tutorial I can follow along no problem and the Java APIs make sense enough where I can figure it out how to customize them for my purposes, sometimes with the help of the forum of course :D

0

Please sign in to leave a comment.