Skip to content

Instantly share code, notes, and snippets.

View DavyLandman's full-sized avatar

Davy Landman DavyLandman

View GitHub Profile
@DavyLandman
DavyLandman / gist:842956
Created February 24, 2011 21:47
Nice, improved the fact extraction for my rascal-csharp AST, looks pretty clean now.. next up, escape rascal keywords and add java, c# and protobuf support :)
module CSharp
public alias CSharpFile=list[Ast];
data AstNode = comment(CommentType commentType, str content, bool startsLine)
| namespaceDeclaration(str name, list[AstNode] identifiers, list[AstNode] members, str name)
| constraint(list[AstType] baseTypes, str typeParameter)
| queryOrdering(QueryOrderingDirection direction, Expression expression)
| attribute(list[Expression] arguments)
| cSharpModifierToken(list[Modifiers] allModifiers, list[Modifiers] modifier)
| variablePlaceholder(str name, str name)
@DavyLandman
DavyLandman / gist:823100
Created February 11, 2011 21:45
I love it when a plan comes together. :) using rascal-dotnet to generate 90% of the source for rascal-csharp
data AstNode =
usingAliasDeclaration(AstType import, str alias, NodeType nodeType)
| typeParameterDeclaration(str identifier, VarianceModifier variance, NodeType nodeType)
| arraySpecifier(int dimensions, NodeType nodeType)
| caseLabel(Expression expression, NodeType nodeType)
| comment(str content, NodeType nodeType, bool startsLine, CommentType commentType)
| namespaceDeclaration(str fullName, str name, list[AstNode] members, list[Identifier] identifiers, NodeType nodeType)
| cSharpModifierToken(ICollection allModifiers, Modifiers modifier, NodeType nodeType)
| parameterDeclaration(str name, Expression defaultExpression, ParameterModifier parameterModifier, AstType type, list[AttributeSection] attributes, NodeType nodeType)
| constructorInitializer(ConstructorInitializerType constructorInitializerType, list[AstNode] arguments, NodeType nodeType)
public class BrowserCacheAttribute : ActionFilterAttribute
{
/// <summary>
/// Gets or sets the cache duration in seconds.
/// The default is 10 seconds.
/// </summary>
/// <value>The cache duration in seconds.</value>
public int Duration
{
get;
public static OrderState GetState(this Order self)
{
return (OrderState)self.State;
}
public static OrderState AsOrderState(this int i)
{
return (OrderState)i;
}