tokens.cpp 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290
  1. /*
  2. * Copyright (c) 2011 Matthew Iselin
  3. *
  4. * Permission to use, copy, modify, and distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #include <map>
  17. #include <string>
  18. #include <string.h>
  19. #include "tibasic.h"
  20. using namespace std;
  21. /// Describes a potential token to be read by the compiler
  22. struct Token {
  23. /// The compiled byte for the token
  24. unsigned char data;
  25. /// The actual text to be converted by the interpreter
  26. const char* text;
  27. };
  28. /// A two byte token (0xBB, 0x7E and SysVar)
  29. struct TwoByte {
  30. unsigned short data;
  31. const char* text;
  32. };
  33. /// Direct ASCII character to token conversion.
  34. struct ConvertRule {
  35. char c; // the character
  36. unsigned char tok; // the equivalent token
  37. };
  38. /// References to lists defined after functions.
  39. extern struct Token StandardTokens[199];
  40. extern struct TwoByte CalcVars[302];
  41. extern struct ConvertRule Replacements[39];
  42. /// string -> token mapping
  43. map<string, token_t> g_TokenLookup;
  44. /// token -> string mapping
  45. map<unsigned short, string> g_ReverseLookup;
  46. /// Longest input string possible
  47. size_t g_LongestInput = 0;
  48. /// Shiny little template function that returns the size of an array.
  49. template <typename T, int N> size_t arrayLen(T(&)[N]){return N;}
  50. /// Initialises the token map
  51. void initialiseTokens()
  52. {
  53. // Iterate the main token list first.
  54. for(size_t i = 0; i < arrayLen(StandardTokens); i++)
  55. {
  56. token_t value;
  57. value.token = StandardTokens[i].data;
  58. value.sz = sizeof(StandardTokens[i].data);
  59. size_t len = strlen(StandardTokens[i].text);
  60. if(len > g_LongestInput)
  61. g_LongestInput = len;
  62. string s = string(StandardTokens[i].text);
  63. g_TokenLookup[s] = value;
  64. g_ReverseLookup[value.token] = s;
  65. }
  66. // Now iterate the two-byte tokens.
  67. for(size_t i = 0; i < (sizeof(CalcVars) / sizeof(Token)); i++)
  68. {
  69. token_t value;
  70. value.token = CalcVars[i].data;
  71. value.sz = sizeof(CalcVars[i].data);
  72. size_t len = strlen(CalcVars[i].text);
  73. if(len > g_LongestInput)
  74. g_LongestInput = len;
  75. string s = string(CalcVars[i].text);
  76. g_TokenLookup[s] = value;
  77. g_ReverseLookup[value.token] = s;
  78. }
  79. // Finally, iterate single-character tokens.
  80. for(size_t i = 0; i < (sizeof(Replacements) / sizeof(ConvertRule)); i++)
  81. {
  82. token_t value;
  83. value.token = Replacements[i].tok;
  84. value.sz = sizeof(Replacements[i].tok);
  85. char c[] = {Replacements[i].c, 0};
  86. string s = c;
  87. g_TokenLookup[s] = value;
  88. g_ReverseLookup[value.token] = s;
  89. }
  90. }
  91. size_t getLongestToken()
  92. {
  93. return g_LongestInput;
  94. }
  95. /// Perform a lookup
  96. bool lookupToken(string in, token_t &ret)
  97. {
  98. if(in.length() > g_LongestInput)
  99. return false;
  100. if(g_TokenLookup.find(in) == g_TokenLookup.end())
  101. return false;
  102. ret = g_TokenLookup[in];
  103. return true;
  104. }
  105. bool lookupToken(unsigned short in, string &out)
  106. {
  107. if(g_ReverseLookup.find(in) == g_ReverseLookup.end())
  108. return false;
  109. out = g_ReverseLookup[in];
  110. return true;
  111. }
  112. // Token List
  113. #define TO_DMS 0x01
  114. #define TO_DEC 0x02
  115. #define TO_FRAC 0x03
  116. #define STORE 0x04
  117. #define BOXPLOT 0x05
  118. #define LEFTSBRACK 0x06
  119. #define RIGHTSBRACK 0x07
  120. #define LEFTBRACE 0x08
  121. #define RIGHTBRACE 0x09
  122. #define RADIANS 0x0A
  123. #define DEGREES 0x0B
  124. #define INVERSE 0x0C
  125. #define SQUARE 0x0D
  126. #define TRANSPOSE 0x0E
  127. #define CUBE 0x0F
  128. #define LEFTBRACKET 0x10
  129. #define RIGHTBRACKET 0x11
  130. #define ROUND 0x12
  131. #define PXLTEST 0x13
  132. #define AUGMENT 0x14
  133. #define ROWSWAP 0x15
  134. #define ROWPLUS 0x16
  135. #define STARROW 0x17
  136. #define STARROWPLUS 0x18
  137. #define MAX 0x19
  138. #define MIN 0x1B
  139. #define MEDIAN 0x1F
  140. #define RANDM 0x20
  141. #define MEAN 0x21
  142. #define SOLVE 0x22
  143. #define SEQFUNC 0x23
  144. #define FNINT 0x24
  145. #define NDERIV 0x25
  146. #define FMIN 0x27
  147. #define FMAX 0x28
  148. #define SPACE 0x29
  149. #define DOUBLEQUOTE 0x2A
  150. #define COMMA 0x2B
  151. #define IMAG_I 0x2C
  152. #define FACTORIAL 0x2D
  153. #define CUBICREG 0x2E
  154. #define QUARTREG 0x2F
  155. #define NUM_0 0x30
  156. #define NUM_1 0x31
  157. #define NUM_2 0x32
  158. #define NUM_3 0x33
  159. #define NUM_4 0x34
  160. #define NUM_5 0x35
  161. #define NUM_6 0x36
  162. #define NUM_7 0x37
  163. #define NUM_8 0x38
  164. #define NUM_9 0x39
  165. #define PERIOD 0x3A
  166. #define EXPONENT 0x3B
  167. #define LOGIC_OR 0x3C
  168. #define LOGIC_XOR 0x3D
  169. #define COLON 0x3E
  170. #define HARD_RETURN 0x3F
  171. #define LOGIC_AND 0x40
  172. #define STR_A 0x41
  173. #define STR_B 0x42
  174. #define STR_C 0x43
  175. #define STR_D 0x44
  176. #define STR_E 0x45
  177. #define STR_F 0x46
  178. #define STR_G 0x47
  179. #define STR_H 0x48
  180. #define STR_I 0x49
  181. #define STR_J 0x4A
  182. #define STR_K 0x4B
  183. #define STR_L 0x4C
  184. #define STR_M 0x4D
  185. #define STR_N 0x4E
  186. #define STR_O 0x4F
  187. #define STR_P 0x50
  188. #define STR_Q 0x51
  189. #define STR_R 0x52
  190. #define STR_S 0x53
  191. #define STR_T 0x54
  192. #define STR_U 0x55
  193. #define STR_V 0x56
  194. #define STR_W 0x57
  195. #define STR_X 0x58
  196. #define STR_Y 0x59
  197. #define STR_Z 0x5A
  198. #define STR_THETA 0x5B
  199. #define PROGRAM 0x5F
  200. /** SysVar **/
  201. #define RADIAN 0x64
  202. #define DEGREE 0x65
  203. #define NORMAL 0x66
  204. #define SCI 0x67
  205. #define ENG 0x68
  206. #define FLOAT 0x69
  207. #define TEST_EQUAL 0x6A
  208. #define TEST_LESSTHAN 0x6B
  209. #define TEST_HIGHTHAN 0x6C
  210. #define TEST_LOREQU 0x6D
  211. #define TEST_GOREQU 0x6E
  212. #define TEST_NOTEQUAL 0x6F
  213. #define ADD 0x70
  214. #define SUBTRACT 0x71
  215. #define ANSWER 0x72
  216. #define FIX 0x73
  217. #define HORIZ 0x74
  218. #define FULL 0x75
  219. #define FUNC 0x76
  220. #define PARAM 0x77
  221. #define POLAR 0x78
  222. #define SEQ 0x79
  223. #define INDPNTAUTO 0x7A
  224. #define INDPNTASK 0x7B
  225. #define DEPENDAUTO 0x7C
  226. #define DEPENDASK 0x7D
  227. /** 7E VARIABLES, ie. graph manipulation **/
  228. #define BOX 0x7F
  229. #define DIVIDE 0x80
  230. #define DOT 0x81
  231. #define MULTIPLY 0x82
  232. #define DIVIDE_SLASH 0x83
  233. #define TRACE 0x84
  234. #define CLRDRAW 0x85
  235. #define ZSTANDARD 0x86
  236. #define ZTRIG 0x87
  237. #define ZBOX 0x88
  238. #define ZOOMIN 0x89
  239. #define ZOOMOUT 0x8A
  240. #define ZSQUARE 0x8B
  241. #define ZINTEGER 0x8C
  242. #define ZPREVIOUS 0x8D
  243. #define ZDECIMAL 0x8E
  244. #define ZOOMSTAT 0x8F
  245. #define ZOOMRCL 0x90
  246. #define PRINTSCREEN 0x91
  247. #define ZOOMSTO 0x92
  248. #define TEXTFUNC 0x93
  249. #define NPR 0x94
  250. #define NCR 0x95
  251. #define FNON 0x96
  252. #define FNOFF 0x97
  253. #define STOREPIC 0x98
  254. #define RECALLPIC 0x99
  255. #define STOREGDB 0x9A
  256. #define RECALLGDB 0x9B
  257. #define LINE 0x9C
  258. #define VERTICAL 0x9D
  259. #define PTON 0x9E
  260. #define PTOFF 0x9F
  261. #define PTCHANGE 0xA0
  262. #define PXLON 0xA1
  263. #define PXLOFF 0xA2
  264. #define PXLCHANGE 0xA3
  265. #define SHADE 0xA4
  266. #define CIRCLE 0xA5
  267. #define HORIZONTAL 0xA6
  268. #define TANGENT 0xA7
  269. #define DRAWINV 0xA8
  270. #define DRAWF 0xA9
  271. #define RAND 0xAB
  272. #define PI 0xAC
  273. #define GETKEY 0xAD
  274. #define APOSTROPHE 0xAE
  275. #define QUESTIONMARK 0xAF
  276. /** SysVar **/
  277. #define NEGATIVE 0xB0
  278. #define CONV_INT 0xB1
  279. #define ABS 0xB2
  280. #define DETERMINANT 0xB3
  281. #define IDENTITY 0xB4
  282. #define DIM 0xB5
  283. #define SUM 0xB6
  284. #define PROD 0xB7
  285. #define NOT 0xB8
  286. #define IPART 0xB9
  287. #define FPART 0xBA
  288. /** BB tokens **/
  289. #define SQR_ROOT 0xBC
  290. #define CUBE_ROOT 0xBD
  291. #define NATLOG 0xBE
  292. #define ETOPOWER 0xBF
  293. #define LOGARITHM 0xC0
  294. #define POWER10 0xC1
  295. #define SINE 0xC2
  296. #define INVSIN 0xC3
  297. #define COSINE 0xC4
  298. #define INVCOSINE 0xC5
  299. #define TANGENT_TRIG 0xC6
  300. #define INVTANGENT 0xC7
  301. #define HYP_SINE 0xC8
  302. #define HYP_ISINE 0xC9
  303. #define HYP_COSINE 0xCA
  304. #define HYP_ICOSINE 0xCB
  305. #define HYP_TANGENT 0xCC
  306. #define HYP_ITANGENT 0xCD
  307. #define LOGIC_IF 0xCE
  308. #define LOGIC_THEN 0xCF
  309. #define LOGIC_ELSE 0xD0
  310. #define CTL_WHILE 0xD1
  311. #define CTL_REPEAT 0xD2
  312. #define CTL_FOR 0xD3
  313. #define CTL_END 0xD4
  314. #define CTL_RETURN 0xD5
  315. #define LABEL 0xD6
  316. #define CTL_GOTO 0xD7
  317. #define CTL_PAUSE 0xD8
  318. #define CTL_STOP 0xD9
  319. #define INCSKIPIFHIGH 0xDA
  320. #define DECSKIPIFLOW 0xDB
  321. #define INPUT 0xDC
  322. #define PROMPT 0xDD
  323. #define DISP 0xDE
  324. #define DISPGRAPH 0xDF
  325. #define OUTPUT 0xE0
  326. #define CLRHOME 0xE1
  327. #define FILL 0xE2
  328. #define SORTA 0xE3
  329. #define SORTD 0xE4
  330. #define DISPTABLE 0xE5
  331. #define MENU 0xE6
  332. #define SEND 0xE7
  333. #define GET 0xE8
  334. #define PLOTSON 0xE9
  335. #define PLOTSOFF 0xEA
  336. #define LIST 0xEB
  337. #define PLOT1 0xEC
  338. #define PLOT2 0xED
  339. #define PLOT3 0xEE
  340. #define POWEROF 0xF0
  341. #define XTHROOT 0xF1
  342. #define VARSTATS_1 0xF2
  343. #define VARSTATS_2 0xF3
  344. #define LINREG1 0xF4
  345. #define EXPREG 0xF5
  346. #define LNREG 0xF6
  347. #define PWRREG 0xF7
  348. #define MEDMED 0xF8
  349. #define QUADREG 0xF9
  350. #define CLRLIST 0xFA
  351. #define CLRTABLE 0xFB
  352. #define HISTOGRAM 0xFC
  353. #define XYLINE 0xFD
  354. #define SCATTER 0xFE
  355. #define LINREG2 0xFF
  356. /** SYSTEM VARIABLES **/
  357. // Matrices
  358. #define MAT_A 0x005C
  359. #define MAT_B 0x015C
  360. #define MAT_C 0x025C
  361. #define MAT_D 0x035C
  362. #define MAT_E 0x045C
  363. #define MAT_F 0x055C
  364. #define MAT_G 0x065C
  365. #define MAT_H 0x075C
  366. #define MAT_I 0x085C
  367. #define MAT_J 0x095C
  368. // Lists
  369. #define L1 0x005D
  370. #define L2 0x015D
  371. #define L3 0x025D
  372. #define L4 0x035D
  373. #define L5 0x045D
  374. #define L6 0x055D
  375. #define L7 0x065D
  376. #define L8 0x075D
  377. #define L9 0x085D
  378. #define L0 0x095D
  379. // Graph (function)
  380. #define Y1 0x105E
  381. #define Y2 0x115E
  382. #define Y3 0x125E
  383. #define Y4 0x135E
  384. #define Y5 0x145E
  385. #define Y6 0x155E
  386. #define Y7 0x165E
  387. #define Y8 0x175E
  388. #define Y9 0x185E
  389. #define Y0 0x195E
  390. // Graph (parametric)
  391. #define X1T 0x205E
  392. #define Y1T 0x215E
  393. #define X2T 0x225E
  394. #define Y2T 0x235E
  395. #define X3T 0x245E
  396. #define Y3T 0x255E
  397. #define X4T 0x265E
  398. #define Y4T 0x275E
  399. #define X5T 0x285E
  400. #define Y5T 0x295E
  401. #define X6T 0x2A5E
  402. #define Y6T 0x2B5E
  403. // Graph (polar)
  404. #define R1 0x405E
  405. #define R2 0x415E
  406. #define R3 0x425E
  407. #define R4 0x435E
  408. #define R5 0x445E
  409. #define R6 0x455E
  410. #define SYSVAR_U 0x805E
  411. #define SYSVAR_V 0x815E
  412. // Pictures
  413. #define PIC1 0x0060
  414. #define PIC2 0x0160
  415. #define PIC3 0x0260
  416. #define PIC4 0x0360
  417. #define PIC5 0x0460
  418. #define PIC6 0x0560
  419. #define PIC7 0x0660
  420. #define PIC8 0x0760
  421. #define PIC9 0x0860
  422. #define PIC0 0x0960
  423. // Graph databases
  424. #define GDB1 0x0061
  425. #define GDB2 0x0161
  426. #define GDB3 0x0261
  427. #define GDB4 0x0361
  428. #define GDB5 0x0461
  429. #define GDB6 0x0561
  430. #define GDB7 0x0661
  431. #define GDB8 0x0761
  432. #define GDB9 0x0861
  433. #define GDB0 0x0961
  434. // Stat data
  435. #define REGEQ 0x0162
  436. #define STAT_N 0x0262
  437. #define MEANX 0x0362
  438. #define SUMX 0x0462
  439. #define SUMXSQUARED 0x0562
  440. #define SX 0x0662
  441. #define SIGMAX 0x0762
  442. #define MINX 0x0862
  443. #define MAXX 0x0962
  444. #define MINY 0x0A62
  445. #define MAXY 0x0B02
  446. #define MEANY 0x0C62
  447. #define SUMY 0x0D62
  448. #define SUMYSQUARED 0x0E62
  449. #define SY 0x0F62
  450. #define SIGMAY 0x1062
  451. #define SUMXY 0x1162
  452. #define SYSVAR_R 0x1262
  453. #define MED 0x1362
  454. #define Q1 0x1462
  455. #define Q3 0x1562
  456. #define SYSVAR_A 0x1662
  457. #define SYSVAR_B 0x1762
  458. #define SYSVAR_C 0x1862
  459. #define SYSVAR_D 0x1962
  460. #define SYSVAR_E 0x1A62
  461. #define X1 0x1B62
  462. #define X2 0x1C62
  463. #define X3 0x1D62
  464. #define Y1_1 0x1E62
  465. #define Y2_1 0x1F62
  466. #define Y3_1 0x2062
  467. #define SYSVAR_N 0x2162
  468. #define SYSVAR_P 0x2262
  469. #define SYSVAR_Z 0x2362
  470. #define SYSVAR_T 0x2462
  471. #define CHISQUARED 0x2562
  472. #define FIN 0x2662
  473. #define DF 0x2762
  474. #define PHAT 0x2862
  475. #define PHAT1 0x2962
  476. #define PHAT2 0x2A62
  477. #define MEANX1 0x2B62
  478. #define SX1 0x2C62
  479. #define N1 0x2D62
  480. #define MEANX2 0x2E62
  481. #define SX2 0x2F62
  482. #define N2 0x3062
  483. #define SXP 0x3162
  484. #define LOWER 0x3262
  485. #define UPPER 0x3362
  486. #define SYSVAR_S 0x3462
  487. #define RSQUARED 0x3562
  488. #define CAPRSQUARED 0x3662
  489. #define DF2 0x3762 // not sure about this one
  490. #define SS 0x3862
  491. #define MS 0x3962
  492. #define DF3 0x3A62 // again here?
  493. #define SS1 0x3B62 // another double
  494. #define MS1 0x3C62 // " "
  495. // Graph data
  496. #define ZXSCL 0x0063
  497. #define ZYSCL 0x0163
  498. #define XSCL 0x0263
  499. #define YSCL 0x0363
  500. #define UNSTART 0x0463
  501. #define VNSTART 0x0563
  502. #define UNINVERSE 0x0663
  503. #define VNINVERSE 0x0763
  504. #define ZUNSTART 0x0863
  505. #define ZVNSTART 0x0963
  506. #define XMIN 0x0A63
  507. #define XMAX 0x0B63
  508. #define YMIN 0x0C63
  509. #define YMAX 0x0D63
  510. #define TMIN 0x0E63
  511. #define TMAX 0x0F63
  512. #define THETAMIN 0x1063
  513. #define THETAMAX 0x1163
  514. #define ZXMIN 0x1263
  515. #define ZXMAX 0x1363
  516. #define ZYMIN 0x1463
  517. #define ZYMAX 0x1563
  518. #define ZTHETAMIN 0x1663
  519. #define ZTHETAMAX 0x1763
  520. #define ZTMIN 0x1863
  521. #define ZTMAX 0x1963
  522. #define TBLMIN 0x1A63
  523. #define NMIN 0x1B63
  524. #define ZNMIN 0x1C63
  525. #define NMAX 0x1D63
  526. #define ZNMAX 0x1E63
  527. #define NSTART 0x1F63
  528. #define ZNSTART 0x2063
  529. #define DELTATABLE 0x2163
  530. #define TSTEP 0x2263
  531. #define THETASTEP 0x2363
  532. #define ZTSTEP 0x2463
  533. #define ZTHETASTEP 0x2563
  534. #define DELTAX 0x2663
  535. #define DELTAY 0x2763
  536. #define XFACT 0x2863
  537. #define YFACT 0x2963
  538. #define TBLINPUT 0x2A63
  539. #define SYSVAR_CAPN 0x2B63
  540. #define IPERCENT 0x2C63
  541. #define PV 0x2D63
  542. #define PMT 0x2E63
  543. #define FV 0x2F63
  544. #define XRES 0x3063
  545. #define ZXRES 0x3163
  546. // Strings
  547. #define STR1 0x00AA
  548. #define STR2 0x01AA
  549. #define STR3 0x02AA
  550. #define STR4 0x03AA
  551. #define STR5 0x04AA
  552. #define STR6 0x05AA
  553. #define STR7 0x06AA
  554. #define STR8 0x07AA
  555. #define STR9 0x08AA
  556. #define STR0 0x09AA
  557. /** 7E VARIABLES **/
  558. #define SEQUENTIAL_7E 0x007E
  559. #define SIMUL 0x017E
  560. #define POLARGC 0x027E
  561. #define RECTGC 0x037E
  562. #define COORDON 0x047E
  563. #define COORDOFF 0x057E
  564. #define CONNECTED 0x067E
  565. #define DOT_7E 0x077E
  566. #define AXESON 0x087E
  567. #define AXESOFF 0x097E
  568. #define GRIDON 0x0A7E
  569. #define GRIDOFF 0x0B7E
  570. #define LABELON 0x0C7E
  571. #define LABELOFF 0x0D7E
  572. #define WEB 0x0E7E
  573. #define TIME 0x0F7E
  574. #define UVAXES 0x107E
  575. #define VWAXES 0x117E
  576. #define UWAXES 0x127E
  577. /** BB VARIABLES **/
  578. #define NPV 0x00BB
  579. #define IRR 0x01BB
  580. #define BAL 0x02BB
  581. #define SUMPRN 0x03BB
  582. #define SUMINT 0x04BB
  583. #define TONOM 0x05BB
  584. #define TOEFF 0x06BB
  585. #define DBD 0x07BB
  586. #define LCM 0x08BB
  587. #define GCD 0x09BB
  588. #define RANDINT 0x0ABB
  589. #define RANDBIN 0x0BBB
  590. #define SUB 0x0CBB
  591. #define STDDEV 0x0DBB
  592. #define VARIANCE 0x0EBB
  593. #define INSTRING 0x0FBB
  594. #define NORMALCDF 0x10BB
  595. #define INVNORM 0x11BB
  596. #define TCDF 0x12BB
  597. #define XSQUCDF 0x13BB
  598. #define FCDF 0x14BB
  599. #define BINOMPDF 0x15BB
  600. #define BINOMCDF 0x16BB
  601. #define POISSONPDF 0x17BB
  602. #define POISSONCDF 0x18BB
  603. #define GEOMETPDF 0x19BB
  604. #define GEOMETCDF 0x1ABB
  605. #define NORMALPDF 0x1BBB
  606. #define TPDF 0x1CBB
  607. #define XSQUPDF 0x1DBB
  608. #define FPDF 0x1EBB
  609. #define RANDNORM 0x1FBB
  610. #define TVM_PMT 0x20BB
  611. #define TVM_I_PERCENT 0x21BB
  612. #define TVM_PV 0x22BB
  613. #define TVM_N 0x23BB
  614. #define TVM_FV 0x24BB
  615. #define CONJ 0x25BB
  616. #define REAL 0x26BB
  617. #define IMAG 0x27BB
  618. #define ANGLE 0x28BB
  619. #define CUMSUM 0x29BB
  620. #define EXPR 0x2ABB
  621. #define LENGTH 0x2BBB
  622. #define DELTA_LIST 0x2CBB
  623. #define REF 0x2DBB
  624. #define RREF 0x2EBB
  625. #define TORECT 0x2FBB
  626. #define TOPOLAR 0x30BB
  627. #define VAR_E 0x31BB
  628. #define SINREG 0x32BB
  629. #define LOGISTIC 0x33BB
  630. #define LINREGTTEST 0x34BB
  631. #define SHADENORM 0x35BB
  632. #define SHADE_T 0x36BB
  633. #define SHADEXSQU 0x37BB
  634. #define SHADEF 0x38BB
  635. #define MATRTOLIST 0x39BB
  636. #define LISTTOMATR 0x3ABB
  637. #define ZTEST 0x3BBB
  638. #define TTEST 0x3CBB
  639. #define TWO_SAMPZTEST 0x3DBB
  640. #define ONE_PROPZTEST 0x3EBB
  641. #define TWO_PROPZTEST 0x3FBB
  642. #define XSQUTEST 0x40BB
  643. #define ZINTERVAL 0x41BB
  644. #define TWO_SAMPZINT 0x42BB
  645. #define ONE_PROPZINT 0x43BB
  646. #define TWO_PROPZINT 0x44BB
  647. #define GRAPHSTYLE 0x45BB
  648. #define TWO_SAMPTTEST 0x46BB
  649. #define TWO_SAMPFTEST 0x47BB
  650. #define TINTERVAL 0x48BB
  651. #define TWO_SAMPTINT 0x49BB
  652. #define SETUPEDITOR 0x4ABB
  653. #define PMT_END 0x4BBB
  654. #define PMT_BGN 0x4CBB
  655. #define REAL_BB 0x4DBB
  656. #define REPOWTHETAI 0x4EBB
  657. #define APLUSBI 0x4FBB
  658. #define EXPRON 0x50BB
  659. #define EXPROFF 0x51BB
  660. #define CLRALLLISTS 0x52BB
  661. #define GETCALC 0x53BB
  662. #define DELVAR 0x54BB
  663. #define EQUTOSTRING 0x55BB
  664. #define STRINGTOEQU 0x56BB
  665. #define CLEARENTRIES 0x57BB
  666. #define SELECT 0x58BB
  667. #define ANOVA 0x59BB
  668. #define MODBOXPLOT 0x5ABB
  669. #define NORMPROBPLOT 0x5BBB
  670. // Standard Tokens are any token that can be used anywhere in the line.
  671. struct Token StandardTokens[] = {
  672. /** CONTROL page of PROGRAM EDITOR (press PRGM when EDITING a program) **/
  673. { LOGIC_IF, "If " },
  674. { LOGIC_THEN, "Then" },
  675. { LOGIC_ELSE, "Else" },
  676. { CTL_FOR, "For(" },
  677. { CTL_WHILE, "While " },
  678. { CTL_REPEAT, "Repeat " },
  679. { CTL_END, "End" },
  680. { CTL_PAUSE, "Pause " },
  681. { CTL_PAUSE, "Pause" },
  682. { LABEL, "Lbl " },
  683. { CTL_GOTO, "Goto " },
  684. { INCSKIPIFHIGH, "IS>(" },
  685. { DECSKIPIFLOW, "DS<(" },
  686. { MENU, "Menu(" },
  687. { PROGRAM, "prgm" },
  688. { CTL_RETURN, "Return" },
  689. { CTL_STOP, "Stop" },
  690. /** I/O page **/
  691. { INPUT, "Input " },
  692. { PROMPT, "Prompt " },
  693. { DISP, "Disp " },
  694. { DISPGRAPH, "DispGraph" },
  695. { DISPTABLE, "DispTable" },
  696. { OUTPUT, "Output(" },
  697. { GETKEY, "getKey" },
  698. { CLRHOME, "ClrHome" },
  699. { CLRTABLE, "ClrTable" },
  700. /** GetCalc **/
  701. { GET, "Get(" },
  702. { SEND, "Send(" },
  703. /** Plots **/
  704. { PLOTSON, "PlotsOn " },
  705. { PLOTSOFF, "PlotsOff " },
  706. /** Others **/
  707. { TRACE, "Trace" },
  708. { ZSTANDARD, "ZStandard" },
  709. { ZTRIG, "ZTrig" },
  710. { ZBOX, "ZBox" },
  711. { ZOOMIN, "ZoomIn" },
  712. { ZOOMOUT, "ZoomOut" },
  713. { ZSQUARE, "ZSquare" },
  714. { ZINTEGER, "ZInteger" },
  715. { ZPREVIOUS, "ZPrevious" },
  716. { ZDECIMAL, "ZDecimal" },
  717. { ZOOMSTAT, "ZoomStat" },
  718. { ZOOMRCL, "ZoomRcl" },
  719. { ZOOMSTO, "ZoomSto" },
  720. { TEXTFUNC, "Text(" },
  721. { STOREPIC, "StorePic" },
  722. { RECALLPIC, "RecallPic" },
  723. { STOREGDB, "StoreGDB" },
  724. /** OTHERS **/
  725. { TO_DMS, "->DMS" },
  726. { TO_DEC, "->DEC" },
  727. { TO_FRAC, "->FRAC" },
  728. { STORE, "->" },
  729. { BOXPLOT, "BoxPlot" },
  730. { RADIANS, "[radians]" },
  731. { DEGREES, "[degrees]" },
  732. { INVERSE, "^-1" },
  733. { SQUARE, "^2" },
  734. { TRANSPOSE, "[transpose]" },
  735. { CUBE, "^3" },
  736. { ROUND, "round(" },
  737. { PXLTEST, "pxl-Test(" },
  738. { AUGMENT, "augment(" },
  739. { ROWSWAP, "RowSwap(" },
  740. { ROWPLUS, "row+(" },
  741. { STARROW, "*row(" },
  742. { STARROWPLUS, "*row+(" },
  743. { MAX, "max(" },
  744. { MIN, "min(" },
  745. { MEDIAN, "median(" },
  746. { RANDM, "randM(" },
  747. { MEAN, "mean(" },
  748. { SOLVE, "solve(" },
  749. { SEQFUNC, "seq(" },
  750. { FNINT, "fnInt(" },
  751. { NDERIV, "NDeriv(" },
  752. { FMIN, "FMin(" },
  753. { FMAX, "FMax(" },
  754. { CUBICREG, "CubicReg " },
  755. { QUARTREG, "QuartReg " },
  756. { LOGIC_OR, " or " },
  757. { LOGIC_XOR, " xor " },
  758. { LOGIC_AND, "and" },
  759. { STR_THETA, "[theta]" },
  760. { PROGRAM, "prgm" },
  761. { RADIAN, "Radian" },
  762. { DEGREE, "Degree" },
  763. { NORMAL, "Normal" },
  764. { SCI, "Sci" },
  765. { ENG, "Eng" },
  766. { FLOAT, "Float" },
  767. { TEST_LOREQU, "<=" },
  768. { TEST_GOREQU, ">=" },
  769. { TEST_NOTEQUAL, "!=" },
  770. { ANSWER, "Ans" },
  771. { FIX, "Fix " },
  772. { HORIZ, "Horiz" },
  773. { FULL, "Full" },
  774. { FUNC, "Func" },
  775. { PARAM, "Param" },
  776. { POLAR, "Polar" },
  777. { SEQ, "Seq" },
  778. { INDPNTAUTO, "IndpntAuto" },
  779. { INDPNTASK, "IndpntAsk" },
  780. { DEPENDAUTO, "DependAuto" },
  781. { DEPENDASK, "DependAsk" },
  782. { BOX, "[box]" },
  783. { DOT, "[dot]" },
  784. { TRACE, "Trace" },
  785. { CLRDRAW, "ClrDraw" },
  786. { ZSTANDARD, "ZStandard" },
  787. { ZTRIG, "ZTrig" },
  788. { ZBOX, "ZBox" },
  789. { ZOOMIN, "Zoom In" },
  790. { ZOOMOUT, "Zoom Out" },
  791. { ZSQUARE, "ZSquare" },
  792. { ZINTEGER, "ZInteger" },
  793. { ZPREVIOUS, "ZPrevious" },
  794. { ZDECIMAL, "ZDecimal" },
  795. { ZOOMSTAT, "ZoomStat" },
  796. { ZOOMRCL, "ZoomRcl" },
  797. { PRINTSCREEN, "PrintScreen" },
  798. { ZOOMSTO, "ZoomSto" },
  799. { TEXTFUNC, "Text(" },
  800. { NPR, "nPr" },
  801. { NCR, "nCr" },
  802. { FNON, "FnOn " },
  803. { FNOFF, "FnOff " },
  804. { STOREPIC, "StorePic " },
  805. { RECALLPIC, "RecallPic " },
  806. { STOREGDB, "StoreGDB " },
  807. { RECALLGDB, "RecallGDB " },
  808. { LINE, "Line(" },
  809. { VERTICAL, "Vertical " },
  810. { PTON, "Pt-On(" },
  811. { PTOFF, "Pt-Off(" },
  812. { PTCHANGE, "Pt-Change(" },
  813. { PXLON, "Pxl-On(" },
  814. { PXLOFF, "Pxl-Off(" },
  815. { PXLCHANGE, "Pxl-Change(" },
  816. { SHADE, "Shade(" },
  817. { CIRCLE, "Circle(" },
  818. { HORIZONTAL, "Horizontal " },
  819. { TANGENT, "Tangent(" },
  820. { DRAWINV, "DrawInv " },
  821. { DRAWF, "DrawF " },
  822. { PI, "[pi]" },
  823. { GETKEY, "getKey" },
  824. { NEGATIVE, "[neg]" },
  825. { CONV_INT, "int(" },
  826. { ABS, "abs(" },
  827. { DETERMINANT, "det(" },
  828. { IDENTITY, "identity(" },
  829. { DIM, "dim(" },
  830. { SUM, "sum(" },
  831. { PROD, "prod(" },
  832. { NOT, "not(" },
  833. { IPART, "iPart(" },
  834. { FPART, "fPart(" },
  835. { SQR_ROOT, "[root]^2" },
  836. { CUBE_ROOT, "[root]^3" },
  837. { NATLOG, "ln(" },
  838. { ETOPOWER, "e^" },
  839. { LOGARITHM, "log(" },
  840. { POWER10, "10^(" },
  841. { SINE, "sin(" },
  842. { INVSIN, "asin(" },
  843. { COSINE, "cos(" },
  844. { INVCOSINE, "acos(" },
  845. { TANGENT_TRIG, "tan(" },
  846. { INVTANGENT, "atan(" },
  847. { HYP_SINE, "sinh(" },
  848. { HYP_ISINE, "asinh(" },
  849. { HYP_COSINE, "cosh(" },
  850. { HYP_ICOSINE, "acosh(" },
  851. { HYP_TANGENT, "tanh(" },
  852. { HYP_ITANGENT, "atanh(" },
  853. { LOGIC_ELSE, "Else" },
  854. { FILL, "Fill(" },
  855. { SORTA, "SortA(" },
  856. { SORTD, "SortD(" },
  857. { LIST, "[list]" },
  858. { PLOT1, "Plot1(" },
  859. { PLOT2, "Plot2(" },
  860. { PLOT3, "Plot3(" },
  861. { XTHROOT, "[root]^" },
  862. { VARSTATS_1, "1-Var Stats " },
  863. { VARSTATS_2, "2-Var Stats " },
  864. { LINREG1, "LinReg(a+bx) " },
  865. { EXPREG, "ExpReg " },
  866. { LNREG, "LnReg " },
  867. { PWRREG, "PwrReg " },
  868. { MEDMED, "Med-Med " },
  869. { QUADREG, "QuadReg " },
  870. { CLRLIST, "ClrList " },
  871. { CLRTABLE, "ClrTable" },
  872. { HISTOGRAM, "Histogram" },
  873. { XYLINE, "xyLine" },
  874. { SCATTER, "Scatter" },
  875. { LINREG2, "LinReg(ax+b) " },
  876. { RAND, "rand" },
  877. };
  878. // two-byte variables
  879. struct TwoByte CalcVars[] = {
  880. // AsmPrgm (uncompiled)
  881. { 0x6CBB, "AsmPrgm" },
  882. { 0x6DBB, "AsmPrgm" }, // this means decompilation works, but compilation won't hit this
  883. // SysVar
  884. { MAT_A, "[A]" },
  885. { MAT_B, "[B]" },
  886. { MAT_C, "[C]" },
  887. { MAT_D, "[D]" },
  888. { MAT_E, "[E]" },
  889. { MAT_F, "[F]" },
  890. { MAT_G, "[G]" },
  891. { MAT_H, "[H]" },
  892. { MAT_I, "[I]" },
  893. { MAT_J, "[J]" },
  894. { L1, "L1" },
  895. { L2, "L2" },
  896. { L3, "L3" },
  897. { L4, "L4" },
  898. { L5, "L5" },
  899. { L6, "L6" },
  900. { L7, "L7" },
  901. { L8, "L8" },
  902. { L9, "L9" },
  903. { L0, "L0" },
  904. { Y1, "Y1" },
  905. { Y2, "Y2" },
  906. { Y3, "Y3" },
  907. { Y4, "Y4" },
  908. { Y5, "Y5" },
  909. { Y6, "Y6" },
  910. { Y7, "Y7" },
  911. { Y8, "Y8" },
  912. { Y9, "Y9" },
  913. { Y0, "Y0" },
  914. { X1T, "X1T" },
  915. { Y1T, "Y1T" },
  916. { X2T, "X2T" },
  917. { Y2T, "Y2T" },
  918. { X3T, "X3T" },
  919. { Y3T, "Y3T" },
  920. { X4T, "X4T" },
  921. { Y4T, "Y4T" },
  922. { X5T, "X5T" },
  923. { Y5T, "Y5T" },
  924. { X6T, "X6T" },
  925. { Y6T, "Y6T" },
  926. { R1, "R1" },
  927. { R2, "R2" },
  928. { R3, "R3" },
  929. { R4, "R4" },
  930. { R5, "R5" },
  931. { R6, "R6" },
  932. { SYSVAR_U, "[u]" },
  933. { SYSVAR_V, "[v]" },
  934. { PIC1, "PIC1" },
  935. { PIC2, "PIC2" },
  936. { PIC3, "PIC3" },
  937. { PIC4, "PIC4" },
  938. { PIC5, "PIC5" },
  939. { PIC6, "PIC6" },
  940. { PIC7, "PIC7" },
  941. { PIC8, "PIC8" },
  942. { PIC9, "PIC9" },
  943. { PIC0, "PIC0" },
  944. { GDB1, "GDB1" },
  945. { GDB2, "GDB2" },
  946. { GDB3, "GDB3" },
  947. { GDB4, "GDB4" },
  948. { GDB5, "GDB5" },
  949. { GDB6, "GDB6" },
  950. { GDB7, "GDB7" },
  951. { GDB8, "GDB8" },
  952. { GDB9, "GDB9" },
  953. { GDB0, "GDB0" },
  954. // finally, StatVars
  955. { SX1, "Sx1" },
  956. { SX2, "Sx2" },
  957. { SXP, "Sxp" },
  958. { REGEQ, "RegEq" },
  959. { STAT_N, "[n]" },
  960. { MEANX, "mean(x)" },
  961. { SUMXSQUARED, "sum(x)^2" },
  962. { SUMX, "sum(x)" },
  963. { SX, "Sx" },
  964. { SIGMAX, "[sigma]x" },
  965. { MINX, "minX" },
  966. { MAXX, "maxX" },
  967. { MINY, "minY" },
  968. { MAXY, "maxY" },
  969. { MEANY, "mean(y)" },
  970. { SUMYSQUARED, "sum(y)^2" },
  971. { SUMY, "sum(y)" },
  972. { SY, "Sy" },
  973. { SIGMAY, "[sigma]y" },
  974. { SUMXY, "sum(xy)" },
  975. { SYSVAR_R, "[r]" },
  976. { MED, "Med" },
  977. { Q1, "Q1" },
  978. { Q3, "Q3" },
  979. { SYSVAR_A, "[a]" },
  980. { SYSVAR_B, "[b]" },
  981. { SYSVAR_C, "[c]" },
  982. { SYSVAR_D, "[d]" },
  983. { SYSVAR_E, "[stat_e]" }, // because '[e]' refers to the constant e
  984. { X1, "x1" },
  985. { X2, "x2" },
  986. { X3, "x3" },
  987. { Y1_1, "y1" },
  988. { Y2_1, "y2" },
  989. { Y3_1, "y3" },
  990. { SYSVAR_N, "[n]" }, // somebody please tell me why there are so many variations on n
  991. { SYSVAR_P, "[p]" },
  992. { SYSVAR_Z, "[z]" },
  993. { SYSVAR_T, "[t]" },
  994. { CHISQUARED, "[chi]^2" },
  995. { FIN, "[fin]" },
  996. { DF, "[df]" },
  997. { PHAT, "[p^]" },
  998. { PHAT1, "[p^1]" },
  999. { PHAT2, "[p^2]" },
  1000. { MEANX1, "mean(x1)" },
  1001. { N1, "[n1]" },
  1002. { MEANX2, "mean(x2)" },
  1003. { N2, "[n2]" },
  1004. { LOWER, "[lower]" },
  1005. { UPPER, "[upper]" },
  1006. { SYSVAR_S, "[s]" },
  1007. { RSQUARED, "r^2" },
  1008. { CAPRSQUARED, "R^2" },
  1009. { DF2, "[df]" }, // somebody was high when they invented the token tables
  1010. { SS, "SS" },
  1011. { DF3, "[df]" }, // see previous comment
  1012. { SS1, "SS" }, // again...
  1013. { MS1, "MS" }, // and again!
  1014. // graph data
  1015. { ZXSCL, "ZXscl" },
  1016. { ZYSCL, "ZYscl" },
  1017. { XSCL, "Xscl" },
  1018. { YSCL, "Yscl" },
  1019. { ZUNSTART, "ZUnStart" },
  1020. { ZVNSTART, "ZVnStart" },
  1021. { UNSTART, "UnStart" },
  1022. { VNSTART, "VnStart" },
  1023. { UNINVERSE, "Un-1" }, // i read a ^-1, but it's actually a -1...
  1024. { VNINVERSE, "Vn-1" }, // same as above
  1025. { ZXMIN, "ZXmin" },
  1026. { ZXMAX, "ZXmax" },
  1027. { ZYMIN, "ZYmin" },
  1028. { ZYMAX, "ZYmax" },
  1029. { ZTHETAMIN, "Ztheta_min"},
  1030. { ZTHETAMAX, "Ztheta_max"},
  1031. { ZTMIN, "ZTmin" },
  1032. { ZTMAX, "ZTmax" },
  1033. { XMIN, "Xmin" },
  1034. { XMAX, "Xmax" },
  1035. { YMIN, "Ymin" },
  1036. { YMAX, "Ymax" },
  1037. { TMIN, "Tmin" },
  1038. { TMAX, "Tmax" },
  1039. { THETAMIN, "theta_min" },
  1040. { THETAMAX, "theta_max" },
  1041. { TBLMIN, "TblMin" },
  1042. { ZNMIN, "ZnMin" },
  1043. { NMIN, "nMin" },
  1044. { ZNMAX, "ZnMax" },
  1045. { NMAX, "nMax" },
  1046. { ZNSTART, "ZnStart" },
  1047. { NSTART, "nStart" },
  1048. { DELTATABLE, "delta_Tbl" },
  1049. { ZTSTEP, "ZTstep" },
  1050. { ZTHETASTEP, "Ztheta_step"},
  1051. { TSTEP, "Tstep" },
  1052. { THETASTEP, "theta_step"},
  1053. { DELTAX, "delta_X" },
  1054. { DELTAY, "delta_Y" },
  1055. { XFACT, "XFact" },
  1056. { YFACT, "YFact" },
  1057. { TBLINPUT, "TblInput" },
  1058. // finance app
  1059. { SYSVAR_CAPN, "[N]" }, // this is the N in the Finance app
  1060. { IPERCENT, "I%" },
  1061. { PV, "PV" },
  1062. { PMT, "PMT" },
  1063. { FV, "FV" },
  1064. { ZXRES, "ZXres" },
  1065. { XRES, "Xres" },
  1066. // strings
  1067. { STR1, "STR1" },
  1068. { STR2, "STR2" },
  1069. { STR3, "STR3" },
  1070. { STR4, "STR4" },
  1071. { STR5, "STR5" },
  1072. { STR6, "STR6" },
  1073. { STR7, "STR7" },
  1074. { STR8, "STR8" },
  1075. { STR9, "STR9" },
  1076. { STR0, "STR0" },
  1077. // 7E Variables
  1078. { SEQ, "Sequential" },
  1079. { SIMUL, "Simul" },
  1080. { POLARGC, "PolarGC" },
  1081. { RECTGC, "RectGC" },
  1082. { COORDON, "CoordOn" },
  1083. { COORDOFF, "CoordOff" },
  1084. { CONNECTED, "Connected" },
  1085. { DOT_7E, "Dot" },
  1086. { AXESON, "AxesOn" },
  1087. { AXESOFF, "AxesOff" },
  1088. { GRIDON, "GridOn" },
  1089. { GRIDOFF, "GridOff" },
  1090. { LABELON, "LabelOn" },
  1091. { LABELOFF, "LabelOff" },
  1092. { WEB, "Web" },
  1093. { TIME, "Time" },
  1094. { UVAXES, "uvAxes" },
  1095. { VWAXES, "vwAxes" },
  1096. { UWAXES, "uwAxes" },
  1097. // BB Variables
  1098. { NPV, "npv(" },
  1099. { IRR, "irr(" },
  1100. { BAL, "bal(" },
  1101. { SUMPRN, "sum_prn(" },
  1102. { SUMINT, "sum_int(" },
  1103. { TONOM, "->Nom" },
  1104. { TOEFF, "->Eff" },
  1105. { DBD, "dbd(" },
  1106. { LCM, "lcm(" },
  1107. { GCD, "gcd(" },
  1108. { RANDINT, "RandInt(" },
  1109. { RANDBIN, "RandBin(" },
  1110. { SUB, "sub(" },
  1111. { STDDEV, "StdDev(" },
  1112. { VARIANCE, "variance(" },
  1113. { INSTRING, "inString(" },
  1114. { NORMALCDF, "normalcdf(" },
  1115. { INVNORM, "invNorm(" },
  1116. { TCDF, "tcdf(" },
  1117. { XSQUCDF, "x^2cdf(" },
  1118. { FCDF, "fcdf(" },
  1119. { BINOMPDF, "binompdf(" },
  1120. { BINOMCDF, "binomcdf(" },
  1121. { POISSONPDF, "poissonpdf(" },
  1122. { POISSONCDF, "poissoncdf(" },
  1123. { GEOMETPDF, "geometpdf(" },
  1124. { GEOMETCDF, "geometcdf(" },
  1125. { NORMALPDF, "normalpdf(" },
  1126. { TPDF, "tpdf(" },
  1127. { XSQUPDF, "x^2pdf(" },
  1128. { FPDF, "fpdf(" },
  1129. { RANDNORM, "RandNorm(" },
  1130. { TVM_PMT, "tvm_pmt" },
  1131. { TVM_I_PERCENT, "tvm_i%" },
  1132. { TVM_PV, "tvm_PV" },
  1133. { TVM_N, "tvm_N" },
  1134. { TVM_FV, "tvm_FV" },
  1135. { CONJ, "conj(" },
  1136. { REAL, "real(" },
  1137. { IMAG, "imag(" },
  1138. { ANGLE, "angle(" },
  1139. { CUMSUM, "cumSum(" },
  1140. { EXPR, "expr(" },
  1141. { LENGTH, "length(" },
  1142. { DELTA_LIST, "delta_List(" },
  1143. { REF, "ref(" },
  1144. { RREF, "rref(" },
  1145. { TORECT, "->Rect" },
  1146. { TOPOLAR, "->Polar" },
  1147. { VAR_E, "[e]" }, // e by itself is impossible, and dangerous (imagine Disp "Hello"!)
  1148. { SINREG, "SinReg " },
  1149. { LOGISTIC, "Logistic " },
  1150. { LINREGTTEST, "LinRegTTest " },
  1151. { SHADENORM, "ShadeNorm(" },
  1152. { SHADE_T, "Shade_t(" },
  1153. { SHADEXSQU, "Shade_x^2(" },
  1154. { SHADEF, "ShadeF(" },
  1155. { MATRTOLIST, "Matr->list" },
  1156. { LISTTOMATR, "List->matr" },
  1157. { ZTEST, "Z-Test(" },
  1158. { TTEST, "T-Test " },
  1159. { TWO_SAMPZTEST, "2-SampZTest(" },
  1160. { ONE_PROPZTEST, "1-PropZTest(" },
  1161. { TWO_PROPZTEST, "2-PropZTest(" },
  1162. { XSQUTEST, "x^2_test(" },
  1163. { ZINTERVAL, "ZInterval" },
  1164. { TWO_SAMPZINT, "2-SampZInt(" },
  1165. { ONE_PROPZINT, "1-PropZInt(" },
  1166. { TWO_PROPZINT, "2-PropZInt(" },
  1167. { GRAPHSTYLE, "GraphStyle(" },
  1168. { TWO_SAMPTTEST, "2-SampTTest " },
  1169. { TWO_SAMPFTEST, "2-SampFTest_" },
  1170. { TINTERVAL, "TInterval " },
  1171. { TWO_SAMPTINT, "2-SampTInt " },
  1172. { SETUPEDITOR, "SetUpEditor " },
  1173. { PMT_END, "PMT_End" },
  1174. { PMT_BGN, "PMT_Bgn" },
  1175. { REAL_BB, "Real" },
  1176. { REPOWTHETAI, "re^[theta]i" },
  1177. { APLUSBI, "a+bi" },
  1178. { EXPRON, "ExprOn" },
  1179. { EXPROFF, "ExprOff" },
  1180. { CLRALLLISTS, "ClrAllLists" },
  1181. { GETCALC, "GetCalc(" },
  1182. { DELVAR, "DelVar " },
  1183. { EQUTOSTRING, "Equ->String(" },
  1184. { STRINGTOEQU, "String->Equ(" },
  1185. { CLEARENTRIES, "Clear Entries" },
  1186. { SELECT, "Select(" },
  1187. { ANOVA, "ANOVA(" },
  1188. { MODBOXPLOT, "ModBoxPlot" },
  1189. { NORMPROBPLOT, "NormProbPlot" },
  1190. };
  1191. // Replacements
  1192. // Replacements are rules that define special characters that must be replaced with a token.
  1193. struct ConvertRule Replacements[] = {
  1194. { '"', DOUBLEQUOTE },
  1195. { '\'', APOSTROPHE },
  1196. { ',', COMMA },
  1197. { '?', QUESTIONMARK },
  1198. { ' ', SPACE },
  1199. { '=', TEST_EQUAL },
  1200. { '<', TEST_LESSTHAN },
  1201. { '>', TEST_HIGHTHAN },
  1202. { '+', ADD },
  1203. { '-', SUBTRACT },
  1204. { '/', DIVIDE_SLASH },
  1205. { '*', MULTIPLY },
  1206. { '!', FACTORIAL },
  1207. { ':', COLON },
  1208. { '\n', HARD_RETURN },
  1209. { '0', NUM_0 },
  1210. { '1', NUM_1 },
  1211. { '2', NUM_2 },
  1212. { '3', NUM_3 },
  1213. { '4', NUM_4 },
  1214. { '5', NUM_5 },
  1215. { '6', NUM_6 },
  1216. { '7', NUM_7 },
  1217. { '8', NUM_8 },
  1218. { '9', NUM_9 },
  1219. { '.', PERIOD },
  1220. { '[', LEFTSBRACK },
  1221. { ']', RIGHTSBRACK },
  1222. { '{', LEFTBRACE },
  1223. { '}', RIGHTBRACE },
  1224. { '(', LEFTBRACKET },
  1225. { ')', RIGHTBRACKET },
  1226. { '&', LOGIC_AND },
  1227. { '|', LOGIC_OR },
  1228. { '~', LOGIC_XOR },
  1229. { '=', TEST_EQUAL },
  1230. { '<', TEST_LESSTHAN },
  1231. { '>', TEST_HIGHTHAN },
  1232. { '^', POWEROF },
  1233. };