Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: original definition vs final language

by Lexicon (Chaplain)
on Oct 28, 2002 at 23:36 UTC ( #208636=note: print w/ replies, xml ) Need Help??


in reply to original definition vs final language

The class you're taking, known as Automata Theory at my University, is a definate precursor to the Compilers class.

We wrote a Java compiler (in Java, ha ha). We broke the problem into 4 steps: lexical analysis - turning identifies, parens, +-*/, etc... into 'tokens', syntactic analysis - turning tokens into phrases, semantic analysis - matching referents in the symbol table (making all the identifiers point to the same thing), and code generation - writing java byte code.

It turns out that (for Java, and I think most other languages) lex is context-free, while syn requires a turring machine. Perl is kinda weird though. I imagine it's context free at the lex level, but I'm not sure. We put a lot of things into our languages to keep them CF (mostly keywords, ; statement delimiters, and {} block delimiters) and Perl has no shortage of it's own: Funny Characters $@%&. I recall that 1 token lookahead in the syn phase is equivalent to N token lookahead (where N is a fixed constant), so as long as Perl's oddities (like disambiguating that $x is a scalar and $x['bob'] is an array element) cannot be arbitrarily nested beyond what a simple stack can handle.

OK, enough Perl meditation.


Comment on Re: original definition vs final language
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://208636]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (15)
As of 2015-07-02 13:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (38 votes), past polls