本文整理汇总了C#中TokenStream.ReadLine方法的典型用法代码示例。如果您正苦于以下问题:C# TokenStream.ReadLine方法的具体用法?C# TokenStream.ReadLine怎么用?C# TokenStream.ReadLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TokenStream
的用法示例。
在下文中一共展示了TokenStream.ReadLine方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Render
public ReturnCode Render(string f)
{
var fe = new StreamReaderParser(f,a=>!a.StartsWith("//", StringComparison.Ordinal));
var fs = new StreamWriter(f.LeftToFar(".pre.cs") + ".tsk.cs",false, Encoding.UTF8);
var tokens = new TokenStream<TokenizerCSharp>(fe.ReadLines());
var linetoken= tokens.ReadLine();
while (!linetoken.ContainsToken(TokenKind.ReservedWord,SubKindCSharp.Namespace))
{
if (linetoken.ContainsToken(TokenKind.ReservedWord,SubKindCSharp.Using))
{
fs.WriteLine(linetoken.Line);
}
linetoken = tokens.ReadLine();
}
if (!linetoken.ContainsToken(TokenKind.ReservedWord, SubKindCSharp.Namespace)) return ReturnCode.Prefile_Error;
var name = linetoken.Find(Token.Create(TokenKind.ReservedWord, SubKindCSharp.Namespace)).Next.Value;
var tasknamespace = new TaskNamespace(name.Value,new string[] { });
var parent = tasknamespace;
fs.WriteLine("namespace "+name.Value);
fs.WriteLine("{");
foreach (var cad in PreCode) fs.WriteLine(cad);
while (!tokens.EOF)
{
var line = tokens.ReadLine();
var strtokens = line.Line.Trim();
Switch.On(strtokens.Trim(), (a, b) => a.StartsWith(b, StringComparison.CurrentCulture))
.Case("[TaskClass(").Do(() =>
{
var cad = strtokens.Between("(\"", "\")");
if (!TaskClasses.ContainsKey(cad))
{
fs.Write("//Error: Task Clase " + cad + " no encontrada");
}
else
{
var currentclass = TaskClasses[cad];
line = tokens.ReadLine();
currentclass.Render(parent, line, fs);
}
})
.Case("//!", "using").Do(() => fs.WriteLine(line))
.Case("[TaskMember(").Do(() =>
{
var cad = strtokens.Between("(\"", "\")");
if (!TaskMembers.ContainsKey(cad))
{
fs.Write("//Error: Task Member " + cad + " no encontrado");
}
else
{
var currentclass = TaskMembers[cad];
line = tokens.ReadLine();
currentclass.Render(parent, new TokenLine(line), fs);
}
});
}
fs.WriteLine("}");
fs.Close();
return ReturnCode.Ok;
}