StateMachine.txt 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. // This file is used for automatically generating the ANSI escape sequence state machine
  2. //
  3. // The description of the state machine is taken from https://vt100.net/emu/dec_ansi_parser
  4. // with added support for UTF-8 parsing
  5. @name EscapeSequenceStateMachine
  6. @namespace VT
  7. @begin Ground
  8. @anywhere {
  9. 0x18 => (Ground, Execute)
  10. 0x1a => (Ground, Execute)
  11. 0x1b => (Escape, _)
  12. }
  13. Ground {
  14. [0x00..0x17] => (_, Execute)
  15. 0x19 => (_, Execute)
  16. [0x1c..0x1f] => (_, Execute)
  17. [0x20..0x7f] => (_, Print)
  18. [0x80..0xc1] => (Ground, FailUTF8)
  19. [0xc2..0xdf] => (UTF81ByteNeeded, BeginUTF8)
  20. [0xe0..0xef] => (UTF82BytesNeeded, BeginUTF8)
  21. [0xf0..0xf4] => (UTF83BytesNeeded, BeginUTF8)
  22. [0xf5..0xff] => (Ground, FailUTF8)
  23. }
  24. UTF81ByteNeeded {
  25. [0x00..0x7f] => (Ground, FailUTF8)
  26. [0x80..0xbf] => (Ground, PrintUTF8)
  27. [0xc0..0xff] => (Ground, FailUTF8)
  28. }
  29. UTF82BytesNeeded {
  30. [0x00..0x7f] => (Ground, FailUTF8)
  31. [0x80..0xbf] => (UTF81ByteNeeded, AdvanceUTF8)
  32. [0xc0..0xff] => (Ground, FailUTF8)
  33. }
  34. UTF83BytesNeeded {
  35. [0x00..0x7f] => (Ground, FailUTF8)
  36. [0x80..0xbf] => (UTF82BytesNeeded, AdvanceUTF8)
  37. [0xc0..0xff] => (Ground, FailUTF8)
  38. }
  39. Escape {
  40. @entry Clear
  41. [0x00..0x17] => (_, Execute)
  42. 0x19 => (_, Execute)
  43. [0x1c..0x1f] => (_, Execute)
  44. [0x20..0x2f] => (EscapeIntermediate, Collect)
  45. [0x30..0x4f] => (Ground, EscDispatch)
  46. 0x50 => (DcsEntry, _)
  47. [0x51..0x57] => (Ground, EscDispatch)
  48. 0x58 => (SosPmApcString, _)
  49. 0x59 => (Ground, EscDispatch)
  50. 0x5a => (Ground, EscDispatch)
  51. 0x5b => (CsiEntry, _)
  52. 0x5c => (Ground, EscDispatch)
  53. 0x5d => (OscString, _)
  54. 0x5e => (SosPmApcString, _)
  55. 0x5f => (SosPmApcString, _)
  56. [0x60..0x7e] => (Ground, EscDispatch)
  57. 0x7f => (_, _)
  58. }
  59. EscapeIntermediate {
  60. [0x00..0x17] => (_, Execute)
  61. 0x19 => (_, Execute)
  62. [0x1c..0x1f] => (_, Execute)
  63. [0x20..0x2f] => (_, Collect)
  64. [0x30..0x7e] => (Ground, EscDispatch)
  65. 0x7f => (_, _)
  66. }
  67. CsiEntry {
  68. @entry Clear
  69. [0x00..0x17] => (_, Execute)
  70. 0x19 => (_, Execute)
  71. [0x1c..0x1f] => (_, Execute)
  72. [0x20..0x2f] => (CsiIntermediate, Execute)
  73. [0x30..0x39] => (CsiParam, Param)
  74. 0x3a => (CsiIgnore, _)
  75. 0x3b => (CsiParam, Param)
  76. [0x3c..0x3f] => (CsiParam, Collect)
  77. [0x40..0x7e] => (Ground, CsiDispatch)
  78. 0x7f => (_, _)
  79. }
  80. CsiIgnore {
  81. [0x00..0x17] => (_, Execute)
  82. 0x19 => (_, Execute)
  83. [0x1c..0x1f] => (_, Execute)
  84. [0x20..0x3f] => (_, _)
  85. [0x40..0x7e] => (Ground, _)
  86. 0x7f => (_, _)
  87. }
  88. CsiParam {
  89. [0x00..0x17] => (_, Execute)
  90. 0x19 => (_, Execute)
  91. [0x1c..0x1f] => (_, Execute)
  92. [0x20..0x2f] => (CsiIntermediate, Collect)
  93. [0x30..0x39] => (_, Param)
  94. 0x3a => (CsiIgnore, _)
  95. 0x3b => (_, Param)
  96. [0x3c..0x3f] => (CsiIgnore, _)
  97. [0x40..0x7e] => (Ground, CsiDispatch)
  98. 0x7f => (_, _)
  99. }
  100. CsiIntermediate {
  101. [0x00..0x17] => (_, Execute)
  102. 0x19 => (_, Execute)
  103. [0x1c..0x1f] => (_, Execute)
  104. [0x20..0x2f] => (_, Collect)
  105. [0x30..0x3f] => (CsiIgnore, _)
  106. [0x40..0x7e] => (Ground, CsiDispatch)
  107. 0x7f => (_, _)
  108. }
  109. DcsEntry {
  110. @entry Clear
  111. [0x00..0x17] => (_, _)
  112. 0x19 => (_, _)
  113. [0x1c..0x1f] => (_, _)
  114. [0x20..0x2f] => (DcsIntermediate, Collect)
  115. [0x30..0x39] => (DcsParam, Param)
  116. 0x3a => (DcsIgnore, _)
  117. 0x3b => (DcsParam, Param)
  118. [0x3c..0x3f] => (DcsParam, Collect)
  119. [0x40..0x7e] => (DcsPassthrough, _)
  120. 0x7f => (_, _)
  121. }
  122. DcsIntermediate {
  123. [0x00..0x17] => (_, _)
  124. 0x19 => (_, _)
  125. [0x1c..0x1f] => (_, _)
  126. [0x20..0x2f] => (_, Collect)
  127. [0x30..0x3f] => (DcsIgnore, _)
  128. [0x40..0x7e] => (DcsPassthrough, _)
  129. 0x7f => (_, _)
  130. }
  131. DcsIgnore {
  132. [0x00..0x17] => (_, _)
  133. 0x19 => (_, _)
  134. [0x1c..0x1f] => (_, _)
  135. [0x20..0x7f] => (_, _)
  136. 0x9c => (Ground, _)
  137. }
  138. DcsParam {
  139. [0x00..0x17] => (_, _)
  140. 0x19 => (_, _)
  141. [0x1c..0x1f] => (_, _)
  142. [0x20..0x2f] => (DcsIntermediate, Collect)
  143. [0x30..0x39] => (_, Param)
  144. 0x3a => (DcsIgnore, _)
  145. 0x3b => (_, Param)
  146. [0x3c..0x3f] => (DcsIgnore, _)
  147. [0x40..0x7e] => (DcsPassthrough, _)
  148. 0x7f => (_, _)
  149. }
  150. DcsPassthrough {
  151. @entry Hook
  152. [0x00..0x17] => (_, Put)
  153. 0x19 => (_, Put)
  154. [0x1c..0x1f] => (_, Put)
  155. [0x20..0x7e] => (_, Put)
  156. 0x7f => (_, _)
  157. 0x9c => (Ground, _)
  158. @exit Unhook
  159. }
  160. SosPmApcString {
  161. [0x00..0x17] => (_, _)
  162. 0x19 => (_, _)
  163. [0x1c..0x1f] => (_, _)
  164. [0x20..0x7f] => (_, _)
  165. 0x9c => (Ground, _)
  166. }
  167. OscString {
  168. @entry OscStart
  169. [0x00..0x06] => (_, _)
  170. // While the standard says that only ST can terminate the string,
  171. // xterm uses BEL (0x07)
  172. 0x07 => (Ground, _)
  173. [0x08..0x17] => (_, _)
  174. 0x19 => (_, _)
  175. [0x1c..0x1f] => (_, _)
  176. [0x20..0xff] => (_, OscPut)
  177. @exit OscEnd
  178. }