Take the 2-minute tour ×
Programming Puzzles & Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. It's 100% free, no registration required.

The Challenge

Write the shortest possible program that demonstrates a programming language's entire syntax: statements, expressions, operators, reserved words, etc.

Take the language's grammar (usually in EBNF) and create a program that uses all of it.

The program doesn't have to do anything particularly useful, but if it does that's a bonus :)


  • You must use all of the language's syntax: every type of statement, expression, operator, keyword, etc the language defines.
  • It must be able to be run with no dependencies, except for the standard library included with the language (it doesn't need to use the entire standard lib though).
  • Include a link to the language spec you used (e.g. here is the Python 2.7 grammar).
share|improve this question
I think the Turing Tarpit entries below demonstrate pretty clearly what a fuzzy idea "complete syntax" is. I'm not sure that this is going anywhere. –  dmckee Mar 13 '12 at 14:05
Here's one on c#: blogs.msdn.com/b/kirillosenkov/archive/2010/05/11/… Very very long because the specification is very big. It also tests things like very long identifiers, which the spec says it needs to handle. Meant to be a stress test for the parse. –  CMP Mar 13 '12 at 19:46
@dmckee I had a feeling it was going to go that way. Any suggestions on how it could be less fuzzy? –  calebbrown Mar 13 '12 at 21:36
Not really. Minimal languages are minimal. A nop program written for a oisc would be three words. Define the machine word as a octet and you have a tree byte program, though the machine won't be capable of much. –  dmckee Mar 13 '12 at 22:26

6 Answers 6

SK combinator calculus (4 chars)



E ::= K | S | (E) | EE |
share|improve this answer



with the syntax being:

S=> '.'S|','S|'>'S|'<'S|'-'S|'+'S|'['S']'S|emptyStr
share|improve this answer

HQ9+ (4 chars)


It will print Hello World, then Quine, then 99 bottles of beer on the wall and then increment accumulator.

share|improve this answer

Lambda calculus (9 chars)

λx. (x y)


E ::= Letter | (E E) | 'λ' Letter '. ' E
Letter ::= 'a' | 'b' | ... | 'z'

Looks how much more verbose than SK this is!

share|improve this answer

Unary 1


With the syntax being

P => 0+

(syntax is technically more complicated, but I'm too lazy to figure out binary to unary conversion as an EBNF)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.