I'm currently researching a basic syntax highlighter for preloaded files in an app.
This doesn't need to be 'live' (as in a text editor) because the file will be loaded read-only.
As I understand it from a SOTW the procedure for this is as follows :
- Scan the file placing all tokens into a bin or bins.
- Use a recursive descent algorithm with a BNF language file to verify syntax for all the tokens in the bin(s).
- Apply specified highlighting to appropriate verified tokens.
I'd like to know if anyone has done this or has knowledge of this type of thing, can comment on whether the above is the 'correct' approach or has any suggestions.
I'm also a little concerned about the scanner. I'd prefer not to brute force it but can't find reference to any algorithms or techniques on the web.
Any pointers would be appreciated.
This doesn't need to be 'live' (as in a text editor) because the file will be loaded read-only.
As I understand it from a SOTW the procedure for this is as follows :
- Scan the file placing all tokens into a bin or bins.
- Use a recursive descent algorithm with a BNF language file to verify syntax for all the tokens in the bin(s).
- Apply specified highlighting to appropriate verified tokens.
I'd like to know if anyone has done this or has knowledge of this type of thing, can comment on whether the above is the 'correct' approach or has any suggestions.
I'm also a little concerned about the scanner. I'd prefer not to brute force it but can't find reference to any algorithms or techniques on the web.
Any pointers would be appreciated.