Regular expression – the best modern text parsing? When is AKA to use Lex and Yacc?

I have commands and parameters for inputting text blocks, one per line, such as

XYZ ARG1,ARG2,ARG3, ..., ARGN

I want to verify whether the parameters of XYZ are applicable to that particular command, and if they are, execute the correct code block. There are about 100 commands, some of which have a variable number of parameters, Different relationships (that is, if the command XYZ is called, then I also need the command ABC to call).

There are also commands, for example:

COMMAND
XYZ ARG1
BEF ARG1 ARG2
ENDCOMMAND

The important thing is that the text is included in COMMAND and ENDCOMMAND.

Usually for such things, I would use Lex and Yacc instead of regular expressions, but is there something more modern? The code is written in C#. Is there anything in MSDN that can do this instead of the old school C Lex and Yacc?

If you are looking for an alternative to Lex / Yacc, please check ANTLR. It supports various languages Code generation for, including C#.

I have commands and parameters for inputting text blocks, one per line, such as

 XYZ ARG1,ARG2,ARG3,...,ARGN

I want to verify whether the parameters of XYZ are applicable to that particular command, and if so, execute the correct code block. There are about 100 commands, some of them There are a variable number of parameters and different relationships (that is, if the command XYZ is called, then I also need the command ABC to call).

There are also commands, such as:

COMMAND
XYZ ARG1
BEF ARG1 ARG2
ENDCOMMAND

The important thing is that the text is contained in COMMAND and ENDCOMMAND.

Usually For such things, I would use Lex and Yacc instead of regular expressions, but is there something more modern? The code is written in C#. Is there anything in MSDN that can do this instead of the old school C Lex and Yacc?

If you are looking for an alternative to Lex/Yacc, please check ANTLR. It supports code generation in various languages, including C#.

< p>

Leave a Comment

Your email address will not be published.