BlitzMax Code Parser
BlitzMax Forums/BlitzMax Programming/BlitzMax Code Parser
| ||
Is there a BlitzMax CodeParser or should I need to write my own? If not then is there Anywhere a code parsing tutorial? |
| ||
There's a Lexer by Nilium http://maximus.htbaa.com/module/cower/bmxlexer |
| ||
Parsing is a popular topic in introductory CS, so there are tutorials for it all over the internet. BlitzMax has the major problem that there don't seem to be any parser frameworks or parser generators for it, so you aren't easily going to be able to write one in BlitzMax itself (actual parser code is one of those things you absolutely never want to write by hand: for The easiest option is probably to use a C or C++ generator like Yacc or BISON, and take advantage of BlitzMax's C Import capability to plug the generated module directly into your Max code (since you don't normally hand-modify generated code anyway, it doesn't matter that the target isn't BlitzMax). The hard part is reverse-engineering a grammar for BlitzMax, because one hasn't been made publicly available. That said, if this is for your editor project, you'll want a slightly more flexible kind of parser that ignores most constructs anyway and only picks out interesting things like names and types, so you don't need to work out all of the rules, only the interesting ones. Depending upon how simple the editor is (where is it on the long line between Geany and Visual Studio?), you can actually get away with some very simple one-liner rules indeed. |
| ||
Grable has already done all the heavy lifting. https://sites.google.com/site/grable0/coocoo I've used it for a few projects and it works great! |
| ||
Wow, that's extremely cool. |
| ||
Thanks yasha and GW you are both very helpful Ill do my best and see where ill get. But Is there a tutorial for this CooCoo Thingy I have no Clue in parsing |
| ||
actual parser code is one of those things you absolutely never want to write by hand I would recommend the oposite. BlitzMax is simple enough to allow for a hardcoded by-hand written parser and you'll learn a lot from it. Parser generators are great, but I imagine you'll want to make a simple tokenizer first, instead of going the full AST route... ? (just gessing) |
| ||
What the heck do you mean by Saying Handwritten Parser. I keep seeing it in relation of Parser Writing. Is there another way to write :)? |
| ||
Is there another way to write By automated code generation, presumably. |
| ||
I've had to fun in the past with this document http://effbot.org/zone/simple-top-down-parsing.htm mind you it's for Python (but Python is a pretty good pseudocode language) I can have a look and see if I can find the simple parser I've made in monkey. But the code it could parse wasn't as advanced as blitzmax.. edit: tha Coocoo seems much better Wow! for tutorials : "Its grammar is similar to ParserGen, but more like real Coco/R (with my own take on it of course ;)). " so * https://sites.google.com/site/grable0/parsergen * http://www.ssw.uni-linz.ac.at/coco/ and offcourse the samples in the Coocoo folders ;) |