Brain dump

Sep 28, 2008 at 6:19 PM
Some thoughts after spending a bit more recreational time with OMeta#...$0$0$0$0It is easier to build a parser with OMeta than anything I've attempted to use before - unambiguous, contextual matching is so nice!$0$0$0$0$0OMeta# is getting easier to use. It will be a lot more approachable with some better support for error messages, and a syntax "quick reference" but these things take work I know... All in good time :)$0$0$0$0$0The biggest points of confusion for me so far have been:$0$0$0$0Negative matches - ~blah just doesn't seem to work for me :($0$0Confusion between 'strings' and 'lists' - i.e. Foo+:f ends up spitting out a list, rather than a string of n Foos - yet trying to manipulate f in the transformation section to create a string gives me errors because it is cast in the generated code to a string :) - the result is output that looks like [h, e, l, l, o]$0$0$0I think perhaps looking back I would have been better off not specifying that the Markup grammar produces a string, and instead perhaps transformed to a nested XmlNode structure of some kind? Need to experiment some more - living and learning.$0$0$0$0$0Sure I'll work my way through some of this. Just thought I'd post an update. Cheers!$0$0
Sep 28, 2008 at 7:39 PM
Thanks for the update Nick! (as well as the praise for OMeta. Alex and friends have made a very interesting language)

I agree that negative matches are confusing at first. The trick to realize is that "~SomeRule" does not, as commonsense might first lead you to believe, match any rule but "SomeRule." To understand the core of language on this point, you need to look at what "~~SomeRule" means. A "~~" or "not not" means a "lookahead" assertion (see the original OMeta paper for more on this). Thus, "~~SomeRule" means "verify that the SomeRule is what follows, but don't actually consume the input. Likewise, "~SomeRule" means "verify that SomeRule is not what follows", but don't actually consume any input.

You've keyed in on a big design issue when you discuss lists and strings. It is quite confusing. The pain you experience is my possibly poor decision to make a list of characters and a string to be roughly equivalent in OMeta# just like they are in OMeta/JS. At first, I forced grammar writers to say "Sugar.Implode(listName)" to take a character list and convert it to a string, but then I decided this was the common case, so I made it automatic. I can revisit this decision if it's causing problems that can't be worked around. Let me know specifics if you get stuck.

I don't think that moving to XML would necessarily make things easier. OMetaList is fairly flexible as a recursive data structure if you need it. It's the data structure that the optimizer uses to optimize parsed OMeta/C# code.

Let me know what you would find helpful in a "quick reference" or ideas for future example programs and I'd be happy to work on those if that'd be helpful.

Keep up the great work and questions!