Page 1 of 1

Backus–Naur Form for TM1 Syntax

Posted: Thu Apr 26, 2012 2:50 pm
by John Hammond
Just wondered if there is TM1 Syntax in Backus–Naur Form or equivalent out there.

If not I might have a go myself when Caprice goes on one of her girlie nights out and I have nothing to do of an evening...

Re: Backus–Naur Form for TM1 Syntax

Posted: Thu Apr 26, 2012 3:30 pm
by stephen waters
John Hammond wrote:If not I might have a go myself when Caprice goes on one of her girlie nights out and I have nothing to do of an evening...
John, are you posting in the right sort of forum?? ;)

Re: Backus–Naur Form for TM1 Syntax

Posted: Thu Apr 26, 2012 6:15 pm
by jim wood
I guess the nearest would be variables within TI?

Re: Backus–Naur Form for TM1 Syntax

Posted: Thu Apr 26, 2012 8:40 pm
by Martin Ryan
I'd never heard of it till now. After a bit of Wikipedia I think I grasp it and now the question that comes to mind is why? The documentation gives you all of this information, though obviously not as formally.

I'm just curious as it seems (to me) that watching an episode of Geordie Shore would be an equally productive use of your evening.

Re: Backus–Naur Form for TM1 Syntax

Posted: Thu Apr 26, 2012 8:47 pm
by declanr
Martin Ryan wrote: I'm just curious as it seems (to me) that watching an episode of Geordie Shore would be an equally productive use of your evening.
Somewhat off topic but the knowledge that such a creation is actually known to people outside of the UK makes me ashamed to be English and I need to go rethink my whole existence.

Re: Backus–Naur Form for TM1 Syntax

Posted: Thu Apr 26, 2012 9:48 pm
by rmackenzie
John Hammond wrote:Just wondered if there is TM1 Syntax in Backus–Naur Form or equivalent out there.
Are you talking about rules or TI? If you mean rules, then there are quite a few online resources for E(xtended)BNF grammars for Excel formulae - TM1 rules syntax is kind of similar to this but ... the way the left hand side works is outside of this and also right-hand side multi-dimensional references obviously don't play well in the Excel context. I've also seen some interesting efforts at Excel-formula parsing engines that don't rely at all on BNF.

If you're talking about TI then there's probably a lot more information about BASIC-like languages, however the problem here is that a full BNF grammar would really have to take account of the implied loops of the Metadata and Data tabs.

Re: Backus–Naur Form for TM1 Syntax

Posted: Thu Apr 26, 2012 10:38 pm
by Duncan P
I think I disagree.
rmackenzie wrote:... however the problem here is that a full BNF grammar would really have to take account of the implied loops of the Metadata and Data tabs.
A grammar for TI wouldn't have to take into account the implicit looping on the middle tabs. The grammar just defines what is a properly formed program and not about what that program does in execution.

The slightly difficult thing about both rules and TI (if you are intending to use the grammar for real work) is the interaction of newlines and comments with the rest of the rule or TI program.

The first thing is that newlines can appear anywhere, and indeed when they are put in to break up long lines by TM1 they often break a word - with no ill effect. However they are not completely insignificant. A #, if and only if it is the first non-blank character of a line, marks all the text till the end of the line as a comment. The combination of these things gives the following oddity.

Code: Select all

[] = LONG( 'one
   # a comment
2  # not a comment
   two' );
will fill the cube with the number 30. The number of characters from each line that contribute to the string is 3 ("one"), 3 (3 spaces), 18 (all of the line) and 6 (3 spaces and the "two").

All of this means that you have to strip comments and newlines before you can even think about splitting the rule up into tokens and working out what the quoted strings are. Only when you have done that can you get down to using the grammar to parse the rule.

Re: Backus–Naur Form for TM1 Syntax

Posted: Fri Apr 27, 2012 8:27 am
by John Hammond
Made a start last night

Code: Select all

<square-bkt-open> ::= ‘[‘
<square-bkt-close> ::= ‘]‘
<dimension-element-list> ::= ‘{‘ < single-dimension-element > [,<single-dimension-element >]... ‘}’
<complex-dimension-element-list> ::= < single-dimension-element > | <dimension-element-list>
<lhs-area> ::= <square-bkt-open><complex-dimension-element-list> [‘,’<complex-dimension-element-list>]… <square-bkt-close>
<rhs-area> ::= <square-bkt-open> <single-dimension-element> [‘,’<complex-dimension-element-list>]… <square-bkt-close>
<db-statement> ::= ‘DB(’ <alpha-expression> ‘,’ <alpha-expression> ‘,’   <alpha-expression> [‘,’   <alpha-expression>  ]…  ‘)’

But then Geordie Shore came on...

Re: Backus–Naur Form for TM1 Syntax

Posted: Sun Apr 29, 2012 3:54 am
by rmackenzie
Duncan P wrote:I think I disagree.
rmackenzie wrote:... however the problem here is that a full BNF grammar would really have to take account of the implied loops of the Metadata and Data tabs.
A grammar for TI wouldn't have to take into account the implicit looping on the middle tabs. The grammar just defines what is a properly formed program and not about what that program does in execution.
I think you're right and I'd got ahead of myself thinking about what the grammar would be practically useful for. Chomsky nicely sums up this issue you're raising.

Re: Backus–Naur Form for TM1 Syntax

Posted: Tue May 01, 2012 11:28 am
by ParisHilton
Martin Ryan wrote:I'd never heard of it till now. After a bit of Wikipedia I think I grasp it and now the question that comes to mind is why?
I would suspect, that if you have a BN or something similar, then it would be very possible to write a decent rules editor.

I keep starting this project myself, but it's a whole big can of worms !