interpreter.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742
  1. #include "../mem/mem.h"
  2. #ifndef _INTERPRETER_H
  3. #define _INTERPRETER_H
  4. #define MAX_SIZE (1024)
  5. #define false 0
  6. #define true 1
  7. #define bool int
  8. #define assignment_statement(the_statement,the_var,login_var,right_result,global_inter) assignment_statement_core(the_statement,the_var,login_var,right_result,0,auto_public,global_inter)
  9. #define read_statement_list(the_statement,the_var,global_inter) read_statement(the_statement,the_var,NULL,NULL,lock,global_inter)
  10. #define run_func(base_the_var,the_var,name,global_inter) run_func_core(base_the_var,the_var,name,false,global_inter)
  11. #define GWARF_value_reset {.type=NULL_value,.value.int_value=0,.lock_token=base}
  12. #define GWARF_result_reset {.value.type=NULL_value,.value.value.int_value=0,.value.lock_token=base}
  13. #define push_statement(base,token) \
  14. do{ \
  15. statement *tmp = find_statement_list(0, base); \
  16. append_statement(tmp, token.data.statement_value); \
  17. }while(0);
  18. // the type of data(GWARF_value)
  19. typedef enum{
  20. NUMBER_value = 1, // [只允许系统使用] [1]
  21. INT_value, // INT 类型[只允许系统使用] [2]
  22. BOOL_value, // bool : true or false [只允许系统使用] [3]
  23. STRING_value, // char * [只允许系统使用] [4]
  24. NULL_value, // 无值类型 [5]
  25. FUNC_value, // 函数 [6]
  26. CLASS_value, // 对象 [7]
  27. OBJECT_value, // 实例 [8]
  28. LIST_value, // 列表类型 [只允许系统使用] [9]
  29. DICT_value, // 字典类型 [只允许系统使用] [10]
  30. } GWARF_value_type;
  31. // all value is GWARF_value
  32. typedef struct GWARF_value{
  33. GWARF_value_type type;
  34. enum {
  35. base,
  36. lock,
  37. } lock_token; // 代表object、class等的访问权限 之对self和cls有效
  38. union
  39. {
  40. double double_value; // NUMBER
  41. int int_value;
  42. bool bool_value;
  43. char *string; // STRING
  44. struct func *func_value;
  45. struct class_object *class_value;
  46. struct the_object *object_value;
  47. struct the_list *list_value;
  48. struct the_dict *dict_value;
  49. } value;
  50. } GWARF_value;
  51. // ------------------------- parameter for def
  52. typedef struct parameter{
  53. struct
  54. {
  55. struct statement *var; // the_var
  56. struct statement *value; // var value
  57. } u;
  58. enum {
  59. only_value,
  60. name_value, // 形参/实参
  61. put_args,
  62. put_kwargs,
  63. } type;
  64. struct parameter *next; // for list
  65. } parameter;
  66. // ------------------------- var
  67. typedef struct var{
  68. enum{ // 代表变量访问权限
  69. auto_public, // 自动权限
  70. public,
  71. protect,
  72. private,
  73. } lock;
  74. char *name; // var name
  75. GWARF_value value;
  76. struct var *next; // for list
  77. } var;
  78. // ------------------------- hash_var
  79. typedef struct hash_var{
  80. struct var **hash; // 这是一个指针数组
  81. } hash_var;
  82. // ------------------------- statement
  83. typedef struct statement{
  84. enum statement_type{
  85. start=1, // for base statement
  86. operation, // such as + - * /
  87. base_var, // return var value by name
  88. base_value, // return an GWARF_value
  89. base_tuple,
  90. base_list, // return an GWARF_value->LIST_value
  91. base_dict, // return an GWARF_value->DICT_value
  92. while_cycle, // while
  93. for_cycle,
  94. if_branch, // if
  95. break_cycle, // break
  96. broken, // break_cycle and other {}
  97. continue_cycle,
  98. continued,
  99. restart,
  100. restarted,
  101. rego,
  102. rewent,
  103. set_default,
  104. set_global,
  105. set_nonlocal,
  106. code_block,
  107. def, // func
  108. lambda_func, // lambda x:x**2
  109. call, // func()
  110. point, // a.b 注:返回变量同时返回the_var链表[func 用于回调]
  111. down, // a[b] 注:返回变量同时返回the_var链表[func 用于回调]
  112. slice,
  113. return_code, // [26]
  114. set_class, // class aaa; b = aaa() is ```call```
  115. try_code, // try to do something except to do something
  116. raise_e, // raise exception
  117. throw_e, // throw the object class func or NULL
  118. import_class, // import file
  119. include_import, // include file
  120. for_in_cycle, // for i in a
  121. assert_e,
  122. chose_exp,
  123. pack_eq,
  124. base_svar,
  125. } type; // the statement type
  126. union
  127. {
  128. struct{
  129. enum{
  130. ADD_func = 1, // +
  131. SUB_func, // -
  132. DIV_func, // /
  133. MUL_func, // *
  134. ASSIGnMENT_func, // =
  135. EQUAL_func, // ==
  136. MORE_func, // >
  137. LESS_func, // <
  138. MOREEQ_func, // >=
  139. LESSEQ_func, // <=
  140. NOTEQ_func, // <>
  141. POW_func, // <>
  142. LOG_func, // <>
  143. SQRT_func, // <>
  144. NEGATIVE_func, // -a
  145. AND_func, // -a
  146. OR_func, // -a
  147. NOT_func, // -a
  148. MOD_func, // %
  149. INTDIV_func, // //
  150. AADD_func, // +=
  151. ASUB_func, // -=
  152. ADIV_func, // /=
  153. AMUL_func, // *=
  154. AMOD_func, // %=
  155. AINTDIV_func, // //=
  156. FADD_func, // a++
  157. LADD_func, // ++a
  158. FSUB_func, // a--
  159. LSUB_func, // --a
  160. APOW_func, // ^=
  161. BITAND_func,
  162. BITOR_func,
  163. BITNOTOR_func,
  164. BITRIGHT_func,
  165. BITLEFT_func,
  166. BITNOT_func,
  167. } type;
  168. struct statement *right_exp; // the right exp
  169. struct statement *left_exp; // the left exp
  170. } operation;
  171. struct{
  172. struct statement *condition; // xxx if yyy else zzz -> xxx
  173. struct statement *true_do; // xxx if yyy else zzz -> yyy
  174. struct statement *false_do; // xxx if yyy else zzz -> zzz
  175. } chose_exp;
  176. struct{
  177. struct statement *condition; // when to while
  178. struct statement *done; // while to do
  179. bool first_do; // do_while = true, while = false
  180. } while_cycle;
  181. struct{
  182. struct statement *first; // the first to do
  183. struct statement *condition; // when to while
  184. struct statement *after; // what to do after the done
  185. struct statement *done; // while to do
  186. } for_cycle;
  187. struct{
  188. struct if_list *done; // if_list
  189. } if_branch;
  190. struct{
  191. char *var_name; // return var
  192. struct statement *from; // from where [double->int]
  193. enum {
  194. auto_token, // 默认情况下auto_token是具有权限访问protetc base_var的,但不具有权限修改protect var,使用point运算符时会修改auto_token
  195. public_token,
  196. protect_token,
  197. private_token,
  198. } lock_token; // 如果用于赋值,则是新变量的权限,如果用于读取则是访问的权限 [默认情况 base_var访问权限不受限制,point的时候会更正访问权限]
  199. } base_var;
  200. struct{
  201. struct statement *var; // return var
  202. struct statement *from; // from where [double->int]
  203. } base_svar;
  204. struct{
  205. struct statement *base_var; // a.b --> a
  206. struct statement *child_var; // a.b --> b
  207. } point;
  208. struct{
  209. struct statement *base_var; // a[b] --> a
  210. struct parameter *child_var; // a[b,c,d] --> b,c,d
  211. } down;
  212. struct{
  213. GWARF_value value; // return value
  214. } base_value;
  215. struct{
  216. parameter *value; // [1,2,3,4] -> to_list
  217. } base_list;
  218. struct{
  219. parameter *value; // [1,2,3,4] -> to_tuple
  220. } base_tuple;
  221. struct{
  222. parameter *right; // 实参
  223. parameter *left; // 形参
  224. } pack_eq;
  225. struct{
  226. parameter *value; // [1,2,3,4] -> to_list
  227. } base_dict;
  228. struct{
  229. struct statement *base_var; // a[1:2:3] -> a
  230. parameter *value; // a[1:2:3] -> 1 2 3
  231. } slice;
  232. struct{
  233. struct statement *times; // 层数
  234. } break_cycle;
  235. struct{
  236. struct statement *times; // 层数
  237. } broken;
  238. struct{
  239. struct statement *times; // 层数
  240. } continue_cycle;
  241. struct{
  242. struct statement *times; // 层数
  243. } continued;
  244. struct{
  245. struct statement *times; // 层数
  246. } restart;
  247. struct{
  248. struct statement *times; // 层数
  249. } restarted;
  250. struct{
  251. } rego;
  252. struct{
  253. } rewent;
  254. struct{
  255. char *name;
  256. struct statement *times; // 层数
  257. } set_default;
  258. struct{
  259. char *name;
  260. } set_global;
  261. struct{
  262. char *name;
  263. } set_nonlocal;
  264. struct{
  265. struct statement *done; // block to do
  266. } code_block;
  267. struct{
  268. parameter *parameter_list; // def parameter
  269. struct statement *done; // def to do
  270. struct statement *var; // 方法的名字
  271. struct statement *setup; // setup to do
  272. enum {
  273. function,
  274. action,
  275. cls,
  276. auto_func,
  277. } type; // 静态函数[function] or 实例函数[action] or 类方法[cls] or 默认[def]
  278. bool is_inline; // inline函数不设单独的func_var空间
  279. } def;
  280. struct{
  281. parameter *parameter_list; // lambda parameter
  282. struct statement *done; // lambda to do
  283. } lambda_func;
  284. struct{
  285. parameter *parameter_list; // def parameter
  286. struct statement *func; // get func value
  287. } call;
  288. struct{
  289. struct statement *times; // 层数
  290. struct statement *value; // return value
  291. } return_code;
  292. struct{
  293. struct statement *done; // class to do
  294. parameter *father_list; // 继承
  295. struct statement *var; // from where [double->int]
  296. } set_class;
  297. struct
  298. {
  299. struct statement *try;
  300. struct statement *except;
  301. struct statement *var; // as var
  302. } try_code;
  303. struct
  304. {
  305. struct statement *done; // done to get exception object
  306. struct statement *info; // the info
  307. } raise_e;
  308. struct
  309. {
  310. struct statement *done; // done to get exception object
  311. } throw_e;
  312. struct
  313. {
  314. struct statement *file; // get address for file
  315. struct statement *var; // as name
  316. } import_class;
  317. struct
  318. {
  319. struct statement *file; // get address for file
  320. } include_import;
  321. struct
  322. {
  323. struct statement *var; // for i in a -> i
  324. struct statement *iter; // for i in a -> a
  325. struct statement *done; // for while to do
  326. } for_in_cycle;
  327. struct
  328. {
  329. struct statement *condition; // for i in a -> i
  330. struct statement *info; // for while to do
  331. } assert_e;
  332. } code;
  333. struct statement *next;
  334. } statement;
  335. // ------------------------- result value
  336. typedef struct GWARF_result{
  337. enum{
  338. return_def=1,
  339. statement_end,
  340. cycle_break,
  341. code_broken,
  342. cycle_continue,
  343. code_continued,
  344. cycle_restart,
  345. code_restarted,
  346. code_rego,
  347. code_rewent,
  348. error,
  349. } u; // the result type[from where]
  350. GWARF_value value;
  351. GWARF_value *father; // a.b --> a
  352. int return_times; // return用
  353. char *error_info; // 输出的错误信息
  354. char *base_name; // 返回名字
  355. } GWARF_result;
  356. // ------------------------- default_var [记录默认变量[层]] 用于default语句
  357. typedef struct default_var{
  358. char *name;
  359. int from;
  360. struct default_var *next;
  361. } default_var;
  362. // ------------------------- var base list [记录每一层变量base的链表]
  363. typedef struct var_list{
  364. struct hash_var *hash_var_base;
  365. struct default_var *default_list;
  366. struct var_list *next;
  367. enum{
  368. run_func,
  369. run_while,
  370. run_if,
  371. run_class,
  372. run_object,
  373. } tag; // var_list的标签
  374. } var_list;
  375. // ------------------------- inter paser [记录每一层变量code的链表]
  376. typedef struct statement_list{
  377. statement *statement_base;
  378. struct statement_list *next;
  379. } statement_list;
  380. // ------------------------- if list [记录着if...elif...else]
  381. typedef struct if_list{
  382. struct statement *condition; // when to while
  383. struct statement *done; // while to do
  384. struct if_list *next;
  385. } if_list;
  386. // ------------------------- inter
  387. typedef struct{
  388. hash_var *global_var; // global var链表
  389. statement *global_code; // global code链表
  390. } inter;
  391. //------- class/object/func
  392. typedef enum{
  393. customize = 1, // func by user
  394. official, // func by gwarf
  395. } func_type;
  396. typedef enum{
  397. printf_func = 1, // print_func
  398. __init__func = 2,
  399. __value__func = 3,
  400. __add__func = 4,
  401. __sub__func = 5,
  402. __mul__func = 6,
  403. __div__func = 7,
  404. __eq__func = 8,
  405. __more__func = 9,
  406. __less__func = 10,
  407. __eqmore__func = 11,
  408. __eqless__func = 12,
  409. __noteq__func = 13,
  410. __pow__func = 14,
  411. __log__func = 15,
  412. __sqrt__func = 16,
  413. __negative__func = 17,
  414. __powr__func = 18,
  415. __logr__func = 19,
  416. __sqrtr__func = 20,
  417. __subr__func = 21,
  418. __divr__func = 22,
  419. __len__func = 23,
  420. __down__func = 24,
  421. __set__func = 25,
  422. __slice__func = 26,
  423. __iter__func = 27,
  424. __next__func = 28,
  425. __idiv__func = 29,
  426. __idivr__func = 30,
  427. __mod__func = 31,
  428. __modr__func = 32,
  429. __bitand__func = 33,
  430. __bitor__func = 34,
  431. __bitnotor__func = 35,
  432. __bitleft__func = 36,
  433. __bitleftr__func = 37,
  434. __bitright__func = 38,
  435. __bitrightr__func = 39,
  436. __bitnot__func = 40,
  437. __assignment__func = 41, // 赋值左值,对于int类型等赋值时需要复制
  438. } official_func_type;
  439. typedef struct func{
  440. func_type type;
  441. official_func_type official_func;
  442. struct GWARF_result (*paser)(struct func *, struct parameter *, struct var_list *the_var, GWARF_result, var_list *);
  443. struct parameter *parameter_list; // def parameter
  444. struct statement *done; // def to do
  445. struct var_list *the_var; // func会记录the_var,因为不同地方调用var如果var链不统一那就会很乱
  446. struct var_list *self; // func会记录自己的self信息(可以类似于class和object那样调用),对于setup func会合并到the_var中
  447. int is_class;
  448. bool is_lambda;
  449. } func;
  450. typedef struct class_object{
  451. struct var_list *out_var; // 外部the_var list
  452. struct var_list *the_var; // 记录class_object的 -- 相当与cls
  453. } class_object;
  454. typedef struct the_object{
  455. struct var_list *cls; // 记录class_object的 -- 相当与cls
  456. struct var_list *the_var; // 记录class_object的实例 -- 相当与self
  457. } the_object;
  458. typedef struct the_list // 列表类型
  459. {
  460. GWARF_value *list_value; // 列表类型
  461. int index; // the max index
  462. } the_list;
  463. typedef struct the_dict // 列表类型
  464. {
  465. struct hash_var *dict_value; // 列表类型
  466. int index; // the max index
  467. struct dict_key *name_list; // 值插入的顺序
  468. } the_dict;
  469. typedef struct dict_key // dict的key类型
  470. {
  471. char *key;
  472. struct dict_key *next;
  473. } dict_key;
  474. // 函数声明
  475. GWARF_result operation_func(statement *, var_list *, var_list *, inter *);
  476. GWARF_result while_func(statement *, var_list *, inter *);
  477. GWARF_result if_func(if_list *, var_list *, inter *);
  478. GWARF_result for_func(statement *, var_list *, inter *);
  479. GWARF_result call_back(statement *, var_list *, inter *);
  480. GWARF_result login_var(var_list *, var_list *, parameter *, parameter *, inter *);
  481. GWARF_result call_back_core(GWARF_result, var_list *, parameter *, inter *);
  482. GWARF_result block_func(statement *, var_list *, inter *);
  483. GWARF_result try_func(statement *, var_list *, inter *);
  484. GWARF_result raise_func(statement *, var_list *, bool, inter *);
  485. GWARF_result import_func(statement *, var_list *, inter *);
  486. GWARF_result include_func(statement *, var_list *, inter *);
  487. GWARF_result forin_func(statement *, var_list *, inter *);
  488. GWARF_result assert_func(statement *, var_list *, inter *);
  489. GWARF_result add_func(GWARF_result, GWARF_result, var_list *, inter *);
  490. GWARF_result sub_func(GWARF_result, GWARF_result, var_list *, inter *);
  491. GWARF_result mul_func(GWARF_result, GWARF_result, var_list *, inter *);
  492. GWARF_result div_func(GWARF_result, GWARF_result, var_list *, inter *);
  493. GWARF_result pow_func(GWARF_result, GWARF_result, var_list *, inter *);
  494. GWARF_result log_func(GWARF_result, GWARF_result, var_list *, inter *);
  495. GWARF_result sqrt_func(GWARF_result, GWARF_result, var_list *, inter *);
  496. GWARF_result assignment_func(char *, GWARF_result, var_list *, int, int); // 不需要inter
  497. GWARF_result equal_func(GWARF_result, GWARF_result, var_list *, int, inter *);
  498. GWARF_result negative_func(GWARF_result, var_list *, inter *);
  499. GWARF_result assignment_statement_core(statement *, var_list *, var_list *, GWARF_result, bool, int, inter *);
  500. GWARF_result assignment_statement_value(statement *, var_list *, var_list *, GWARF_value, inter *);
  501. GWARF_result not_func(GWARF_result, var_list *, inter *);
  502. GWARF_result or_func(statement *, statement *, var_list *, inter *);
  503. GWARF_result and_func(statement *, statement *, var_list *, inter *);
  504. GWARF_result int_div_func(GWARF_result, GWARF_result, var_list *, inter *);
  505. GWARF_result mod_func(GWARF_result, GWARF_result, var_list *, inter *);
  506. GWARF_result bit_not_func(GWARF_result, var_list *, inter *);
  507. GWARF_result bit_right_func(GWARF_result, GWARF_result, var_list *, inter *);
  508. GWARF_result bit_left_func(GWARF_result, GWARF_result, var_list *, inter *);
  509. GWARF_result bit_notor_func(GWARF_result, GWARF_result, var_list *, inter *);
  510. GWARF_result bit_or_func(GWARF_result, GWARF_result, var_list *, inter *);
  511. GWARF_result bit_and_func(GWARF_result, GWARF_result, var_list *, inter *);
  512. double sqrt_(double, double);
  513. double log_(double, double);
  514. GWARF_value to_int(GWARF_value, var_list *the_var,inter *);
  515. GWARF_value to_double(GWARF_value value, var_list *the_var,inter *);
  516. GWARF_value to_str(GWARF_value value, var_list *the_var,inter *);
  517. GWARF_value to_str_dict(GWARF_value value, var_list *the_var,inter *);
  518. GWARF_value to_bool_(GWARF_value value, var_list *the_var,inter *);
  519. GWARF_value to_list(GWARF_value value, var_list *the_var,inter *);
  520. GWARF_value to_dict(GWARF_value value, var_list *the_var,inter *);
  521. GWARF_value parameter_to_list(parameter *tmp_s, var_list *the_var, inter *global_inter);
  522. GWARF_value parameter_to_dict(parameter *tmp_s, var_list *the_var, inter *global_inter);
  523. bool start_with(char *, char *);
  524. char *del_start(char *, char *);
  525. GWARF_value key_to_str(char *);
  526. bool to_bool(GWARF_value, inter *global_inter);
  527. GWARF_result get__value__(GWARF_value *, var_list *, inter *);
  528. GWARF_result get__bool__(GWARF_value *, var_list *, inter *);
  529. GWARF_result get__iter__(GWARF_value *, var_list *, inter *);
  530. GWARF_result get__next__(GWARF_value *, var_list *, inter *);
  531. GWARF_result get__assignment__(GWARF_value *, var_list *, inter *);
  532. GWARF_result run_func_core(GWARF_value *, var_list *, char *, bool, inter *);
  533. int len_only_double(double num);
  534. int len_double(double num);
  535. int len_int(int num);
  536. int len_intx(unsigned int num);
  537. GWARF_value to_object(GWARF_value, inter *);
  538. GWARF_result get_object(parameter *, char *, var_list *, inter *);
  539. class_object *make_object(var_list *the_var, var_list *father_var_list);
  540. void login_official_func(int type, int is_class, var_list *the_var, char *name, GWARF_result (*paser)(func *, parameter *, var_list *, GWARF_result, var_list *,inter *));
  541. void login_official(var_list *the_var, GWARF_result (*paser)(func *, parameter *, var_list *, GWARF_result, var_list *,inter *),inter *);
  542. // 内置函数
  543. GWARF_result official_func(func *the_func, parameter *tmp_s, var_list *the_var, GWARF_result father, var_list *out_var,inter *global_inter);
  544. // object内置类
  545. class_object *object_login_official(var_list *the_var, GWARF_result (*paser)(func *, parameter *, var_list *, GWARF_result, var_list *,inter *),inter *);
  546. GWARF_result object_official_func(func *the_func, parameter *tmp_s, var_list *the_var, GWARF_result father, var_list *out_var,inter *global_inter);
  547. // gobject内置类
  548. class_object *gobject_login_official(var_list *the_var, GWARF_result (*paser)(func *, parameter *, var_list *, GWARF_result, var_list *,inter *), var_list *father_var_list,inter *);
  549. GWARF_result gobject_official_func(func *the_func, parameter *tmp_s, var_list *the_var, GWARF_result father, var_list *out_var,inter *global_inter);
  550. // int内置类
  551. class_object *int_login_official(var_list *the_var, GWARF_result (*paser)(func *, parameter *, var_list *, GWARF_result, var_list *,inter *), var_list *father_var_list,inter *);
  552. GWARF_result int_official_func(func *the_func, parameter *tmp_s, var_list *the_var, GWARF_result father, var_list *out_var,inter *global_inter);
  553. // double内置类
  554. class_object *double_login_official(var_list *the_var, GWARF_result (*paser)(func *, parameter *, var_list *, GWARF_result, var_list *,inter *), var_list *father_var_list,inter *);
  555. GWARF_result double_official_func(func *the_func, parameter *tmp_s, var_list *the_var, GWARF_result father, var_list *out_var,inter *global_inter);
  556. // str内置类
  557. class_object *str_login_official(var_list *the_var, GWARF_result (*paser)(func *, parameter *, var_list *, GWARF_result, var_list *,inter *), var_list *father_var_list,inter *);
  558. GWARF_result str_official_func(func *the_func, parameter *tmp_s, var_list *the_var, GWARF_result father, var_list *out_var,inter *global_inter);
  559. // bool内置类
  560. class_object *bool_login_official(var_list *the_var, GWARF_result (*paser)(func *, parameter *, var_list *, GWARF_result, var_list *,inter *), var_list *father_var_list,inter *);
  561. GWARF_result bool_official_func(func *the_func, parameter *tmp_s, var_list *the_var, GWARF_result father, var_list *out_var,inter *global_inter);
  562. // list内置类
  563. class_object *tuple_login_official(var_list *the_var, GWARF_result (*paser)(func *, parameter *, var_list *, GWARF_result, var_list *,inter *), var_list *father_var_list,inter *);
  564. GWARF_result tuple_official_func(func *the_func, parameter *tmp_s, var_list *the_var, GWARF_result father, var_list *out_var,inter *global_inter);
  565. // list内置类
  566. class_object *list_login_official(var_list *the_var, GWARF_result (*paser)(func *, parameter *, var_list *, GWARF_result, var_list *,inter *), var_list *father_var_list,inter *);
  567. GWARF_result list_official_func(func *the_func, parameter *tmp_s, var_list *the_var, GWARF_result father, var_list *out_var,inter *global_inter);
  568. // dict内置类
  569. class_object *dict_login_official(var_list *the_var, GWARF_result (*paser)(func *, parameter *, var_list *, GWARF_result, var_list *,inter *), var_list *father_var_list,inter *);
  570. GWARF_result dict_official_func(func *the_func, parameter *tmp_s, var_list *the_var, GWARF_result father, var_list *out_var,inter *global_inter);
  571. // 错误内置类
  572. class_object *BaseException_login_official(var_list *the_var, GWARF_result (*paser)(func *, parameter *, var_list *, GWARF_result, var_list *,inter *), var_list *father_var_list,inter *);
  573. GWARF_result BaseException_official_func(func *the_func, parameter *tmp_s, var_list *the_var, GWARF_result father, var_list *out_var,inter *global_inter);
  574. class_object *Exception_login_official(var_list *the_var, var_list *father_var_list,inter *global_inter);
  575. class_object *NameException_login_official(var_list *the_var, var_list *father_var_list,inter *global_inter);
  576. class_object *IterException_login_official(var_list *the_var, var_list *father_var_list,inter *global_inter);
  577. class_object *AssertException_login_official(var_list *the_var, var_list *father_var_list,inter *global_inter);
  578. class_object *AssignmentException_login_official(var_list *the_var, var_list *father_var_list,inter *global_inter);
  579. // 生成错误
  580. GWARF_result to_error(char *, char *, inter *);
  581. bool is_space(GWARF_result *);
  582. bool is_error(GWARF_result *tmp);
  583. if_list *make_base_if();
  584. if_list *make_if(statement *, statement *);
  585. if_list *append_elif(if_list *, if_list *);
  586. statement *make_statement();
  587. statement *append_statement(statement *, statement*);
  588. statement_list *make_statement_list();
  589. statement_list *make_statement_base(statement *);
  590. statement_list *append_statement_list(statement *, statement_list *);
  591. statement *find_statement_list(int, statement_list *);
  592. statement_list *free_statement_list(statement_list *);
  593. var *make_var();
  594. void append_var(char *name, GWARF_value, var *, int);
  595. void free_var(var *);
  596. var *get_var(char *, var *);
  597. void del_var(char *, var *);
  598. default_var *make_default_var();
  599. default_var *make_default_var_base();
  600. void append_default_var_base(char * ,int , default_var *);
  601. int get_default(char *, default_var *);
  602. var_list *make_var_list();
  603. var_list *make_var_base(hash_var *);
  604. var_list *append_var_list(hash_var *, var_list *);
  605. var_list *append_by_var_list(var_list *, var_list *);
  606. var_list *free_var_list(var_list *);
  607. int get_var_list_len(var_list *);
  608. var *find_var(var_list *,int , char *, int *);
  609. void add_var(var_list *,int , char *, GWARF_value, int);
  610. void del_var_var_list(var_list *,int, char *);
  611. var_list *copy_var_list(var_list *);
  612. hash_var *make_hash_var();
  613. unsigned int time33(char *);
  614. int login_node(char *, GWARF_value, hash_var *, int);
  615. var *find_node(char *, hash_var *);
  616. void del_var_node(char *, hash_var *);
  617. parameter *make_parameter_name(statement *);
  618. parameter *append_parameter_name(statement *, parameter *);
  619. parameter *make_parameter_value(statement *);
  620. parameter *append_parameter_value(statement *, parameter *);
  621. parameter *add_parameter_value(statement *, parameter *);
  622. parameter *pack_value_parameter(GWARF_value);
  623. statement *pack_call_name(char *, statement *);
  624. GWARF_result traverse(statement *, var_list *, bool,inter *);
  625. GWARF_result traverse_global(statement *, var_list *,inter *);
  626. GWARF_result traverse_get_value(statement *, var_list *, var_list *,inter *);
  627. inter *get_inter();
  628. void login(var_list *the_var, inter *global_inter);
  629. // inter *global_inter;
  630. statement_list *statement_base;
  631. int yyerror(char const *);
  632. FILE *yyin;
  633. char *yytext;
  634. #endif