Click here to Skip to main content
15,891,136 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Reviews on Intel's New Processor Are Out Pin
honey the codewitch4-Nov-21 14:26
mvahoney the codewitch4-Nov-21 14:26 
GeneralRe: Reviews on Intel's New Processor Are Out Pin
Rick York4-Nov-21 16:38
mveRick York4-Nov-21 16:38 
JokeRe: Reviews on Intel's New Processor Are Out Pin
den2k884-Nov-21 22:28
professionalden2k884-Nov-21 22:28 
GeneralRe: Reviews on Intel's New Processor Are Out Pin
honey the codewitch4-Nov-21 22:29
mvahoney the codewitch4-Nov-21 22:29 
GeneralRe: Reviews on Intel's New Processor Are Out Pin
Slow Eddie5-Nov-21 3:09
professionalSlow Eddie5-Nov-21 3:09 
GeneralRe: Reviews on Intel's New Processor Are Out Pin
Rick York5-Nov-21 5:08
mveRick York5-Nov-21 5:08 
GeneralRe: Reviews on Intel's New Processor Are Out Pin
trønderen5-Nov-21 16:46
trønderen5-Nov-21 16:46 
GeneralThe Slog Pin
honey the codewitch4-Nov-21 7:06
mvahoney the codewitch4-Nov-21 7:06 
I've been working on a complicated set of templates used to render state machines for matching text in various ways.

The templates are complicated because they allow for targeting multiple languages by plugging in new templates.

Prior, I was just making one template per target per option, so like SQL matching code vs C# matching code would be two templates.

Well now, it's many templates but, they're structured such that you're forced to basically produce the same code regardless of target (like C#, or SQL). For example, the following is the basic structure of a matching state machine in an language independent way.

C#
a.Comment("Matches text based on a DFA table and block end DFA table");
a.MethodPrologue("None",true,"TableMatcherMatchReturn","TableMatch","TableMatcherMatchImplParams");
	a.MatcherCreateResultList();
	a.TableMatcherMatchDeclarations();
	a.ReadCodePoint();
	a.InputLoopPrologue();
		a.MatcherResetMatch();
		a.TableMachineLoopPrologue();
			a.TableMove("dfa");
		a.TableMachineLoopEpilogue();
		a.TableAcceptPrologue();
			a.TableIfBlockEndPrologue();
				a.TableStateReset();
				a.InputLoopPrologue();
					a.TableMachineLoopPrologue();
						a.TableMove("blockEnd");
					a.TableMachineLoopEpilogue();
					a.TableAcceptPrologue();
						a.TableMatchYieldResult();
						a.BreakInputLoop();
					a.TableAcceptEpilogue();
					a.TableRejectPrologue();
						a.UpdateLineAny();
						a.AppendCapture();
						a.ReadCodepoint();
						a.AdvanceCursor();
					a.TableRejectEpilogue();
					a.TableStateReset();
				a.InputLoopEpilogue();
				a.TableStateReset();
				a.ContinueInputLoop();
			a.TableIfBlockEndEpilogue();
			a.TableIfNotBlockEndPrologue();
				a.TableMatchYieldNonEmptyResult();
			a.TableIfNotBlockEndEpilogue();
	    a.TableAcceptEpilogue();
    	a.UpdateLineAny();
	    a.ReadCodepoint();
    	a.AdvanceCursor();
	    a.TableStateReset();
	a.InputLoopEpilogue();
	a.MatcherReturnResultList();
a.MethodEpilogue();


where a in this case is a especial expando object (dynamic) I built that resolves to template generation calls that are selected based on your target (like SQL or C#)

Sorry for all the code, it's just hard to explain without it.

I've basically imposed a structure over the flow the code so that it renders the same regardless of target because I was failing tests doing one target per template.

Unfortunately, this method yields dozens of templates per target, but at least my code is consistent.

I had to hack the crap out of my csppg tool to even make this work, but now it's pretty powerful.

I can do this:
ASP.NET
<%@param name="docTemplate" type="string"%>
<%@param name="@private" type="bool"%>
<%@param name="returnTemplate" type="string"%>
<%@param name="methodName" type="string"%>
<%@param name="parametersTemplate" type="string"%>


To add parameters to my generator routines. I use this in MethodPrologue and TableMove above.

It's crazy code, folks. Just a zoo. But it works. I wish I had a better way to do this. It's a chore.
Real programmers use butterflies


modified 4-Nov-21 19:20pm.

JokeRe: The Slog Pin
devenv.exe4-Nov-21 8:38
professionaldevenv.exe4-Nov-21 8:38 
GeneralRe: The Slog Pin
honey the codewitch4-Nov-21 8:59
mvahoney the codewitch4-Nov-21 8:59 
GeneralRe: The Slog Pin
Rick York4-Nov-21 10:57
mveRick York4-Nov-21 10:57 
GeneralRe: The Slog Pin
TNCaver4-Nov-21 11:00
TNCaver4-Nov-21 11:00 
GeneralRe: The Slog Pin
Gary R. Wheeler5-Nov-21 12:27
Gary R. Wheeler5-Nov-21 12:27 
GeneralCCC 2021-11-04 Pin
Greg Utas4-Nov-21 1:17
professionalGreg Utas4-Nov-21 1:17 
GeneralRe: CCC 2021-11-04 Pin
OriginalGriff4-Nov-21 2:06
mveOriginalGriff4-Nov-21 2:06 
GeneralRe: CCC 2021-11-04 - winner Pin
Greg Utas4-Nov-21 2:11
professionalGreg Utas4-Nov-21 2:11 
GeneralA very Happy Diwali... PinPopular
ChandraRam4-Nov-21 0:07
ChandraRam4-Nov-21 0:07 
GeneralRe: A very Happy Diwali... Pin
Slow Eddie6-Nov-21 5:05
professionalSlow Eddie6-Nov-21 5:05 
GeneralRe: A very Happy Diwali... Pin
ChandraRam7-Nov-21 21:50
ChandraRam7-Nov-21 21:50 
GeneralOi Griff ! time for an Oi Greg Utas Pin
pkfox4-Nov-21 0:02
professionalpkfox4-Nov-21 0:02 
GeneralRe: Oi Griff ! time for an Oi Greg Utas Pin
Greg Utas4-Nov-21 1:11
professionalGreg Utas4-Nov-21 1:11 
GeneralRe: Oi Griff ! time for an Oi Greg Utas Pin
OriginalGriff4-Nov-21 2:01
mveOriginalGriff4-Nov-21 2:01 
GeneralRe: Oi Griff ! time for an Oi Greg Utas Pin
pkfox4-Nov-21 2:05
professionalpkfox4-Nov-21 2:05 
GeneralRe: Oi Griff ! time for an Oi Greg Utas Pin
OriginalGriff4-Nov-21 2:13
mveOriginalGriff4-Nov-21 2:13 
GeneralRe: Oi Griff ! time for an Oi Greg Utas Pin
pkfox4-Nov-21 2:16
professionalpkfox4-Nov-21 2:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.