hi to all. I want to make a lexical analyzer that basically parse a switch statement. So where to start and how can i make it?

Recommended Answers

All 2 Replies

Start with making or using a parser, then... finish with making an algorithm that analyzes.

General answer :

compiler = lexer (lexical analyser) + parser + code generator
lexer = scanner (implemented usually as FSM) + tokenizer
compile process :
source code -> lexical analysis -> parsing code tree -> generate compiled code for linking (optimize where necessary)

It seems you need both the lexer and parser; I recommend you the following links

http://en.wikipedia.org/wiki/Compiler

http://en.wikipedia.org/wiki/Lexical_analysis

I recomend you to use a compiler generator, check http://en.wikipedia.org/wiki/List_of_parser_generators

Best regards,
Loren Soth

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.