Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.52 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace HMcutword
  8. {
  9. class Program
  10. {
  11.  
  12. static void Main(string[] args)
  13. {
  14. //string label = "int123<float112.33tong$";
  15. string label = "222in11t=float<==12.22uuu12.$";
  16. //string label = "==flojjat11.22flo33at$";
  17. int i = -1;
  18. char[] charArray = label.ToCharArray(0, label.Length);
  19. char c;
  20. string w = " ";
  21. string x = " ";
  22. L1: c = getchar(ref i, charArray);
  23. while (c != '$')
  24. {
  25. if (c == 'i') // int
  26. {
  27. w += c;
  28. c = getchar(ref i, charArray);
  29. if (c != 'n')
  30. {
  31. if (Isdigit(c))
  32. {
  33. Console.WriteLine(w);
  34. w = x;
  35. Unchar(ref i, charArray);
  36. goto L1;
  37. }
  38. else if(Isletter(c))
  39. {
  40. goto L1;
  41. }
  42. }
  43. else
  44. {
  45. w += c;
  46. c = getchar(ref i, charArray);
  47. if (c != 't')
  48. {
  49. if (Isdigit(c))
  50. {
  51. Console.WriteLine(w);
  52. w = x;
  53. Unchar(ref i, charArray);
  54. goto L1;
  55. }
  56. else if (Isletter(c))
  57. {
  58. goto L1;
  59. }
  60. }
  61. else
  62. {
  63. w += c;
  64. }
  65. }
  66. Console.WriteLine(w);
  67. w = x;
  68. goto L1;
  69.  
  70. }
  71. else if (c == 'f') //float
  72. {
  73. w += c;
  74. c = getchar(ref i, charArray);
  75. if (c != 'l')
  76. {
  77. if (Isdigit(c))
  78. {
  79. Console.WriteLine(w);
  80. w = x;
  81. Unchar(ref i, charArray);
  82. goto L1;
  83. }
  84. else if (Isletter(c))
  85. {
  86. goto L1;
  87. }
  88. }
  89. else
  90. {
  91. w += c;
  92. c = getchar(ref i, charArray);
  93. if (c != 'o')
  94. {
  95. if (Isdigit(c))
  96. {
  97. Console.WriteLine(w);
  98. w = x;
  99. Unchar(ref i, charArray);
  100. goto L1;
  101. }
  102. else if (Isletter(c))
  103. {
  104. goto L1;
  105. }
  106. }
  107. else
  108. {
  109. w += c;
  110. c = getchar(ref i, charArray);
  111. if (c != 'a')
  112. {
  113. if (Isdigit(c))
  114. {
  115. Console.WriteLine(w);
  116. w = x;
  117. Unchar(ref i, charArray);
  118. goto L1;
  119. }
  120. else if (Isletter(c))
  121. {
  122. goto L1;
  123. }
  124. }
  125. else
  126. {
  127. w += c;
  128. c = getchar(ref i, charArray);
  129. if (c != 't')
  130. {
  131. if (Isdigit(c))
  132. {
  133. Console.WriteLine(w);
  134. w = x;
  135. Unchar(ref i, charArray);
  136. goto L1;
  137. }
  138. else if (Isletter(c))
  139. {
  140. w += c;
  141. goto L1;
  142. }
  143. }
  144. else
  145. {
  146. w += c;
  147. //Console.WriteLine(w);
  148. }
  149. }
  150. }
  151. }
  152. Console.WriteLine(w);
  153. w = x;
  154. goto L1;
  155. }
  156. else if (c == '<') //<
  157. {
  158. w += c;
  159. Console.WriteLine(w);
  160. w = x;
  161. goto L1;
  162. }
  163. else if (c == '=') //= =
  164. {
  165. w += c;
  166. c = getchar(ref i, charArray);
  167.  
  168. if (c != '=')
  169. {
  170. Console.WriteLine(w);
  171. w = x;
  172. Unchar(ref i, charArray);
  173. goto L1;
  174. }
  175. else
  176. {
  177. w += c;
  178. Console.WriteLine(w);
  179. w = x;
  180. goto L1;
  181. }
  182. }
  183. else if (Isdigit(c)) //digit int_const or float_const
  184. {
  185. w += c;
  186. c = getchar(ref i, charArray);
  187. while (Isdigit(c))
  188. {
  189. w += c;
  190. c = getchar(ref i, charArray);
  191. }
  192. if (c != '.')
  193. {
  194. Console.WriteLine(w);
  195. w = x;
  196. Unchar(ref i, charArray);
  197. goto L1;
  198. }
  199. else
  200. {
  201. w += c;
  202. c = getchar(ref i, charArray);
  203. while (Isdigit(c))
  204. {
  205. w += c;
  206. c = getchar(ref i, charArray);
  207. }
  208. Console.WriteLine(w);
  209. w = x;
  210. Unchar(ref i, charArray);
  211. goto L1;
  212. }
  213. }
  214. else if (c == '"') // " " (String)
  215. {
  216. w += c;
  217. c = getchar(ref i, charArray);
  218. while ((Isdigit(c)) || (Isletter(c)) || (c == '<'))
  219. {
  220. w += c;
  221. c = getchar(ref i, charArray);
  222. }
  223. if (c == '"')
  224. {
  225. w += c;
  226. goto L1;
  227. }
  228. Console.WriteLine(w);
  229. }
  230. else if (Isletter(c)) //letter
  231. {
  232. w += c;
  233. c = getchar(ref i, charArray);
  234. while (Isletter(c))
  235. {
  236. w += c;
  237. c = getchar(ref i, charArray);
  238. }
  239. Console.WriteLine(w);
  240. Unchar(ref i, charArray);
  241. w = x;
  242. goto L1;
  243. }
  244. else
  245. {
  246. Console.WriteLine("Sezntence end....");
  247. }
  248. }
  249. Console.ReadLine();
  250. //Console.WriteLine("");
  251.  
  252.  
  253. }
  254. public static char getchar(ref int i, char[] lebelArray)
  255. {
  256. i++;
  257. char c = lebelArray[i];
  258. return c;
  259. }
  260. public static char Unchar(ref int i, char[] labelArray)
  261. {
  262.  
  263. char c = labelArray[i];
  264. i--;
  265. return c;
  266. }
  267. public static bool Isletter(char c)
  268. {
  269. if ((c >= 'a') && (c <= 'z') || (c >= 'A') && (c <= 'Z'))
  270. {
  271. return true;
  272. }
  273. return false;
  274. }
  275. public static bool Isdigit(char c)
  276. {
  277. if ((c >= '0') && (c <= '9'))
  278. {
  279. return true;
  280. }
  281. return false;
  282. }
  283. }
  284. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement