t.ml 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. (**
  2. This module contains the basic operators used in the QSP syntax.
  3. *)
  4. type 'a literal = Text of string | Expression of 'a
  5. let map_litteral : f:('a -> 'b) -> 'a literal -> 'b literal =
  6. fun ~f -> function Text t -> Text t | Expression e -> Expression (f e)
  7. let eq_literal : eq:('a -> 'a -> bool) -> 'a literal -> 'a literal -> bool =
  8. fun ~eq l1 l2 ->
  9. match (l1, l2) with
  10. | Text s1, Text s2 -> String.equal s1 s2
  11. | Expression e1, Expression e2 -> eq e1 e2
  12. | _ -> false
  13. type boperator =
  14. | Eq
  15. | Neq
  16. | Plus
  17. | Minus
  18. | Product
  19. | Div
  20. | Gt
  21. | Lt
  22. | Gte
  23. | Lte
  24. | And
  25. | Or
  26. | Mod
  27. [@@deriving eq, show]
  28. and uoperator = No | Neg | Add [@@deriving eq, show]
  29. and assignation_operator =
  30. | Eq'
  31. | Inc (** += *)
  32. | Decr (** -= *)
  33. | Mult
  34. | Div_assign
  35. [@@deriving eq, show]
  36. type function_ =
  37. | Arrcomp
  38. | Arrpos
  39. | Arrsize
  40. | Countobj
  41. | Desc
  42. | Desc'
  43. | Dyneval
  44. | Dyneval'
  45. | Func
  46. | Func'
  47. | Getobj
  48. | Getobj'
  49. | Iif
  50. | Iif'
  51. | Input
  52. | Input'
  53. | Instr
  54. | Isnum
  55. | Isplay
  56. | Lcase
  57. | Lcase'
  58. | Len
  59. | Loc
  60. | Max
  61. | Max'
  62. | Mid
  63. | Mid'
  64. | Min
  65. | Min'
  66. | Msecscount
  67. | Rand
  68. | Replace
  69. | Replace'
  70. | Rgb
  71. | Rnd
  72. | Selact
  73. | Str
  74. | Str'
  75. | Strcomp
  76. | Strfind
  77. | Strfind'
  78. | Strpos
  79. | Trim
  80. | Trim'
  81. | Ucase
  82. | Ucase'
  83. | Val
  84. [@@deriving eq, show]
  85. type keywords =
  86. | IncLib
  87. | Addobj
  88. | Cla
  89. | Clear
  90. | Clear'
  91. | Close
  92. | CloseAll
  93. | Cls
  94. | CmdClear
  95. | CopyArr
  96. | DelAct
  97. | FreeLib
  98. | DelObj
  99. | Dynamic
  100. | Exec
  101. | Exit
  102. | Gosub
  103. | Goto
  104. | Jump
  105. | KillAll
  106. | KillObj
  107. | KillVar
  108. | MainTxt
  109. | MainTxt'
  110. | Menu
  111. | Msg
  112. | Nl
  113. | Nl'
  114. | P
  115. | P'
  116. | Pl
  117. | Pl'
  118. | Play
  119. | OpenGame
  120. | OpenQst
  121. | RefInt
  122. | SaveGame
  123. | SetTimer
  124. | ShowActs
  125. | ShowInput
  126. | ShowObjs
  127. | ShowStat
  128. | Stattxt
  129. | Stattxt'
  130. | Unselect
  131. | View
  132. | Wait
  133. | XGoto
  134. [@@deriving eq, show]