XML based language grammar standard

BlitzMax Forums/BlitzMax Programming/XML based language grammar standard

beanage(Posted 2010) [#1]
I'm looking for something like this, and ain't found it so far. In the end, a whole parser should be able to work based on the input of a scheme similar to this:

<language name="Testlanguage" casesensitive="false" linesensitive="false">
  <grammar>
    <token name="command" prefix=" ">
      <has side="right" optional="true">arguments</has>
      <callback function="CompileCommand(command,arguments)"/>
    </token>
    <token_array name="arguments" separator="," prefix="(" postfix=")">
      <has side="left">command</has>
    </token_array>
  </grammar>
<language>

e.g. this would parse:
" Print(Hello World) End"


The above example is nearly complete, but it gives a clue of what I am looking for. Any answers appreciated. [It could be damn powerful, couldnt it? Fascinating!]

[Edit:] No problem if it didnt exist. I'd enjoy creating something similar, just wanna go with standards wherever possible.

[Edit2:] Backus-Naur is the way to go, thanks to Warpy and Otus I do know finally :)


Dreamora(Posted 2010) [#2]
No, there is no "FlexiMax" ;)


Otus(Posted 2010) [#3]
I'm not sure exactly what you are looking for, but I have been working (on and off) on a parser framework. It doesn't use XML for grammar files, though, but my own format based loosely on Backus-Naur Form.

Why do you want to use XML and what exactly are you looking for?


ziggy(Posted 2010) [#4]
Use Regex expressions. This is the standard for XML language definitions. If you use BLIde, you will see some examples inside the folder DEF of the blide setup, as BLIde is highlighting some source code formats based on XML language descriptions.

Regex info: http://msdn.microsoft.com/en-us/library/az24scfc.aspx


Otus(Posted 2010) [#5]
Use Regex expressions.

That's indeed a good idea for regular languages. Brucey's RegExModule is very useful. However, it's not enough for a context free language, like anything with nesting of arbitrary depth.


Warpy(Posted 2010) [#6]
Backus-Naur form really is the way to go.


beanage(Posted 2010) [#7]
@Warpy
Oh hell yea, Backus-Naur looks pretty perfect! Thank you!

@ziggy
RegEx leaves me in doubts.. not just that I cant realy determine whether what I wanna do fits the scheme of a "regular language", but the inavailability of "structures nested into arbitrary depth" and incompatibility with context-free languages, as Otus pointed out, is the dealbreaker here.