> On 23 Apr 2015, at 16:34, brahim sahbi <brahim.sa...@gmail.com> 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.



_______________________________________________
help-bison@gnu.org https://lists.gnu.org/mailman/listinfo/help-bison

Reply via email to