Posted 19 years ago
by Markus Foser
-
Developer,
PROCOS AG
I generated the Tokens and the Sematic states class with Code Smith
But somehow the the token.id isn't set to an other value than 0
Do I have to set special properties or make a special call?
The code used to test
Document document = new Document();
Stream stream = SyntaxEditorHelper.GetLanguageStream(Language.CSharp);
// load language definition of CSharp
document.LoadLanguageFromXml(stream, 0);
document.Language.TokenIDType= typeof(CSharp.Tokens);
document.Language.LexicalStateIDType = typeof(CSharp.States);
// Set programming text
document.Text = Content;
foreach (Token token in document.Tokens)
{
Debug.WriteLine(token.ID);
Always prints out 0
}
namespace Test
{
public class CSharp
{
public class Tokens
{
public const int Default = 1;
public const int Whitespace = 2;
public const int LineTerminator = 3;
public const int OpenParenthesis = 4;
public const int CloseParenthesis = 5;
public const int OpenCurlyBrace = 6;
public const int CloseCurlyBrace = 7;
public const int OpenSquareBrace = 8;
public const int CloseSquareBrace = 9;
public const int Punctuation = 10;
public const int Null = 11;
public const int NativeType = 12;
public const int Boolean = 13;
public const int ReservedWord = 14;
public const int Identifier = 15;
public const int Operator = 16;
public const int RealNumber = 17;
public const int IntegerNumber = 18;
public const int HexIntegerNumber = 19;
public const int CharacterDefault = 20;
public const int CharacterEscapedCharacter = 21;
public const int CharacterWhitespace = 22;
public const int CharacterWord = 23;
public const int CharacterStart = 24;
public const int CharacterEnd = 25;
public const int StringDefault = 26;
public const int StringEscapedCharacter = 27;
public const int StringWhitespace = 28;
public const int StringWord = 29;
public const int StringStart = 30;
public const int StringEnd = 31;
public const int VerbatimStringDefault = 32;
public const int VerbatimStringEscapedQuote = 33;
public const int VerbatimStringWhitespace = 34;
public const int VerbatimStringWord = 35;
public const int VerbatimStringStart = 36;
public const int VerbatimStringEnd = 37;
public const int CommentDefault = 38;
public const int CommentDelimiter = 39;
public const int CommentWhitespace = 40;
public const int CommentURL = 41;
public const int CommentLineTerminator = 42;
public const int CommentWord = 43;
public const int CommentStart = 44;
public const int CommentEnd = 45;
public const int MultiLineCommentDefault = 46;
public const int MultiLineCommentWhitespace = 47;
public const int MultiLineCommentLineTerminator = 48;
public const int MultiLineCommentURL = 49;
public const int MultiLineCommentWord = 50;
public const int MultiLineCommentStart = 51;
public const int MultiLineCommentEnd = 52;
public const int XMLCommentDefault = 53;
public const int XMLCommentDelimiter = 54;
public const int XMLCommentStartTag = 55;
public const int XMLCommentEndTag = 56;
public const int XMLCommentWhitespace = 57;
public const int XMLCommentLineTerminator = 58;
public const int XMLCommentURL = 59;
public const int XMLCommentWord = 60;
public const int XMLCommentStart = 61;
public const int XMLCommentEnd = 62;
public const int PreProcessorDirectiveDefault = 63;
public const int PreProcessorDirectiveWhitespace = 64;
public const int PreProcessorDirectiveWord = 65;
public const int RegionPreProcessorDirectiveStart = 66;
public const int PreProcessorDirectiveEnd = 67;
public const int EndRegionPreProcessorDirectiveStart = 68;
public const int DefinePreProcessorDirectiveStart = 69;
public const int UndefPreProcessorDirectiveStart = 70;
public const int IfPreProcessorDirectiveIfStart = 71;
public const int IfPreProcessorDirectiveElIfStart = 72;
public const int IfPreProcessorDirectiveElseStart = 73;
public const int IfPreProcessorDirectiveEndIfStart = 74;
public const int LinePreProcessorDirectiveStart = 75;
public const int WarningPreProcessorDirectiveStart = 76;
public const int ErrorPreProcessorDirectiveStart = 77;
}
public class States
{
public const int DefaultState = 1;
public const int CharacterState = 2;
public const int StringState = 3;
public const int VerbatimStringState = 4;
public const int CommentState = 5;
public const int MultiLineCommentState = 6;
public const int XMLCommentState = 7;
public const int PreProcessorDirectiveState = 8;
public const int PreProcessorDirectiveCommentState = 9;
}
}
}
But somehow the the token.id isn't set to an other value than 0
Do I have to set special properties or make a special call?
The code used to test
Document document = new Document();
Stream stream = SyntaxEditorHelper.GetLanguageStream(Language.CSharp);
// load language definition of CSharp
document.LoadLanguageFromXml(stream, 0);
document.Language.TokenIDType= typeof(CSharp.Tokens);
document.Language.LexicalStateIDType = typeof(CSharp.States);
// Set programming text
document.Text = Content;
foreach (Token token in document.Tokens)
{
Debug.WriteLine(token.ID);
Always prints out 0
}
namespace Test
{
public class CSharp
{
public class Tokens
{
public const int Default = 1;
public const int Whitespace = 2;
public const int LineTerminator = 3;
public const int OpenParenthesis = 4;
public const int CloseParenthesis = 5;
public const int OpenCurlyBrace = 6;
public const int CloseCurlyBrace = 7;
public const int OpenSquareBrace = 8;
public const int CloseSquareBrace = 9;
public const int Punctuation = 10;
public const int Null = 11;
public const int NativeType = 12;
public const int Boolean = 13;
public const int ReservedWord = 14;
public const int Identifier = 15;
public const int Operator = 16;
public const int RealNumber = 17;
public const int IntegerNumber = 18;
public const int HexIntegerNumber = 19;
public const int CharacterDefault = 20;
public const int CharacterEscapedCharacter = 21;
public const int CharacterWhitespace = 22;
public const int CharacterWord = 23;
public const int CharacterStart = 24;
public const int CharacterEnd = 25;
public const int StringDefault = 26;
public const int StringEscapedCharacter = 27;
public const int StringWhitespace = 28;
public const int StringWord = 29;
public const int StringStart = 30;
public const int StringEnd = 31;
public const int VerbatimStringDefault = 32;
public const int VerbatimStringEscapedQuote = 33;
public const int VerbatimStringWhitespace = 34;
public const int VerbatimStringWord = 35;
public const int VerbatimStringStart = 36;
public const int VerbatimStringEnd = 37;
public const int CommentDefault = 38;
public const int CommentDelimiter = 39;
public const int CommentWhitespace = 40;
public const int CommentURL = 41;
public const int CommentLineTerminator = 42;
public const int CommentWord = 43;
public const int CommentStart = 44;
public const int CommentEnd = 45;
public const int MultiLineCommentDefault = 46;
public const int MultiLineCommentWhitespace = 47;
public const int MultiLineCommentLineTerminator = 48;
public const int MultiLineCommentURL = 49;
public const int MultiLineCommentWord = 50;
public const int MultiLineCommentStart = 51;
public const int MultiLineCommentEnd = 52;
public const int XMLCommentDefault = 53;
public const int XMLCommentDelimiter = 54;
public const int XMLCommentStartTag = 55;
public const int XMLCommentEndTag = 56;
public const int XMLCommentWhitespace = 57;
public const int XMLCommentLineTerminator = 58;
public const int XMLCommentURL = 59;
public const int XMLCommentWord = 60;
public const int XMLCommentStart = 61;
public const int XMLCommentEnd = 62;
public const int PreProcessorDirectiveDefault = 63;
public const int PreProcessorDirectiveWhitespace = 64;
public const int PreProcessorDirectiveWord = 65;
public const int RegionPreProcessorDirectiveStart = 66;
public const int PreProcessorDirectiveEnd = 67;
public const int EndRegionPreProcessorDirectiveStart = 68;
public const int DefinePreProcessorDirectiveStart = 69;
public const int UndefPreProcessorDirectiveStart = 70;
public const int IfPreProcessorDirectiveIfStart = 71;
public const int IfPreProcessorDirectiveElIfStart = 72;
public const int IfPreProcessorDirectiveElseStart = 73;
public const int IfPreProcessorDirectiveEndIfStart = 74;
public const int LinePreProcessorDirectiveStart = 75;
public const int WarningPreProcessorDirectiveStart = 76;
public const int ErrorPreProcessorDirectiveStart = 77;
}
public class States
{
public const int DefaultState = 1;
public const int CharacterState = 2;
public const int StringState = 3;
public const int VerbatimStringState = 4;
public const int CommentState = 5;
public const int MultiLineCommentState = 6;
public const int XMLCommentState = 7;
public const int PreProcessorDirectiveState = 8;
public const int PreProcessorDirectiveCommentState = 9;
}
}
}