|
-
November 18th, 2014, 09:14 AM
#1
Help! StreamReader read one line up
Hi there,
I'm working on a parser/scaffolding proggy to insert a .cs File and automatically read out all the scopes (new namespace, new class, new methos, attributes, fields, constructor etc.) and for noe I'm reading the input line by line and check wether the line starts with a "{". If it does, that means there's a new scope starting and whatever follows defines what is in the scope.
BUT:
the TYPE of scope (wether it's a class, or a method or a namespace etc) is written in the line above the "{". At least if we go by auto formatted c# code in VS 2012.
so what i need it so actually read line by line, and if i hit a "{", read the line above that and add it to my list of lines for that scope.
this is what i got so for for that particular part
Code:
while ((line = input.ReadLine()) != null)
{
line = line.Trim();
if (line == "{")
{
Scope s = new Scope();
//add the line above the opened scope as line to the scope
ScopeBlock.Add(File.ReadLines(path).Take(lineNumber-1).First());
while (line != "}")
{
ScopeBlock.Add(line);
}
}
foreach (string zeile in ScopeBlock)
{
ReadScope(line);
}
lineNumber++;
}
it throws an exception cause of course it can't find anything at the line specified.
anyone got an idea? Anything is greatly appreciated
Thanks
Lisa
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|