.NET Framework Bookmark and Share   
 index > Microsoft Codename 'Oslo' > MGrammar control of function production
 

MGrammar control of function production

Here is my syntax:

syntax Binary(expression, operator)
= e:expression => e
| e1:expression o:operator e:Binary(expression, operator)
=> BinaryExpression[Left[e1], Operator[o], Right[e]];

When calling it you might have something like this:

syntax BinaryLogicalExpression
= b:Binary(BinaryEqualityOperatorsExpression, BooleanLogicalOperators)
=> b;

But b is resulting in the node named:

Binary(MetaSharp.CodeDom.BinaryEqualityOperatorsExpression,MetaSharp.CodeDom.BooleanLogicalOperators)[
BinaryExpression[
Left[...],
Operator[...],
Right[...]
]
]

When what I really want is just:

BinaryExpression[
Left[...],
Operator[...],
Right[...]
]

This was working in CTP1 but is suddenly now not working in CTP2... how can I strip of the name of the function and just get what it is returning?
justncase80
I think to fix this I have to change the calling syntax to be:

syntax BinaryLogicalExpression
= b:Binary(BinaryEqualityOperatorsExpression, BooleanLogicalOperators)
=> BinaryExpression[valuesof(b)];

Which I don't really like :( I basically had to drop the function and just inline it into all of the places it was being called because of this change. Very unfortunate.

You probably need another keyword where you can essentially do valuesof(x) without having to actually put it into [...] itself. If I could have had:

syntax BinaryLogicalExpression
= b:Binary(BinaryEqualityOperatorsExpression, BooleanLogicalOperators)
=> valuesof(b);

That would have been fine. But as is, I feel like this is a major issue. It totally prevents me from outputting a correct graph when using parameterized syntax in some situations. Yuck.
  • Marked As Answer byjustncase80 Thursday, February 19, 2009 1:12 PM
  •  
justncase80
I think to fix this I have to change the calling syntax to be:

syntax BinaryLogicalExpression
= b:Binary(BinaryEqualityOperatorsExpression, BooleanLogicalOperators)
=> BinaryExpression[valuesof(b)];

Which I don't really like :( I basically had to drop the function and just inline it into all of the places it was being called because of this change. Very unfortunate.

You probably need another keyword where you can essentially do valuesof(x) without having to actually put it into [...] itself. If I could have had:

syntax BinaryLogicalExpression
= b:Binary(BinaryEqualityOperatorsExpression, BooleanLogicalOperators)
=> valuesof(b);

That would have been fine. But as is, I feel like this is a major issue. It totally prevents me from outputting a correct graph when using parameterized syntax in some situations. Yuck.
  • Marked As Answer byjustncase80 Thursday, February 19, 2009 1:12 PM
  •  
justncase80

You can use google to search for other answers

Custom Search

More Threads

• feature suggestion; simple types declared in M -> alias types in TSQL
• Defining String Literals in MGrammar?
• Component Model Instances vs. Component Consumer Model Instances
• target:source?
• Is there any way to define conditional rules in MGrammar?
• oslo Repository Database install error.
• Oslo May 2009 CTP procedures rely too much on DOS Command functions
• MProject.targets complains that Enumeration does not define a primary key
• Syntax Coloring for Your Custom Mg Language with Intellipad
• MGrammar: Parameterized production's output