"Every corpse on Mount Everest was once a highly motivated person"
-
I keep thinking of that as I work on my source generator for my Visual FA project. It's a lot of work and I have a long way to go before I can write an article or anything. Writing source generators for C# is difficult, especially in Visual Studio where your updated generation code doesn't always "take" until you exit and relaunch Visual Studio. I had to find that out the hard way, after hours of struggle. I've also got to learn to make NuGet packages, and probably something more than just a simple DLL or something. Here's what I have so far, and I'm quite happy with it. So far you can declare a regex matcher (one FARule) or lexer (multiple FARules, possibly with symbol names and ids):
using VisualFA;
partial class TestSource
{
// Declare a lexer. Here we specify the rules and the type of lexer
// as indicated by FARule attributes and the return type
// shared dependency code is automatically generated as needed.
// It won't be generated if your code references VisualFA.
[FARule(@"\/\*",Symbol="commentBlock",BlockEnd=@"\*\/")]
[FARule(@"\/\/[^\n]*", Symbol = "lineComment")]
[FARule(@"[ \t\r\n]+", Symbol = "whiteSpace")]
[FARule(@"[A-Za-z_][A-Za-z0-9_]*",Symbol="identifier")]
[FARule(@"(0|([1-9][0-9]*))((\.[0-9]+[Ee]\-?[1-9][0-9]*)?|\.[0-9]+)",Symbol="number")]
[FARule(@"\+",Symbol = "plus")]
[FARule(@"\-", Symbol = "minus")]
[FARule(@"\*", Symbol = "multiply")]
[FARule(@"\/", Symbol = "divide")]
[FARule(@"%", Symbol = "modulo")]
internal static partial FATextReaderRunner Calc(TextReader text);
}That causes the C# compiler, with the help of my source generator to generate all the code necessary such that you can do this with it:
var exp = "the 10 quick brown foxes jumped over 1.5 lazy dogs";
foreach (var match in TestSource.Calc(new StringReader(exp)))
{
Console.WriteLine(match);
}Which nets you this:
[SymbolId: 3, Value: "the", Position: 0 (1, 1)]
[SymbolId: 2, Value: " ", Position: 3 (1, 4)]
[SymbolId: 4, Value: "10", Position: 4 (1, 5)]
[SymbolId: 2, Value: " ", Position: 6 (1, 7)]
[SymbolId: 3, Value: "quick", Position: 7 (1, 8)]
[SymbolId: 2, Value: " ", Position: 12 (1, 13)]
[SymbolId: 3, Value: "brown", Position: 13 (1, 14)]
[SymbolId: 2, Value: " ", Position: 18 (1, 19)]
[SymbolId: 3, Value: "foxes", Position: 19 (1, 20)]
[SymbolId: 2, Value: " ", Position: 24 (1, 25)]
[SymbolId: 3, Value: "jumped", Position: 25 (1, 26)]honey the codewitch wrote:
Writing source generators for C# is difficult, especially in Visual Studio where your updated generation code doesn't always "take" until you exit and relaunch Visual Studio. I had to find that out the hard way, after hours of struggle.
I assume you've read Andrew Lock's 10-part series on writing source generators, particularly Testing an incremental generator with snapshot testing[^]? :)
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
honey the codewitch wrote:
Writing source generators for C# is difficult, especially in Visual Studio where your updated generation code doesn't always "take" until you exit and relaunch Visual Studio. I had to find that out the hard way, after hours of struggle.
I assume you've read Andrew Lock's 10-part series on writing source generators, particularly Testing an incremental generator with snapshot testing[^]? :)
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
Yep, and if he mentioned having to restart visual studio for your source generator code adjustments to take effect sometimes I missed it.
Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix
-
I keep thinking of that as I work on my source generator for my Visual FA project. It's a lot of work and I have a long way to go before I can write an article or anything. Writing source generators for C# is difficult, especially in Visual Studio where your updated generation code doesn't always "take" until you exit and relaunch Visual Studio. I had to find that out the hard way, after hours of struggle. I've also got to learn to make NuGet packages, and probably something more than just a simple DLL or something. Here's what I have so far, and I'm quite happy with it. So far you can declare a regex matcher (one FARule) or lexer (multiple FARules, possibly with symbol names and ids):
using VisualFA;
partial class TestSource
{
// Declare a lexer. Here we specify the rules and the type of lexer
// as indicated by FARule attributes and the return type
// shared dependency code is automatically generated as needed.
// It won't be generated if your code references VisualFA.
[FARule(@"\/\*",Symbol="commentBlock",BlockEnd=@"\*\/")]
[FARule(@"\/\/[^\n]*", Symbol = "lineComment")]
[FARule(@"[ \t\r\n]+", Symbol = "whiteSpace")]
[FARule(@"[A-Za-z_][A-Za-z0-9_]*",Symbol="identifier")]
[FARule(@"(0|([1-9][0-9]*))((\.[0-9]+[Ee]\-?[1-9][0-9]*)?|\.[0-9]+)",Symbol="number")]
[FARule(@"\+",Symbol = "plus")]
[FARule(@"\-", Symbol = "minus")]
[FARule(@"\*", Symbol = "multiply")]
[FARule(@"\/", Symbol = "divide")]
[FARule(@"%", Symbol = "modulo")]
internal static partial FATextReaderRunner Calc(TextReader text);
}That causes the C# compiler, with the help of my source generator to generate all the code necessary such that you can do this with it:
var exp = "the 10 quick brown foxes jumped over 1.5 lazy dogs";
foreach (var match in TestSource.Calc(new StringReader(exp)))
{
Console.WriteLine(match);
}Which nets you this:
[SymbolId: 3, Value: "the", Position: 0 (1, 1)]
[SymbolId: 2, Value: " ", Position: 3 (1, 4)]
[SymbolId: 4, Value: "10", Position: 4 (1, 5)]
[SymbolId: 2, Value: " ", Position: 6 (1, 7)]
[SymbolId: 3, Value: "quick", Position: 7 (1, 8)]
[SymbolId: 2, Value: " ", Position: 12 (1, 13)]
[SymbolId: 3, Value: "brown", Position: 13 (1, 14)]
[SymbolId: 2, Value: " ", Position: 18 (1, 19)]
[SymbolId: 3, Value: "foxes", Position: 19 (1, 20)]
[SymbolId: 2, Value: " ", Position: 24 (1, 25)]
[SymbolId: 3, Value: "jumped", Position: 25 (1, 26)]honey the codewitch wrote:
Every corpse on Mount Everest was once a highly motivated person
Is this also highly likely - Every corpse was once a highly motivated person ... ... with a few dashed dreams.
-
honey the codewitch wrote:
Every corpse on Mount Everest was once a highly motivated person
Is this also highly likely - Every corpse was once a highly motivated person ... ... with a few dashed dreams.
I don't know. I've met some pretty lazy people - I imagine they'd make lazy corpses.
Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix
-
I don't know. I've met some pretty lazy people - I imagine they'd make lazy corpses.
Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix
honey the codewitch wrote:
I imagine they'd make lazy corpses.
There's another kind? :~
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows. -- 6079 Smith W.
-
honey the codewitch wrote:
I imagine they'd make lazy corpses.
There's another kind? :~
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows. -- 6079 Smith W.
Zombies
I’ve given up trying to be calm. However, I am open to feeling slightly less agitated. I’m begging you for the benefit of everyone, don’t be STUPID.
-
honey the codewitch wrote:
I imagine they'd make lazy corpses.
There's another kind? :~
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows. -- 6079 Smith W.
-
honey the codewitch wrote:
I imagine they'd make lazy corpses.
There's another kind? :~
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows. -- 6079 Smith W.
Depends on how many George Romero movies you've watched, I suppose.
Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix
-
I keep thinking of that as I work on my source generator for my Visual FA project. It's a lot of work and I have a long way to go before I can write an article or anything. Writing source generators for C# is difficult, especially in Visual Studio where your updated generation code doesn't always "take" until you exit and relaunch Visual Studio. I had to find that out the hard way, after hours of struggle. I've also got to learn to make NuGet packages, and probably something more than just a simple DLL or something. Here's what I have so far, and I'm quite happy with it. So far you can declare a regex matcher (one FARule) or lexer (multiple FARules, possibly with symbol names and ids):
using VisualFA;
partial class TestSource
{
// Declare a lexer. Here we specify the rules and the type of lexer
// as indicated by FARule attributes and the return type
// shared dependency code is automatically generated as needed.
// It won't be generated if your code references VisualFA.
[FARule(@"\/\*",Symbol="commentBlock",BlockEnd=@"\*\/")]
[FARule(@"\/\/[^\n]*", Symbol = "lineComment")]
[FARule(@"[ \t\r\n]+", Symbol = "whiteSpace")]
[FARule(@"[A-Za-z_][A-Za-z0-9_]*",Symbol="identifier")]
[FARule(@"(0|([1-9][0-9]*))((\.[0-9]+[Ee]\-?[1-9][0-9]*)?|\.[0-9]+)",Symbol="number")]
[FARule(@"\+",Symbol = "plus")]
[FARule(@"\-", Symbol = "minus")]
[FARule(@"\*", Symbol = "multiply")]
[FARule(@"\/", Symbol = "divide")]
[FARule(@"%", Symbol = "modulo")]
internal static partial FATextReaderRunner Calc(TextReader text);
}That causes the C# compiler, with the help of my source generator to generate all the code necessary such that you can do this with it:
var exp = "the 10 quick brown foxes jumped over 1.5 lazy dogs";
foreach (var match in TestSource.Calc(new StringReader(exp)))
{
Console.WriteLine(match);
}Which nets you this:
[SymbolId: 3, Value: "the", Position: 0 (1, 1)]
[SymbolId: 2, Value: " ", Position: 3 (1, 4)]
[SymbolId: 4, Value: "10", Position: 4 (1, 5)]
[SymbolId: 2, Value: " ", Position: 6 (1, 7)]
[SymbolId: 3, Value: "quick", Position: 7 (1, 8)]
[SymbolId: 2, Value: " ", Position: 12 (1, 13)]
[SymbolId: 3, Value: "brown", Position: 13 (1, 14)]
[SymbolId: 2, Value: " ", Position: 18 (1, 19)]
[SymbolId: 3, Value: "foxes", Position: 19 (1, 20)]
[SymbolId: 2, Value: " ", Position: 24 (1, 25)]
[SymbolId: 3, Value: "jumped", Position: 25 (1, 26)]Did you get that subject line from the Demotivators[^] collection?
Quote:
When we started Despair, we had a dream. To crush other people's dreams. But we knew, given our goal, we'd be in for a fight. After all, the Motivation Industry has been crushing dreams for decades, selling the easy lie of success you can buy. That's why we decided to differentiate ourselves- by crushing dreams with hard truths!
The difficult we do right away... ...the impossible takes slightly longer.
-
Did you get that subject line from the Demotivators[^] collection?
Quote:
When we started Despair, we had a dream. To crush other people's dreams. But we knew, given our goal, we'd be in for a fight. After all, the Motivation Industry has been crushing dreams for decades, selling the easy lie of success you can buy. That's why we decided to differentiate ourselves- by crushing dreams with hard truths!
The difficult we do right away... ...the impossible takes slightly longer.
LOL, it may have come that way to me indirectly, as I read it on the Internet somewhere.
Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix