mgrammar

Oslo's Intellipad: How to set up the 3 column MGrammarMode?

I've been using Oslo for MSchema. Works great. I can write an M Schema for a database design and it generates T-SQL to build the entire db with PKs, FKs, checks for integrity etc. I've set up a .bat file to compile the .m into .mx then load it into the db, then run SqlMetal into my project and in 30 seconds I'm moving on with my chang...

Shift reduce and reduce reduce conflicts

I'm having a hard time wrapping my head around this and need some help understanding shift reduce and reduce reduce conflicts. I have a grammar which I can't seem to understand why it's problematic. I could attach the grammar, but I want to learn how this really works. First question, what type of parser does MGrammer create? As I under...

MGrammar grammar and variable declaration

I'm sure I'll get told to do it another way, but for specific reasons it has to be done this way. If it didn't, I wouldn't be stuck :-P The scripting language I'm working on has to accept variables defined like this: Variables: x(1), y("hi"); This is a requirement. I wrote a small grammar before that would let me define them like t...

MGrammar and more than one valid interpretation

I think what I may have is the dangling else problem, but I'm not really sure. The language I'm tasked with writing needs to support multi-line if statements as well as single line i.e. if(conditions){ print "multi"; print "line"; } and if(conditions) print "single line" Which in my language corresponds to if conditions t...

Is there a better way to define a decimal in an MGrammar?

I'm working on a DSL in Microsoft's new M Grammar, and it needs to allow decimal values. I've defined decimal as token digits = "0".."9"; token spot = "."; token decimal = digits+ | digits+ spot digits+ | spot digits+; That seems to work, but is there a better way? It just feels like I'm missing something. ...

MGrammar for parsing IF statement

I am building up a MGrammar spec to parse some pseudo code looking for particular bits of information. I have most of the spec working except for 1 cruical element. The pseudo code supports an if-then-else syntax and I have been unable to find a satisfactory way of parsing it. The exact construct is... IF expression operator expres...

Is it possible to parse multi-line c style comments in MGrammar?

I've been hacking around with the May09 Oslo bits, experimented with tokenizing some source code. I can't seem to figure out how to correctly handle multiline C-style comments though. For example: /*comment*/ Some cases that elude me: /***/ or /**//**/ I can make one or the other work, but not both. The grammar was: module Te...

Writing a parser with M, consume while not rule

I'm writing a HTML parser for my own amusement and I wanted to try out M. I base this work on the HTML 4.01 standard and in there it says Although the STYLE and SCRIPT elements use CDATA for their data model, for these elements, CDATA must be handled differently by user agents. Markup and entities must be treated as raw tex...

Parsing blocks of line comments using MGrammar

How can I parse blocks of line comments with MGrammar? I want to parse blocks of line comments. Line comments that are next to each should grouped in the MGraph output. I'm having trouble grouping blocks of line comments together. My current grammar uses "\r\n\r\n" to terminate a block but that will not work in all cases such as at end...