FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help please - why isn't this lmn file working?

 
Post new topic   Reply to topic     Forum Index -> The Language Machine
View previous topic :: View next topic  
Author Message
gamerChad



Joined: 13 Aug 2005
Posts: 21
Location: Cydonia, Mars

PostPosted: Sat Jul 28, 2007 8:35 pm    Post subject: Help please - why isn't this lmn file working? Reply with quote

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
View user's profile Send private message
gamerChad



Joined: 13 Aug 2005
Posts: 21
Location: Cydonia, Mars

PostPosted: Tue Jul 31, 2007 10:24 pm    Post subject: Reply with quote

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
View user's profile Send private message
gamerChad



Joined: 13 Aug 2005
Posts: 21
Location: Cydonia, Mars

PostPosted: Thu Aug 02, 2007 4:17 pm    Post subject: Reply with quote

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 Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> The Language Machine All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group