automata - Does a language compiler use a complex DFA to accept programs? -


i reading on theory of computation. , have no practical experience of programming compiler.

so occurred me, c or java compiler use huge dfa validate program (string in toc parlance)?

are compilers practical implementations of dfa?

some compilers do, others don't. use dfas typically use scanner-generators lex/flex build dfa.

of course, dfa take far (up regular language, in fact). no practical programming languages can described regular expression, since regular expressions cannot handle recursive structures parenthesized expressions or nested control-flow blocks. dfa, if any, used break input sequence of tokens. tokens parsed kind of pushdown automaton, or recursive descent parser, or pure black magic on part of coder. again, pda (if any) may generated automatically, using tool bison, antlr, , many others.

it's rare find language pure enough simple two-phase dfa scan / pda parse correctly create parse tree. there seems temptation add syntactic construct can parsed using turing-complete formalism. in practical compilers, there places potentially elegant theoretical model has small holes drilled spaghetti threaded through them.

despite that, theoretical study of parsing techniques has simplified compiler construction considerably on years, being beautiful , intriguing corner of mathematics.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -