Tags: droyo/APL
Tags
Some tidying. Threw in an error check for applying functions.
disp.c - changed display of empty character to '⍝' Removed some token types; braces, brackets, and semicolons are out, conforming with 'A dictionary of APL'. } and { will be operators for accessing array slots. Restructured the parser to be more robust. It now receives a start and end pointer. It creates two mstacks, one that shrinks to the left, and one that grows to the left. This parser handles nested expressions correctly. I also threw in a debug function to show the interaction between the two stacks. I'm pretty proud of it.
THE PARSER WORKS!! very exciting, i got the table-based parseing scheme from the J source code to work! All rules are firing at the right times. I will need to add a rule for array indexes (a[2], etc), and throw in recursion to parse nested expressions as well, but I made great progress.
Extended scanner to recognize dyadic operators '.', and '∘' and ddtre… …at '∘' in '∘.' as a function. Also forgot to add disp.c which contains routines for displaying arrays
Fixed segfaults and pointer typos; Scanned words are now all stored i… …n an array structure. Temporary storage is taken from a memory stack managed in scan.c. Space separated number literals are combined into a list of numbers.
Factored out the scanning code into one function for each type of tok… …en. Still not very short, but easier to modify. Threw all declarations in a header file, and changed some variable names: lex -> scan, parse -> eval, etc. The parser still just echoes the token stream.