How is Finite Automation Linked to Lexical Analyser

54 Views Asked by At

I understand that Finite Automaton is a Mathematical model of a system with discrete number of input and outputs. Also the system has finite number of states.My question is how is this linked with Lexical Analyser. Can some one explain in Layman's terms

1

There are 1 best solutions below

0
On

Well, I think this is not the best site to ask this question (Stackoverflow is may be a better one) but here is a short answer. For example in the C programming language a valid variable name should satisfy the following condition:

Variable names in C are made up of letters (upper and lower case) and digits. The underscore character ("_") is also permitted.Names must not begin with a digit.

You can make a finite automaton that accepts strings based on this condition and check which of the tokens in the source code can be valid variable names. This is part of lexical analysis.