|
|
| version 1.17, 2001/02/25 08:50:13 | version 1.33, 2001/03/19 17:42:15 |
|---|---|
| Line 1 | Line 1 |
| /* | /** @file |
| $Id$ | Parser: compiler support helper functions decls. |
| Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) | |
| Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf) | |
| $Id$ | |
| */ | */ |
| #ifndef COMPILE_TOOLS | #ifndef COMPILE_TOOLS |
| Line 16 enum lexical_state { | Line 22 enum lexical_state { |
| LS_DEF_PARAMS, | LS_DEF_PARAMS, |
| LS_DEF_LOCALS, | LS_DEF_LOCALS, |
| LS_DEF_COMMENT, | LS_DEF_COMMENT, |
| LS_SPEC_CODE, | LS_DEF_SPECIAL_BODY, |
| LS_EXPRESSION_STRING, | |
| LS_EXPRESSION_VAR_NAME, | |
| LS_VAR_NAME_SIMPLE, | LS_VAR_NAME_SIMPLE, |
| LS_VAR_NAME_CURLY, | LS_VAR_NAME_CURLY, |
| LS_VAR_ROUND, | LS_VAR_ROUND, |
| LS_VAR_SQUARE, | |
| LS_VAR_CURLY, | LS_VAR_CURLY, |
| LS_METHOD_NAME, | LS_METHOD_NAME, |
| LS_METHOD_ROUND, | LS_METHOD_SQUARE, |
| LS_METHOD_CURLY, | LS_METHOD_CURLY, |
| LS_METHOD_ROUND, | |
| LS_METHOD_AFTER | LS_METHOD_AFTER |
| }; | }; |
| struct parse_control { | struct parse_control { |
| // input | // input |
| Pool *pool; | Pool *pool; |
| Request *request; | Request *request; |
| VClass *vclass; | VStateless_class *cclass; |
| #ifndef NO_CSTRING_ORIGIN | #ifndef NO_CSTRING_ORIGIN |
| char *source; | const char *source; |
| char *file; | const char *file; |
| int line, col; | int line, col; |
| #endif | #endif |
| // state | // state |
| Line 51 struct parse_control { | Line 61 struct parse_control { |
| }; | }; |
| // New array // return empty array | // New array // return empty array |
| inline Array/*<op>*/ *N(Pool& pool) { | inline Array/*<Operation>*/ *N(Pool& pool) { |
| return new(pool) Array/*<op>*/(pool); | return new(pool) Array/*<Operation>*/(pool); |
| } | } |
| // Assembler instruction // append ordinary instruction to ops | // Assembler instruction // append ordinary instruction to ops |
| inline void OP(Array/*<op>*/ *result, enum OPCODE code) { | inline void O(Array/*<Operation>*/ *result, enum OPCODE code) { |
| Operation op; op.code=code; | Operation op; op.code=code; |
| *result+=op.cast; | *result+=op.cast; |
| } | } |
| // Argument Eval_expression // append eval_expression to ops | // Argument Eval_expression // append eval_expression to ops |
| inline void AE(Array/*<op>*/ *result, char *eval_expression) { | inline void AE(Array/*<Operation>*/ *result, char *eval_expression) { |
| *result+=eval_expression; | *result+=eval_expression; |
| } | } |
| // aPpend 'code_array' to 'result' | // aPpend 'code_array' to 'result' |
| inline void P(Array/*<op>*/ *result, Array *code_array) { | inline void P(Array/*<Operation>*/ *result, Array *code_array) { |
| result->append_array(*code_array); | result->append_array(*code_array); |
| } | } |
| // aPpend part of 'code_array', starting from offset, to 'result' | // aPpend part of 'code_array', starting from offset, to 'result' |
| inline void P(Array/*<op>*/ *result, Array *code_array, int offset) { | inline void P(Array/*<Operation>*/ *result, Array *code_array, int offset) { |
| result->append_array(*code_array, offset); | result->append_array(*code_array, offset); |
| } | } |
| // aPpend 'vstring' to 'result' | // aPpend 'vstring' to 'result' |
| void PVS(Array/*<op>*/ *result, VString *vstring); | void PV(Array/*<Operation>*/ *result, VString *vstring); |
| // aPpend 'Code_Array' to result | // aPpend 'simple Code_Array' to result |
| void PCA(Array/*<op>*/ *result, Array/*<op>*/ *code_array); | void PCA(Array/*<Operation>*/ *result, Array/*<Operation>*/ *code_array); |
| // aPpend 'expression Code_Array' to result | |
| void PEA(Array/*<Operation>*/ *result, Array/*<Operation>*/ *code_array); | |
| // String Literal // returns array with | // Value Literal // returns array with |
| // first: OP_STRING instruction | // first: OP_VALUE instruction |
| // second op: string itself | // second op: string itself |
| Array *SL(VString *vstring); | Array *VL(Value *value); |
| // Literal Array to(2) String // return string value from literal array OP+string array | // Literal Array to(2) String // return string value from literal array OP+string array |
| String *SLA2S(Array *literal_string_array, int offset=0); | const String *SLA2S(Array *literal_string_array, int offset=0); |
| // Class Literal // returns array with | |
| // first: OP_CLASS instruction | |
| // second op: vclass itself | |
| Array *CL(VClass *vclass); | |
| void change_string_literal_to_double_literal(Array *literal_string_array); | |
| void change_string_literal_to_write_string_literal(Array *literal_string_array); | |
| void push_LS(struct parse_control *pc, lexical_state new_state); | void push_LS(struct parse_control *pc, lexical_state new_state); |
| void pop_LS(struct parse_control *pc); | void pop_LS(struct parse_control *pc); |