help-bison
[Top][All Lists]
Advanced

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

Re: Using bison without Flex


From: Hans Aberg
Subject: Re: Using bison without Flex
Date: Thu, 23 Apr 2015 23:15:54 +0200

> On 23 Apr 2015, at 16:34, brahim sahbi <address@hidden> wrote:

> can we use bison without flex by describing grammatical
> rules for tokens(like number <- list_of_digits).

A lexer like generated by Flex scans forward to find the longest match which 
may require significant lookahead. A Bison generated parser just looks ahead at 
most one token.

So in theory yes, but in practise not really.

> Can it recognize a language's keywords and prohibit an identifier to be a
> keyword?

You can hardcode keywords. Otherwise, one typically has an identifier lookup 
table, for environments a stacked table, which the lexer checks and returns the 
correct token value. This way, one can have keywords depending on context as 
well.





reply via email to

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