Click here to Skip to main content
15,890,882 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.

 
GeneralWonders of our brain Pin
dan!sh 31-Jan-20 3:24
professional dan!sh 31-Jan-20 3:24 
GeneralRe: Wonders of our brain Pin
Rage31-Jan-20 3:27
professionalRage31-Jan-20 3:27 
GeneralRe: Wonders of our brain Pin
dan!sh 31-Jan-20 3:29
professional dan!sh 31-Jan-20 3:29 
GeneralRe: Wonders of our brain Pin
lopatir31-Jan-20 4:11
lopatir31-Jan-20 4:11 
GeneralRe: Wonders of our brain Pin
kalberts31-Jan-20 5:57
kalberts31-Jan-20 5:57 
GeneralRe: Wonders of our brain Pin
kmoorevs31-Jan-20 6:43
kmoorevs31-Jan-20 6:43 
GeneralRe: Wonders of our brain Pin
H.Brydon1-Feb-20 16:41
professionalH.Brydon1-Feb-20 16:41 
GeneralIt's alive. Damn it Jim, it's actually alive. Pin
honey the codewitch30-Jan-20 23:12
mvahoney the codewitch30-Jan-20 23:12 
Well, I suppose that's progress. I brought my "Rolex" lexer project back from the brink of disaster a few times yesterday and I've finally got it rendering lexers from my preferred input format.


So this:


integerLiteral= '(0x[0-9A-Fa-f]{1,16}|([0-9]+))([Uu][Ll]?|[Ll][Uu]?)?'
floatLiteral= '(([0-9]+)(\.[0-9]+)?([Ee][\+\-]?[0-9]+)?[DdMmFf]?)|((\.[0-9]+)([Ee][\+\-]?[0-9]+)?[DdMmFf]?)'
whitespace<hidden>='[ \t\r\n\v\f]+'
lineComment<hidden>='\/\/[^\n]*'
blockComment<hidden,blockEnd="*/">="/*"
identifier='[_[:IsLetter:]][_[:IsLetterOrDigit:]]*



instead of this nonsense:


%%
[_[:IsLetter:]][_[:IsLetterOrDigit:]]* { return 0; }
\"([^\"]|[\\.])*\" { return 1; }
"+" {return 2;}
"-" {return 3;}
[0-9]+ {return 4;}
[ \t\r\n\v\f]+ { }
.        { return -1; }



And now the output is in a nice, single file, with the primary output implementing IEnumerable<Token>/IEnumerator<Token>


I still have to update the command line argument parsing and a bit of the grammar spec but at least I'll have a deliverable for Codeproject very early this next month

Accomplishing this was so much harder than it looks. I'm using some really grotty code someone else wrote and hasn't maintained for 6 years and I had to retool the front end and back end of it both.

I still barely understand it, but apparently well enough to get it to tease out a lexer that looks how I want it.

The hard part was adjusting the input file format. The original parser is heavily embedded with the app's logic. I had to reverse engineer it, and it's not a hand written parser. It's not even top down so it's impossible to follow in a debugger. It's a table driven LALR(1) parser with syntax directed actions. Fun. =(

I finally went back to the original .y file to get at the parser logic. Of course to change it I had to find an old copy of gppg.exe on the web somewhere (behind a "dangerous" link so I had to wget it - my browser refused to download) - that's so I could get GPLEX to rebuild its parser code.

Anyway, I can see daylight now. I just have to change a few more things with the input spec and then change up the command line argument processing some more.

I'm probably the only person that will ever use this. Laugh | :laugh:
Real programmers use butterflies

JokeRe: It's alive. Damn it Jim, it's actually alive. Pin
MehreenTahir30-Jan-20 23:52
MehreenTahir30-Jan-20 23:52 
GeneralRe: It's alive. Damn it Jim, it's actually alive. Pin
honey the codewitch30-Jan-20 23:53
mvahoney the codewitch30-Jan-20 23:53 
GeneralRe: It's alive. Damn it Jim, it's actually alive. Pin
MehreenTahir31-Jan-20 4:15
MehreenTahir31-Jan-20 4:15 
GeneralRe: It's alive. Damn it Jim, it's actually alive. Pin
honey the codewitch31-Jan-20 5:24
mvahoney the codewitch31-Jan-20 5:24 
GeneralRe: It's alive. Damn it Jim, it's actually alive. Pin
Daniel Pfeffer30-Jan-20 23:56
professionalDaniel Pfeffer30-Jan-20 23:56 
GeneralRe: It's alive. Damn it Jim, it's actually alive. Pin
jsc4231-Jan-20 4:21
professionaljsc4231-Jan-20 4:21 
GeneralRe: It's alive. Damn it Jim, it's actually alive. Pin
honey the codewitch31-Jan-20 5:20
mvahoney the codewitch31-Jan-20 5:20 
GeneralHappy Brexit Day everybody Pin
The pompey30-Jan-20 23:00
The pompey30-Jan-20 23:00 
GeneralRe: Happy Brexit Day everybody Pin
musefan30-Jan-20 23:11
musefan30-Jan-20 23:11 
GeneralRe: Happy Brexit Day everybody Pin
Daniel Pfeffer30-Jan-20 23:38
professionalDaniel Pfeffer30-Jan-20 23:38 
GeneralRe: Happy Brexit Day everybody Pin
musefan30-Jan-20 23:59
musefan30-Jan-20 23:59 
GeneralRe: Happy Brexit Day everybody Pin
Nelek31-Jan-20 4:41
protectorNelek31-Jan-20 4:41 
GeneralRe: Happy Brexit Day everybody Pin
Pete O'Hanlon31-Jan-20 0:52
mvePete O'Hanlon31-Jan-20 0:52 
GeneralRe: Happy Brexit Day everybody Pin
glennPattonWork331-Jan-20 1:16
professionalglennPattonWork331-Jan-20 1:16 
GeneralRe: Happy Brexit Day everybody Pin
The pompey31-Jan-20 7:20
The pompey31-Jan-20 7:20 
GeneralRe: Happy Brexit Day everybody Pin
Nagy Vilmos31-Jan-20 3:14
professionalNagy Vilmos31-Jan-20 3:14 
GeneralRe: Happy Brexit Day everybody Pin
glennPattonWork331-Jan-20 6:51
professionalglennPattonWork331-Jan-20 6:51 

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.