Scope of Child State

SyntaxEditor for Silverlight Forum

Posted 14 years ago by Christel
Version: 10.2.0105
Avatar
I use the Language Definition Designer to create a custom language.
The Default lexical state supports 3 child lexical states. One of the Child lexical state is a nummer with 5 digits like 01430 or 34678.
I have no idea how to describe the Scope (Start and End Pattern Group) for this State. I tried explicitly '0', then a regexp for a digit etc.
It only works, when I write it like {01430} and the start pattern is explicit '{'.
But this is not the reality.
There is a textline like
"Datum 01430 (Text)"
The part '01430' is a number and when entering, the start and end pattern should be recognized to switch the lexical state, but it didn't, and therefore ist has the wrong text highlighting and anything
else.
Could you please help me?
what is the start or end pattern group for a number?

Comments (2)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hello,

In general, it is not necessary or beneficial to use a state for a number. Usually, a number pattern group could be defined instead. For an integer number, you could use the pattern, “{Digit}+” with a lookahead of, “{NonWord}|\z”. This pattern would be in an number pattern group, and that pattern group would be placed in the default state instead of creating a child state.

Does this do what you need? If not, could you please describe the special circumstances that your language has that necessitate using a state instead so that we can best describe how to make this work?

Two examples of where states are best to be used include strings and comments, where there is a clear start and end, and the text between is interpreted completely different than if the lexer were in the default state.


Actipro Software Support

Posted 14 years ago by Christel
Avatar
Ok, that solves the problem.
I defined it as a pattern group in the default state and that worked!
No I understand the using of states better. Thanks for the clear and quick answer!
The latest build of this product (v18.1 build 0233) was released 4 years ago, which was after the last post in this thread.