I've been searching the internet about the Syntax highlighting of a particular file in a text editor and i read about Lexers and Yacc. i'm quite confuse about the concepts on syntax highlighting.
I've created a simple text editor using PyQt4 and i want it to enable syntax highlighting of programming languages such as HTML,CSS,Python,C/C++. But i've no clue on how to start implementing this and where to start. Please someone point me to the right direction and pliz clear my doubts on syntax highlighting. please.
You need to divide the text into lexical tokens (words, numbers, symbols, and so on), find out what each one is, and colour it accordingly. It's easy enough to recognize numbers and symbols, but to know whether a word is a variable, a function, a keyword or whatever means parsing the text according to the syntactical rules of the language. That's why your search finds references to lexical analysis (Lex) and parsing (Yacc). Lexical analysis is about assembling letters and symbols into words and other tokens, and parsing is about how those tokens go together to make up a syntactically valid program.
Python has a library module, tokenize, that does exactly what you need for the Python language. The documentation even says that it is useful for pretty-printing and colouring on-screen displays. Hopefully, using that will give you more of an idea how all this stuff works. Then you can either search for Python libraries for parsing other languages, or have a go at writing one yourself.
There's a Stack Overflow question here that suggests pyPEG for parsing other languages. Jimothy's suggests of Pygments is good too.