Luthor 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package Luthor --version 1.0.1                
NuGet\Install-Package Luthor -Version 1.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Luthor" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Luthor --version 1.0.1                
#r "nuget: Luthor, 1.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .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.

Version Downloads Last updated
2.3.0 258 8/30/2023
2.2.1 474 6/19/2021
2.2.0 386 6/18/2021
2.1.0 410 6/18/2021
1.0.1 925 8/19/2018