Answer the question
In order to leave comments, you need to log in
Lexer for highlighting language syntax given by BNF grammar?
Good day.
I wanted to implement syntax highlighting for the language using a lexer for this. The essence is simple, we find a token, we frame it with a set of symbols for a particular color. But the fact is that language tokens are described in BNF, and lex / flex work with regular expressions to write tokens. The question actually is how to build a lexer for the BNF grammar?
Answer the question
In order to leave comments, you need to log in
Are you confusing a token with a terminal/non-terminal? Because for lexical analysis and parsing into tokens, a grammar in the form of BNF is not needed. More precisely, it will be very simple - stupidly listing all the tokens.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question