From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 4E270BC37 for ; Thu, 11 Jun 2009 14:57:13 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApgDAPubMEpKfU6WlGdsb2JhbACOQgGJPT8BAQEBCQsICRIDtjKECgU X-IronPort-AV: E=Sophos;i="4.42,202,1243807200"; d="scan'208";a="29322246" Received: from ey-out-1920.google.com ([74.125.78.150]) by mail3-smtp-sop.national.inria.fr with ESMTP; 11 Jun 2009 14:57:13 +0200 Received: by ey-out-1920.google.com with SMTP id 3so173781eyh.22 for ; Thu, 11 Jun 2009 05:57:12 -0700 (PDT) MIME-Version: 1.0 Received: by 10.216.3.206 with SMTP id 56mr897897weh.99.1244725032305; Thu, 11 Jun 2009 05:57:12 -0700 (PDT) Date: Thu, 11 Jun 2009 14:57:12 +0200 Message-ID: <7d8707de0906110557n6a1511a2k9f4f00827f954cb6@mail.gmail.com> Subject: ocamllex and python-style indentation From: Andrej Bauer To: caml-list@inria.fr Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; ocamllex:01 andrej:01 andrej:01 lexer:01 parser:01 ocamllex:01 lexer:01 parser:01 ocaml:01 parsing:01 newline:02 variables:02 python:03 indentation:04 indentation:04 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