help-flex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Flex recognition of "split" keywords


From: John R Levine
Subject: Re: Flex recognition of "split" keywords
Date: 20 Jul 2003 10:55:36 -0400

> The idea of prescan falls into a general pattern: One usually uses a lexer
> and a scanner, which from the formal point of view are both parsing
> grammars. They are hooked up in a pipe so that the sentences of the lexer
> language become the words of the parser language. The prescan hooks up
> another language parse before the lexer, and its sentences becomes the
> words of the lexer language.

Sounds useful for many things, but still not really enough for Fortran.

> Any other Fortran quirks coming to your mind?

Many.  The unusual problem with Fortran is that the token boundaries are
context dependent.

        assign 10 to foo        // four tokens, "to" is a reserved word
                                // only in this case
        assign 10 to foo = 1    // three tokens

        a = 10 e2               // 10e6 is a number

        do 10 e2 = 1,10 e3      // 10 is a statement number, e6 is
                                // a name, 10e3 is a number

        c(3,3) = (4,4)          // (3,3) is a subscript expression
                                // (4,4) is a complex constant

        c(3,3,3) = (4,4,4)      // (3,3,3) is a subscript expression
                                // (4,4,4) is an error


I remember that when I wrote INfort (one of the first f77 compilers,
contemporary with f77) I had at least 12 different lexer kludges, but I
don't remember now, 25 years later, what they all were.

Regards,
John Levine, address@hidden, Primary Perpetrator of "The Internet for Dummies",
Information Superhighwayman wanna-be, http://iecc.com/johnl, Sewer Commissioner
"I dropped the toothpaste", said Tom, crestfallenly.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]