Problem The lexer hack



this code multiplication of 2 variables, in case variable; written unambiguously:



alternatively, casting dereferenced value of b type a, in case typedef name; written unambiguously:



in more detail, in compiler, lexer performs 1 of earliest stages of converting source code program. scans text extract meaningful tokens, such words, numbers, , strings. parser analyzes sequences of tokens attempting match them syntax rules representing language structures, such loops , variable declarations. problem occurs here if single sequence of tokens can ambiguously match more 1 syntax rule.


this ambiguity can happen in c if lexer not distinguish between variable , typedef identifiers. example, in c expression:



the lexer may find these tokens:



the problem precisely lexical class of cannot determined without further context: parser can interpret variable multiplied b or type casting dereferenced value of b. known typedef-name: identifier problem, due name of problematic production rule.








Comments

Popular posts from this blog

The Tom Leykis Show Tom Leykis

Cosmological concepts Chinese architecture

Chinese Papercutting