default.txt 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /**
  2. * An example of Flix for syntax highlighting.
  3. */
  4. // Here is a namespace.
  5. namespace a.b.c {
  6. // Here are some literals.
  7. def b: Bool = true
  8. def c: Char = 'a'
  9. def f: Float = 1.23
  10. def i: Int = 42
  11. def s: Str = "string"
  12. // Here are some relations.
  13. rel LitStm(r: Str, c: Int)
  14. rel AddStm(r: Str, x: Str, y: Str)
  15. rel DivStm(r: Str, x: Str, y: Str)
  16. // Here is a lattice.
  17. lat LocalVar(k: Str, v: Constant)
  18. // Here is an index.
  19. index LitStm{{r}, {r, c}}
  20. // Here is an enum.
  21. enum Constant {
  22. case Top,
  23. case Cst(Int),
  24. case Bot
  25. }
  26. // Here is a function.
  27. def leq(e1: Constant, e2: Constant): Bool = match (e1, e2) with {
  28. case (Constant.Bot, _) => true
  29. case (Constant.Cst(n1), Constant.Cst(n2)) => n1 == n2
  30. case (_, Constant.Top) => true
  31. case _ => false
  32. }
  33. // Here are some rules.
  34. LocalVar(r, alpha(c)) :- LitStm(r, c).
  35. LocalVar(r, sum(v1, v2)) :- AddStm(r, x, y),
  36. LocalVar(x, v1),
  37. LocalVar(y, v2).
  38. }