axiom-developer
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Axiom-developer] [axiom] Undefined Chunks behavior


From: root
Subject: [Axiom-developer] [axiom] Undefined Chunks behavior
Date: Tue, 19 Nov 2002 20:26:39 -0500

re: awk filter. 

Thanks.  I've avoided shell programming for all these years and
virtually never use awk. Changing the C code was my only viable option.
I'd already modified the C code by the time your first reply arrived.
Your solution is clearly better. 

Tim


===================================================================

 > Actually, it appears that the correct fix is to modify modules.c
 > (line 201 in modules.nw, line 117 in modules.c) to create a new,
 > dummy Module that expands into <<foo>> if foo is not found and
 > then calls expand on that.

Absolutely *don't* do this.  It is not necessary.

 > I don't see how to do this with filters. Perhaps I'm missing something.

Write an awk script that copies all lines to stdout, and in the
process, identifies each @use that has no corresponding @defn.
For each such @use emit this code chunk:

@begin code
@defn this is my text
@text <<this is my text>>
@end code



Norman

===================================================================

 > Norman,
 > 
 > I have included two patch files you can apply to change the
 > behavior for undefined chunks. 

What this problem needs is ten lines of awk.  Here's your noweb filter:

  #!/bin/sh
  
  awk '
  /address@hidden /  { uses [substr($0, 6)] = 1 }
  /address@hidden / { defns[substr($0, 7)] = 1 }
  { print }
  END {
    for (i in uses) 
      if (!defns[i])
        printf "@begin address@hidden address@hidden@text <<%s>>address@hidden 
code\n", i, i
  }'
  
  exit 0
  
  # test with
  
  sed '1,/test with/d' $0 | notangle -filter $0
  
  <<*>>=
  return x << 2 >> 2;
  @




reply via email to

[Prev in Thread] Current Thread [Next in Thread]