Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parser How To in .NET

I'd like to understand how to construct a parser in .NET to process source files. For example, maybe I could begin by learning how to parse SQL or HTML or CSS and then act on the results to be able to format them for readability or something similar.

Where can I learn how to do this? Are there specific books I can refer to? Do I need to learn about lexers/parsers?

Specifically for the .NET platform since I'm comfortable in C#.

like image 663
Rudy Avatar asked Oct 15 '09 20:10

Rudy


People also ask

What is Parse method in C#?

The Parse method returns the converted number; the TryParse method returns a boolean value that indicates whether the conversion succeeded, and returns the converted number in an out parameter. If the string isn't in a valid format, Parse throws an exception, but TryParse returns false .

How do parser generators work?

A parser generator takes a grammar as input and automatically generates source code that can parse streams of characters using the grammar. The generated code is a parser, which takes a sequence of characters and tries to match the sequence against the grammar.

What is parser in API?

The Parser API can be used to perform parsing of response message from the devices. The response can be parsed as a token of strings, table, scalar, or some other user-defined form. WebNMS CLI API provides the following parser implementations. Line parsing.

What is parser data?

Data parsing is converting data from one format to another. Widely used for data structuring, it is generally done to make the existing, often unstructured, unreadable data more comprehensible.


1 Answers

I personally found this article, Grammars and Parsing with C# 2.0, a great introduction on writing lexers/parsers, with examples specifically relating to C#.

I wrote a brief blog post about it not long ago, doing it praise. The nice thing is that it's very much aimed at complete beginners to parse theory (it gives background to the theory as well as implementation), and takes matters in gradual steps. Of course, if you want to proceed to learn the more advanced ideas of the field, you will need various other resources, but I think this is an excellent foundation.

like image 179
Noldorin Avatar answered Oct 20 '22 01:10

Noldorin