#include "tweak.h"#include "stack.h"#include "types.h"

gehe zum Quellcode dieser Datei
Funktionen | |
| private inherit | HOME ("lex") |
| static nomask void | initialize () |
| static void | create () |
| static nomask private mixed | CodeGen (mixed token) |
| static nomask int | parse (mixed msg, int interactive) |
Variablen | |
| static private mixed | code |
| static private mixed | stack |
| static private int | quot |
| static private int | assume |
| static nomask private mixed CodeGen | ( | mixed | token | ) | [static] |
Definiert in Zeile 33 der Datei parser.c.
Benutzt CL_LAMBDA, code, POP, pre_parse(), prog_parse(), PUSH, quot, SP, stack und TOP.
00034 { 00035 switch(pre_parse(&code)) 00036 { 00037 case 1: PUSH(stack, "'"); // standard autoquote 00038 quot++; 00039 break; 00040 case 2: PUSH(stack, "'CODE"); // special QUOTE for code generation 00041 break; 00042 } 00043 if(stringp(token)) 00044 switch(token) 00045 { 00046 case "'": PUSH(stack, token); quot++; return; 00047 case "(": PUSH(stack, code); code = ({}); break; 00048 case ")": 00049 { 00050 mixed tmp; 00051 if(SP(stack) && pointerp(TOP(stack))) POP(stack, tmp); 00052 else tmp = ({}); 00053 if(SP(stack) && TOP(stack) == "'") 00054 /* do nothing */ ; 00055 else 00056 if(sizeof(code)) 00057 { 00058 code[0] = prog_parse(code[0]); 00059 if(CL_LAMBDA(code[0]) || symbolp(code[0]) || pointerp(code[0])) 00060 code = ({#'funcall}) + code; 00061 } 00062 code = tmp + ({ code }); 00063 break; 00064 } 00065 default : code += ({ token[1..<2] }); break; 00066 } 00067 else 00068 code += ({ quot ? token : prog_parse(token, !sizeof(code)) }); 00069 00070 while(SP(stack) && (TOP(stack) == "'" || TOP(stack) == "'CODE") && 00071 sizeof(code)) 00072 { 00073 int q; 00074 if(stringp(code[<1]) || symbolp(code[<1]) || pointerp(code[<1]) || 00075 get_type_info(code[<1])[0] == 10) // quoted array 00076 code[<1] = quote(code[<1]); 00077 POPX(stack); 00078 } 00079 }

| static void create | ( | ) | [static] |
Definiert in Zeile 27 der Datei parser.c.
Benutzt create() und initialize().
00028 { 00029 lex::create(); 00030 initialize(); 00031 }

| private inherit HOME | ( | "lex" | ) |
| static nomask void initialize | ( | ) | [static] |
| static nomask int parse | ( | mixed | msg, | |
| int | interactive | |||
| ) | [static] |
Definiert in Zeile 82 der Datei parser.c.
00083 { 00084 mixed token, res; 00085 int lexing, missing_par; 00086 do { 00087 if(lexing = lex(&token)) 00088 { // try to assume outer "(" 00089 if(!SP(stack) && token != "(") { CodeGen("("); assume = 1; } 00090 CodeGen(token); 00091 } 00092 else // add ")" if "(" is assumed 00093 if(sizeof(stack) == 1 && assume) { CodeGen(")"); assume = 0; lexing = 1; } 00094 if(lexing && !SP(stack)) // complete expression found 00095 { 00096 mixed exec_code; exec_code = code; initialize(); 00097 if(sizeof(exec_code) && pointerp(exec_code[0])) 00098 exec_code = ({#',}) + exec_code;// more than one expr on one line 00099 if(msg = catch(res = eval(exec_code))) 00100 return -2; // execution error 00101 if(interactive) printf(output(res)); 00102 else msg = res; 00103 } 00104 } 00105 while(lexing); 00106 if(missing_par = SP(stack)) 00107 return (msg = sprintf("*Missing %d )\n", missing_par), -3); 00108 return 0; 00109 }
private mixed code [static] |
Definiert in Zeile 16 der Datei parser.c.
Wird benutzt von CodeGen(), handle_runtime_error() und initialize().
private int quot [static] |
Definiert in Zeile 18 der Datei parser.c.
Wird benutzt von CodeGen() und initialize().
1.6.3