interpreter.h 29 KB

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