tokens.cpp 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292
  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[200];
  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 TOSTRING 0xEF
  341. #define POWEROF 0xF0
  342. #define XTHROOT 0xF1
  343. #define VARSTATS_1 0xF2
  344. #define VARSTATS_2 0xF3
  345. #define LINREG1 0xF4
  346. #define EXPREG 0xF5
  347. #define LNREG 0xF6
  348. #define PWRREG 0xF7
  349. #define MEDMED 0xF8
  350. #define QUADREG 0xF9
  351. #define CLRLIST 0xFA
  352. #define CLRTABLE 0xFB
  353. #define HISTOGRAM 0xFC
  354. #define XYLINE 0xFD
  355. #define SCATTER 0xFE
  356. #define LINREG2 0xFF
  357. /** SYSTEM VARIABLES **/
  358. // Matrices
  359. #define MAT_A 0x005C
  360. #define MAT_B 0x015C
  361. #define MAT_C 0x025C
  362. #define MAT_D 0x035C
  363. #define MAT_E 0x045C
  364. #define MAT_F 0x055C
  365. #define MAT_G 0x065C
  366. #define MAT_H 0x075C
  367. #define MAT_I 0x085C
  368. #define MAT_J 0x095C
  369. // Lists
  370. #define L1 0x005D
  371. #define L2 0x015D
  372. #define L3 0x025D
  373. #define L4 0x035D
  374. #define L5 0x045D
  375. #define L6 0x055D
  376. #define L7 0x065D
  377. #define L8 0x075D
  378. #define L9 0x085D
  379. #define L0 0x095D
  380. // Graph (function)
  381. #define Y1 0x105E
  382. #define Y2 0x115E
  383. #define Y3 0x125E
  384. #define Y4 0x135E
  385. #define Y5 0x145E
  386. #define Y6 0x155E
  387. #define Y7 0x165E
  388. #define Y8 0x175E
  389. #define Y9 0x185E
  390. #define Y0 0x195E
  391. // Graph (parametric)
  392. #define X1T 0x205E
  393. #define Y1T 0x215E
  394. #define X2T 0x225E
  395. #define Y2T 0x235E
  396. #define X3T 0x245E
  397. #define Y3T 0x255E
  398. #define X4T 0x265E
  399. #define Y4T 0x275E
  400. #define X5T 0x285E
  401. #define Y5T 0x295E
  402. #define X6T 0x2A5E
  403. #define Y6T 0x2B5E
  404. // Graph (polar)
  405. #define R1 0x405E
  406. #define R2 0x415E
  407. #define R3 0x425E
  408. #define R4 0x435E
  409. #define R5 0x445E
  410. #define R6 0x455E
  411. #define SYSVAR_U 0x805E
  412. #define SYSVAR_V 0x815E
  413. // Pictures
  414. #define PIC1 0x0060
  415. #define PIC2 0x0160
  416. #define PIC3 0x0260
  417. #define PIC4 0x0360
  418. #define PIC5 0x0460
  419. #define PIC6 0x0560
  420. #define PIC7 0x0660
  421. #define PIC8 0x0760
  422. #define PIC9 0x0860
  423. #define PIC0 0x0960
  424. // Graph databases
  425. #define GDB1 0x0061
  426. #define GDB2 0x0161
  427. #define GDB3 0x0261
  428. #define GDB4 0x0361
  429. #define GDB5 0x0461
  430. #define GDB6 0x0561
  431. #define GDB7 0x0661
  432. #define GDB8 0x0761
  433. #define GDB9 0x0861
  434. #define GDB0 0x0961
  435. // Stat data
  436. #define REGEQ 0x0162
  437. #define STAT_N 0x0262
  438. #define MEANX 0x0362
  439. #define SUMX 0x0462
  440. #define SUMXSQUARED 0x0562
  441. #define SX 0x0662
  442. #define SIGMAX 0x0762
  443. #define MINX 0x0862
  444. #define MAXX 0x0962
  445. #define MINY 0x0A62
  446. #define MAXY 0x0B02
  447. #define MEANY 0x0C62
  448. #define SUMY 0x0D62
  449. #define SUMYSQUARED 0x0E62
  450. #define SY 0x0F62
  451. #define SIGMAY 0x1062
  452. #define SUMXY 0x1162
  453. #define SYSVAR_R 0x1262
  454. #define MED 0x1362
  455. #define Q1 0x1462
  456. #define Q3 0x1562
  457. #define SYSVAR_A 0x1662
  458. #define SYSVAR_B 0x1762
  459. #define SYSVAR_C 0x1862
  460. #define SYSVAR_D 0x1962
  461. #define SYSVAR_E 0x1A62
  462. #define X1 0x1B62
  463. #define X2 0x1C62
  464. #define X3 0x1D62
  465. #define Y1_1 0x1E62
  466. #define Y2_1 0x1F62
  467. #define Y3_1 0x2062
  468. #define SYSVAR_N 0x2162
  469. #define SYSVAR_P 0x2262
  470. #define SYSVAR_Z 0x2362
  471. #define SYSVAR_T 0x2462
  472. #define CHISQUARED 0x2562
  473. #define FIN 0x2662
  474. #define DF 0x2762
  475. #define PHAT 0x2862
  476. #define PHAT1 0x2962
  477. #define PHAT2 0x2A62
  478. #define MEANX1 0x2B62
  479. #define SX1 0x2C62
  480. #define N1 0x2D62
  481. #define MEANX2 0x2E62
  482. #define SX2 0x2F62
  483. #define N2 0x3062
  484. #define SXP 0x3162
  485. #define LOWER 0x3262
  486. #define UPPER 0x3362
  487. #define SYSVAR_S 0x3462
  488. #define RSQUARED 0x3562
  489. #define CAPRSQUARED 0x3662
  490. #define DF2 0x3762 // not sure about this one
  491. #define SS 0x3862
  492. #define MS 0x3962
  493. #define DF3 0x3A62 // again here?
  494. #define SS1 0x3B62 // another double
  495. #define MS1 0x3C62 // " "
  496. // Graph data
  497. #define ZXSCL 0x0063
  498. #define ZYSCL 0x0163
  499. #define XSCL 0x0263
  500. #define YSCL 0x0363
  501. #define UNSTART 0x0463
  502. #define VNSTART 0x0563
  503. #define UNINVERSE 0x0663
  504. #define VNINVERSE 0x0763
  505. #define ZUNSTART 0x0863
  506. #define ZVNSTART 0x0963
  507. #define XMIN 0x0A63
  508. #define XMAX 0x0B63
  509. #define YMIN 0x0C63
  510. #define YMAX 0x0D63
  511. #define TMIN 0x0E63
  512. #define TMAX 0x0F63
  513. #define THETAMIN 0x1063
  514. #define THETAMAX 0x1163
  515. #define ZXMIN 0x1263
  516. #define ZXMAX 0x1363
  517. #define ZYMIN 0x1463
  518. #define ZYMAX 0x1563
  519. #define ZTHETAMIN 0x1663
  520. #define ZTHETAMAX 0x1763
  521. #define ZTMIN 0x1863
  522. #define ZTMAX 0x1963
  523. #define TBLMIN 0x1A63
  524. #define NMIN 0x1B63
  525. #define ZNMIN 0x1C63
  526. #define NMAX 0x1D63
  527. #define ZNMAX 0x1E63
  528. #define NSTART 0x1F63
  529. #define ZNSTART 0x2063
  530. #define DELTATABLE 0x2163
  531. #define TSTEP 0x2263
  532. #define THETASTEP 0x2363
  533. #define ZTSTEP 0x2463
  534. #define ZTHETASTEP 0x2563
  535. #define DELTAX 0x2663
  536. #define DELTAY 0x2763
  537. #define XFACT 0x2863
  538. #define YFACT 0x2963
  539. #define TBLINPUT 0x2A63
  540. #define SYSVAR_CAPN 0x2B63
  541. #define IPERCENT 0x2C63
  542. #define PV 0x2D63
  543. #define PMT 0x2E63
  544. #define FV 0x2F63
  545. #define XRES 0x3063
  546. #define ZXRES 0x3163
  547. // Strings
  548. #define STR1 0x00AA
  549. #define STR2 0x01AA
  550. #define STR3 0x02AA
  551. #define STR4 0x03AA
  552. #define STR5 0x04AA
  553. #define STR6 0x05AA
  554. #define STR7 0x06AA
  555. #define STR8 0x07AA
  556. #define STR9 0x08AA
  557. #define STR0 0x09AA
  558. /** 7E VARIABLES **/
  559. #define SEQUENTIAL_7E 0x007E
  560. #define SIMUL 0x017E
  561. #define POLARGC 0x027E
  562. #define RECTGC 0x037E
  563. #define COORDON 0x047E
  564. #define COORDOFF 0x057E
  565. #define CONNECTED 0x067E
  566. #define DOT_7E 0x077E
  567. #define AXESON 0x087E
  568. #define AXESOFF 0x097E
  569. #define GRIDON 0x0A7E
  570. #define GRIDOFF 0x0B7E
  571. #define LABELON 0x0C7E
  572. #define LABELOFF 0x0D7E
  573. #define WEB 0x0E7E
  574. #define TIME 0x0F7E
  575. #define UVAXES 0x107E
  576. #define VWAXES 0x117E
  577. #define UWAXES 0x127E
  578. /** BB VARIABLES **/
  579. #define NPV 0x00BB
  580. #define IRR 0x01BB
  581. #define BAL 0x02BB
  582. #define SUMPRN 0x03BB
  583. #define SUMINT 0x04BB
  584. #define TONOM 0x05BB
  585. #define TOEFF 0x06BB
  586. #define DBD 0x07BB
  587. #define LCM 0x08BB
  588. #define GCD 0x09BB
  589. #define RANDINT 0x0ABB
  590. #define RANDBIN 0x0BBB
  591. #define SUB 0x0CBB
  592. #define STDDEV 0x0DBB
  593. #define VARIANCE 0x0EBB
  594. #define INSTRING 0x0FBB
  595. #define NORMALCDF 0x10BB
  596. #define INVNORM 0x11BB
  597. #define TCDF 0x12BB
  598. #define XSQUCDF 0x13BB
  599. #define FCDF 0x14BB
  600. #define BINOMPDF 0x15BB
  601. #define BINOMCDF 0x16BB
  602. #define POISSONPDF 0x17BB
  603. #define POISSONCDF 0x18BB
  604. #define GEOMETPDF 0x19BB
  605. #define GEOMETCDF 0x1ABB
  606. #define NORMALPDF 0x1BBB
  607. #define TPDF 0x1CBB
  608. #define XSQUPDF 0x1DBB
  609. #define FPDF 0x1EBB
  610. #define RANDNORM 0x1FBB
  611. #define TVM_PMT 0x20BB
  612. #define TVM_I_PERCENT 0x21BB
  613. #define TVM_PV 0x22BB
  614. #define TVM_N 0x23BB
  615. #define TVM_FV 0x24BB
  616. #define CONJ 0x25BB
  617. #define REAL 0x26BB
  618. #define IMAG 0x27BB
  619. #define ANGLE 0x28BB
  620. #define CUMSUM 0x29BB
  621. #define EXPR 0x2ABB
  622. #define LENGTH 0x2BBB
  623. #define DELTA_LIST 0x2CBB
  624. #define REF 0x2DBB
  625. #define RREF 0x2EBB
  626. #define TORECT 0x2FBB
  627. #define TOPOLAR 0x30BB
  628. #define VAR_E 0x31BB
  629. #define SINREG 0x32BB
  630. #define LOGISTIC 0x33BB
  631. #define LINREGTTEST 0x34BB
  632. #define SHADENORM 0x35BB
  633. #define SHADE_T 0x36BB
  634. #define SHADEXSQU 0x37BB
  635. #define SHADEF 0x38BB
  636. #define MATRTOLIST 0x39BB
  637. #define LISTTOMATR 0x3ABB
  638. #define ZTEST 0x3BBB
  639. #define TTEST 0x3CBB
  640. #define TWO_SAMPZTEST 0x3DBB
  641. #define ONE_PROPZTEST 0x3EBB
  642. #define TWO_PROPZTEST 0x3FBB
  643. #define XSQUTEST 0x40BB
  644. #define ZINTERVAL 0x41BB
  645. #define TWO_SAMPZINT 0x42BB
  646. #define ONE_PROPZINT 0x43BB
  647. #define TWO_PROPZINT 0x44BB
  648. #define GRAPHSTYLE 0x45BB
  649. #define TWO_SAMPTTEST 0x46BB
  650. #define TWO_SAMPFTEST 0x47BB
  651. #define TINTERVAL 0x48BB
  652. #define TWO_SAMPTINT 0x49BB
  653. #define SETUPEDITOR 0x4ABB
  654. #define PMT_END 0x4BBB
  655. #define PMT_BGN 0x4CBB
  656. #define REAL_BB 0x4DBB
  657. #define REPOWTHETAI 0x4EBB
  658. #define APLUSBI 0x4FBB
  659. #define EXPRON 0x50BB
  660. #define EXPROFF 0x51BB
  661. #define CLRALLLISTS 0x52BB
  662. #define GETCALC 0x53BB
  663. #define DELVAR 0x54BB
  664. #define EQUTOSTRING 0x55BB
  665. #define STRINGTOEQU 0x56BB
  666. #define CLEARENTRIES 0x57BB
  667. #define SELECT 0x58BB
  668. #define ANOVA 0x59BB
  669. #define MODBOXPLOT 0x5ABB
  670. #define NORMPROBPLOT 0x5BBB
  671. // Standard Tokens are any token that can be used anywhere in the line.
  672. struct Token StandardTokens[] = {
  673. /** CONTROL page of PROGRAM EDITOR (press PRGM when EDITING a program) **/
  674. { LOGIC_IF, "If " },
  675. { LOGIC_THEN, "Then" },
  676. { LOGIC_ELSE, "Else" },
  677. { CTL_FOR, "For(" },
  678. { CTL_WHILE, "While " },
  679. { CTL_REPEAT, "Repeat " },
  680. { CTL_END, "End" },
  681. { CTL_PAUSE, "Pause " },
  682. { CTL_PAUSE, "Pause" }, // note the space above
  683. { LABEL, "Lbl " },
  684. { CTL_GOTO, "Goto " },
  685. { INCSKIPIFHIGH, "IS>(" },
  686. { DECSKIPIFLOW, "DS<(" },
  687. { MENU, "Menu(" },
  688. { PROGRAM, "prgm" },
  689. { CTL_RETURN, "Return" },
  690. { CTL_STOP, "Stop" },
  691. /** I/O page **/
  692. { INPUT, "Input " },
  693. { PROMPT, "Prompt " },
  694. { DISP, "Disp " },
  695. { DISPGRAPH, "DispGraph" },
  696. { DISPTABLE, "DispTable" },
  697. { OUTPUT, "Output(" },
  698. { GETKEY, "getKey" },
  699. { CLRHOME, "ClrHome" },
  700. { CLRTABLE, "ClrTable" },
  701. { TOSTRING, "toString(" },
  702. /** GetCalc **/
  703. { GET, "Get(" },
  704. { SEND, "Send(" },
  705. /** Plots **/
  706. { PLOTSON, "PlotsOn " },
  707. { PLOTSOFF, "PlotsOff " },
  708. /** Others **/
  709. { TRACE, "Trace" },
  710. { ZSTANDARD, "ZStandard" },
  711. { ZTRIG, "ZTrig" },
  712. { ZBOX, "ZBox" },
  713. { ZOOMIN, "ZoomIn" },
  714. { ZOOMOUT, "ZoomOut" },
  715. { ZSQUARE, "ZSquare" },
  716. { ZINTEGER, "ZInteger" },
  717. { ZPREVIOUS, "ZPrevious" },
  718. { ZDECIMAL, "ZDecimal" },
  719. { ZOOMSTAT, "ZoomStat" },
  720. { ZOOMRCL, "ZoomRcl" },
  721. { ZOOMSTO, "ZoomSto" },
  722. { TEXTFUNC, "Text(" },
  723. { STOREPIC, "StorePic" },
  724. { RECALLPIC, "RecallPic" },
  725. { STOREGDB, "StoreGDB" },
  726. /** OTHERS **/
  727. { TO_DMS, "->DMS" },
  728. { TO_DEC, "->DEC" },
  729. { TO_FRAC, "->FRAC" },
  730. { STORE, "->" },
  731. { BOXPLOT, "BoxPlot" },
  732. { RADIANS, "[radians]" },
  733. { DEGREES, "[degrees]" },
  734. { INVERSE, "^-1" },
  735. { SQUARE, "^2" },
  736. { TRANSPOSE, "[transpose]" },
  737. { CUBE, "^3" },
  738. { ROUND, "round(" },
  739. { PXLTEST, "pxl-Test(" },
  740. { AUGMENT, "augment(" },
  741. { ROWSWAP, "RowSwap(" },
  742. { ROWPLUS, "row+(" },
  743. { STARROW, "*row(" },
  744. { STARROWPLUS, "*row+(" },
  745. { MAX, "max(" },
  746. { MIN, "min(" },
  747. { MEDIAN, "median(" },
  748. { RANDM, "randM(" },
  749. { MEAN, "mean(" },
  750. { SOLVE, "solve(" },
  751. { SEQFUNC, "seq(" },
  752. { FNINT, "fnInt(" },
  753. { NDERIV, "NDeriv(" },
  754. { FMIN, "FMin(" },
  755. { FMAX, "FMax(" },
  756. { CUBICREG, "CubicReg " },
  757. { QUARTREG, "QuartReg " },
  758. { LOGIC_OR, " or " },
  759. { LOGIC_XOR, " xor " },
  760. { LOGIC_AND, "and" },
  761. { STR_THETA, "[theta]" },
  762. { PROGRAM, "prgm" },
  763. { RADIAN, "Radian" },
  764. { DEGREE, "Degree" },
  765. { NORMAL, "Normal" },
  766. { SCI, "Sci" },
  767. { ENG, "Eng" },
  768. { FLOAT, "Float" },
  769. { TEST_LOREQU, "<=" },
  770. { TEST_GOREQU, ">=" },
  771. { TEST_NOTEQUAL, "!=" },
  772. { ANSWER, "Ans" },
  773. { FIX, "Fix " },
  774. { HORIZ, "Horiz" },
  775. { FULL, "Full" },
  776. { FUNC, "Func" },
  777. { PARAM, "Param" },
  778. { POLAR, "Polar" },
  779. { SEQ, "Seq" },
  780. { INDPNTAUTO, "IndpntAuto" },
  781. { INDPNTASK, "IndpntAsk" },
  782. { DEPENDAUTO, "DependAuto" },
  783. { DEPENDASK, "DependAsk" },
  784. { BOX, "[box]" },
  785. { DOT, "[dot]" },
  786. { TRACE, "Trace" },
  787. { CLRDRAW, "ClrDraw" },
  788. { ZSTANDARD, "ZStandard" },
  789. { ZTRIG, "ZTrig" },
  790. { ZBOX, "ZBox" },
  791. { ZOOMIN, "Zoom In" },
  792. { ZOOMOUT, "Zoom Out" },
  793. { ZSQUARE, "ZSquare" },
  794. { ZINTEGER, "ZInteger" },
  795. { ZPREVIOUS, "ZPrevious" },
  796. { ZDECIMAL, "ZDecimal" },
  797. { ZOOMSTAT, "ZoomStat" },
  798. { ZOOMRCL, "ZoomRcl" },
  799. { PRINTSCREEN, "PrintScreen" },
  800. { ZOOMSTO, "ZoomSto" },
  801. { TEXTFUNC, "Text(" },
  802. { NPR, "nPr" },
  803. { NCR, "nCr" },
  804. { FNON, "FnOn " },
  805. { FNOFF, "FnOff " },
  806. { STOREPIC, "StorePic " },
  807. { RECALLPIC, "RecallPic " },
  808. { STOREGDB, "StoreGDB " },
  809. { RECALLGDB, "RecallGDB " },
  810. { LINE, "Line(" },
  811. { VERTICAL, "Vertical " },
  812. { PTON, "Pt-On(" },
  813. { PTOFF, "Pt-Off(" },
  814. { PTCHANGE, "Pt-Change(" },
  815. { PXLON, "Pxl-On(" },
  816. { PXLOFF, "Pxl-Off(" },
  817. { PXLCHANGE, "Pxl-Change(" },
  818. { SHADE, "Shade(" },
  819. { CIRCLE, "Circle(" },
  820. { HORIZONTAL, "Horizontal " },
  821. { TANGENT, "Tangent(" },
  822. { DRAWINV, "DrawInv " },
  823. { DRAWF, "DrawF " },
  824. { PI, "[pi]" },
  825. { GETKEY, "getKey" },
  826. { NEGATIVE, "[neg]" },
  827. { CONV_INT, "int(" },
  828. { ABS, "abs(" },
  829. { DETERMINANT, "det(" },
  830. { IDENTITY, "identity(" },
  831. { DIM, "dim(" },
  832. { SUM, "sum(" },
  833. { PROD, "prod(" },
  834. { NOT, "not(" },
  835. { IPART, "iPart(" },
  836. { FPART, "fPart(" },
  837. { SQR_ROOT, "[root]^2" },
  838. { CUBE_ROOT, "[root]^3" },
  839. { NATLOG, "ln(" },
  840. { ETOPOWER, "e^" },
  841. { LOGARITHM, "log(" },
  842. { POWER10, "10^(" },
  843. { SINE, "sin(" },
  844. { INVSIN, "asin(" },
  845. { COSINE, "cos(" },
  846. { INVCOSINE, "acos(" },
  847. { TANGENT_TRIG, "tan(" },
  848. { INVTANGENT, "atan(" },
  849. { HYP_SINE, "sinh(" },
  850. { HYP_ISINE, "asinh(" },
  851. { HYP_COSINE, "cosh(" },
  852. { HYP_ICOSINE, "acosh(" },
  853. { HYP_TANGENT, "tanh(" },
  854. { HYP_ITANGENT, "atanh(" },
  855. { LOGIC_ELSE, "Else" },
  856. { FILL, "Fill(" },
  857. { SORTA, "SortA(" },
  858. { SORTD, "SortD(" },
  859. { LIST, "[list]" },
  860. { PLOT1, "Plot1(" },
  861. { PLOT2, "Plot2(" },
  862. { PLOT3, "Plot3(" },
  863. { XTHROOT, "[root]^" },
  864. { VARSTATS_1, "1-Var Stats " },
  865. { VARSTATS_2, "2-Var Stats " },
  866. { LINREG1, "LinReg(a+bx) " },
  867. { EXPREG, "ExpReg " },
  868. { LNREG, "LnReg " },
  869. { PWRREG, "PwrReg " },
  870. { MEDMED, "Med-Med " },
  871. { QUADREG, "QuadReg " },
  872. { CLRLIST, "ClrList " },
  873. { CLRTABLE, "ClrTable" },
  874. { HISTOGRAM, "Histogram" },
  875. { XYLINE, "xyLine" },
  876. { SCATTER, "Scatter" },
  877. { LINREG2, "LinReg(ax+b) " },
  878. { RAND, "rand" },
  879. };
  880. // two-byte variables
  881. struct TwoByte CalcVars[] = {
  882. // AsmPrgm (uncompiled)
  883. { 0x6CBB, "AsmPrgm" },
  884. { 0x6DBB, "AsmPrgm" }, // this means decompilation works, but compilation won't hit this
  885. // SysVar
  886. { MAT_A, "[A]" },
  887. { MAT_B, "[B]" },
  888. { MAT_C, "[C]" },
  889. { MAT_D, "[D]" },
  890. { MAT_E, "[E]" },
  891. { MAT_F, "[F]" },
  892. { MAT_G, "[G]" },
  893. { MAT_H, "[H]" },
  894. { MAT_I, "[I]" },
  895. { MAT_J, "[J]" },
  896. { L1, "L1" },
  897. { L2, "L2" },
  898. { L3, "L3" },
  899. { L4, "L4" },
  900. { L5, "L5" },
  901. { L6, "L6" },
  902. { L7, "L7" },
  903. { L8, "L8" },
  904. { L9, "L9" },
  905. { L0, "L0" },
  906. { Y1, "Y1" },
  907. { Y2, "Y2" },
  908. { Y3, "Y3" },
  909. { Y4, "Y4" },
  910. { Y5, "Y5" },
  911. { Y6, "Y6" },
  912. { Y7, "Y7" },
  913. { Y8, "Y8" },
  914. { Y9, "Y9" },
  915. { Y0, "Y0" },
  916. { X1T, "X1T" },
  917. { Y1T, "Y1T" },
  918. { X2T, "X2T" },
  919. { Y2T, "Y2T" },
  920. { X3T, "X3T" },
  921. { Y3T, "Y3T" },
  922. { X4T, "X4T" },
  923. { Y4T, "Y4T" },
  924. { X5T, "X5T" },
  925. { Y5T, "Y5T" },
  926. { X6T, "X6T" },
  927. { Y6T, "Y6T" },
  928. { R1, "R1" },
  929. { R2, "R2" },
  930. { R3, "R3" },
  931. { R4, "R4" },
  932. { R5, "R5" },
  933. { R6, "R6" },
  934. { SYSVAR_U, "[u]" },
  935. { SYSVAR_V, "[v]" },
  936. { PIC1, "PIC1" },
  937. { PIC2, "PIC2" },
  938. { PIC3, "PIC3" },
  939. { PIC4, "PIC4" },
  940. { PIC5, "PIC5" },
  941. { PIC6, "PIC6" },
  942. { PIC7, "PIC7" },
  943. { PIC8, "PIC8" },
  944. { PIC9, "PIC9" },
  945. { PIC0, "PIC0" },
  946. { GDB1, "GDB1" },
  947. { GDB2, "GDB2" },
  948. { GDB3, "GDB3" },
  949. { GDB4, "GDB4" },
  950. { GDB5, "GDB5" },
  951. { GDB6, "GDB6" },
  952. { GDB7, "GDB7" },
  953. { GDB8, "GDB8" },
  954. { GDB9, "GDB9" },
  955. { GDB0, "GDB0" },
  956. // finally, StatVars
  957. { SX1, "Sx1" },
  958. { SX2, "Sx2" },
  959. { SXP, "Sxp" },
  960. { REGEQ, "RegEq" },
  961. { STAT_N, "[n]" },
  962. { MEANX, "mean(x)" },
  963. { SUMXSQUARED, "sum(x)^2" },
  964. { SUMX, "sum(x)" },
  965. { SX, "Sx" },
  966. { SIGMAX, "[sigma]x" },
  967. { MINX, "minX" },
  968. { MAXX, "maxX" },
  969. { MINY, "minY" },
  970. { MAXY, "maxY" },
  971. { MEANY, "mean(y)" },
  972. { SUMYSQUARED, "sum(y)^2" },
  973. { SUMY, "sum(y)" },
  974. { SY, "Sy" },
  975. { SIGMAY, "[sigma]y" },
  976. { SUMXY, "sum(xy)" },
  977. { SYSVAR_R, "[r]" },
  978. { MED, "Med" },
  979. { Q1, "Q1" },
  980. { Q3, "Q3" },
  981. { SYSVAR_A, "[a]" },
  982. { SYSVAR_B, "[b]" },
  983. { SYSVAR_C, "[c]" },
  984. { SYSVAR_D, "[d]" },
  985. { SYSVAR_E, "[stat_e]" }, // because '[e]' refers to the constant e
  986. { X1, "x1" },
  987. { X2, "x2" },
  988. { X3, "x3" },
  989. { Y1_1, "y1" },
  990. { Y2_1, "y2" },
  991. { Y3_1, "y3" },
  992. { SYSVAR_N, "[n]" }, // somebody please tell me why there are so many variations on n
  993. { SYSVAR_P, "[p]" },
  994. { SYSVAR_Z, "[z]" },
  995. { SYSVAR_T, "[t]" },
  996. { CHISQUARED, "[chi]^2" },
  997. { FIN, "[fin]" },
  998. { DF, "[df]" },
  999. { PHAT, "[p^]" },
  1000. { PHAT1, "[p^1]" },
  1001. { PHAT2, "[p^2]" },
  1002. { MEANX1, "mean(x1)" },
  1003. { N1, "[n1]" },
  1004. { MEANX2, "mean(x2)" },
  1005. { N2, "[n2]" },
  1006. { LOWER, "[lower]" },
  1007. { UPPER, "[upper]" },
  1008. { SYSVAR_S, "[s]" },
  1009. { RSQUARED, "r^2" },
  1010. { CAPRSQUARED, "R^2" },
  1011. { DF2, "[df]" }, // somebody was high when they invented the token tables
  1012. { SS, "SS" },
  1013. { DF3, "[df]" }, // see previous comment
  1014. { SS1, "SS" }, // again...
  1015. { MS1, "MS" }, // and again!
  1016. // graph data
  1017. { ZXSCL, "ZXscl" },
  1018. { ZYSCL, "ZYscl" },
  1019. { XSCL, "Xscl" },
  1020. { YSCL, "Yscl" },
  1021. { ZUNSTART, "ZUnStart" },
  1022. { ZVNSTART, "ZVnStart" },
  1023. { UNSTART, "UnStart" },
  1024. { VNSTART, "VnStart" },
  1025. { UNINVERSE, "Un-1" }, // i read a ^-1, but it's actually a -1...
  1026. { VNINVERSE, "Vn-1" }, // same as above
  1027. { ZXMIN, "ZXmin" },
  1028. { ZXMAX, "ZXmax" },
  1029. { ZYMIN, "ZYmin" },
  1030. { ZYMAX, "ZYmax" },
  1031. { ZTHETAMIN, "Ztheta_min"},
  1032. { ZTHETAMAX, "Ztheta_max"},
  1033. { ZTMIN, "ZTmin" },
  1034. { ZTMAX, "ZTmax" },
  1035. { XMIN, "Xmin" },
  1036. { XMAX, "Xmax" },
  1037. { YMIN, "Ymin" },
  1038. { YMAX, "Ymax" },
  1039. { TMIN, "Tmin" },
  1040. { TMAX, "Tmax" },
  1041. { THETAMIN, "theta_min" },
  1042. { THETAMAX, "theta_max" },
  1043. { TBLMIN, "TblMin" },
  1044. { ZNMIN, "ZnMin" },
  1045. { NMIN, "nMin" },
  1046. { ZNMAX, "ZnMax" },
  1047. { NMAX, "nMax" },
  1048. { ZNSTART, "ZnStart" },
  1049. { NSTART, "nStart" },
  1050. { DELTATABLE, "delta_Tbl" },
  1051. { ZTSTEP, "ZTstep" },
  1052. { ZTHETASTEP, "Ztheta_step"},
  1053. { TSTEP, "Tstep" },
  1054. { THETASTEP, "theta_step"},
  1055. { DELTAX, "delta_X" },
  1056. { DELTAY, "delta_Y" },
  1057. { XFACT, "XFact" },
  1058. { YFACT, "YFact" },
  1059. { TBLINPUT, "TblInput" },
  1060. // finance app
  1061. { SYSVAR_CAPN, "[N]" }, // this is the N in the Finance app
  1062. { IPERCENT, "I%" },
  1063. { PV, "PV" },
  1064. { PMT, "PMT" },
  1065. { FV, "FV" },
  1066. { ZXRES, "ZXres" },
  1067. { XRES, "Xres" },
  1068. // strings
  1069. { STR1, "STR1" },
  1070. { STR2, "STR2" },
  1071. { STR3, "STR3" },
  1072. { STR4, "STR4" },
  1073. { STR5, "STR5" },
  1074. { STR6, "STR6" },
  1075. { STR7, "STR7" },
  1076. { STR8, "STR8" },
  1077. { STR9, "STR9" },
  1078. { STR0, "STR0" },
  1079. // 7E Variables
  1080. { SEQ, "Sequential" },
  1081. { SIMUL, "Simul" },
  1082. { POLARGC, "PolarGC" },
  1083. { RECTGC, "RectGC" },
  1084. { COORDON, "CoordOn" },
  1085. { COORDOFF, "CoordOff" },
  1086. { CONNECTED, "Connected" },
  1087. { DOT_7E, "Dot" },
  1088. { AXESON, "AxesOn" },
  1089. { AXESOFF, "AxesOff" },
  1090. { GRIDON, "GridOn" },
  1091. { GRIDOFF, "GridOff" },
  1092. { LABELON, "LabelOn" },
  1093. { LABELOFF, "LabelOff" },
  1094. { WEB, "Web" },
  1095. { TIME, "Time" },
  1096. { UVAXES, "uvAxes" },
  1097. { VWAXES, "vwAxes" },
  1098. { UWAXES, "uwAxes" },
  1099. // BB Variables
  1100. { NPV, "npv(" },
  1101. { IRR, "irr(" },
  1102. { BAL, "bal(" },
  1103. { SUMPRN, "sum_prn(" },
  1104. { SUMINT, "sum_int(" },
  1105. { TONOM, "->Nom" },
  1106. { TOEFF, "->Eff" },
  1107. { DBD, "dbd(" },
  1108. { LCM, "lcm(" },
  1109. { GCD, "gcd(" },
  1110. { RANDINT, "RandInt(" },
  1111. { RANDBIN, "RandBin(" },
  1112. { SUB, "sub(" },
  1113. { STDDEV, "StdDev(" },
  1114. { VARIANCE, "variance(" },
  1115. { INSTRING, "inString(" },
  1116. { NORMALCDF, "normalcdf(" },
  1117. { INVNORM, "invNorm(" },
  1118. { TCDF, "tcdf(" },
  1119. { XSQUCDF, "x^2cdf(" },
  1120. { FCDF, "fcdf(" },
  1121. { BINOMPDF, "binompdf(" },
  1122. { BINOMCDF, "binomcdf(" },
  1123. { POISSONPDF, "poissonpdf(" },
  1124. { POISSONCDF, "poissoncdf(" },
  1125. { GEOMETPDF, "geometpdf(" },
  1126. { GEOMETCDF, "geometcdf(" },
  1127. { NORMALPDF, "normalpdf(" },
  1128. { TPDF, "tpdf(" },
  1129. { XSQUPDF, "x^2pdf(" },
  1130. { FPDF, "fpdf(" },
  1131. { RANDNORM, "RandNorm(" },
  1132. { TVM_PMT, "tvm_pmt" },
  1133. { TVM_I_PERCENT, "tvm_i%" },
  1134. { TVM_PV, "tvm_PV" },
  1135. { TVM_N, "tvm_N" },
  1136. { TVM_FV, "tvm_FV" },
  1137. { CONJ, "conj(" },
  1138. { REAL, "real(" },
  1139. { IMAG, "imag(" },
  1140. { ANGLE, "angle(" },
  1141. { CUMSUM, "cumSum(" },
  1142. { EXPR, "expr(" },
  1143. { LENGTH, "length(" },
  1144. { DELTA_LIST, "delta_List(" },
  1145. { REF, "ref(" },
  1146. { RREF, "rref(" },
  1147. { TORECT, "->Rect" },
  1148. { TOPOLAR, "->Polar" },
  1149. { VAR_E, "[e]" }, // e by itself is impossible, and dangerous (imagine Disp "Hello"!)
  1150. { SINREG, "SinReg " },
  1151. { LOGISTIC, "Logistic " },
  1152. { LINREGTTEST, "LinRegTTest " },
  1153. { SHADENORM, "ShadeNorm(" },
  1154. { SHADE_T, "Shade_t(" },
  1155. { SHADEXSQU, "Shade_x^2(" },
  1156. { SHADEF, "ShadeF(" },
  1157. { MATRTOLIST, "Matr->list" },
  1158. { LISTTOMATR, "List->matr" },
  1159. { ZTEST, "Z-Test(" },
  1160. { TTEST, "T-Test " },
  1161. { TWO_SAMPZTEST, "2-SampZTest(" },
  1162. { ONE_PROPZTEST, "1-PropZTest(" },
  1163. { TWO_PROPZTEST, "2-PropZTest(" },
  1164. { XSQUTEST, "x^2_test(" },
  1165. { ZINTERVAL, "ZInterval" },
  1166. { TWO_SAMPZINT, "2-SampZInt(" },
  1167. { ONE_PROPZINT, "1-PropZInt(" },
  1168. { TWO_PROPZINT, "2-PropZInt(" },
  1169. { GRAPHSTYLE, "GraphStyle(" },
  1170. { TWO_SAMPTTEST, "2-SampTTest " },
  1171. { TWO_SAMPFTEST, "2-SampFTest_" },
  1172. { TINTERVAL, "TInterval " },
  1173. { TWO_SAMPTINT, "2-SampTInt " },
  1174. { SETUPEDITOR, "SetUpEditor " },
  1175. { PMT_END, "PMT_End" },
  1176. { PMT_BGN, "PMT_Bgn" },
  1177. { REAL_BB, "Real" },
  1178. { REPOWTHETAI, "re^[theta]i" },
  1179. { APLUSBI, "a+bi" },
  1180. { EXPRON, "ExprOn" },
  1181. { EXPROFF, "ExprOff" },
  1182. { CLRALLLISTS, "ClrAllLists" },
  1183. { GETCALC, "GetCalc(" },
  1184. { DELVAR, "DelVar " },
  1185. { EQUTOSTRING, "Equ->String(" },
  1186. { STRINGTOEQU, "String->Equ(" },
  1187. { CLEARENTRIES, "Clear Entries" },
  1188. { SELECT, "Select(" },
  1189. { ANOVA, "ANOVA(" },
  1190. { MODBOXPLOT, "ModBoxPlot" },
  1191. { NORMPROBPLOT, "NormProbPlot" },
  1192. };
  1193. // Replacements
  1194. // Replacements are rules that define special characters that must be replaced with a token.
  1195. struct ConvertRule Replacements[] = {
  1196. { '"', DOUBLEQUOTE },
  1197. { '\'', APOSTROPHE },
  1198. { ',', COMMA },
  1199. { '?', QUESTIONMARK },
  1200. { ' ', SPACE },
  1201. { '=', TEST_EQUAL },
  1202. { '<', TEST_LESSTHAN },
  1203. { '>', TEST_HIGHTHAN },
  1204. { '+', ADD },
  1205. { '-', SUBTRACT },
  1206. { '/', DIVIDE_SLASH },
  1207. { '*', MULTIPLY },
  1208. { '!', FACTORIAL },
  1209. { ':', COLON },
  1210. { '\n', HARD_RETURN },
  1211. { '0', NUM_0 },
  1212. { '1', NUM_1 },
  1213. { '2', NUM_2 },
  1214. { '3', NUM_3 },
  1215. { '4', NUM_4 },
  1216. { '5', NUM_5 },
  1217. { '6', NUM_6 },
  1218. { '7', NUM_7 },
  1219. { '8', NUM_8 },
  1220. { '9', NUM_9 },
  1221. { '.', PERIOD },
  1222. { '[', LEFTSBRACK },
  1223. { ']', RIGHTSBRACK },
  1224. { '{', LEFTBRACE },
  1225. { '}', RIGHTBRACE },
  1226. { '(', LEFTBRACKET },
  1227. { ')', RIGHTBRACKET },
  1228. { '&', LOGIC_AND },
  1229. { '|', LOGIC_OR },
  1230. { '~', LOGIC_XOR },
  1231. { '=', TEST_EQUAL },
  1232. { '<', TEST_LESSTHAN },
  1233. { '>', TEST_HIGHTHAN },
  1234. { '^', POWEROF },
  1235. };