Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which programming languages have a regular grammar?

I'm curious about which (if any) real-world programming languages have a regular grammar (i.e. the set of all syntactically correct programs is regular).

See also this question: What programming languages are context-free?.

like image 647
Giovanni Funchal Avatar asked Apr 11 '11 12:04

Giovanni Funchal


1 Answers

Brainfuck and Whitespace and similars are certainly regular.

On the other side, any language that supports (parens) is not regular, as the automaton recognizing it would need a stack. And I don't really know many languages without (){}[] support that would do anything more than assembly.

Only real-worldy example that comes to mind and probably is regular is Forth.

like image 98
Mirek Kratochvil Avatar answered Nov 09 '22 01:11

Mirek Kratochvil