BlitzMax Code Parser

BlitzMax Forums/BlitzMax Programming/BlitzMax Code Parser

Hardcoal(Posted 2013) [#1]
Is there a BlitzMax CodeParser or should I need to write my own?
If not then is there Anywhere a code parsing tutorial?


Htbaa(Posted 2013) [#2]
There's a Lexer by Nilium http://maximus.htbaa.com/module/cower/bmxlexer


Yasha(Posted 2013) [#3]
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 bestusable results they should always be left to machine-generation, so for most languages you plug in abstract language rules to a parser framework and get out an auto-generated parser module).

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.


GW(Posted 2013) [#4]
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!


Yasha(Posted 2013) [#5]
Wow, that's extremely cool.


Hardcoal(Posted 2013) [#6]
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


ziggy(Posted 2013) [#7]
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)


Hardcoal(Posted 2013) [#8]
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 :)?


Brucey(Posted 2013) [#9]
Is there another way to write

By automated code generation, presumably.


nitti(Posted 2013) [#10]
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 ;)