Click here to Skip to main content
15,901,426 members
Home / Discussions / C#
   

C#

 
GeneralRe: Advice required on Matching Input: Code copied from ARL(Advanced Reporting Language) Pin
KaptinKrunch24-Apr-08 7:16
KaptinKrunch24-Apr-08 7:16 
GeneralRe: Advice required on Matching Input: Code copied from ARL(Advanced Reporting Language) Pin
MumbleB24-Apr-08 7:26
MumbleB24-Apr-08 7:26 
GeneralRe: Advice required on Matching Input: Code copied from ARL(Advanced Reporting Language) Pin
carbon_golem24-Apr-08 7:17
carbon_golem24-Apr-08 7:17 
GeneralRe: Advice required on Matching Input: Code copied from ARL(Advanced Reporting Language) Pin
KaptinKrunch24-Apr-08 7:34
KaptinKrunch24-Apr-08 7:34 
GeneralRe: Advice required on Matching Input: Code copied from ARL(Advanced Reporting Language) Pin
MumbleB24-Apr-08 7:40
MumbleB24-Apr-08 7:40 
GeneralRe: Advice required on Matching Input: Code copied from ARL(Advanced Reporting Language) Pin
Ed.Poore24-Apr-08 8:45
Ed.Poore24-Apr-08 8:45 
GeneralRe: Advice required on Matching Input: Code copied from ARL(Advanced Reporting Language) Pin
MumbleB24-Apr-08 18:46
MumbleB24-Apr-08 18:46 
Generalproblems parsing [modified] Pin
stephan_00724-Apr-08 6:46
stephan_00724-Apr-08 6:46 
hy everyone!

sorry for me asking again, but i encountered two additional problems during realizing my parser:

problem number one:
after i finished parsing, there might be some fields which weren't replaced by it's values. they are of a special format

< format|varname|format >


in this example format has to be replaced by a format value which i defined myself.

*) there could be 0 to n "#" which define the fieldlength and right- or leftalignment (e.g. <###|varname|> for rightalignment of a filed with length 3 - because of 3 #s) <|varname|###> would be the counterpart but leftalignment.

*) there could be a formatstring on the right e.g. <|varname|{#,##0.00}>

*) there could be 0 to n "~" which define the string to be centered and define the fieldlength e.g. <|varname|~~~> for fieldlength 3 and centering

*) and there could be either a sign "]" or "[" on the right which define on which page the variable should be replaced by it's value or by an empty string. e.g <|varname|[>

and (which makes it even harder and causes my second problem) a combination of the formatings above (except left-, rightalignment and center at the same time!) in not defined order (but not mixed!). e.g. <###|varname|{##0.00}[> (but not e.g. <|varname|~~[~~> etc.)

so i have to replace strings between < and > without knowing whats inbetween by an "empty" string (but of defined length, if # or { is found!).

my solution would be to search the final parsed string for an occurence of "<" and then parse in the string until the ">" is found. then do the formating for # and ~ but ignoring all other formatings).
but if i have to do this more often then this could be of bad performance because the more often i do change a string the longer it will take (i guess even when using a stringbuilder).

problem number 2:
well but this is not my only problem. my other problem is to do the formating in general if there are more than one format value on one side.
i allowed # to be on the left and right but all other values just to be on the right. so the left side is easy. but the right is not.

so my idea would be to first parse from the index i get for the start of the variable (e.g. |varname|) and then parse to the left until i reach the "<" sign. this info will be stored in a variable called e.g. string leftformat. then i do the same at the right by parsing from index + lengthofvariable (so from the first sign after |varname|) again until i reach the ">" this time. well, this side is tricky, because i have to check for more possible signs: "#" or "~", a format string {...} and a sign "[" or "]" (the ors are exclusive in this case so either this or that but not at the same time!). then i would put the right side into a loop until the rightformat string is parsed (empty, or length index). in this loop i would check for all possible signs, which could be there. but i do not know in which order they might occur, that's why i do the loop. because i could check for the sign sequentially. so if the last if is the one then i have to repeat the check for the next signs.

example for the right side: #####{##0.00}[
(note that the #s in the formatstring are treated differently, because they are sourounded by "{" and "}"!!).
so my could would look like (pseudocode!)

while (string not empty or i < length) // have to think what's better!
{
  if char == "#" { while still "#" replace this one }
  if char == "~" { check needed if "#" was alreaday used!
                   while still "~" replace this one}
  if char == "{" { parse until the "}" sign is reached }
  if char == "[" { do the operation }
  if char == "]" { check if not already "[" and do the operation }
}


well i hope i did describe my problems well enough but not to long on the other hand side Smile | :)

what do you think about this? from my point of view i am not sure if this doesn't slow down my parser too much. that's why i posted it here for discussion and further ideas.

so if anyone of you has comments or any better solution to handle this, please let me know by replying to my post.

thanks.

stephan.



modified on Thursday, April 24, 2008 12:54 PM

GeneralRe: problems parsing Pin
KaptinKrunch24-Apr-08 7:31
KaptinKrunch24-Apr-08 7:31 
GeneralRe: problems parsing Pin
Anthony Mushrow24-Apr-08 12:18
professionalAnthony Mushrow24-Apr-08 12:18 
Questionthe main class in C# Pin
A@YZ24-Apr-08 6:31
A@YZ24-Apr-08 6:31 
GeneralRe: the main class in C# Pin
Anthony Mushrow24-Apr-08 6:52
professionalAnthony Mushrow24-Apr-08 6:52 
GeneralRe: the main class in C# Pin
Colin Angus Mackay24-Apr-08 7:50
Colin Angus Mackay24-Apr-08 7:50 
GeneralRe: the main class in C# Pin
Jasmine250124-Apr-08 8:51
Jasmine250124-Apr-08 8:51 
GeneralRe: the main class in C# Pin
Colin Angus Mackay24-Apr-08 7:51
Colin Angus Mackay24-Apr-08 7:51 
GeneralRe: the main class in C# Pin
PIEBALDconsult24-Apr-08 8:51
mvePIEBALDconsult24-Apr-08 8:51 
JokeRe: the main class in C# Pin
Guffa24-Apr-08 9:29
Guffa24-Apr-08 9:29 
GeneralRe: the main class in C# Pin
Vikram A Punathambekar24-Apr-08 19:03
Vikram A Punathambekar24-Apr-08 19:03 
Questionwhat is meant by Interface in C#? Pin
A@YZ24-Apr-08 6:29
A@YZ24-Apr-08 6:29 
AnswerRe: what is meant by Interface in C#? Pin
johnnycantcode24-Apr-08 6:41
johnnycantcode24-Apr-08 6:41 
AnswerRe: what is meant by Interface in C#? Pin
Gareth H24-Apr-08 6:57
Gareth H24-Apr-08 6:57 
QuestionMultiple Inheritance is possible in C# are not? Pin
A@YZ24-Apr-08 6:26
A@YZ24-Apr-08 6:26 
AnswerRe: Multiple Inheritance is possible in C# are not? Pin
Gareth H24-Apr-08 6:45
Gareth H24-Apr-08 6:45 
AnswerRe: Multiple Inheritance is possible in C# are not? Pin
Guffa24-Apr-08 9:13
Guffa24-Apr-08 9:13 
QuestionMultiple Inheritance is possible in C# are not? Pin
A@YZ24-Apr-08 6:25
A@YZ24-Apr-08 6:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.