Did I say AST too much? ;)
{thing1; thing2; thing3} list literal"blah", "blah\n" string literal234, 3.14 int and float literalnew BlahBlah(arg1; arg2); create a new object of type BlahBlah (often AST nodes)blahblah: new BlahBlah(); create a new object and assign it to name blahblah.Rationale for ';' as a list separator: a macro/function is a list of statements, separated by ';'. Unifying ',' and ';' is more consistent. Rationale for ':' as a name association operator: logical meaning from english, also reminiscent of Pascal's ':=' but shorter. Rationale for the 'new' keyword: unambiguous syntax Rationale for the lack of 'f' suffix for float literals: implementation detail. Rationale for {} for lists but () for constructors/macro calls: unambiguous syntax, allows "late binding" of macro names, for example. (Note: not necessarily a satisfying reason)
A token is defined like that:
TOKEN_NAME: new Token( { [A-Za-z_]+ ; .* ; "str" } );
Syntax elements in the sequence of the token's definition are like:
They are enclosed in []. Ranges can be defined like A-Z. ']' has to be escaped with a backslash., e.g. [\]] Examples:
DUMB_TOKEN: new Token( [abc], [abc] ); // matches aa, ab, ac, ba, bb, bc, ca, cb, cc
C-like string literals, delimited by ", escaped with backslash:
FUNC_KEYWORD: new Token( "func" );
. matches everything, ex:
SIMPLE_XML_TAG: new Token( "<", .*, ">" );
Tokens can be ordered to avoid conflicts (e.g. between keywords and names: both token definitions match, ). Example:
NAME: new Token( [A-Za-z_]; [A-Za-z_0-9]* ); FUNC_KEYWORD: new Token( "func" );
Here, (Houston), we have a problem. Now the string "func" matches both NAME and FUNC_KEYWORD. As the situation is ambiguous, meta will refuse straight out to compile and yield an error (with a detailed message of course). It's easily solved by defining an order:
new Order( FUNC_KEYWORD; NAME );
Now, as it should, FUNC_KEYWORD will have a greater priority than NAME, and the conflict is gone.
Of course if you have more keywords, it would be cumbersome to define an Order for each of them individually so you'd want to use Groups.
Like Tokens are usually sequences of characters, Constructs are usually sequences of Tokens and other Constructs, e.g.:
<# PLUS: new Token( "+" ); DIGIT: new Token( [1-9]; [0-9]* ); // a decimal number doesn't begin with a 0 NumberLiteral: new Construct( DIGIT ); Addition: new Construct( Expr; PLUS; Expr ); Expr: new Group( NumberLiteral; Addition ); #>
The easiest way to understand groups is by re-considering the 'keywords vs name token priority problem' explained above. Let's say we now have two keywords in our language, "func" and "class", we'd naively code:
NAME: new Token( [A-Za-z_]; [A-Za-z_0-9]* ); FUNC_KEYWORD: new Token( "func" ); CLASS_KEYWORD: new Token( "class" ); new Order( FUNC_KEYWORD; NAME ); new Order( CLASS_KEYWORD; NAME );
But there's a better way:
NAME: new Token( [A-Za-z_]; [A-Za-z_0-9]* ); FUNC_KEYWORD: new Token( "func" ); CLASS_KEYWORD: new Token( "class" ); KEYWORDS: new Group( FUNC_KEYWORD; CLASS_KEYWORD ); new Order( KEYWORDS; NAME );
This way you can easily add keywords to the group. The same trick can be used for constructs, e.g.
// Line and Block defined earlier
Code: new Group( Line; Block );
FOREACH: new Token( "foreach" );
Foreach: new Construct({
in: { FOREACH; Code }; // now you can foreach with a single statement or a code block =)
});
Capitalization:
Departure from C/C++/Java? Yeah, pretty much. Get used to it. int → Int, float → Float, and so on.
about
blog
docs
community
downloads
Starting soon this month is the Google Summer of Code (GSOC). ooc-lang.org will apply. We need your ideas! http://bit.ly/bKHTRE
From now on, the mailing list will be used more frequently, big decisions will happen there - have your say, subscribe http://bit.ly/bnHuEY
@Dubhead I updated the instructions here http://ooc-lang.org/downloads and there http://ooc-lang.org/setup - hope it's clearer
Till we have'em automated, here's a j/ooc nightbuild http://bit.ly/aDc05q rock is on the way to compile itself. exciting times!
rock has version blocks, more and more sdk classes compile. Soon j/ooc and rock's sdk will merge.
rock has preliminary support for interfaces. mixins and namespaced imports are coming up soon! killer, simple syntax as usual.
for the first time, rock, a 10k SLOC pure ooc codebase, compiles under Win32, and produces executables with gcc. party?
blogpost! gtksourceview highlighting for ooc – gedit & anjuta, rock progress, sudoku solver http://bit.ly/dt0GI1
#ooc_lang for the web! fastcgi bindings by joshthecoder: http://bit.ly/9AcGCa
discount bindings (markdown text to html library) for @ooc_lang by @zenhob http://bit.ly/5dg2K7 coolness!
rock has constructors, half generics, operator overloads on the way. commit frenzy! http://bit.ly/5M8syC
finalizers in j/ooc, meta-classes in rock, yajit, deadlogger, woot, oos, arbitrary precision arithmetic http://bit.ly/5kHIcZ
The ooc blog is online again, thanks @aguspiza for reporting the problem!
@aguspiza Ow. Investigating, thanks for reporting!
yajit works again! check it out: http://github.com/nddrylliog/yajit (special thanks to fredreichbier & showstopper)
rock (ooc compiler in ooc) compiles classes and covers =) don't try it at home yet, though - it's still highly experimental
@alejandrocrosa Hmmm, rtfm? http://docs.ooc-lang.org/ooc-slim/executable-size.html ;)
@arvennard The C++ object model is too complex. And the C syntax has many drawbacks. ooc is, imho, much more readable/light/flexible.
(continued)... that change will allow very nice array and map literals, and other data structs will be usable easily too. Stay tuned.
SubProcess new() now takes an ArrayList<String> instead of String*. (breaking change). ArrayList and HashMap will be BasicTypes soon.