Subroutine call

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

Subroutine call

NotRandom
I'm wondering what is possibly going on with this.

The subroutineCall is used in two different places, but a compileSubroutineCall function isn't in the recommended implementation.

Using it with the test xml files it adds an extra level of recursion. So I just don't increase the level in that function. The alternative would be duplicating the function to compileTerms and compilleDo.
[ The Matrix Musical for Kids ]
[ Signed ]

"As you recall, a product term is a term with either a single variable or two or more variables ANDed together, whereas, a sum term is a term with either a single variable or two or more variables ORed together. To differentiate between a term that contains any number of variables with a term that contains all of the variables used in the function, we use the words minterm and maxterm. We are not introducing new ideas here; rather, we are just introducing two new words and notations for defining what we already have learned."
- Digital Logic and Microprocessor Design with Interfacing
Reply | Threaded
Open this post in threaded view
|

Re: Subroutine call

dolomiti7
From the book:
"The need for this irregular lookahead operation occurs in the
CompilationEngine twice: when parsing a term, which happens only when
parsing an expression, and when parsing a subroutineCall. Now, an
inspection of the Jack grammar shows that subroutineCall appears in two
places only: either in a do subroutineCall statement or in a term.
With that in mind, we propose parsing do subroutineCall statements as if
their syntax were do expression. This pragmatic recommendation obviates
the need to write the irregular lookahead code twice. It also implies that the
parsing of subroutineCall can now be handled directly by the compileTerm
routine. In short, we’ve localized the need to write the irregular token
lookahead code to one routine only, compileTerm, and we’ve eliminated the
need for a compileSubroutineCall routine."

This can be implemented differently though.
Reply | Threaded
Open this post in threaded view
|

Re: Subroutine call

NotRandom
Thanks. I really need to get the book, it would be awesome to have.
[ The Matrix Musical for Kids ]
[ Signed ]

"As you recall, a product term is a term with either a single variable or two or more variables ANDed together, whereas, a sum term is a term with either a single variable or two or more variables ORed together. To differentiate between a term that contains any number of variables with a term that contains all of the variables used in the function, we use the words minterm and maxterm. We are not introducing new ideas here; rather, we are just introducing two new words and notations for defining what we already have learned."
- Digital Logic and Microprocessor Design with Interfacing