From: helly Date: Mon, 17 Apr 2006 20:16:15 +0000 (+0000) Subject: - Fixes by Derick X-Git-Tag: 0.13.6~366 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d0e0e194e88715ad4a5473ed602cc6035d47edcb;p=re2c - Fixes by Derick --- diff --git a/lessons/001_upn_calculator/calc_001.c b/lessons/001_upn_calculator/calc_001.c index a4171120..ab941e90 100755 --- a/lessons/001_upn_calculator/calc_001.c +++ b/lessons/001_upn_calculator/calc_001.c @@ -11,11 +11,11 @@ int scan(char *s, int l) { char *p = s; char *q = 0; - #define YYCTYPE char - #define YYCURSOR p - #define YYLIMIT (s+l) - #define YYMARKER q - #define YYFILL(n) +#define YYCTYPE char +#define YYCURSOR p +#define YYLIMIT (s+l) +#define YYMARKER q +#define YYFILL(n) for(;;) { diff --git a/lessons/001_upn_calculator/calc_001.re b/lessons/001_upn_calculator/calc_001.re index a810f18c..2b24404e 100755 --- a/lessons/001_upn_calculator/calc_001.re +++ b/lessons/001_upn_calculator/calc_001.re @@ -17,13 +17,13 @@ in this lesson. In the next example we see one way to get rid of it. . We use a 'for(;;)'-loop around the scanner block. We could have used a 'while(1)'-loop instead but some compilers generate a warning for it. - . To make the output more readable we use 're2c:indent:top' scanenr + . To make the output more readable we use 're2c:indent:top' scanner configuration that configures re2c to prepend a single tab (the default) to the beginning of each output line. . The following lines are expressions and for each expression we output the token name and continue the scanner loop. . The second last token detects the end of our input, the terminating zero in - out input string. In other scanners detecting the end of input may vary. + our input string. In other scanners detecting the end of input may vary. For example binary code may contain \0 as valid input. . The last expression accepts any input character. It tells re2c to accept the opposit of the empty range. This includes numbers and our tokens but @@ -49,11 +49,11 @@ int scan(char *s, int l) { char *p = s; char *q = 0; - #define YYCTYPE char - #define YYCURSOR p - #define YYLIMIT (s+l) - #define YYMARKER q - #define YYFILL(n) +#define YYCTYPE char +#define YYCURSOR p +#define YYLIMIT (s+l) +#define YYMARKER q +#define YYFILL(n) for(;;) { diff --git a/lessons/001_upn_calculator/calc_002.c b/lessons/001_upn_calculator/calc_002.c index b380d064..9d5758bd 100755 --- a/lessons/001_upn_calculator/calc_002.c +++ b/lessons/001_upn_calculator/calc_002.c @@ -19,11 +19,11 @@ int scan(char *s) char *p = s; char *l = s; char *q = 0; - #define YYCTYPE char - #define YYCURSOR p - #define YYLIMIT l - #define YYMARKER q - #define YYFILL(n) { if (!fill(p, n, &l)) break; } +#define YYCTYPE char +#define YYCURSOR p +#define YYLIMIT l +#define YYMARKER q +#define YYFILL(n) { if (!fill(p, n, &l)) break; } for(;;) { diff --git a/lessons/001_upn_calculator/calc_002.re b/lessons/001_upn_calculator/calc_002.re index 0f045241..9547cfaa 100755 --- a/lessons/001_upn_calculator/calc_002.re +++ b/lessons/001_upn_calculator/calc_002.re @@ -33,11 +33,11 @@ int scan(char *s) char *p = s; char *l = s; char *q = 0; - #define YYCTYPE char - #define YYCURSOR p - #define YYLIMIT l - #define YYMARKER q - #define YYFILL(n) { if (!fill(p, n, &l)) break; } +#define YYCTYPE char +#define YYCURSOR p +#define YYLIMIT l +#define YYMARKER q +#define YYFILL(n) { if (!fill(p, n, &l)) break; } for(;;) { diff --git a/lessons/001_upn_calculator/calc_003.c b/lessons/001_upn_calculator/calc_003.c index 2a2e65ff..6f2dcdc6 100755 --- a/lessons/001_upn_calculator/calc_003.c +++ b/lessons/001_upn_calculator/calc_003.c @@ -11,11 +11,11 @@ int scan(char *s, int l) { char *p = s; char *q = 0; - #define YYCTYPE char - #define YYCURSOR p - #define YYLIMIT (s+l+2) - #define YYMARKER q - #define YYFILL(n) { printf("OOD\n"); return 2; } +#define YYCTYPE char +#define YYCURSOR p +#define YYLIMIT (s+l+2) +#define YYMARKER q +#define YYFILL(n) { printf("OOD\n"); return 2; } for(;;) { diff --git a/lessons/001_upn_calculator/calc_003.re b/lessons/001_upn_calculator/calc_003.re index a868be55..b011fe97 100755 --- a/lessons/001_upn_calculator/calc_003.re +++ b/lessons/001_upn_calculator/calc_003.re @@ -25,11 +25,11 @@ int scan(char *s, int l) { char *p = s; char *q = 0; - #define YYCTYPE char - #define YYCURSOR p - #define YYLIMIT (s+l+2) - #define YYMARKER q - #define YYFILL(n) { printf("OOD\n"); return 2; } +#define YYCTYPE char +#define YYCURSOR p +#define YYLIMIT (s+l+2) +#define YYMARKER q +#define YYFILL(n) { printf("OOD\n"); return 2; } for(;;) { diff --git a/lessons/001_upn_calculator/calc_004.c b/lessons/001_upn_calculator/calc_004.c index 0cff796b..03ba4d63 100755 --- a/lessons/001_upn_calculator/calc_004.c +++ b/lessons/001_upn_calculator/calc_004.c @@ -22,11 +22,11 @@ int scan(char *s, int l) char *p = s; char *q = 0; char *t; - #define YYCTYPE char - #define YYCURSOR p - #define YYLIMIT (s+l+2) - #define YYMARKER q - #define YYFILL(n) { printf("OOD\n"); return 2; } +#define YYCTYPE char +#define YYCURSOR p +#define YYLIMIT (s+l+2) +#define YYMARKER q +#define YYFILL(n) { printf("OOD\n"); return 2; } for(;;) { diff --git a/lessons/001_upn_calculator/calc_004.re b/lessons/001_upn_calculator/calc_004.re index 885e8be3..9b621cef 100755 --- a/lessons/001_upn_calculator/calc_004.re +++ b/lessons/001_upn_calculator/calc_004.re @@ -37,11 +37,11 @@ int scan(char *s, int l) char *p = s; char *q = 0; char *t; - #define YYCTYPE char - #define YYCURSOR p - #define YYLIMIT (s+l+2) - #define YYMARKER q - #define YYFILL(n) { printf("OOD\n"); return 2; } +#define YYCTYPE char +#define YYCURSOR p +#define YYLIMIT (s+l+2) +#define YYMARKER q +#define YYFILL(n) { printf("OOD\n"); return 2; } for(;;) { diff --git a/lessons/001_upn_calculator/calc_005.c b/lessons/001_upn_calculator/calc_005.c index c7ff80be..0be831e3 100755 --- a/lessons/001_upn_calculator/calc_005.c +++ b/lessons/001_upn_calculator/calc_005.c @@ -57,11 +57,11 @@ int scan(char *s, int l) char *t; int res = 0; - #define YYCTYPE char - #define YYCURSOR p - #define YYLIMIT (s+l+1) - #define YYMARKER q - #define YYFILL(n) { return depth == 1 ? 0 : 2; } +#define YYCTYPE char +#define YYCURSOR p +#define YYLIMIT (s+l+1) +#define YYMARKER q +#define YYFILL(n) { return depth == 1 ? 0 : 2; } while(!res) { diff --git a/lessons/001_upn_calculator/calc_005.re b/lessons/001_upn_calculator/calc_005.re index ae4c4755..12cbee18 100755 --- a/lessons/001_upn_calculator/calc_005.re +++ b/lessons/001_upn_calculator/calc_005.re @@ -5,7 +5,7 @@ . We are going to write an UPN calculator so we need an additional rule to ignore white space. . Then we need to store the scanned input somewhere and do our math on it. - . Also we need to scann all arguments since the main c code gets the input + . Also we need to scan all arguments since the main c code gets the input split up into chunks. . In contrast to what we did before we now add a variable res that holds the scanner state. We initialize that variable to 0 and quit the loop when it @@ -71,11 +71,11 @@ int scan(char *s, int l) char *t; int res = 0; - #define YYCTYPE char - #define YYCURSOR p - #define YYLIMIT (s+l+1) - #define YYMARKER q - #define YYFILL(n) { return depth == 1 ? 0 : 2; } +#define YYCTYPE char +#define YYCURSOR p +#define YYLIMIT (s+l+1) +#define YYMARKER q +#define YYFILL(n) { return depth == 1 ? 0 : 2; } while(!res) { diff --git a/lessons/001_upn_calculator/calc_006.s.c b/lessons/001_upn_calculator/calc_006.s.c index 941b94c7..4c470e09 100755 --- a/lessons/001_upn_calculator/calc_006.s.c +++ b/lessons/001_upn_calculator/calc_006.s.c @@ -58,8 +58,8 @@ int scan(char *s) char *t; int res = 0; - #define YYCTYPE char - #define YYCURSOR p +#define YYCTYPE char +#define YYCURSOR p while(!res) { diff --git a/lessons/001_upn_calculator/calc_006.s.re b/lessons/001_upn_calculator/calc_006.s.re index a49ef287..6790bee4 100755 --- a/lessons/001_upn_calculator/calc_006.s.re +++ b/lessons/001_upn_calculator/calc_006.s.re @@ -87,8 +87,8 @@ int scan(char *s) char *t; int res = 0; - #define YYCTYPE char - #define YYCURSOR p +#define YYCTYPE char +#define YYCURSOR p while(!res) { diff --git a/lessons/001_upn_calculator/calc_007.b.c b/lessons/001_upn_calculator/calc_007.b.c index 5ea4b190..c60bfe29 100755 --- a/lessons/001_upn_calculator/calc_007.b.c +++ b/lessons/001_upn_calculator/calc_007.b.c @@ -58,8 +58,8 @@ int scan(char *s) char *t; int res = 0; - #define YYCTYPE char - #define YYCURSOR p +#define YYCTYPE char +#define YYCURSOR p while(!res) { diff --git a/lessons/001_upn_calculator/calc_007.b.re b/lessons/001_upn_calculator/calc_007.b.re index 25263120..3ebc9199 100755 --- a/lessons/001_upn_calculator/calc_007.b.re +++ b/lessons/001_upn_calculator/calc_007.b.re @@ -61,8 +61,8 @@ int scan(char *s) char *t; int res = 0; - #define YYCTYPE char - #define YYCURSOR p +#define YYCTYPE char +#define YYCURSOR p while(!res) { diff --git a/lessons/001_upn_calculator/windows/main.b.c b/lessons/001_upn_calculator/windows/main.b.c index 71ea696d..78d03fdb 100755 --- a/lessons/001_upn_calculator/windows/main.b.c +++ b/lessons/001_upn_calculator/windows/main.b.c @@ -42,11 +42,11 @@ int ScanFullSpeed(char *pzStrToScan, size_t lenStrToScan) { char *pzCurScanPos = pzStrToScan; char *pzBacktrackInfo = 0; - #define YYCTYPE char - #define YYCURSOR pzCurScanPos - #define YYLIMIT (pzStrToScan+lenStrToScan) - #define YYMARKER pzBacktrackInfo - #define YYFILL(n) +#define YYCTYPE char +#define YYCURSOR pzCurScanPos +#define YYLIMIT (pzStrToScan+lenStrToScan) +#define YYMARKER pzBacktrackInfo +#define YYFILL(n) for(;;) { @@ -171,11 +171,11 @@ int scan(char *pzStrToScan, size_t lenStrToScan) { char *pzCurScanPos = pzStrToScan; char *pzBacktrackInfo = 0; - #define YYCTYPE char - #define YYCURSOR pzCurScanPos - #define YYLIMIT (pzStrToScan+lenStrToScan) - #define YYMARKER pzBacktrackInfo - #define YYFILL(n) +#define YYCTYPE char +#define YYCURSOR pzCurScanPos +#define YYLIMIT (pzStrToScan+lenStrToScan) +#define YYMARKER pzBacktrackInfo +#define YYFILL(n) for(;;) { diff --git a/lessons/001_upn_calculator/windows/main.b.re b/lessons/001_upn_calculator/windows/main.b.re index efee5d88..3e2abf80 100755 --- a/lessons/001_upn_calculator/windows/main.b.re +++ b/lessons/001_upn_calculator/windows/main.b.re @@ -17,13 +17,13 @@ in this lesson. In the next example we see one way to get rid of it. . We use a 'for(;;)'-loop around the scanner block. We could have used a 'while(1)'-loop instead but some compilers generate a warning for it. - . To make the output more readable we use 're2c:indent:top' scanenr + . To make the output more readable we use 're2c:indent:top' scanner configuration that configures re2c to prepend a single tab (the default) to the beginning of each output line. . The following lines are expressions and for each expression we output the token name and continue the scanner loop. . The second last token detects the end of our input, the terminating zero in - out input string. In other scanners detecting the end of input may vary. + our input string. In other scanners detecting the end of input may vary. For example binary code may contain \0 as valid input. . The last expression accepts any input character. It tells re2c to accept the opposit of the empty range. This includes numbers and our tokens but @@ -80,11 +80,11 @@ int ScanFullSpeed(char *pzStrToScan, size_t lenStrToScan) { char *pzCurScanPos = pzStrToScan; char *pzBacktrackInfo = 0; - #define YYCTYPE char - #define YYCURSOR pzCurScanPos - #define YYLIMIT (pzStrToScan+lenStrToScan) - #define YYMARKER pzBacktrackInfo - #define YYFILL(n) +#define YYCTYPE char +#define YYCURSOR pzCurScanPos +#define YYLIMIT (pzStrToScan+lenStrToScan) +#define YYMARKER pzBacktrackInfo +#define YYFILL(n) for(;;) { @@ -107,11 +107,11 @@ int scan(char *pzStrToScan, size_t lenStrToScan) { char *pzCurScanPos = pzStrToScan; char *pzBacktrackInfo = 0; - #define YYCTYPE char - #define YYCURSOR pzCurScanPos - #define YYLIMIT (pzStrToScan+lenStrToScan) - #define YYMARKER pzBacktrackInfo - #define YYFILL(n) +#define YYCTYPE char +#define YYCURSOR pzCurScanPos +#define YYLIMIT (pzStrToScan+lenStrToScan) +#define YYMARKER pzBacktrackInfo +#define YYFILL(n) for(;;) { diff --git a/lessons/002_strip_comments/strip_001.s.re b/lessons/002_strip_comments/strip_001.s.re index ca735180..5466fcea 100755 --- a/lessons/002_strip_comments/strip_001.s.re +++ b/lessons/002_strip_comments/strip_001.s.re @@ -20,7 +20,7 @@ - multiple scanner blocks . We use a main scanner block that outputs every input character unless the - input is two /s or a / followed by a *. In the lattertwo cases we switch + input is two /s or a / followed by a *. In the latter two cases we switch to a special c++ comment and a comment block respectively. . Both special blocks simply detect their end ignore any other character. . The c++ block is a bit special. Since the terminating new line needs to diff --git a/lessons/002_strip_comments/strip_002.s.re b/lessons/002_strip_comments/strip_002.s.re index 21f11d0b..c18d3784 100755 --- a/lessons/002_strip_comments/strip_002.s.re +++ b/lessons/002_strip_comments/strip_002.s.re @@ -2,7 +2,7 @@ /*!ignore:re2c - complexity - . When a comemnt is preceeded by a new line and followed by whitespace and a + . When a comment is preceeded by a new line and followed by whitespace and a new line then we can drop the trailing whitespace and new line. . Additional to what we strip out already what about two consequtive comment blocks? When two comments are only separated by whitespace we want to drop diff --git a/lessons/002_strip_comments/strip_003.b.re b/lessons/002_strip_comments/strip_003.b.re index 065d31ab..b53cee05 100755 --- a/lessons/002_strip_comments/strip_003.b.re +++ b/lessons/002_strip_comments/strip_003.b.re @@ -27,11 +27,11 @@ - formatting . Until now we only used single line expression code and we always had the opening { on the same line as the rule itself. If we have multiline rule - code and care for formatting we can nolonger rely on re2c. Now we have + code and care for formatting we can no longer rely on re2c. Now we have to indent the rule code ourself. Also we need to take care of the opening {. If we keep it on the same line as the rule then re2c will indent it correctly and the emitted #line informations will be correct. If we place - it on the next line then the #line directivy will also point to that line + it on the next line then the #line directive will also point to that line and not to the rule. */ diff --git a/lessons/readme.txt b/lessons/readme.txt index 2d26179c..d445a0d4 100755 --- a/lessons/readme.txt +++ b/lessons/readme.txt @@ -2,19 +2,19 @@ re2c lessons, (c) M. Boerger 2006 001_upn_calculator - This lesson gets you started with re2c. In the end you will have an easy UPN - calculator for use at command line. + This lesson gets you started with re2c. In the end you will have an easy + RPN calculator for use at command line. - You will learn about the basic interface of re2c when scanning input strings. - How to detect the end of the input and use that to stop scanning in order to - avoid problems. + You will learn about the basic interface of re2c when scanning input + strings. How to detect the end of the input and use that to stop scanning + in order to avoid problems. The lesson also contains a windows subdirectory to get you started in the Microsoft world. 002_strip_comments - In this lesson you will learn how to use multiple scanner blocks and how to - read the input from a file instead of a zero terminated string. In the end you - will have a scanner that filters comments out of c source files but keeps re2c - comments. + In this lesson you will learn how to use multiple scanner blocks and how + to read the input from a file instead of a zero terminated string. In the + end you will have a scanner that filters comments out of c source files + but keeps re2c comments.