User code region markers

Posts   
 
    
Stevenn
User
Posts: 30
Joined: 26-Sep-2007
# Posted on: 04-Feb-2011 06:48:38   

Hi,

i decided to have a look at the parser that generates the code for the user code regions. Partially due to the tab/space issue and also due to the fact that the regex is defined in code and would need to be recompiled if i wanted to change it into the future. I decided to see if i could make the regex string user editable so that one wouldn't have to recompile the task performer dlls.

I found instances of __LLBLGENPRO_USER_CODE_REGION_START in the following files: TDLInterpret->Interpreter.cs and LPTParserEngine->DotNetTemplateEngine.cs.

I decided to just add a _S to the end of the token just as a test. Recompiled, slapped the dlls in the TaskPerformer folder and regenned my project. The code that is generated still contains the original token though, even if i totally delete those projects from the solution and regen. I've searched all the SDK source that i have downloaded, but can't seem to find where that token is being created, except the files i mentioned above. Got any tips?

Using version 2.6.

Thanks

Steven

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39590
Joined: 17-Aug-2003
# Posted on: 04-Feb-2011 10:50:12   

It works like this: - the parser parses the template and sees the usercode region tokens (the <[UserCodeRegion ]> token and <[EndUserCodeRegion]> token) and from the start to end token the text is stored in 1 non-terminal object in the token stream.

  • the interpreter interprets non-terminal objects in the token stream produced by the parser. Right before it starts interpreting, it first checks if there's an existing file. If so, it scans that file for user code regions using the regular expression (In FindUserCodeRegions()). Every region found is stored in a dictionary, where the text between the comment markers is stored in the dictionary.

  • when the interpreter sees the usercode region non terminal in the token stream, it checks the name stored with it. It then looks up in the found user code region contents of the existing file whether it was found. If so, it will emit the contents of that block into the output surrounded by the user code markers. Otherwise, it will simply emit the user code markers. This is done in HandleUserCodeRegionStart(). Now here's the trick: in the template, the <[UserCodeRegion]> and <[EndUserCodeRegion]> tokens already contain the markers. simple_smile So if you don't add anything to the region, the original template contents is copied. If you do add something to the regions, it is between the markers in the code, so the markers are copied as well. simple_smile

So don't know where you added the _S, if it's to the reg-exp, it simply would mean no region was found and no content was copied over and the original markers from the template were copied.

Frans Bouma | Lead developer LLBLGen Pro
Stevenn
User
Posts: 30
Joined: 26-Sep-2007
# Posted on: 04-Feb-2011 12:58:14   

Hi Frans,

thanks for the response.

Never mind, it was short circuit. I'd actually edited my original templtes and taken that text out, so i wasn't seeing it in the anymore. Knew it must have been a brain cell issue.

Thanks

Steven