Enums, and other stuff

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Enums, and other stuff

DiamondCoder1000
So ive been working on crafting interpreters, the book, and the book used lots of data types that aren't in jack, like enums. is there like some class code(jack please) that can be used to simulate making enums? just asking. I know the jack STL repo on github, but that only covers hash tables, matrices... So you know...

(P.S Sorry for the bad grammer im just a dumb kid who got interested in CS lol)
Reply | Threaded
Open this post in threaded view
|

Re: Enums, and other stuff

DiamondCoder1000
And on the subject of Crafting Interpreters, does anyone have tips for the book? im working on an OS in jack thats more sophisticated and i wanted Lox to be one of the programs.
Reply | Threaded
Open this post in threaded view
|

Re: Enums, and other stuff

WBahn
Administrator
Are you trying to write a Jack interpreter that is written in Jack that will run on the Hack?

If so, that is a very tall order, not the least because the Hack platform lacks things that would be pretty important, such as any semblance of a file system.

You could, in principle, write an interpreter that let the user enter code at the terminal and then run that code. That's the way a lot of early microcomputers worked. They commonly had a BASIC interpreter in ROM that served as the OS. You created a program line by line and had the ability to save it to some kind of storage (tape or disk) and could load it later. But my school had some that didn't have that ability and so every time you wanted to run a program you had to type it in from scratch (these were machines that were given to the school because their tape drives (or the associated hardware in the computer) had failed. Since most of the programs were a dozen or so lines long (initial part of the "computer math" course), this wasn't horrible and it actually forced students to gain familiarity with the code details much more quickly.

Most of these machines had 4 KB of RAM. The ROM OS may have been larger, but who knows.

The CPUs (typically 6502 or z80 or something comparable) had significantly more capable instruction sets than the Hack, but not out-of-the-world more capable. So I don't think it is completely unreasonable to do something similar on the Hack.

However, hoping to write the interpreter in Jack may well be going a bridge too far. Even with a very well written compiler and virtual machine translator, getting the code tight enough to run in the amount of ROM available may be biting off too much. I believe all of the OSs and interpreters in those early days (at least for those machines) were written in assembly language. If they weren't, there were almost certainly written in C or a comparable language and compiled on a different computer with very carefully written code that was specifically designed to leverage the compiler's implementation patterns, which were in turn specifically designed for the target processor.
Reply | Threaded
Open this post in threaded view
|

Re: Enums, and other stuff

DiamondCoder1000
so i'm trying to write a Lox interpreter(from the book) but it requires java features like enums and hash tables (I already got the hash table down). So i want to know if there is like a class( Like the standard Array, String, List...) that implements these.
Reply | Threaded
Open this post in threaded view
|

Re: Enums, and other stuff

DiamondCoder1000
In reply to this post by WBahn
also i got an fs working
it runs on an enhanced hack platform with a more rich and diverse assembly language and more RAM
+ more I/O Devices (like in chapter 13)
also it removes the built in ROM (So like external ROM chips instead) and has a simulated "disk" that takes up about 1 MB of memory. It's still 16 bit so it accomplishes this with bank-switching.
Reply | Threaded
Open this post in threaded view
|

Re: Enums, and other stuff

Lozminda
I'd just like to say fair play, sounds cool, though I can't answer your question directly..