Backus–Naur Form for TM1 Syntax

Post Reply
John Hammond
Community Contributor
Posts: 295
Joined: Mon Mar 23, 2009 10:50 am
OLAP Product: PAW/PAX 2.0.72 Perspectives
Version: TM1 Server 11.8.003
Excel Version: 365 and 2016
Location: South London

Backus–Naur Form for TM1 Syntax

Post 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...
User avatar
stephen waters
MVP
Posts: 324
Joined: Mon Jun 30, 2008 12:59 pm
OLAP Product: TM1
Version: 10_2_2
Excel Version: Excel 2010

Re: Backus–Naur Form for TM1 Syntax

Post 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?? ;)
User avatar
jim wood
Site Admin
Posts: 3953
Joined: Wed May 14, 2008 1:51 pm
OLAP Product: TM1
Version: PA 2.0.7
Excel Version: Office 365
Location: 37 East 18th Street New York
Contact:

Re: Backus–Naur Form for TM1 Syntax

Post by jim wood »

I guess the nearest would be variables within TI?
Struggling through the quagmire of life to reach the other side of who knows where.
Shop at Amazon
Jimbo PC Builds on YouTube
OS: Mac OS 11 PA Version: 2.0.7
User avatar
Martin Ryan
Site Admin
Posts: 1988
Joined: Sat May 10, 2008 9:08 am
OLAP Product: TM1
Version: 10.1
Excel Version: 2010
Location: Wellington, New Zealand
Contact:

Re: Backus–Naur Form for TM1 Syntax

Post 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.
Please do not send technical questions via private message or email. Post them in the forum where you'll probably get a faster reply, and everyone can benefit from the answers.
Jodi Ryan Family Lawyer
declanr
MVP
Posts: 1817
Joined: Mon Dec 05, 2011 11:51 am
OLAP Product: Cognos TM1
Version: PA2.0 and most of the old ones
Excel Version: All of em
Location: Manchester, United Kingdom
Contact:

Re: Backus–Naur Form for TM1 Syntax

Post 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.
Declan Rodger
rmackenzie
MVP
Posts: 733
Joined: Wed May 14, 2008 11:06 pm

Re: Backus–Naur Form for TM1 Syntax

Post 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.
Robin Mackenzie
Duncan P
MVP
Posts: 600
Joined: Wed Aug 17, 2011 1:19 pm
OLAP Product: TM1
Version: 9.5.2 10.1 10.2
Excel Version: 2003 2007
Location: York, UK

Re: Backus–Naur Form for TM1 Syntax

Post 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.
John Hammond
Community Contributor
Posts: 295
Joined: Mon Mar 23, 2009 10:50 am
OLAP Product: PAW/PAX 2.0.72 Perspectives
Version: TM1 Server 11.8.003
Excel Version: 365 and 2016
Location: South London

Re: Backus–Naur Form for TM1 Syntax

Post 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...
rmackenzie
MVP
Posts: 733
Joined: Wed May 14, 2008 11:06 pm

Re: Backus–Naur Form for TM1 Syntax

Post 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.
Robin Mackenzie
ParisHilton
Posts: 73
Joined: Fri Apr 23, 2010 11:35 am
OLAP Product: Tm1
Version: 9.5
Excel Version: 2007 2010

Re: Backus–Naur Form for TM1 Syntax

Post 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 !
“The way I see it, you should live everyday like its your birthday”


TM1 9.5 Cognos BI 8.4 Excel 2007. 128GB Ram. E7450@2.40Ghz -24 core. Fluffy white dog.
Post Reply