For people who want to add syntax highlighting to their favorite editor, here are some tips:
Comments are single line and start with #
Strings can use single or double quotes.
Cobra has the usual arithmetic operators. The boolean operators are and, or, and not. It has the arithmetic assignment such as +=. It has // for integer division and ** for power-to.
There are hardly any "built-ins" in Cobra. If you want the length of a string, you write "s.length", not "len(s)".
In addition to your normal identifiers like "Customer" there are also generics like "List<of int>".
Classes are named by their real name so there is no "object" or "string" like in C#. It's "Object" and "String".
You can use keywords as member names (properties and methods) since member access is always dotted. For example, you could have a method called throw. You cannot use keywords for argument or locals.
The integer types include not only "int" and "uint", but also int8, int16, int32, int64, uint8, uint16, uint32, uint64. You might as well add float32 and float64 in there even though they're not implemented yet.
Below are the current keywords. Some are reserved for future use. Some like "every" probably don't need to be reserved anymore, but still are. Btw I plan that the Cobra command line will eventually support a -keywords command line argument so you can get this info straight from the compiler's memory.
all and any as assert base be body bool branch break callable catch char class continue cue decimal def down dynamic else end ensure enum event every except expect extend false finally float for from get global has if ignore implements implies import in inherits inlined inout instance int interface invariant is listen must namespace nil not number objc of off old on or out override pass passthrough post print pro raise ref require return same set shared step stop struct success test this throw to to? trace true try use using var vari virtual where where while yield
You might start your syntax highlight spec from scratch. Or you might start with the Python spec for your editor and morph it.
Eventually we'll have a wiki and therefore a place to put these things.
Let me know if have further questions. Or if you figure out some interesting things, feel free to add to this topic.
Forums
Syntax Highlighting Tips
2 posts
• Page 1 of 1
Re: Syntax Highlighting Tips
Cobra has so-called "is names" as in:
From another topic:
They are pseudo keywords meaning they are recognized in this syntax, but you can otherwise use them for variable names. By the way, I call these particular ones "is names" in the docs.
And straight from the compiler source:
_validIsNames = ['fake', 'shared', 'virtual', 'nonvirtual', 'override', 'new', 'public', 'protected', 'private', 'internal', 'abstract']
def foo is protected, override
pass
From another topic:
They are pseudo keywords meaning they are recognized in this syntax, but you can otherwise use them for variable names. By the way, I call these particular ones "is names" in the docs.
And straight from the compiler source:
_validIsNames = ['fake', 'shared', 'virtual', 'nonvirtual', 'override', 'new', 'public', 'protected', 'private', 'internal', 'abstract']
- Charles
- Posts: 2515
- Location: Los Angeles, CA
2 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 23 guests