c# - Roslyn - Change TextSpan of SyntaxToken or SyntaxNode -


Anyone to create and change any syntaxtoken or syntaxNode Is the fullspan property ?

As all sections have been closed, is irreversible and there is no accessory constructor, the only way to create a SyntaxFactory static method and to specify the location There is no surcharge for.

I am writing a scripting language which is parsed in Rosane syntax . When using Visitor Pattern to check the expression's words, I can tell the user that there was an error while mapping any nodes to a location.

Is there anyway? Thanks in advance.

No, there is no way to do this. We ensure that our syntax trees follow several main principles:

  1. The starting position of a tree is zero.
  2. The children's full spans are in order, and each
  3. The whole round of a node is equal to the sum of all children.

These core alternatives mean that any code (including the compiler) that is analyzing a tree, can work with the tree. If we have given you a way to specify the fulpain for some nodes and not to others, we will not be able to maintain these inventions and who knows what will break. We may potentially require you to specify all spans , but at that time you will try to keep yourself in control of these restrictions.

You have a few options:

  1. Using the # line command in your generated source, tell the compiler the rows of "real" code in your script file Usually, this means that before placing the user code in the file, it means that you stick to the # line before. We have functions like SyntaxTree.GetMappedLineSpan , which take a regular period and convert it into file / row / column information based on our interpretation of # line instructions.

  2. If you generate a bunch of small trees for different expressions, just keep a tree map in your paste -> start the situation in your file, And when you have to convert it to a display location, map it on it.

  3. If you generate a tree with a group of expressions, then insert Syntax Annotation in your expression that contains the status of your script file Is where the expression came from. Then, as long as you do not search for syntax annotation , you can calculate that kind of space in that way.


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -