Page 1 of 1

Official Cobra grammar

PostPosted: Mon Jan 14, 2013 10:00 am
by didrik
Hi,

I would like to add support for the remaining keywords (or most of them, at least) to the TextMate bundle posted under "Editor Support".
However, in order to do it properly, it would be nice to know the context of each of the keywords.

Is there an official Cobra grammar available anywhere?

I apologize if it is already easily located — I just can't seem to find it!

Re: Official Cobra grammar

PostPosted: Tue Jan 15, 2013 1:26 am
by hopscc
Theres no formal grammar document. :(

This page Keywords is the best keyword reference we have outside the source code.
It has all the keywords in alpha order and a link to the code file.

If you follow that page then the KeywordSpecs 'View Online' link to the keywords file/class you can look for the
rawSpecs property - List ( about a page or so down) which gives a table of the keywords and some indication of their use and what they're for though not the full grammatical context...

If thats insufficient then the only other recourse is to walk through the CobraParser.cobra source following the recursive descent code.
( that will be 100% correct by definition)

Perhaps slightly less onerous is to look at the wiki doc (From 'wiki:LanguageTopics' under 'Program Structure') and pick the keywords from the doc/grammar descriptions for each construct/statement there ....
Its possible the doc there is not 100% complete/correct though :) and you might find it difficult to pick the keywords out easily rapidly for your purposes.

Re: Official Cobra grammar

PostPosted: Tue Jan 15, 2013 12:45 pm
by didrik
Thank you. I must say that I am a bit surprised that there is no formal grammar, but I guess I will manage without it. :)

While looking at the CobraParser source, I found a property called validIsNames, in which the keyword readonly is listed. (line 830 in CobraParser.cobra)
A bit surprised, as readonly is not specified as a keyword in any of the other resources you specify, I tried to compile it — it works.

Is this keyword planned for removal later, or is it just a mistake that it isn't mentioned elsewhere?

Re: Official Cobra grammar

PostPosted: Tue Jan 15, 2013 3:34 pm
by hopscc
Its probably that it has been added since the doc on isnames/access modifiers was done
or the code run that emitted the keywords list was run

readonly support is relatively recent in comparison to some of the other items....

Re: Official Cobra grammar

PostPosted: Tue Jan 15, 2013 3:47 pm
by hopscc
Actually that omission is definitely a doc lag/issue and
its probably a bug that its not listed in the keywords table with the rest of the isNames modifiers

I'll open a ticket and a patch for it - Thanx - well spotted.

Re: Official Cobra grammar

PostPosted: Tue Jan 15, 2013 4:08 pm
by hopscc
So noted on ticket:313.

Re: Official Cobra grammar

PostPosted: Tue Jul 09, 2013 5:07 pm
by nerdzero
Man, I'm finishing up tooltips in the MD/XS addin and am trying to include the grammar in the tooltip for keywords and I am really wishing we had the grammar all in one place right about now :)

Re: Official Cobra grammar

PostPosted: Tue Jul 09, 2013 5:26 pm
by Charles
Sorry, I'm still on "partial types" and then "parser recovery" after that.

Re: Official Cobra grammar

PostPosted: Tue Jul 09, 2013 5:39 pm
by nerdzero
Heh, yeah for sure those are higher priority. This doesn't even have to be done by you. I mean, the info is available, just not in one place...but I'm lazy.