Re: Indenting vs begin/end (Itai Nahshon)
Fri, 14 Jul 1995 18:59:20 GMT

          From comp.compilers

Related articles
Indenting vs begin/end (1995-07-06)
Re: Indenting vs begin/end (Ronald F. Guilmette) (1995-07-11)
Re: Indenting vs begin/end (Jens Peter Secher) (1995-07-12)
Re: Indenting vs begin/end (Charles Fiterman) (1995-07-17)
Re: Indenting vs begin/end (1995-07-14)
| List of all articles for this month |

Newsgroups: comp.compilers
From: (Itai Nahshon)
Keywords: syntax, design
Organization: IBM Israel Science and Technology, Haifa, Israel
References: 95-07-062
Date: Fri, 14 Jul 1995 18:59:20 GMT (M.M._van_der_Laan) writes:
>I am designing a language where end-of-line means end-of-statement
>and where indenting is used instead of begin-end. While this saves
>a lot of typing and prevents the programmer from errors, there are
>a lot of people against it (see 'the semicolon habit' and other
>articles). I can think of two extensions to the language to
>overcome their problems:

As a student's project I have one implemented a preprocessor for
OCCAM. If I recall it right, OCAAM uses indentation as structure
directive and EOL and a statement terminator.

Surprisingly, implementation using lex and yacc was easy. Lex
emitted BEGIN and END tokens when it has seen a change in the
indentation, and a EOL token on end of line. It auto-compensated for
different indentation styles (It still had to know what's the
tab-stop used in your editor). I had to keep a stack of indentation
levels because lex had to generate more than one END statement when
leaving a nested compound statement.

It also knew about continuation lines when a statement did not finish
in one line (for example, when the last token seen before the end of
line is a binary operator).

Well, Writing a parser for that language is one thing. Using it is
another. Personally I like the "semicolon style" languages better.

Itai Nahshon

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.