Sample Tangled Source Code

The following is the result of running tangle on the sample source file:

// File:convertInteger.nw Line:7 chunk:convertInteger.m + (int) convertInteger: (NSString*) inString { // File:convertInteger.nw Line:25 chunk:if string is null then exit with 0 if ( inString == NULL ) return 0; // File:convertInteger.nw Line:29 chunk:Find where the prefix character is in the string NSRange radixRange = [inString rangeOfString:@"r"]; if ( radixRange.location == NSNotFound) { // File:convertInteger.nw Line:33 chunk:decimal string found so return integer value directly return (int)[inString integerValue]; } else { // File:convertInteger.nw Line:37 chunk:radix value found so process remainder of string // File:convertInteger.nw Line:78 chunk:extract the prefix radix NSUInteger radixLength = radixRange.location; NSString *radixString = [inString substringToIndex:radixLength]; int radix = [radixString intValue]; // File:convertInteger.nw Line:84 chunk:set up return value int returnValue = 0; // File:convertInteger.nw Line:56 chunk:Set up loop variables NSRange charRange; // File:convertInteger.nw Line:56 chunk:Set up loop variables NSString *s; for ( int i = (int)radixLength+1; i < [inString length]; i++ ) { // File:convertInteger.nw Line:50 chunk:get next character into a string value s = [NSString stringWithFormat:@"%c", [inString characterAtIndex:i]]; // File:convertInteger.nw Line:62 chunk:get character range from list of possible digits charRange = [ @"0123456789ABCDEF" rangeOfCharacterFromSet: [NSCharacterSet characterSetWithCharactersInString: s]]; // File:convertInteger.nw Line:68 chunk:add the digit to the return value returnValue = radix * returnValue + (int)charRange.location; } } return returnValue; } // convertInteger

Running weave on the same sample source file produces a TeX file which can be processed (with the noweb style file available from here with the master distribution) to convertInteger.pdf.

Copyright 2016 Hugh Field-Richards. All Rights Reserved.