Skip to content

Commit d02a51f

Browse files
Many changes:
- added ACS ASN, TAN, COSH/CSH, SINH/SNH, TANH/THN functions - add INKEY$ function - added PI pseudo-function/variable - added MOD operator - added XOR operator - added ROUND function, 1-arity rounds to integer, 2-arity rounds to a given decimal point - properly implemented CLR/CLEAR to clear variables - implemented CLS for clear screen - properly cast calculated values to the underlying type, single/double/integer, on assignment - added case where string constant is "closed" by a newline, instead of a quote - updates to test.bas for some of the above
1 parent f5e5906 commit d02a51f

File tree

8 files changed

+721
-501
lines changed

8 files changed

+721
-501
lines changed

bas/test.bas

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,18 @@
5050
185 REM making a 2x2 array and then printing it out
5151
186 REM
5252
200 DIM A(2,2)
53-
300 A(1,1)=1:A(1,2)=2:A(2,1)=3:A(2,2)=4
54-
400 PRINT"Array 1 to 4: "A(1,1),A(1,2),A(2,1),A(2,2)
53+
210 A(1,1)=1:A(1,2)=2:A(2,1)=3:A(2,2)=4
54+
220 PRINT"Array 1 to 4: "A(1,1),A(1,2),A(2,1),A(2,2)
55+
300 REM
56+
305 REM test fix, int, round, etc
57+
310 REM
58+
315 PRINT "PI should return 3.14... "PI
59+
320 PRINT "INT(4.5) should return 4 "INT(4.5)
60+
325 PRINT "INT(-4.5) should return -5 "INT(-4.5)
61+
330 PRINT "FIX(-4.5) should return -4 "FIX(-4.5)
62+
335 PRINT "FRAC(-4.5) should return -0.5 "FRAC(-4.5)
63+
340 PRINT "ROUND(1.2345) should return 1 "ROUND(1.2345)
64+
345 PRINT "ROUND(1.2345,3) should return 1.235 "ROUND(1.2345,3)
5565
494 REM
5666
495 REM make a simple function that returns itself
5767
496 REM
@@ -182,6 +192,13 @@
182192
3996 REM
183193
3998 LET A=2
184194
4000 PRINT "A=2, A*10=";A*10
195+
4100 REM
196+
4110 REM testing inkey
197+
4120 REM
198+
4130 PRINT"test inkey, waiting for keypress"
199+
4140 I$=INKEY$
200+
4150 IF I$<>"" THEN PRINT "you pressed '";I$;"'"
201+
4160 IF I$<>"X" THEN 4140
185202
4400 input "an input prompt with comma, enter a number (1 to 3)",A
186203
4700 input "an input prompt with semi, enter a number";B
187204
4900 print "a is "A" b is "B
@@ -228,6 +245,12 @@
228245
5330 IF R=2 THEN EXIT
229246
5340 NEXT
230247
5350 PRINT "R is now: "R
248+
6000 REM
249+
6005 REM test CLEAR
250+
6010 REM
251+
6015 PRINT"testing CLEAR, R is currently "R
252+
6020 CLEAR
253+
6025 PRINT"after CLEARing, R is "R
231254
8000 STOP
232255
8100 REM
233256
8101 REM test label'ed gosub

src/parse.h

Lines changed: 143 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -103,68 +103,77 @@
103103
SYS = 319,
104104
VARLIST = 320,
105105
PAUSE = 321,
106-
_ABS = 322,
106+
ABS = 322,
107107
SGN = 323,
108-
ATN = 324,
109-
COS = 325,
110-
SIN = 326,
111-
TAN = 327,
112-
CLOG = 328,
113-
EXP = 329,
114-
LOG = 330,
115-
SQR = 331,
116-
RND = 332,
117-
INT = 333,
118-
FIX = 334,
119-
FRAC = 335,
120-
CINT = 336,
121-
CSNG = 337,
122-
CDBL = 338,
123-
ASC = 339,
124-
LEFT = 340,
125-
MID = 341,
126-
RIGHT = 342,
127-
LEN = 343,
128-
STR = 344,
129-
VAL = 345,
130-
CHR = 346,
131-
SEG = 347,
132-
SUBSTR = 348,
133-
INSTR = 349,
134-
AND = 350,
135-
OR = 351,
136-
NOT = 352,
137-
XOR = 353,
138-
CMP_LE = 354,
139-
CMP_GE = 355,
140-
CMP_NE = 356,
141-
CMP_HASH = 357,
142-
FRE = 358,
143-
SPC = 359,
144-
TAB = 360,
145-
POS = 361,
146-
USR = 362,
147-
LIN = 363,
148-
DEFSTR = 364,
149-
DEFINT = 365,
150-
DEFSNG = 366,
151-
DEFDBL = 367,
152-
CHANGE = 368,
153-
CONVERT = 369,
154-
UCASE = 370,
155-
LCASE = 371,
156-
STRNG = 372,
157-
TIME = 373,
158-
TIME_STR = 374,
159-
HEX = 375,
160-
OCT = 376,
161-
BIN = 377,
162-
HEXSTR = 378,
163-
OCTSTR = 379,
164-
BINSTR = 380,
165-
UBOUND = 381,
166-
LBOUND = 382,
167-
LABEL = 383
108+
CLOG = 324,
109+
EXP = 325,
110+
LOG = 326,
111+
SQR = 327,
112+
PI = 328,
113+
RND = 329,
114+
INT = 330,
115+
FIX = 331,
116+
FRAC = 332,
117+
ROUND = 333,
118+
CINT = 334,
119+
CSNG = 335,
120+
CDBL = 336,
121+
MOD = 337,
122+
COS = 338,
123+
SIN = 339,
124+
ATN = 340,
125+
ACS = 341,
126+
ASN = 342,
127+
TAN = 343,
128+
COSH = 344,
129+
SINH = 345,
130+
TANH = 346,
131+
ASC = 347,
132+
LEFT = 348,
133+
MID = 349,
134+
RIGHT = 350,
135+
LEN = 351,
136+
STR = 352,
137+
VAL = 353,
138+
CHR = 354,
139+
SEG = 355,
140+
SUBSTR = 356,
141+
INSTR = 357,
142+
INKEY = 358,
143+
AND = 359,
144+
OR = 360,
145+
NOT = 361,
146+
XOR = 362,
147+
CMP_LE = 363,
148+
CMP_GE = 364,
149+
CMP_NE = 365,
150+
CMP_HASH = 366,
151+
FRE = 367,
152+
SPC = 368,
153+
TAB = 369,
154+
POS = 370,
155+
USR = 371,
156+
LIN = 372,
157+
DEFSTR = 373,
158+
DEFINT = 374,
159+
DEFSNG = 375,
160+
DEFDBL = 376,
161+
CHANGE = 377,
162+
CONVERT = 378,
163+
UCASE = 379,
164+
LCASE = 380,
165+
STRNG = 381,
166+
TIME = 382,
167+
TIME_STR = 383,
168+
HEX = 384,
169+
OCT = 385,
170+
BIN = 386,
171+
HEXSTR = 387,
172+
OCTSTR = 388,
173+
BINSTR = 389,
174+
UBOUND = 390,
175+
LBOUND = 391,
176+
LABEL = 392
168177
};
169178
#endif
170179
/* Tokens. */
@@ -232,75 +241,84 @@
232241
#define SYS 319
233242
#define VARLIST 320
234243
#define PAUSE 321
235-
#define _ABS 322
244+
#define ABS 322
236245
#define SGN 323
237-
#define ATN 324
238-
#define COS 325
239-
#define SIN 326
240-
#define TAN 327
241-
#define CLOG 328
242-
#define EXP 329
243-
#define LOG 330
244-
#define SQR 331
245-
#define RND 332
246-
#define INT 333
247-
#define FIX 334
248-
#define FRAC 335
249-
#define CINT 336
250-
#define CSNG 337
251-
#define CDBL 338
252-
#define ASC 339
253-
#define LEFT 340
254-
#define MID 341
255-
#define RIGHT 342
256-
#define LEN 343
257-
#define STR 344
258-
#define VAL 345
259-
#define CHR 346
260-
#define SEG 347
261-
#define SUBSTR 348
262-
#define INSTR 349
263-
#define AND 350
264-
#define OR 351
265-
#define NOT 352
266-
#define XOR 353
267-
#define CMP_LE 354
268-
#define CMP_GE 355
269-
#define CMP_NE 356
270-
#define CMP_HASH 357
271-
#define FRE 358
272-
#define SPC 359
273-
#define TAB 360
274-
#define POS 361
275-
#define USR 362
276-
#define LIN 363
277-
#define DEFSTR 364
278-
#define DEFINT 365
279-
#define DEFSNG 366
280-
#define DEFDBL 367
281-
#define CHANGE 368
282-
#define CONVERT 369
283-
#define UCASE 370
284-
#define LCASE 371
285-
#define STRNG 372
286-
#define TIME 373
287-
#define TIME_STR 374
288-
#define HEX 375
289-
#define OCT 376
290-
#define BIN 377
291-
#define HEXSTR 378
292-
#define OCTSTR 379
293-
#define BINSTR 380
294-
#define UBOUND 381
295-
#define LBOUND 382
296-
#define LABEL 383
246+
#define CLOG 324
247+
#define EXP 325
248+
#define LOG 326
249+
#define SQR 327
250+
#define PI 328
251+
#define RND 329
252+
#define INT 330
253+
#define FIX 331
254+
#define FRAC 332
255+
#define ROUND 333
256+
#define CINT 334
257+
#define CSNG 335
258+
#define CDBL 336
259+
#define MOD 337
260+
#define COS 338
261+
#define SIN 339
262+
#define ATN 340
263+
#define ACS 341
264+
#define ASN 342
265+
#define TAN 343
266+
#define COSH 344
267+
#define SINH 345
268+
#define TANH 346
269+
#define ASC 347
270+
#define LEFT 348
271+
#define MID 349
272+
#define RIGHT 350
273+
#define LEN 351
274+
#define STR 352
275+
#define VAL 353
276+
#define CHR 354
277+
#define SEG 355
278+
#define SUBSTR 356
279+
#define INSTR 357
280+
#define INKEY 358
281+
#define AND 359
282+
#define OR 360
283+
#define NOT 361
284+
#define XOR 362
285+
#define CMP_LE 363
286+
#define CMP_GE 364
287+
#define CMP_NE 365
288+
#define CMP_HASH 366
289+
#define FRE 367
290+
#define SPC 368
291+
#define TAB 369
292+
#define POS 370
293+
#define USR 371
294+
#define LIN 372
295+
#define DEFSTR 373
296+
#define DEFINT 374
297+
#define DEFSNG 375
298+
#define DEFDBL 376
299+
#define CHANGE 377
300+
#define CONVERT 378
301+
#define UCASE 379
302+
#define LCASE 380
303+
#define STRNG 381
304+
#define TIME 382
305+
#define TIME_STR 383
306+
#define HEX 384
307+
#define OCT 385
308+
#define BIN 386
309+
#define HEXSTR 387
310+
#define OCTSTR 388
311+
#define BINSTR 389
312+
#define UBOUND 390
313+
#define LBOUND 391
314+
#define LABEL 392
297315

298316

299317

300318

301319
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
302320
typedef union YYSTYPE
303-
#line 72 "/Volumes/Bigger/Users/maury/Desktop/RetroBASIC/src/parse.y"
321+
#line 73 "/Volumes/Bigger/Users/maury/Desktop/RetroBASIC/src/parse.y"
304322
{
305323
double d;
306324
int i;
@@ -311,8 +329,8 @@ typedef union YYSTYPE
311329
variable_reference_t *variable;
312330
}
313331
/* Line 1529 of yacc.c. */
314-
#line 315 "/Volumes/Bigger/Users/maury/Desktop/RetroBASIC/obj/Intermediates.noindex/RetroBASIC.build/Debug/retrobasic.build/DerivedSources/y.tab.h"
315-
YYSTYPE;
332+
#line 333 "/Volumes/Bigger/Users/maury/Desktop/RetroBASIC/obj/Intermediates.noindex/RetroBASIC.build/Debug/retrobasic.build/DerivedSources/y.tab.h"
333+
YYSTYPE;
316334
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
317335
# define YYSTYPE_IS_DECLARED 1
318336
# define YYSTYPE_IS_TRIVIAL 1

0 commit comments

Comments
 (0)