Luthor 1.0.1
See the version list below for details.
dotnet add package Luthor --version 1.0.1
NuGet\Install-Package Luthor -Version 1.0.1
<PackageReference Include="Luthor" Version="1.0.1" />
paket add Luthor --version 1.0.1
#r "nuget: Luthor, 1.0.1"
// Install Luthor as a Cake Addin #addin nuget:?package=Luthor&version=1.0.1 // Install Luthor as a Cake Tool #tool nuget:?package=Luthor&version=1.0.1
Luthor
Extract structure from any text using a generic lexer.
Using Luthor you can quickly (and easily) convert any text string into a sequence of Token
, each of which represents an instance of a particular TokenType
with a Content
property holding the entire 'run' of that type of token.
In essence you get a sequence of things which represent the contents in a higher level of abstraction, allowing you to process the text further without having to worry about the specifics of the text as you go (a classic example would be a parser).
For example:
Sample text.\nAcross 2 lines.
This gives a list of tokens like this:
TokenType.Letters - "sample"
TokenType.Whitespace - " "
TokenType.Letters - "text"
TokenType.Symbols - "."
TokenType.EOL - "\n"
TokenType.Letters - "Across"
TokenType.Whitespace - " "
TokenType.Digits - "2"
TokenType.Whitespace - " "
TokenType.Letters - "lines"
TokenType.Symbols - "."
TokenType.EOF - ""
Now your code can look at words, or keywords, or identifiers, or whatever it's context is expecting. No need to split text or manually hack at it.
Usage
- Create a scanner
- Pass it to Luther
- Request the output
var scanner = new Scanner(sourceAsString);
var lexer = new Lexer(scanner);
var result = lexer.GetTokens();
There's an optional parameter to GetTokens
, which is compressWhitespace
(defaults to false
). If set, then runs of whitespace are all compressed down to a single space.
Output
- Linux/Unix, Mac OS, and Windows all have a
\n
as part (or all) of their line endings. Since Mac OS arrived, none of them rely solely on\r
. Therefore any\r
characters are ignored entirely - they are neither in the output, nor do they impact column numbering. - Regardless of the presence/absence of
Ctrl+Z
or similar, the output will always end with an EOF token.
Token types
- Whitespace - spaces, tabs
- Letters - upper and lower case English alphabet
- Digits - 0 to 9
- Symbols - any of !£$%^&*()-_=+[]{};:'@#~,.<>/?|
- String - anything enclosed in either ", ', or `
- Other - input characters not covered by other types
- EOL - a
\n
, regardless of whether\r
was present - EOF - automatically added
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.