| Change Set |
Date |
Downloads |
Comment |
17706
by
jeffmoser
|
Sep 23 2008 at
12:57 AM
|
96 |
Added "Markup" project based off discussion question by nblumhardt on Codeplex. See http://www.codeplex.com/ometasharp/Thread/View.aspx?ThreadId=36146 |
17578
by
jeffmoser
|
Sep 16 2008 at
4:03 AM
|
3 |
Moved CalculatorParser to be siblings with the Calculator example. |
17577
by
jeffmoser
|
Sep 16 2008 at
3:57 AM
|
1 |
Removed excess directories |
17576
by
jeffmoser
|
Sep 16 2008 at
3:54 AM
|
1 |
Very initial check-in of some noticable restructuring of the entire project. Based off some good comments by Nicholas Blumhardt, I decided to do some re-arranging of the folders to improve the distinction between the core runtime, host languages, examples, and then unit tests. In addition, I created a console based interpreter playground where you can experiment with each grammar that you create. For example, if you set "Calculator" as your startup project and then run it, you can see a very primitive calculator in action :)
In addition, I put some work into the Prolog interpreter to make it handle basic queries via the console.
Each project has sample input and responses that are shown right when you start the project so you get a feel for what's expected.
Finally, the "README" project basically does what the previous unit test runner did (e.g. compile all grammars and run most tests).
I'd love to hear feedback if you download the code. My contact info is on my blog at http://www.moserware.com/
(NOTE: Since I did some heavy moving in the source code, there might be some problems synchronizing everything in TFS. It might take another changeset to remove extra files) |
17196
by
jeffmoser
|
Sep 8 2008 at
3:00 AM
|
7 |
Added first glimpse of ideas for syntax sugar in the host semantic actions. I started with a simple list cons. This allows you to say { "add", x, y } instead of "Sugar.Cons("add", x, y)". This notably simplified CalculatorParser and NullOptimization grammars.
The eventual goal is that "Sugar" wouldn't have to be explicitly referenced in an action but would rather rely on the CSharpRecgonizer to convert the nicer syntax to a Sugar usage. The nicer syntax should play nice with the overal goals of C#. |
16907
by
jeffmoser
|
Sep 1 2008 at
10:15 PM
|
1 |
Small update to Meta-FizzBuzz grammar by using C#'s type aliasing ability (e.g. "using E = System.Func<object>") to make the code less verbose. I'm not sure if this is best long term for readability/comprehension, but I do like how it makes things more compact. |
16784
by
jeffmoser
|
Aug 29 2008 at
3:52 AM
|
7 |
Implemented support for automatic casting of a type in the semantic action and host expression part of a grammar (e.g. the C# part) based on a grammar default ("ometa Factorial<int, ***int***>") or by specifying the type by the variable capture. The former allows you to get a notably simpler Calculator, Factorial, LittleTypeChecker, and NumberParser (take a peek at their new version in this changesteThe latter allows "Super(Digit):d<int>".
The focus on this release is therefore less typing. Hopefully with a few more iterations will bring us closer to the compactness similar to what can occur in a dynamic language like JavaScript but being strongly typed. |
16572
by
jeffmoser
|
Aug 25 2008 at
11:41 AM
|
7 |
Added a Meta-FizzBuzz implementation and two versions of FizzBuzz written in it. |
16467
by
jeffmoser
|
Aug 22 2008 at
3:27 AM
|
3 |
Added support for defining overrides in a grammar via the ^ character.
For example, the Calculator grammar now has
Digit ^= Super(Digit):d -> { d.ToDigit() },
since it is overriding the "Digit" rule in its base grammar. This now generates an "override" in the C# code. With this extension, I can now emit enough information to get rid of the warning about unverifiable code from using a base class reference in an anonymous method. I do this by storing the reference to a local variable "__baseRule__".
For the first time, the entire OMeta project compiles without any warnings. |
16203
by
jeffmoser
|
Aug 15 2008 at
4:45 AM
|
3 |
More syntax updates. I now make inheritance look more C++/C#-ish of "MyClass : BaseClass" instead of "MyClass <: BaseClass".
This was driven by another change that I made where I add types to the grammar definition to specify what goes in (e.g. "ometa OMetaTranslator<HostExpression> : Parser<HostExpression>").
This annotation used to be done in the tests themselves. Now it's right in the grammar itself (by default I assume a char input).
You can also define the "default" type as in "ometa Calculator<char, int> : Parser<char> {". My thought is that in an upcoming change I can dramatically simplify the calculator grammar (among others) by making it unnecessary to do all those .As<int>() and have that be automatic if you define a default. |
16095
by
jeffmoser
|
Aug 12 2008 at
3:50 AM
|
0 |
Added preliminary support for namespaces. You can now use "using" statements like C# as well as specify a namespace prefix to your grammar name. If you don't specify one, defaults will be provided.
This is the first noticable addition to the grammar to make it more .NET friendly. |
16066
by
jeffmoser
|
Aug 11 2008 at
2:48 AM
|
1 |
Added Prolog library and grammar that I translated based off of the ones on the OMeta/JS project. This shows a symbiosis of OMeta# for the language aspects and C# for other logic (e.g. Prolog's unification concept) |
15986
by
jeffmoser
|
Aug 9 2008 at
4:50 AM
|
1 |
Removed about 30 lines from OMetaTranslator.ometacs by introducing a Format option to CodeGen. Slowly trying to get cleaner syntax. |
15985
by
jeffmoser
|
Aug 9 2008 at
3:24 AM
|
0 |
Got rid of manually created grammar-ish code. Most notable is that the manual translator is out. The OMeta# one is quite a bit easier to understand.
This is symbolic of OMeta#'s future of more of it being written in itself. This requires removing the hints of the past where we had to manually bootstrap ourself :-) |
15984
by
jeffmoser
|
Aug 9 2008 at
3:14 AM
|
0 |
Updated OMetaParser's HostExpr and C# recognizer so that a HostExpr is
Expr = ParenExpr | Spaces (StringLiteral | FunctionCall | BasicName)
This finally allows for less ()'s
Compare
Block = EverythingInside(("{"), ("}"))
With
Block = EverythingInside("{", "}") |
15954
by
jeffmoser
|
Aug 8 2008 at
3:52 AM
|
1 |
OMeta# now bootstraps itself!
Added a OMetaTranslator written in OMeta# to make this happen. This involved a new grammar (OMetaTranslator.ometacs). As of this check-in, no manually "parsed" grammar-ish code is used and thus the code generates the code that generates the code.
This is a notable milestone in this project because the recognizer -> parser -> translator chain is a reasonably complex grammar and is a good proof of concept.
This will probably be the last changeset that has the manually created code in it. I'll use TFS to preserve the roots of where it came from so that the main project isn't littered with it.
The next major step is to clean things up in preparation of CTP 1.
|
15766
by
jeffmoser
|
Aug 2 2008 at
6:50 PM
|
5 |
OMeta# now has an optimzer that was written in OMeta#!
Most of the code was just a port of the OMeta/JS optimizer. See the NullOptimization.ometacs, AndOrOptimization.ometacs, and OMetaOptimizer.ometacs grammars for more details.
One of the most fascinating lines of OMeta# is this one:
OptimizeRule = :r (Foreign((typeof(AndOrOptimization)), ("Optimize"), (r)):r)* -> { r }
This basically keeps optimizing a rule until it can't be optimized any further. Very neat way of expressing it.
The optimizer is making a noticable improvement in generated code. Average savings is around 15% for simple grammars and 40% for more complicated ones. For example, the OMetaParser.cs generated code shrank from 3022 lines to 1843 lines with the optimizer turned on. A savings of 1179 lines or 39%.
The next piece of optimization will be to eliminate unnecessary wrapped functions from And expressions. That is, if the MetaRules.Apply(...) is the only function, then just generate the inner scope instead of wrapping it.
I'll defer this this last major optimization until after the code generator is rewritten into OMeta#. |
15748
by
jeffmoser
|
Aug 2 2008 at
3:52 AM
|
4 |
Fixed the RegularString rule. Forgot to implode the list of EscapedChar's |
15710
by
jeffmoser
|
Aug 1 2008 at
4:31 AM
|
0 |
Oops. Forgot to actually turn on OMetaParser. Previous version was using ManualOMetaParser. This exposed a bug in my implementation of RegularString that I'll need to fix soon. |
15493
by
jeffmoser
|
Jul 28 2008 at
12:23 AM
|
4 |
Did work on CSharpRecognizer.ometacs so that it works properly. This required some changes in other spots to fix up a few problems.
Now OMeta# can parse itself and the C# recognizer. Furthermore, the generated parser now uses the generated C# recognizer. |
15383
by
jeffmoser
|
Jul 26 2008 at
3:17 AM
|
0 |
OMetaParser.ometacs is feature complete! It can be used to generate a parser that parses itself. All internal non-manual tests are now using that parser instead of the ManualOMetaParser.
It's definitely getting neater :-)
There are still some issues with the C# recognizer not imploding things correctly. Additionally, inline comments in grammars seems to be troublesome. |
15349
by
jeffmoser
|
Jul 25 2008 at
1:18 PM
|
0 |
Added Args, Application, SemAction , and SemPred to OMetaParser.ometacs |
15341
by
jeffmoser
|
Jul 25 2008 at
4:47 AM
|
0 |
Updated OMetaParser.ometacs to support calling into the C# recognizer foreign grammar. This discovered some glitches with my generated C# recognizer not imploding strings correctly (e.g. converting a list of characters into a single string). This will need to get fixed soon. |
15300
by
jeffmoser
|
Jul 24 2008 at
3:50 AM
|
3 |
Initial work OMetaParser.ometacs (right up to the point where Foreign rule would be called). Along the way, had to put AND translations into their own delegate since two of them can be right after each other in unoptimized grammars. |
15261
by
jeffmoser
|
Jul 23 2008 at
4:40 AM
|
0 |
Fixed the compiler and translator so that the C# recognizer is produced from the .ometacs file. Updated the CSharpRecognizer.ometacs so that it should be enough to be useful in bootstrapping.
The generated code really needs the And/Or optimizer on the parse tree. Instead of doing this by manually, I'm going to wait until I can bootstrap the optimizer via a .ometacs. |