Regular Expressions

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

Regular Expressions

lewlking
Woohoo Done.

But Ive got a Q:
I mainly used regular expressions, is this a a normal approach to solve this problem? Also I looked into Lexical Analyzers but couldn't really figure them out. (newbie programmer)

But I feel there is a gap. Shouldn't the assembler be built right from the Binary Code? - Where could I learn more about the step from Binary->Assembly?

Thanks!
Reply | Threaded
Open this post in threaded view
|

Re: Regular Expressions

cadet1620
Administrator
lewlking wrote
Woohoo Done.

But Ive got a Q:
I mainly used regular expressions, is this a a normal approach to solve this problem? Also I looked into Lexical Analyzers but couldn't really figure them out. (newbie programmer)
Regular expressions are overkill, but a useful skill for most programmers. Lex/yacc and similar are too much to learn at this level.

The grammars for the Hack tools are carefully designed to require minimal string parsing. For instance, for the assembler, after you strip whitespace and comments the first remaining character tells you which of the 3 command types you are parsing.
But I feel there is a gap. Shouldn't the assembler be built right from the Binary Code? - Where could I learn more about the step from Binary->Assembly?
Since your assembler is not running on the Hack computer, you would need to be writing binary code for your PC or Mac.

The earliest programs were indeed "assembled" by pencil and paper, but that was tedious enough that somebody wrote a program to do that job and Symbolic Assemblers were born. Once you have an assembler running on one computer, you can write a cross assembler for the next computer, followed by a native assembler for that new computer.

It is an interesting exercise to write an assembler in assembly language, and I had to do that for an Assembly Language Programming class in the late 70s; the final was to use your assembler to assemble itself!

--Mark