Skip to content

Instantly share code, notes, and snippets.

@jonsterling
Created January 2, 2011 07:33
Show Gist options
  • Select an option

  • Save jonsterling/762382 to your computer and use it in GitHub Desktop.

Select an option

Save jonsterling/762382 to your computer and use it in GitHub Desktop.
Foam-Lang Samples

My tiny language, Foam, is coming along nicely! The following code:

tv := @textView
as := tv typingAttributes. mutableCopy
as setObject:@defaultParagraphStyle forKey:NSParagraphStyleAttributeName
@defaultTypingAttributes = as

tv setTypingAttributes:@defaultTypingAttributes
tv setDefaultParagraphStyle:@defaultParagraphStyle

options := {"NSValueTransformerName": "BlahBlahTransformer"}
tv bind:"value" toObject:@document withKeyPath:"text" options:options

...translates to the following:

id tv = self.textView
id as = [[tv typingAttributes] mutableCopy];
[as setObject:self.defaultParagraphStyle forKey:NSParagraphStyleAttributeName];
self.defaultTypingAttributes = as

[tv setTypingAttributes:self.defaultTypingAttributes];
[tv setDefaultParagraphStyle:self.defaultParagraphStyle];

id options = [NSDictionary dictionaryWithObjectsAndKeys:@"BlahBlahTransformer",@"NSValueTransformerName",nil];
[tv bind:@"value" toObject:self.document withKeyPath:@"text" options:options];

To see the annotated source of its parser, go here: http://jonsterling.github.com/Foam/Parse.hs.html.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment