Advertisement
ptrelford

Simple C# AST

Dec 31st, 2013
508
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 1.86 KB | None | 0 0
  1. open System
  2.  
  3. type Name = string
  4. type VarName = Name
  5. type MemberName = Name
  6. type LabelName = Name
  7. type Arg = Type * VarName
  8. type Value = obj
  9. type EnumValue = Name * Value
  10. type Import =
  11.     | Import of Name
  12.     | Abbreviation of Name * Name
  13. type Access = Public | Private | Protected | Internal
  14. type Modifier = Sealed | Static
  15. type Expr =
  16.     | Literal of Value
  17.     | Variable of VarName
  18.     | MethodInvoke of MemberName * Expr list
  19.     | PropertyGet of MemberName
  20.     | InfixOperator of Expr * string * Expr
  21.     | PrefixOperator of string * Expr
  22.     | PostfixOperator of Expr * string
  23.     | TernaryOperator of Expr * Expr * Expr
  24. type From = Type * Name * Expr
  25. type To = Expr
  26. type Step = Expr list
  27. type Statement =
  28.     | Define of Type * VarName
  29.     | Assignment of VarName * Expr
  30.     | PropertySet of MemberName * Expr
  31.     | If of Expr * Block
  32.     | Else of Expr * Block
  33.     | Switch of Expr * Case list
  34.     | For of From * To * Step * Block
  35.     | ForEach of Type * VarName * Expr    
  36.     | While of Expr * Statement list
  37.     | DoWhile of Statement List * Expr
  38.     | Try of Statement list
  39.     | Catch of Type * Block
  40.     | Finally of Type * Block
  41.     | Lock of Expr * Block    
  42.     | Using of Expr * Block
  43.     | Label of LabelName
  44.     | Goto of LabelName
  45.     | Break
  46.     | Continue
  47.     | Return of Expr
  48. and Case = Case of Value option * Block
  49. and Block = Statement list
  50. type MemberInfo = Access * Modifier option * Type * Name
  51. type Member =
  52.     | Field of MemberInfo * Expr option
  53.     | Method of MemberInfo * Arg list * Block
  54.     | Property of MemberInfo * Block
  55. type CSharpType =
  56.     | Class of Access * Modifier option * Name * Member list
  57.     | Struct of Access * Name * Member list
  58.     | Enum of Access * Type * EnumValue list
  59. type Scope =
  60.     | Namespace of Import list * Name * Scope list
  61.     | Types of Import list * CSharpType list
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement