Re: port I/O abstraction macros



Tom Lucas wrote:
I see little point in graduating knowing how to write a compiler or design
an FM radio unless you are directly going into Sony's Radio Compiler
division. Knowing what a compiler does and the sort of tricks current
optimisers play will be more useful in the real world than knowing how to
parse an arithmetic expression. Similarly knowing about RF, demodulation and
amplifiers is more useful to the real world than an rudimentary FM radio
kit.

There seems to be a bit of a contradiction here. You seem to be saying
that shallow practice is not good (FM kit), but you also seem to be
saying that basic theory (being able to parse arithmetic expressions)
is not good either.

A person cannot design an FM radio without understanding many aspects
of electronic theory. In the case I was speaking of, the electronics
course gives a bag of components, and a lot of theory. You're expected
to make everything, including the amplifiers, filters, phase-lock loop
(from a pre-packaged VCO), etc. Anyone who had not been paying
attention to the theory would simply not be able to make the radio.
The same course (or the next one) introduces Kalman filtering. It's
not a connect-the-dots type project.

For the compiler, I think it is very important to be able to parse
arithmetic expressions. Knowledge of automata theory can be
invaluable. For my current job, I recently had to make a small
compiler for a stack machine. Here's the tokenizer for lexical
analysis:

bool next_token (Token &token)
{
// Advance past any white space that might be present:
while (isspace(operator[](index)))
++index;

// If we encounter the end of the string after consuming white
space, there are no more tokens to read.
if (operator[](index) == 0)
return false;

switch (operator[](index))
{
case '(' :
token.type = Token::TYPE_LEFT_PARENTHESIS;
token.offset = index++;
token.length = 1;
break;

case ')' :
token.type = Token::TYPE_RIGHT_PARENTHESIS;
token.offset = index++;
token.length = 1;
break;

case '!' :
token.type = Token::TYPE_OPERATOR_NOT;
token.offset = index++;
token.length = 1;
break;

And simple piece of compiler:

case Token::TYPE_PREDICATE :
if (typename
Infectable::predicate_functions.locate(operator ()(token.offset,
token.length)))
instructions.suffix (Instruction(typename
Object::predicate_functions.RHE()));
else
instructions.suffix(Instruction(0)); // DEFECT: Need to
figure out semantics of not finding the predicate.
break;

I have no clue about optimization, but what I needed to know to make
this compiler can be found in the first few chapters of any compiler
book. Self-reliance is achieved by focusing on a small bit and
learning that well, than reading the whole book casually and not
remembering anything. I started dong this long ago after a
converstation I had with a professor just before my graduation. I
asked, "There is so much to learn in the world...is it better to hurry
up and grab what you can and depend on other people for deep insight or
is it bet..." he finished my sentenced quickly and said, "It's better
for you to know." I asked, "But does one person have time in his life
to...?" he says, "Yes." I asked, "Are you sure?" he said, "Yes."

-Le Chaud Lapin-

.



Relevant Pages

  • Re: HLA StdLib2 criticism
    ... But nevertheless it can't be called a C compiler. ... if you add pictures support to a radio, ... Commercial TV audio is FM and video is AM. ... (an HLL is a language, not a compiler for a language). ...
    (alt.lang.asm)
  • Re: port I/O abstraction macros
    ... Radio Compiler division. ... real world than knowing how to parse an arithmetic expression. ... they need is to build some sort of primitive lexer. ...
    (comp.arch.embedded)
  • Re: port I/O abstraction macros
    ... an FM radio unless you are directly going into Sony's Radio Compiler ... Knowing what a compiler does and the sort of tricks current ... saying that basic theory (being able to parse arithmetic expressions) ...
    (comp.arch.embedded)
  • Re: port I/O abstraction macros
    ... without knowing how to write a compiler, ... get a B.S.C.S without knowing how to design an FM radio. ... an FM radio unless you are directly going into Sony's Radio Compiler ...
    (comp.arch.embedded)
  • Re: If you got to choose the syntax, what would you do?
    ... pretty common these days, so I should put in a few thoughts. ... You can execute the stream serially, but there has to be some local storage to hold the largest loop sequence. ... Anyway, you end up with a few predefined tokens for kernel words, ... execute tokens from the outside world, or put a Forth compiler in there ...
    (comp.lang.forth)