Posted 14 years ago
by David
After a long break, I've started looking into SyntaxEditor again. Reading over the past 2 days I think I understand the package a lot better now and have used the simple language sample to write a custom lexer and semantic parser.
For now I'm starting simple and managed to get things like 'var x;' and 'var x = 5;' working, which it is pretty well.
I've just a bit of confusion with my next step. The above sample parsers for NumberExpression, and I'm trying to add a BooleanExpression. I copy the NumberExpression grammar code, and change for System.Boolean with no complaints. Finally I've added a 'Boolean' token just like 'Number'.
My actual issue is how to have the 'Boolean' token generated when either 'true' or 'false' is typed. What I basically want is like a patterngroup but without using a dynamic language.
In the 'ParseIdentifier' method, the keywords list is traversed, so should I check each value for 'true' or 'false' and then return the 'Boolean' ID?
Although I can see that working, it's a little tedious as I hope to have a similar token called 'DataType' which represents values like 'int','short','long','float' etc, so checking each one is a pain.
Hopefully you can guide me to the most sensible solution.
Thanks.
For now I'm starting simple and managed to get things like 'var x;' and 'var x = 5;' working, which it is pretty well.
I've just a bit of confusion with my next step. The above sample parsers for NumberExpression, and I'm trying to add a BooleanExpression. I copy the NumberExpression grammar code, and change for System.Boolean with no complaints. Finally I've added a 'Boolean' token just like 'Number'.
My actual issue is how to have the 'Boolean' token generated when either 'true' or 'false' is typed. What I basically want is like a patterngroup but without using a dynamic language.
In the 'ParseIdentifier' method, the keywords list is traversed, so should I check each value for 'true' or 'false' and then return the 'Boolean' ID?
Although I can see that working, it's a little tedious as I hope to have a similar token called 'DataType' which represents values like 'int','short','long','float' etc, so checking each one is a pain.
Hopefully you can guide me to the most sensible solution.
Thanks.