Skip to content

Language Design and Theory of Computation

andychu edited this page Jan 22, 2017 · 25 revisions

Undecidable Parsing

Deciding whether to print "syntax error" shouldn't require simulating a Turing machine.

  • Parsing Bash is Undecidable
    • Bash, Perl, and Make can't be statically parsed because they interleave parsing and execution.
    • C++ can't be statically parsed because it has two Turing complete computation mechanisms -- the templates at compile times and normal code at runtime -- and parsing sits in between them.

Accidentally Turing Complete

When we control the arguments to printf(), it is possible to obtain Turing-complete computation. We show this formally in Appendix B by giving calls to printf() which create logic gates.

  • x86 MMU Fault Handling
    • trapcc -- Compute with 0 instructions on Intel!

This is a proof by construction that the Intel MMU's fault handling mechanism is Turing complete. We have constructed an assembler that translates 'Move, Branch if Zero, Decrement' instructions to C source that sets up various processor control tables. After this code has executed, the CPU computes by attempting to fault without ever executing a single instruction.

  • sendmail?

Related Issues

  • Turing completeness vs. side effects/capabilities. Both of these are design issues and shouldn't be conflated.
  • Whether there is abstraction power like functions. I think Awk was Turing complete at first, but it didn't have functions. Related lobsters thread.
Clone this wiki locally