Version française
Home     About     Download     Resources     Contact us    
Browse thread
ocamllex and python-style indentation
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Andrej Bauer <andrej.bauer@a...>
Subject: ocamllex and python-style indentation
My parsing powers are not sufficient to easily come up with
lexer/parser for a simple language that uses python-style indentation
and newline rules. Does anyone have such a thing lying around, written
in ocamllex/yacc or menhir? I would appreciate a peek to see how
you've dealt with it.

For example, suppose we want just a very simple fragment of Python
involving True, False, conditional statements, variables, and
assignments, such as:

if True:
    x = 3
    y = (2 +
      4 + 5)
else:
    x = 5
    if False:
        x = 8
        z = 2

How would I go about writing a lexer/parser for such a thing in ocaml?

Andrej