Search code examples
context-free-grammarrascal

Parsing CSV file with dynamic separator


I try to solve the following parsing problem, but I fail:

I have a CSV file that with a certain command inside the file can change separators, and the current separator can be escaped with a slash. Look at this example:

a,b,c,list;with;values
a,b,c,list\,with\,values
@separator,;
a;b;c;list,with,values
a;b;c;list\;with\;values

Is this possible? And how?


Solution

  • It seems you want to have a grammar with context. Rascal only supports context free grammars.

    The format seems simple enough, couldn't a loop with some context variables solve this? (In any language that has basic string operations)