View previous topic :: View next topic |
Author |
Message |
gamerChad
Joined: 13 Aug 2005 Posts: 21 Location: Cydonia, Mars
|
Posted: Sat Jul 28, 2007 8:35 pm Post subject: Help please - why isn't this lmn file working? |
|
|
As a pedagogical exercise, I decided to try and match a very basic subset of the #define and #undef c preprocessor patterns. To make sure it's doing what it's supposed to be doing, I try to have it replace all of the #define and #undef lines with "Define Here!\n" and "Undef here!n".
This doesn't work though; it compiles, but when run on an input file, it simple outputs nothing.
Code: |
.cpp(10L)
- out <- eof - ;
- nl <- eof - '\n';
- slws <- nl - ' ';
- cppMacro define <- slws - "Define here!\n";
- cppMacro undef <- slws - "Undef here!n";
'#' { option slws } 'define' slws identifier slws literal { option slws } nl <- cppMacro define;
'#' { option slws } 'define' slws identifier slws identifier { option slws } nl <- cppMacro define;
'#' { option slws } 'undef' slws identifier { option slws } nl <- cppMacro undef;
.cpp(12L)
- hspace { repeat hspace } <- cppMacro - slws; // same line white space
.cpp(18L)
.[_a-zA-Z] { repeat .[_a-zA-Z0-9] } <- identifier;
.[0-9] { repeat .[0-9] } <- literal;
.cpp(20L)
'\r' <- nl;
'\n' <- nl;
.cpp()
.[\r\n] <- nl;
' ' <- hspace;
'\t' <- hspace;
|
Here's the input file I ran it on:
Code: | abc
# define abc 3
<insert some random text here>
# undef abc
abc |
Any idea what's wrong?
I don't think I'll even be able to understand why the thing works, I just need to get some working design patterns going so I can write useful stuff with lm. At that point I can probably start figuring out details and understanding what is actually going on, as I did when I (successfully) learned imperative/procedural programming.
TIA |
|
Back to top |
|
|
gamerChad
Joined: 13 Aug 2005 Posts: 21 Location: Cydonia, Mars
|
Posted: Tue Jul 31, 2007 10:24 pm Post subject: |
|
|
Just thought I'd mention:
As unlikely as I thought it was, I think my problems might be due to modifications I made to lm in my attempts to make it compile. See my other recent post for details. I'll see how this goes when I manage to get gdc working. |
|
Back to top |
|
|
gamerChad
Joined: 13 Aug 2005 Posts: 21 Location: Cydonia, Mars
|
Posted: Thu Aug 02, 2007 4:17 pm Post subject: |
|
|
OK I worked around that. My setup is working now, and I made a simple hello world type program in lmn. It works and produces correct output. My cpp-ish code in the original post still doesn't produce any output, and I'd still like to know why |
|
Back to top |
|
|
|