Created
January 22, 2018 01:52
-
-
Save waf/8060040e191e91e76ddebdc4abf15a7a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
What is parsing? | |
Turning text (or some other stream of bytes) into a more useful format | |
- Turning strings into JSON objects | |
- Turning bytes into TCP packet structs | |
- Turning strings into some C# object hierarchy | |
Levels of parsing: | |
0 - avoid it -- use some standard format and library (json, xml, etc) | |
1 - string indexOf / split | |
2 - regex | |
3 - parser combinators - pure functions that build simple parsers, compose the functions builds a more complex parser. | |
sprache - https://github.com/sprache/Sprache | |
users: resharper, octopus | |
superpower - https://github.com/datalust/superpower | |
users: serilog | |
pidgin - https://github.com/benjamin-hodgson/Pidgin | |
users: stackoverflow | |
4 - parser generator - specify a grammar, and the parser is generated | |
yacc/lex - older tools from AT&T | |
bison/flex - open source implementation of yacc/lex | |
antlr | |
users: ASP.NET Web Optimization, Apache Cassandra, Groovy, Hibernate | |
http://www.antlr.org/ | |
examples: | |
https://github.com/waf/Donatello/tree/master/src/Donatello.Services/Antlr | |
https://github.com/waf/Donatello/blob/master/src/Donatello.Services/Parser/VectorExpression.cs | |
tooling: | |
https://github.com/antlr/grammars-v4 | |
https://datapsyche.files.wordpress.com/2014/10/screen-shot-2014-10-24-at-12-44-34-am.png | |
http://www.antlr.org/images/antlrdt-v4-plugin.png | |
be careful which C# version you choose! | |
https://github.com/tunnelvisionlabs/antlr4cs | |
https://github.com/antlr/antlr4/tree/master/runtime/CSharp | |
Non C#: | |
- Powershell: just use the above .NET libraries | |
- JavaScript: Ohm | |
https://ohmlang.github.io/editor/#0a9a649c3c630fd0a470ba6cb75393fe | |
- Anything: ANTLR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment