]> granicus.if.org Git - re2c/commitdiff
- Update lessons
authorhelly <helly@642ea486-5414-0410-9d7f-a0204ed87703>
Mon, 17 Apr 2006 14:14:17 +0000 (14:14 +0000)
committerhelly <helly@642ea486-5414-0410-9d7f-a0204ed87703>
Mon, 17 Apr 2006 14:14:17 +0000 (14:14 +0000)
32 files changed:
lessons/001_upn_calculator/calc_001.c
lessons/001_upn_calculator/calc_001.re
lessons/001_upn_calculator/calc_002.c
lessons/001_upn_calculator/calc_002.re
lessons/001_upn_calculator/calc_003.c
lessons/001_upn_calculator/calc_003.re
lessons/001_upn_calculator/calc_004.c
lessons/001_upn_calculator/calc_004.re
lessons/001_upn_calculator/calc_005.c
lessons/001_upn_calculator/calc_005.re
lessons/001_upn_calculator/calc_006.s.c
lessons/001_upn_calculator/calc_006.s.re
lessons/001_upn_calculator/calc_007.b.c
lessons/001_upn_calculator/calc_007.b.re
lessons/001_upn_calculator/readme.txt
lessons/001_upn_calculator/windows/.cvsignore [new file with mode: 0755]
lessons/001_upn_calculator/windows/BuildAndRun.bat [new file with mode: 0755]
lessons/001_upn_calculator/windows/HiResTimer.h [new file with mode: 0755]
lessons/001_upn_calculator/windows/TestRe2c-2005.sln [new file with mode: 0755]
lessons/001_upn_calculator/windows/TestRe2c-2005.vcproj [new file with mode: 0755]
lessons/001_upn_calculator/windows/TestRe2c.dsp [new file with mode: 0755]
lessons/001_upn_calculator/windows/TestRe2c.dsw [new file with mode: 0755]
lessons/001_upn_calculator/windows/TestRe2c.sln [new file with mode: 0755]
lessons/001_upn_calculator/windows/TestRe2c.vcproj [new file with mode: 0755]
lessons/001_upn_calculator/windows/main.b.c [new file with mode: 0755]
lessons/001_upn_calculator/windows/main.b.re [new file with mode: 0755]
lessons/002_strip_comments/readme.txt
lessons/002_strip_comments/strip_001.s.c
lessons/002_strip_comments/strip_001.s.re
lessons/002_strip_comments/strip_002.s.c
lessons/002_strip_comments/strip_002.s.re
lessons/readme.txt [new file with mode: 0755]

index 8a9c2e936917dc3df4cc8a6a14b1ae1bfe168e2a..a4171120fa8d6501cb99425bc5026c4270a907d9 100755 (executable)
@@ -1,6 +1,6 @@
 /* Generated by re2c */
 #line 1 "calc_001.re"
-/* re2c lesson_001, calc_001, (c) M. Boerger 2006 */
+/* re2c lesson 001_upn_calculator, calc_001, (c) M. Boerger 2006 */
 #line 43 "calc_001.re"
 
 #include <stdlib.h>
index 911f89bf8cb2cf4e225a342e9e17614141daae8d..a810f18cd21e1435d534e702b7f32e688b1ec6b9 100755 (executable)
@@ -1,4 +1,4 @@
-/* re2c lesson_001, calc_001, (c) M. Boerger 2006 */
+/* re2c lesson 001_upn_calculator, calc_001, (c) M. Boerger 2006 */
 /*!ignore:re2c
 
 - basic interface for string reading
@@ -12,7 +12,7 @@
     expression handlers, the code blocks after re2c expressions, this can be 
     used to identify the end of the token.
   . YYMARKER is not always being used so we set an initial value to avoid
-    a compiler warning.
+    a compiler warning. Here we could also omit it compleley.
   . YYLIMIT stores the end of the input. Unfortunatley we have to use strlen() 
     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
index c1810aee98062b2c12dd03ffb51fc54a1501ae59..b380d064eb8c0ef5d7d1e36dfdfaf06c87dd1300 100755 (executable)
@@ -1,6 +1,6 @@
 /* Generated by re2c */
 #line 1 "calc_002.re"
-/* re2c lesson_001, calc_002, (c) M. Boerger 2006 */
+/* re2c lesson 001_upn_calculator, calc_002, (c) M. Boerger 2006 */
 #line 19 "calc_002.re"
 
 #include <stdlib.h>
index e8dadae3eede17b4b550e8f9b448fc8e622b52b4..0f045241989791532680487a37f28cdb2630141e 100755 (executable)
@@ -1,4 +1,4 @@
-/* re2c lesson_001, calc_002, (c) M. Boerger 2006 */
+/* re2c lesson 001_upn_calculator, calc_002, (c) M. Boerger 2006 */
 /*!ignore:re2c
 
 - making use of YYFILL
index 763e5eb3d190ccea91773a5ab0147552951a7aec..2a2e65ff7c5f10dc7b8cad40cb14ad2f29b38982 100755 (executable)
@@ -1,6 +1,6 @@
 /* Generated by re2c */
 #line 1 "calc_003.re"
-/* re2c lesson_001, calc_003, (c) M. Boerger 2006 */
+/* re2c lesson 001_upn_calculator, calc_003, (c) M. Boerger 2006 */
 #line 19 "calc_003.re"
 
 #include <stdlib.h>
index 4112cb3c4ba825d11f2cde9f6192ba01f67dda9c..a868be55112e6f2e71a17eea60ad75bfd1b97f0e 100755 (executable)
@@ -1,4 +1,4 @@
-/* re2c lesson_001, calc_003, (c) M. Boerger 2006 */
+/* re2c lesson 001_upn_calculator, calc_003, (c) M. Boerger 2006 */
 /*!ignore:re2c
 
 - making use of YYFILL
index d830ef2123872b2463c840f84542f4ea517810fc..0cff796b2f8f4db76be7f46a698682d00ef54865 100755 (executable)
@@ -1,6 +1,6 @@
 /* Generated by re2c */
 #line 1 "calc_004.re"
-/* re2c lesson_001, calc_004, (c) M. Boerger 2006 */
+/* re2c lesson 001_upn_calculator, calc_004, (c) M. Boerger 2006 */
 #line 20 "calc_004.re"
 
 #include <stdlib.h>
index f892afb98e32e0854d0e466c8444333b2c7028ef..885e8be3f8f06a12805756a62a037ad1fa8b28e8 100755 (executable)
@@ -1,4 +1,4 @@
-/* re2c lesson_001, calc_004, (c) M. Boerger 2006 */
+/* re2c lesson 001_upn_calculator, calc_004, (c) M. Boerger 2006 */
 /*!ignore:re2c
 
 - making use of definitions
index 6babb6348fb7fceaf4c6a2f4e71045058ff543f3..c7ff80bee35e66b07eaa2c79c95f628bf02b9eae 100755 (executable)
@@ -1,6 +1,6 @@
 /* Generated by re2c */
 #line 1 "calc_005.re"
-/* re2c lesson_001, calc_005, (c) M. Boerger 2006 */
+/* re2c lesson 001_upn_calculator, calc_005, (c) M. Boerger 2006 */
 #line 19 "calc_005.re"
 
 #include <stdlib.h>
index 9e3c50b4e8032200a2970761c100af9215785302..ae4c475592df65e1d189fd0dcdfc40a94a035eed 100755 (executable)
@@ -1,4 +1,4 @@
-/* re2c lesson_001, calc_005, (c) M. Boerger 2006 */
+/* re2c lesson 001_upn_calculator, calc_005, (c) M. Boerger 2006 */
 /*!ignore:re2c
 
 - turning this lesson into an easy calculator
index 66b4e292c7dff59ea74515c61e88bc40fde860fc..941b94c7b6d45b75cc045af828409a453b3811b9 100755 (executable)
@@ -1,6 +1,6 @@
 /* Generated by re2c */
 #line 1 "calc_006.s.re"
-/* re2c lesson_001, calc_006, (c) M. Boerger 2006 */
+/* re2c lesson 001_upn_calculator, calc_006, (c) M. Boerger 2006 */
 #line 34 "calc_006.s.re"
 
 #include <stdlib.h>
index 830af3dd2dce8b75f0cd03af40e2e46aada0a48f..a49ef287259f8bfe0d794fb67fac1d83d38d7666 100755 (executable)
@@ -1,4 +1,4 @@
-/* re2c lesson_001, calc_006, (c) M. Boerger 2006 */
+/* re2c lesson 001_upn_calculator, calc_006, (c) M. Boerger 2006 */
 /*!ignore:re2c
 
 - avoiding YYFILL()
index 66d5b368c86e5eeb79d3b1915c72a67035bfdc89..5ea4b19010b360815ce68e3471894362a8bedbbd 100755 (executable)
@@ -1,6 +1,6 @@
 /* Generated by re2c */
 #line 1 "calc_007.b.re"
-/* re2c lesson_001, calc_007, (c) M. Boerger 2006 */
+/* re2c lesson 001_upn_calculator, calc_007, (c) M. Boerger 2006 */
 #line 8 "calc_007.b.re"
 
 #include <stdlib.h>
index 469ae5e13666a348e432fae8c6c19891a67b9d6f..2526312033133ba3a85b63b0df41e0bc049a532a 100755 (executable)
@@ -1,4 +1,4 @@
-/* re2c lesson_001, calc_007, (c) M. Boerger 2006 */
+/* re2c lesson 001_upn_calculator, calc_007, (c) M. Boerger 2006 */
 /*!ignore:re2c
 
 - optimizing the generated code by using -b command line switch of re2c
index 62860bb396495b277bf13965c364aed1560d98d1..321b65e9aaa75756c781579373bb7eb0aa5a739e 100755 (executable)
@@ -1,4 +1,4 @@
-re2c lesson_001, (c) M. Boerger 2006
+re2c lesson 001_upn_calculator, (c) M. Boerger 2006
 
 This lesson gets you started with re2c. In the end you will have an easy UPN
 calculator for use at command line.
@@ -15,7 +15,13 @@ directory and execute the following command:
 
   re2c calc_001.re > test.c
 
-Then use your compiler to compile that code and run it.
+Then use your compiler to compile that code and run it. If you are using gcc
+you simply do the following:
+
+  gcc -o test.o test.c
+  ./test.o <input_file_name>
+
+If you are using windows you might want to read till the end of this lesson.
 
 When you want to debug the code it helps to make re2c generate working #line
 information. To do so you simply specify the output file using the -o switch 
@@ -38,3 +44,35 @@ Finally we use the -b switch to have the code use a decision table. The -b
 switch also contains the -s behavior. 
 
   re2c -b -o test.c calc_007.b.re
+
+
+
+-------------------------------------------------------------------------------
+
+For windows users Lynn Allen provided some additional stuff to get you started 
+in the Microsoft world. This addon resides in the windows subdirectory and 
+gives you something to expereiment with. The code in that directory is based 
+on the first step and has the following changes:
+
+* vc6 .dsp/.dsw and vc7/vc8 .sln/.vcproj project files that have "Custom Build 
+Steps" that can tell when main.re changes, and know how to generate main.c 
+from main.re. They assume that you unpacked the zip package and have re2c
+itself build or installed in Release and Release-2005 directory respectively.
+If re2c cannot be found you need to modify the custom build step and correct
+the path to re2c.
+
+* BuildAndRun.bat to do command line rec2 and then cl and then run the 
+executable (discontinues with message if errors).
+
+* built-in cppunit-like test to confirm it worked as expected.
+
+* array of test strings "fed" to scan rather than file contents to facilitate 
+testing and also reduce the newbie learning curve.
+
+* HiResTimer output for 10,000 loops and 100,000 loops. While this might be 
+excessive for this lesson, it illustrates how to do it for subsequent lessons
+and your own stuff using windows. Also it shows that Release build is as fast 
+as strncmp for this test and can probably be made significantly faster.
+
+* If you want to build the other steps of this lesson using windows tools 
+simply copy the *.re files into the windows directory as main.re and rebuild.
diff --git a/lessons/001_upn_calculator/windows/.cvsignore b/lessons/001_upn_calculator/windows/.cvsignore
new file mode 100755 (executable)
index 0000000..ab030f2
--- /dev/null
@@ -0,0 +1,11 @@
+*.diff
+*.exe
+*.ncb
+*.opt
+*.plg
+*.scc
+*.suo
+*.temp
+*.user
+Debug
+Release
diff --git a/lessons/001_upn_calculator/windows/BuildAndRun.bat b/lessons/001_upn_calculator/windows/BuildAndRun.bat
new file mode 100755 (executable)
index 0000000..e40a7d4
--- /dev/null
@@ -0,0 +1,48 @@
+@echo OFF
+goto Start
+rem BuildAndRun.bat  06-Apr-15  lda
+rem Assumes re2c.exe findable with PATH or . or .. or ..\.. or $(RE2C_HOME)
+rem Assumes cl.exe findable with PATH or VcToolKit2003 installed
+
+:Start
+if exist %RE2C_HOME%\re2c.exe goto ProceedWithGenerate
+if exist .\re2c.exe set RE2C_HOME=.
+if exist ..\re2c.exe set RE2C_HOME=..
+if exist ..\..\re2c.exe set RE2C_HOME=..\..
+if exist ..\..\..\re2c.exe set RE2C_HOME=..\..\..
+if exist ..\..\..\Release\re2c.exe set RE2C_HOME=..\..\..\Release
+if exist ..\..\..\Release-2005\re2c.exe set RE2C_HOME=..\..\..\Release-2005
+if not exist %RE2C_HOME%\re2c.exe goto ReportSetupError
+
+:ProceedWithGenerate
+set BASE_FILE_NAME=main
+%RE2C_HOME%\re2c -b -o%BASE_FILE_NAME%.c %BASE_FILE_NAME%.re
+rem echo ErrorLevel is set to %ERRORLEVEL% after re2c
+IF ERRORLEVEL 1 goto ReportRe2cError
+
+rem (to test) set path=
+cl 1>nul 2>nul
+IF ERRORLEVEL 1 goto AttemptToSetupCompiler
+goto ProceedWithCompile
+
+:AttemptToSetupCompiler
+echo ErrorLevel is set to %ERRORLEVEL% after blank cl command line
+call %VCToolkitInstallDir%\vcvars32.bat 1>nul 2>nul
+cl 1>nul 2>nul
+IF ERRORLEVEL 1 goto ReportClError
+
+:ProceedWithCompile
+cl -O2 /DNDEBUG /D_CONSOLE /DWIN32 %BASE_FILE_NAME%.c
+rem echo ErrorLevel is set to %ERRORLEVEL% after cl
+IF ERRORLEVEL 1 goto ReportClError
+%BASE_FILE_NAME%
+goto AllDone
+
+:ReportSetupError
+echo re2c.exe not found in ., .., ..\.., ..\..\.., ..\..\..\Release 
+echo or ..\..\..\Release-2005 Environment variable RE2C_HOME invalid or not set? 
+
+:ReportClError
+:ReportRe2cError
+:AllDone
+pause
diff --git a/lessons/001_upn_calculator/windows/HiResTimer.h b/lessons/001_upn_calculator/windows/HiResTimer.h
new file mode 100755 (executable)
index 0000000..585a1d9
--- /dev/null
@@ -0,0 +1,54 @@
+/** 
+ * @file HiResTimer.h
+ * @brief 
+ * @note 
+ */
+
+#ifndef _HI_RES_TIMER_H_
+#define _HI_RES_TIMER_H_
+
+#ifdef WIN32
+#include <windows.h>  // probably already done in stdafx.h
+static LARGE_INTEGER start;
+static LARGE_INTEGER stop;
+static LARGE_INTEGER freq;
+static _int64 elapsedCounts;
+static double elapsedMillis;
+static double elapsedMicros;
+static HANDLE processHandle;
+static DWORD  prevPriorityClass;
+
+void HrtInit()
+{
+   processHandle = GetCurrentProcess();
+   prevPriorityClass = GetPriorityClass(processHandle);
+   QueryPerformanceFrequency(&freq);
+}
+
+void HrtStart()
+{
+   QueryPerformanceCounter(&start);
+}
+
+void HrtSetPriority(DWORD priority)
+{
+   int flag;
+   prevPriorityClass = GetPriorityClass(processHandle);
+   flag = SetPriorityClass(processHandle, priority);
+}
+
+void HrtResetPriority(void)
+{
+   int flag = SetPriorityClass(processHandle, prevPriorityClass);
+}
+
+double HrtElapsedMillis()
+{
+   QueryPerformanceCounter(&stop);
+   elapsedCounts = (stop.QuadPart - start.QuadPart);
+   elapsedMillis = ((elapsedCounts * 1000.0) / freq.QuadPart);
+   return elapsedMillis;
+}
+
+#endif
+#endif
\ No newline at end of file
diff --git a/lessons/001_upn_calculator/windows/TestRe2c-2005.sln b/lessons/001_upn_calculator/windows/TestRe2c-2005.sln
new file mode 100755 (executable)
index 0000000..1b4b4e5
--- /dev/null
@@ -0,0 +1,19 @@
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual Studio 2005
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestRe2c", "TestRe2c-2005.vcproj", "{E2CEB3D0-066A-4C9A-B32C-B2197448A57A}"
+EndProject
+Global
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution
+               Debug|Default = Debug|Default
+               Release|Default = Release|Default
+       EndGlobalSection
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution
+               {E2CEB3D0-066A-4C9A-B32C-B2197448A57A}.Debug|Default.ActiveCfg = Debug|Win32
+               {E2CEB3D0-066A-4C9A-B32C-B2197448A57A}.Debug|Default.Build.0 = Debug|Win32
+               {E2CEB3D0-066A-4C9A-B32C-B2197448A57A}.Release|Default.ActiveCfg = Release|Win32
+               {E2CEB3D0-066A-4C9A-B32C-B2197448A57A}.Release|Default.Build.0 = Release|Win32
+       EndGlobalSection
+       GlobalSection(SolutionProperties) = preSolution
+               HideSolutionNode = FALSE
+       EndGlobalSection
+EndGlobal
diff --git a/lessons/001_upn_calculator/windows/TestRe2c-2005.vcproj b/lessons/001_upn_calculator/windows/TestRe2c-2005.vcproj
new file mode 100755 (executable)
index 0000000..1d3582b
--- /dev/null
@@ -0,0 +1,252 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+       ProjectType="Visual C++"
+       Version="8,00"
+       Name="TestRe2c"
+       ProjectGUID="{E2CEB3D0-066A-4C9A-B32C-B2197448A57A}"
+       >
+       <Platforms>
+               <Platform
+                       Name="Win32"
+               />
+       </Platforms>
+       <ToolFiles>
+       </ToolFiles>
+       <Configurations>
+               <Configuration
+                       Name="Debug|Win32"
+                       OutputDirectory=".\Debug"
+                       IntermediateDirectory=".\Debug"
+                       ConfigurationType="1"
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+                       UseOfMFC="0"
+                       ATLMinimizesCRunTimeLibraryUsage="false"
+                       CharacterSet="2"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                               TypeLibraryName=".\Debug/TestRe2c.tlb"
+                               HeaderFileName=""
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="0"
+                               PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE"
+                               BasicRuntimeChecks="3"
+                               RuntimeLibrary="1"
+                               UsePrecompiledHeader="0"
+                               PrecompiledHeaderThrough=""
+                               AssemblerListingLocation=".\Debug/"
+                               ObjectFile=".\Debug/"
+                               ProgramDataBaseFileName=".\Debug/"
+                               WarningLevel="3"
+                               SuppressStartupBanner="true"
+                               DebugInformationFormat="4"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                               PreprocessorDefinitions="_DEBUG"
+                               Culture="1033"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               OutputFile=".\Debug/TestRe2c.exe"
+                               LinkIncremental="0"
+                               SuppressStartupBanner="true"
+                               GenerateDebugInformation="true"
+                               ProgramDatabaseFile=".\Debug/TestRe2c.pdb"
+                               SubSystem="1"
+                               TargetMachine="1"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCWebDeploymentTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+               <Configuration
+                       Name="Release|Win32"
+                       OutputDirectory=".\Release"
+                       IntermediateDirectory=".\Release"
+                       ConfigurationType="1"
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+                       UseOfMFC="0"
+                       ATLMinimizesCRunTimeLibraryUsage="false"
+                       CharacterSet="2"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                               TypeLibraryName=".\Release/TestRe2c.tlb"
+                               HeaderFileName=""
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               AdditionalOptions="/O2"
+                               Optimization="2"
+                               InlineFunctionExpansion="1"
+                               PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE"
+                               StringPooling="true"
+                               RuntimeLibrary="0"
+                               EnableFunctionLevelLinking="true"
+                               UsePrecompiledHeader="0"
+                               PrecompiledHeaderThrough=""
+                               AssemblerListingLocation=".\Release/"
+                               ObjectFile=".\Release/"
+                               ProgramDataBaseFileName=".\Release/"
+                               WarningLevel="3"
+                               SuppressStartupBanner="true"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                               PreprocessorDefinitions="NDEBUG"
+                               Culture="1033"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               OutputFile=".\Release/TestRe2c.exe"
+                               LinkIncremental="0"
+                               SuppressStartupBanner="true"
+                               ProgramDatabaseFile=".\Release/TestRe2c.pdb"
+                               SubSystem="1"
+                               TargetMachine="1"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCWebDeploymentTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+       </Configurations>
+       <References>
+       </References>
+       <Files>
+               <Filter
+                       Name="Source Files"
+                       Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+                       >
+                       <File
+                               RelativePath="main.b.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               Optimization="0"
+                                               PreprocessorDefinitions=""
+                                               BasicRuntimeChecks="3"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               Optimization="2"
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="main.b.re"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCustomBuildTool"
+                                               Description="Generate $(InputName).c from $(InputName).re using Re2c"
+                                               CommandLine="..\..\..\Release-2005\re2c.exe -b -o$(InputName).c $(InputName).re&#x0D;&#x0A;"
+                                               Outputs="$(InputName).c"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCustomBuildTool"
+                                               Description="Generate $(InputName).c from $(InputName).re using Re2c"
+                                               CommandLine="..\..\..\Rlease-2005\re2c.exe -b -o$(InputName).c $(InputName).re&#x0D;&#x0A;"
+                                               Outputs="$(InputName).c"
+                                       />
+                               </FileConfiguration>
+                       </File>
+               </Filter>
+       </Files>
+       <Globals>
+       </Globals>
+</VisualStudioProject>
diff --git a/lessons/001_upn_calculator/windows/TestRe2c.dsp b/lessons/001_upn_calculator/windows/TestRe2c.dsp
new file mode 100755 (executable)
index 0000000..7eb9463
--- /dev/null
@@ -0,0 +1,124 @@
+# Microsoft Developer Studio Project File - Name="TestRe2c" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** NICHT BEARBEITEN **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=TestRe2c - Win32 Debug
+!MESSAGE Dies ist kein gültiges Makefile. Zum Erstellen dieses Projekts mit NMAKE
+!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und führen Sie den Befehl
+!MESSAGE 
+!MESSAGE NMAKE /f "TestRe2c.mak".
+!MESSAGE 
+!MESSAGE Sie können beim Ausführen von NMAKE eine Konfiguration angeben
+!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel:
+!MESSAGE 
+!MESSAGE NMAKE /f "TestRe2c.mak" CFG="TestRe2c - Win32 Debug"
+!MESSAGE 
+!MESSAGE Für die Konfiguration stehen zur Auswahl:
+!MESSAGE 
+!MESSAGE "TestRe2c - Win32 Release" (basierend auf  "Win32 (x86) Console Application")
+!MESSAGE "TestRe2c - Win32 Debug" (basierend auf  "Win32 (x86) Console Application")
+!MESSAGE 
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=xicl6.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "TestRe2c - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
+# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=xilink6.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+
+!ELSEIF  "$(CFG)" == "TestRe2c - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c
+# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=xilink6.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+
+!ENDIF 
+
+# Begin Target
+
+# Name "TestRe2c - Win32 Release"
+# Name "TestRe2c - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\main.b.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\main.b.re
+
+!IF  "$(CFG)" == "TestRe2c - Win32 Release"
+
+# Begin Custom Build - Generate $(InputName).c from $(InputName).re using Re2c
+InputPath=.\main.b.re
+InputName=main.b
+
+"$(InputName).c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+       ..\..\..\Release-2005\re2c -b -o$(InputName).c $(InputName).re
+
+# End Custom Build
+
+!ELSEIF  "$(CFG)" == "TestRe2c - Win32 Debug"
+
+# Begin Custom Build - Generate $(InputName).c from $(InputName).re using Re2c
+InputPath=.\main.b.re
+InputName=main.b
+
+"$(InputName).c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+       ..\..\..\Release-2005\re2c -b -o$(InputName).c $(InputName).re
+
+# End Custom Build
+
+!ENDIF 
+
+# End Source File
+# End Group
+# End Target
+# End Project
diff --git a/lessons/001_upn_calculator/windows/TestRe2c.dsw b/lessons/001_upn_calculator/windows/TestRe2c.dsw
new file mode 100755 (executable)
index 0000000..eb8f630
--- /dev/null
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "TestRe2c"=.\TestRe2c.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/lessons/001_upn_calculator/windows/TestRe2c.sln b/lessons/001_upn_calculator/windows/TestRe2c.sln
new file mode 100755 (executable)
index 0000000..8d051b8
--- /dev/null
@@ -0,0 +1,21 @@
+Microsoft Visual Studio Solution File, Format Version 7.00
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestRe2c", "TestRe2c.vcproj", "{BEC086F1-62CD-4BA7-8E17-367B825FA721}"
+EndProject
+Global
+       GlobalSection(SolutionConfiguration) = preSolution
+               ConfigName.0 = Debug
+               ConfigName.1 = Release
+       EndGlobalSection
+       GlobalSection(ProjectDependencies) = postSolution
+       EndGlobalSection
+       GlobalSection(ProjectConfiguration) = postSolution
+               {BEC086F1-62CD-4BA7-8E17-367B825FA721}.Debug.ActiveCfg = Debug|Win32
+               {BEC086F1-62CD-4BA7-8E17-367B825FA721}.Debug.Build.0 = Debug|Win32
+               {BEC086F1-62CD-4BA7-8E17-367B825FA721}.Release.ActiveCfg = Release|Win32
+               {BEC086F1-62CD-4BA7-8E17-367B825FA721}.Release.Build.0 = Release|Win32
+       EndGlobalSection
+       GlobalSection(ExtensibilityGlobals) = postSolution
+       EndGlobalSection
+       GlobalSection(ExtensibilityAddIns) = postSolution
+       EndGlobalSection
+EndGlobal
diff --git a/lessons/001_upn_calculator/windows/TestRe2c.vcproj b/lessons/001_upn_calculator/windows/TestRe2c.vcproj
new file mode 100755 (executable)
index 0000000..1dca53d
--- /dev/null
@@ -0,0 +1,138 @@
+<?xml version="1.0" encoding = "Windows-1252"?>
+<VisualStudioProject
+       ProjectType="Visual C++"
+       Version="7.00"
+       Name="Re2cTest"
+       ProjectGUID="{BEC086F1-62CD-4BA7-8E17-367B825FA721}"
+       Keyword="Win32Proj">
+       <Platforms>
+               <Platform
+                       Name="Win32"/>
+       </Platforms>
+       <Configurations>
+               <Configuration
+                       Name="Debug|Win32"
+                       OutputDirectory="Debug"
+                       IntermediateDirectory="Debug"
+                       ConfigurationType="1"
+                       CharacterSet="2">
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="0"
+                               PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
+                               MinimalRebuild="TRUE"
+                               BasicRuntimeChecks="3"
+                               RuntimeLibrary="5"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="3"
+                               Detect64BitPortabilityProblems="TRUE"
+                               DebugInformationFormat="4"/>
+                       <Tool
+                               Name="VCCustomBuildTool"/>
+                       <Tool
+                               Name="VCLinkerTool"
+                               OutputFile="$(OutDir)/Re2cTest.exe"
+                               LinkIncremental="2"
+                               GenerateDebugInformation="TRUE"
+                               ProgramDatabaseFile="$(OutDir)/Re2cTest.pdb"
+                               SubSystem="1"
+                               TargetMachine="1"/>
+                       <Tool
+                               Name="VCMIDLTool"/>
+                       <Tool
+                               Name="VCPostBuildEventTool"/>
+                       <Tool
+                               Name="VCPreBuildEventTool"/>
+                       <Tool
+                               Name="VCPreLinkEventTool"/>
+                       <Tool
+                               Name="VCResourceCompilerTool"/>
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"/>
+                       <Tool
+                               Name="VCWebDeploymentTool"/>
+               </Configuration>
+               <Configuration
+                       Name="Release|Win32"
+                       OutputDirectory="Release"
+                       IntermediateDirectory="Release"
+                       ConfigurationType="1"
+                       CharacterSet="2">
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="2"
+                               InlineFunctionExpansion="1"
+                               OmitFramePointers="TRUE"
+                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
+                               StringPooling="TRUE"
+                               RuntimeLibrary="4"
+                               EnableFunctionLevelLinking="TRUE"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="3"
+                               Detect64BitPortabilityProblems="TRUE"
+                               DebugInformationFormat="3"/>
+                       <Tool
+                               Name="VCCustomBuildTool"/>
+                       <Tool
+                               Name="VCLinkerTool"
+                               OutputFile="$(OutDir)/Re2cTest.exe"
+                               LinkIncremental="1"
+                               GenerateDebugInformation="TRUE"
+                               SubSystem="1"
+                               OptimizeReferences="2"
+                               EnableCOMDATFolding="2"
+                               TargetMachine="1"/>
+                       <Tool
+                               Name="VCMIDLTool"/>
+                       <Tool
+                               Name="VCPostBuildEventTool"/>
+                       <Tool
+                               Name="VCPreBuildEventTool"/>
+                       <Tool
+                               Name="VCPreLinkEventTool"/>
+                       <Tool
+                               Name="VCResourceCompilerTool"/>
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"/>
+                       <Tool
+                               Name="VCWebDeploymentTool"/>
+               </Configuration>
+       </Configurations>
+       <Files>
+               <Filter
+                       Name="Source Files"
+                       Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm">
+                       <File
+                               RelativePath="main.b.c">
+                       </File>
+                       <File
+                               RelativePath="main.b.re">
+                               <FileConfiguration
+                                       Name="Debug|Win32">
+                                       <Tool
+                                               Name="VCCustomBuildTool"
+                                               Description="Generate $(InputName).c from $(InputName).re using Re2c"
+                                               CommandLine="..\..\..\Release\re2c.exe -b -o$(InputName).c $(InputName).re"
+                                               Outputs="$(InputName).c"/>
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32">
+                                       <Tool
+                                               Name="VCCustomBuildTool"
+                                               Description="Generate $(InputName).c from $(InputName).re using Re2c"
+                                               CommandLine="..\..\..\Release\re2c.exe -b -o$(InputName).c $(InputName).re"
+                                               Outputs="$(InputName).c"/>
+                               </FileConfiguration>
+                       </File>
+               </Filter>
+               <Filter
+                       Name="Header Files"
+                       Filter="h;hpp;hxx">
+                       <File
+                               RelativePath="HiResTimer.h">
+                       </File>
+               </Filter>
+       </Files>
+       <Globals>
+       </Globals>
+</VisualStudioProject>
diff --git a/lessons/001_upn_calculator/windows/main.b.c b/lessons/001_upn_calculator/windows/main.b.c
new file mode 100755 (executable)
index 0000000..2f9e498
--- /dev/null
@@ -0,0 +1,456 @@
+/* Generated by re2c 0.10.2.dev on Mon Apr 17 16:07:31 2006 */
+#line 1 "main.b.re"
+/* re2c lesson 001_upn_calculator, main.b.re, (c) M. Boerger 2006 */
+#line 43 "main.b.re"
+
+#define VC_EXTRALEAN           // Exclude rarely-used stuff from Windows headers
+
+#if _MSC_VER > 1200
+#define WINVER 0x0400   // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
+#endif                  // Prevents warning from vc7.1 complaining about redefinition
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <string.h>
+#include <windows.h>
+#include "HiResTimer.h"
+
+static char gTestBuf[1000] = "";
+
+/**
+ * @brief Setup HiResolution timer and confirm it is working ok
+ */
+void InitHiResTimerAndVerifyWorking(void)
+{
+   double elapsed;
+   HrtInit();
+   HrtSetPriority(ABOVE_NORMAL_PRIORITY_CLASS);
+   HrtStart();
+   Sleep(100);
+   elapsed = HrtElapsedMillis();
+   if ((elapsed < 90) || (elapsed > 110)) {
+      printf("HiResTimer misbehaving: %f\n", elapsed);
+      exit(2);
+   }
+}
+
+/**
+ * @brief Scan for numbers in different formats
+ */
+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)
+       
+       for(;;)
+       {
+               {
+                       static unsigned char yybm[] = {
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                               128, 128, 128, 128, 128, 128, 128, 128, 
+                               128, 128,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                       };
+
+#line 90 "main.b.c"
+                       {
+                               YYCTYPE yych;
+
+                               if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
+                               yych = *YYCURSOR;
+                               if(yych <= ',') {
+                                       if(yych <= 0x00) goto yy10;
+                                       if(yych == '+') goto yy6;
+                                       goto yy12;
+                               } else {
+                                       if(yych <= '/') {
+                                               if(yych <= '-') goto yy8;
+                                               goto yy12;
+                                       } else {
+                                               if(yych <= '0') goto yy4;
+                                               if(yych >= ':') goto yy12;
+                                       }
+                               }
+                               ++YYCURSOR;
+                               yych = *YYCURSOR;
+                               goto yy17;
+yy3:
+#line 93 "main.b.re"
+                               { continue; }
+#line 115 "main.b.c"
+yy4:
+                               ++YYCURSOR;
+                               if(yybm[0+(yych = *YYCURSOR)] & 128) {
+                                       goto yy13;
+                               }
+yy5:
+#line 98 "main.b.re"
+                               { return 1; }
+#line 124 "main.b.c"
+yy6:
+                               ++YYCURSOR;
+#line 95 "main.b.re"
+                               { continue; }
+#line 129 "main.b.c"
+yy8:
+                               ++YYCURSOR;
+#line 96 "main.b.re"
+                               { continue; }
+#line 134 "main.b.c"
+yy10:
+                               ++YYCURSOR;
+#line 97 "main.b.re"
+                               { return 0; }
+#line 139 "main.b.c"
+yy12:
+                               yych = *++YYCURSOR;
+                               goto yy5;
+yy13:
+                               ++YYCURSOR;
+                               if(YYLIMIT == YYCURSOR) YYFILL(1);
+                               yych = *YYCURSOR;
+                               if(yybm[0+yych] & 128) {
+                                       goto yy13;
+                               }
+#line 94 "main.b.re"
+                               { continue; }
+#line 152 "main.b.c"
+yy16:
+                               ++YYCURSOR;
+                               if(YYLIMIT == YYCURSOR) YYFILL(1);
+                               yych = *YYCURSOR;
+yy17:
+                               if(yych <= '/') goto yy3;
+                               if(yych <= '9') goto yy16;
+                               goto yy3;
+                       }
+               }
+#line 99 "main.b.re"
+
+       }
+}
+
+/**
+ * @brief Scan for numbers in different formats
+ */
+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)
+       
+       for(;;)
+       {
+               {
+                       static unsigned char yybm[] = {
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                               128, 128, 128, 128, 128, 128, 128, 128, 
+                               128, 128,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                                 0,   0,   0,   0,   0,   0,   0,   0, 
+                       };
+
+#line 219 "main.b.c"
+                       {
+                               YYCTYPE yych;
+                               if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
+                               yych = *YYCURSOR;
+                               if(yych <= ',') {
+                                       if(yych <= 0x00) goto yy28;
+                                       if(yych == '+') goto yy24;
+                                       goto yy30;
+                               } else {
+                                       if(yych <= '/') {
+                                               if(yych <= '-') goto yy26;
+                                               goto yy30;
+                                       } else {
+                                               if(yych <= '0') goto yy22;
+                                               if(yych >= ':') goto yy30;
+                                       }
+                               }
+                               ++YYCURSOR;
+                               yych = *YYCURSOR;
+                               goto yy35;
+yy21:
+#line 120 "main.b.re"
+                               { printf("Num\n"); strcat(gTestBuf, "Num "); continue; }
+#line 243 "main.b.c"
+yy22:
+                               ++YYCURSOR;
+                               if(yybm[0+(yych = *YYCURSOR)] & 128) {
+                                       goto yy31;
+                               }
+yy23:
+#line 125 "main.b.re"
+                               { printf("ERR\n"); strcat(gTestBuf, "ERR "); return 1; }
+#line 252 "main.b.c"
+yy24:
+                               ++YYCURSOR;
+#line 122 "main.b.re"
+                               { printf("+\n");   strcat(gTestBuf, "+ ");   continue; }
+#line 257 "main.b.c"
+yy26:
+                               ++YYCURSOR;
+#line 123 "main.b.re"
+                               { printf("-\n");   strcat(gTestBuf, "- ");   continue; }
+#line 262 "main.b.c"
+yy28:
+                               ++YYCURSOR;
+#line 124 "main.b.re"
+                               { printf("EOF\n");                           return 0; }
+#line 267 "main.b.c"
+yy30:
+                               yych = *++YYCURSOR;
+                               goto yy23;
+yy31:
+                               ++YYCURSOR;
+                               if(YYLIMIT == YYCURSOR) YYFILL(1);
+                               yych = *YYCURSOR;
+                               if(yybm[0+yych] & 128) {
+                                       goto yy31;
+                               }
+#line 121 "main.b.re"
+                               { printf("Oct\n"); strcat(gTestBuf, "Oct "); continue; }
+#line 280 "main.b.c"
+yy34:
+                               ++YYCURSOR;
+                               if(YYLIMIT == YYCURSOR) YYFILL(1);
+                               yych = *YYCURSOR;
+yy35:
+                               if(yych <= '/') goto yy21;
+                               if(yych <= '9') goto yy34;
+                               goto yy21;
+                       }
+               }
+#line 126 "main.b.re"
+
+       }
+}
+
+/**
+ * @brief Show high resolution elapsed time for 10,000 and 100,000 loops
+ */
+void DoTimingsOfStrnCmp(void)
+{
+   char testStr[] = "Hello, world";
+   int totLoops = 10000;
+   int totFoundCount = 0;
+   int foundCount = 0;
+   int loop;
+   int rc;
+   const int progressAnd = 0xFFFFF000;
+   double elapsed;
+
+   printf("\n\n%d loops with * every %d loops to confirm\n", totLoops, ((~progressAnd) + 1));
+
+   HrtStart();
+   for (loop = 0; loop < totLoops; ++loop) {
+      foundCount = 0;
+      rc = strncmp(testStr, "Hello", 5);
+      if (rc == 0) {
+         foundCount++;
+         totFoundCount++;
+         if ((totFoundCount & progressAnd) == totFoundCount) {
+            printf("*");
+         }
+      }
+   }
+   elapsed = HrtElapsedMillis();
+   printf("\nstrncmp Elapsed for %7d loops milliseconds: %7.3f\n", totLoops, elapsed);
+   printf("FoundCount each loop: %d\n", foundCount);
+   printf("TotalFoundCount for all loops: %d\n", totFoundCount);
+
+   totLoops = 100000;
+   HrtStart();
+   for (loop = 0; loop < totLoops; ++loop) {
+      foundCount = 0;
+      rc = strncmp(testStr, "Hello", 5);
+      if (rc == 0) {
+         foundCount++;
+         totFoundCount++;
+         if ((totFoundCount & progressAnd) == totFoundCount) {
+            printf("*");
+         }
+      }
+   }
+   elapsed = HrtElapsedMillis();
+   printf("\nstrncmp Elapsed for %7d loops milliseconds: %7.3f\n", totLoops, elapsed);
+   printf("FoundCount each loop: %d\n", foundCount);
+   printf("TotalFoundCount for all loops: %d\n", totFoundCount);
+}
+
+/**
+ * @brief Show high resolution elapsed time for 10,000 and 100,000 loops
+ */
+void DoTimingsOfRe2c(void)
+{
+   char* testStrings[] = { "123", "1234", "+123", "01234", "-04321", "abc", "123abc" };
+   const int testCount = sizeof(testStrings) / sizeof(testStrings[0]);
+   int i;
+   int totLoops = 10000 / testCount;  // Doing more than one per loop
+   int totFoundCount = 0;
+   int foundCount = 0;
+   int loop;
+   int rc;
+   const int progressAnd = 0xFFFFF000;
+   double elapsed;
+
+   printf("\n\n%d loops with * every %d loops to confirm\n", totLoops, ((~progressAnd) + 1));
+
+   HrtStart();
+   for (loop = 0; loop < totLoops; ++loop) {
+      foundCount = 0;
+      strcpy(gTestBuf, "");   
+      for (i = 0; i < testCount; ++i) {
+         char* pzCurStr = testStrings[i];
+         size_t len = strlen(pzCurStr);  // Calc of strlen slows things down ... std::string?
+         rc = ScanFullSpeed(pzCurStr, len);
+         if (rc == 0) {
+            foundCount++;
+            totFoundCount++;
+            if ((totFoundCount & progressAnd) == totFoundCount) {
+               printf("*");
+            }
+         }
+      }
+   }
+   elapsed = HrtElapsedMillis();
+   printf("\nRe2c Elapsed for %7d loops milliseconds: %7.3f\n", totLoops, elapsed);
+   printf("FoundCount each loop: %d\n", foundCount);
+   printf("TotalFoundCount for all loops: %d\n", totFoundCount);
+
+   totLoops = 100000 / testCount;
+   printf("\n\n%d loops with * every %d loops to confirm\n", totLoops, ((~progressAnd) + 1));
+
+   HrtStart();
+   for (loop = 0; loop < totLoops; ++loop) {
+      foundCount = 0;
+      strcpy(gTestBuf, "");   
+      for (i = 0; i < testCount; ++i) {
+         char* pzCurStr = testStrings[i];
+         size_t len = strlen(pzCurStr);  // Calc of strlen slows things down ... std::string?
+         rc = ScanFullSpeed(pzCurStr, len);
+         if (rc == 0) {
+            foundCount++;
+            totFoundCount++;
+            if ((totFoundCount & progressAnd) == totFoundCount) {
+               printf("*");
+            }
+         }
+      }
+   }
+   elapsed = HrtElapsedMillis();
+   printf("\nRe2c Elapsed for %7d loops milliseconds: %7.3f\n", totLoops, elapsed);
+   printf("FoundCount each loop: %d\n", foundCount);
+   printf("TotalFoundCount for all loops: %d\n", totFoundCount);
+}
+
+/**
+ * @brief Entry point for console app
+ */
+int main(int argc, char **argv)
+{
+   char  testStr_A[] = "123";
+   char* testStr_B   = "456";
+   char* testStrings[] = { "123", "1234", "+123", "01234", "-04321", "abc", "123abc" };
+   const int testCount = sizeof(testStrings) / sizeof(testStrings[0]);
+   int i;
+   
+   int rc = scan(testStr_A, 3);
+   printf("rc: %d\n", rc);
+
+   rc = scan(testStr_B, 3);
+   printf("rc: %d\n", rc);
+
+   rc = scan("789", 3);
+   printf("rc: %d\n", rc);
+
+   strcpy(gTestBuf, "");   
+   for (i = 0; i < testCount; ++i) {
+      char* pzCurStr = testStrings[i];
+      size_t len = strlen(pzCurStr);
+      scan(pzCurStr, len);
+   }
+   printf("%s\n", gTestBuf);
+   rc = strcmp(gTestBuf, "Num Num + Num Oct - Oct ERR Num ERR ");
+   if (rc == 0) {
+      printf("Success\n");
+   }
+   else {
+      printf("Failure\n");
+   }
+   assert(0 == rc); // Doesn't work with Release build
+   
+   InitHiResTimerAndVerifyWorking();
+
+   DoTimingsOfStrnCmp();
+   
+   DoTimingsOfRe2c();
+   
+   return 0;
+}
diff --git a/lessons/001_upn_calculator/windows/main.b.re b/lessons/001_upn_calculator/windows/main.b.re
new file mode 100755 (executable)
index 0000000..f782ec9
--- /dev/null
@@ -0,0 +1,291 @@
+/* re2c lesson 001_upn_calculator, main.b.re, (c) M. Boerger 2006 */
+/*!ignore:re2c
+
+- basic interface for string reading
+
+  . We define the macros YYCTYPE, YYCURSOR, YYLIMIT, YYMARKER, YYFILL
+  . YYCTYPE is the type re2c operates on or in other words the type that 
+    it generates code for. While it is not a big difference when we were
+    using 'unsigned char' here we would need to run re2c with option -w
+    to fully support types with sieof() > 1.
+  . YYCURSOR is used internally and holds the current scanner position. In
+    expression handlers, the code blocks after re2c expressions, this can be 
+    used to identify the end of the token.
+  . YYMARKER is not always being used so we set an initial value to avoid
+    a compiler warning.
+  . YYLIMIT stores the end of the input. Unfortunatley we have to use strlen() 
+    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 
+    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.
+    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
+    as re2c goes from top to botton when evaluating the expressions this is no 
+    problem.
+  . The first three rules show that re2c actually prioritizes the expressions 
+    from top to bottom. Octal number require a starting "0" and the actual 
+    number. Normal numbers start with a digit greater 0. And zero is finally a
+    special case. A single "0" is detected by the last rule of this set. And
+    valid ocal number is already being detected by the first rule. This even
+    includes multi "0" sequences that in octal notation also means zero.
+    Another way would be to only use two rules:
+    "0" [0-9]+
+    "0" | ( [1-9] [0-9]* )
+    A full description of re2c rule syntax can be found in the manual.
+*/
+
+#define VC_EXTRALEAN           // Exclude rarely-used stuff from Windows headers
+
+#if _MSC_VER > 1200
+#define WINVER 0x0400   // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
+#endif                  // Prevents warning from vc7.1 complaining about redefinition
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <string.h>
+#include <windows.h>
+#include "HiResTimer.h"
+
+static char gTestBuf[1000] = "";
+
+/**
+ * @brief Setup HiResolution timer and confirm it is working ok
+ */
+void InitHiResTimerAndVerifyWorking(void)
+{
+   double elapsed;
+   HrtInit();
+   HrtSetPriority(ABOVE_NORMAL_PRIORITY_CLASS);
+   HrtStart();
+   Sleep(100);
+   elapsed = HrtElapsedMillis();
+   if ((elapsed < 90) || (elapsed > 110)) {
+      printf("HiResTimer misbehaving: %f\n", elapsed);
+      exit(2);
+   }
+}
+
+/**
+ * @brief Scan for numbers in different formats
+ */
+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)
+       
+       for(;;)
+       {
+/*!re2c
+       re2c:indent:top = 2;
+       [1-9][0-9]*     { continue; }
+       [0][0-9]+       { continue; }
+       "+"                     { continue; }
+       "-"                     { continue; }
+       "\000"          { return 0; }
+       [^]                     { return 1; }
+*/
+       }
+}
+
+/**
+ * @brief Scan for numbers in different formats
+ */
+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)
+       
+       for(;;)
+       {
+/*!re2c
+       re2c:indent:top = 2;
+       [1-9][0-9]*     { printf("Num\n"); strcat(gTestBuf, "Num "); continue; }
+       [0][0-9]+       { printf("Oct\n"); strcat(gTestBuf, "Oct "); continue; }
+       "+"                     { printf("+\n");   strcat(gTestBuf, "+ ");   continue; }
+       "-"                     { printf("-\n");   strcat(gTestBuf, "- ");   continue; }
+       "\000"          { printf("EOF\n");                           return 0; }
+       [^]                     { printf("ERR\n"); strcat(gTestBuf, "ERR "); return 1; }
+*/
+       }
+}
+
+/**
+ * @brief Show high resolution elapsed time for 10,000 and 100,000 loops
+ */
+void DoTimingsOfStrnCmp(void)
+{
+   char testStr[] = "Hello, world";
+   int totLoops = 10000;
+   int totFoundCount = 0;
+   int foundCount = 0;
+   int loop;
+   int rc;
+   const int progressAnd = 0xFFFFF000;
+   double elapsed;
+
+   printf("\n\n%d loops with * every %d loops to confirm\n", totLoops, ((~progressAnd) + 1));
+
+   HrtStart();
+   for (loop = 0; loop < totLoops; ++loop) {
+      foundCount = 0;
+      rc = strncmp(testStr, "Hello", 5);
+      if (rc == 0) {
+         foundCount++;
+         totFoundCount++;
+         if ((totFoundCount & progressAnd) == totFoundCount) {
+            printf("*");
+         }
+      }
+   }
+   elapsed = HrtElapsedMillis();
+   printf("\nstrncmp Elapsed for %7d loops milliseconds: %7.3f\n", totLoops, elapsed);
+   printf("FoundCount each loop: %d\n", foundCount);
+   printf("TotalFoundCount for all loops: %d\n", totFoundCount);
+
+   totLoops = 100000;
+   HrtStart();
+   for (loop = 0; loop < totLoops; ++loop) {
+      foundCount = 0;
+      rc = strncmp(testStr, "Hello", 5);
+      if (rc == 0) {
+         foundCount++;
+         totFoundCount++;
+         if ((totFoundCount & progressAnd) == totFoundCount) {
+            printf("*");
+         }
+      }
+   }
+   elapsed = HrtElapsedMillis();
+   printf("\nstrncmp Elapsed for %7d loops milliseconds: %7.3f\n", totLoops, elapsed);
+   printf("FoundCount each loop: %d\n", foundCount);
+   printf("TotalFoundCount for all loops: %d\n", totFoundCount);
+}
+
+/**
+ * @brief Show high resolution elapsed time for 10,000 and 100,000 loops
+ */
+void DoTimingsOfRe2c(void)
+{
+   char* testStrings[] = { "123", "1234", "+123", "01234", "-04321", "abc", "123abc" };
+   const int testCount = sizeof(testStrings) / sizeof(testStrings[0]);
+   int i;
+   int totLoops = 10000 / testCount;  // Doing more than one per loop
+   int totFoundCount = 0;
+   int foundCount = 0;
+   int loop;
+   int rc;
+   const int progressAnd = 0xFFFFF000;
+   double elapsed;
+
+   printf("\n\n%d loops with * every %d loops to confirm\n", totLoops, ((~progressAnd) + 1));
+
+   HrtStart();
+   for (loop = 0; loop < totLoops; ++loop) {
+      foundCount = 0;
+      strcpy(gTestBuf, "");   
+      for (i = 0; i < testCount; ++i) {
+         char* pzCurStr = testStrings[i];
+         size_t len = strlen(pzCurStr);  // Calc of strlen slows things down ... std::string?
+         rc = ScanFullSpeed(pzCurStr, len);
+         if (rc == 0) {
+            foundCount++;
+            totFoundCount++;
+            if ((totFoundCount & progressAnd) == totFoundCount) {
+               printf("*");
+            }
+         }
+      }
+   }
+   elapsed = HrtElapsedMillis();
+   printf("\nRe2c Elapsed for %7d loops milliseconds: %7.3f\n", totLoops, elapsed);
+   printf("FoundCount each loop: %d\n", foundCount);
+   printf("TotalFoundCount for all loops: %d\n", totFoundCount);
+
+   totLoops = 100000 / testCount;
+   printf("\n\n%d loops with * every %d loops to confirm\n", totLoops, ((~progressAnd) + 1));
+
+   HrtStart();
+   for (loop = 0; loop < totLoops; ++loop) {
+      foundCount = 0;
+      strcpy(gTestBuf, "");   
+      for (i = 0; i < testCount; ++i) {
+         char* pzCurStr = testStrings[i];
+         size_t len = strlen(pzCurStr);  // Calc of strlen slows things down ... std::string?
+         rc = ScanFullSpeed(pzCurStr, len);
+         if (rc == 0) {
+            foundCount++;
+            totFoundCount++;
+            if ((totFoundCount & progressAnd) == totFoundCount) {
+               printf("*");
+            }
+         }
+      }
+   }
+   elapsed = HrtElapsedMillis();
+   printf("\nRe2c Elapsed for %7d loops milliseconds: %7.3f\n", totLoops, elapsed);
+   printf("FoundCount each loop: %d\n", foundCount);
+   printf("TotalFoundCount for all loops: %d\n", totFoundCount);
+}
+
+/**
+ * @brief Entry point for console app
+ */
+int main(int argc, char **argv)
+{
+   char  testStr_A[] = "123";
+   char* testStr_B   = "456";
+   char* testStrings[] = { "123", "1234", "+123", "01234", "-04321", "abc", "123abc" };
+   const int testCount = sizeof(testStrings) / sizeof(testStrings[0]);
+   int i;
+   
+   int rc = scan(testStr_A, 3);
+   printf("rc: %d\n", rc);
+
+   rc = scan(testStr_B, 3);
+   printf("rc: %d\n", rc);
+
+   rc = scan("789", 3);
+   printf("rc: %d\n", rc);
+
+   strcpy(gTestBuf, "");   
+   for (i = 0; i < testCount; ++i) {
+      char* pzCurStr = testStrings[i];
+      size_t len = strlen(pzCurStr);
+      scan(pzCurStr, len);
+   }
+   printf("%s\n", gTestBuf);
+   rc = strcmp(gTestBuf, "Num Num + Num Oct - Oct ERR Num ERR ");
+   if (rc == 0) {
+      printf("Success\n");
+   }
+   else {
+      printf("Failure\n");
+   }
+   assert(0 == rc); // Doesn't work with Release build
+   
+   InitHiResTimerAndVerifyWorking();
+
+   DoTimingsOfStrnCmp();
+   
+   DoTimingsOfRe2c();
+   
+   return 0;
+}
index 535a4ea798f373b23d2135b57b5be42a03a5b8a0..9805d20b77fdc425f1da27015c9430f9a260e70a 100755 (executable)
@@ -1,4 +1,4 @@
-re2c lesson_002, (c) M. Boerger 2006
+re2c lesson 002_strip_comments, (c) M. Boerger 2006
 
 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
@@ -10,4 +10,4 @@ The first scanner can be generated with:
   re2c -s -o t.c strip_001.s.re
 
 In the second step we will learn about YYMARKER that stores backtracking 
-information and YYCTXMARKER that is used for trailing contexts.
\ No newline at end of file
+information and YYCTXMARKER that is used for trailing contexts.
index ad0d85b8e0629f911288f7d45a363714de15e6b9..c4ff92748c9bcfafc9a17dde3af341f7f26b9bb1 100755 (executable)
@@ -1,6 +1,6 @@
 /* Generated by re2c */
 #line 1 "strip_001.s.re"
-/* re2c lesson_002, strip_001.s, (c) M. Boerger 2006 */
+/* re2c lesson 002_strip_comments, strip_001.s, (c) M. Boerger 2006 */
 #line 32 "strip_001.s.re"
 
 #include <stdlib.h>
index cf09d5e21a98c68c2ec1f0403063ed79c0c62fb1..ca7351800144d142f53696da4b08b5b05d10fd2b 100755 (executable)
@@ -1,4 +1,4 @@
-/* re2c lesson_002, strip_001.s, (c) M. Boerger 2006 */
+/* re2c lesson 002_strip_comments, strip_001.s, (c) M. Boerger 2006 */
 /*!ignore:re2c
 
 - basic interface for file reading
index 63d103cd3de080c96032f3b9329aabae50bdcb2e..b87912cf60fe7a51353264892f0980de26fc81c0 100755 (executable)
@@ -1,6 +1,6 @@
 /* Generated by re2c */
 #line 1 "strip_002.s.re"
-/* re2c lesson_002, strip_002.s, (c) M. Boerger 2006 */
+/* re2c lesson 002_strip_comments, strip_002.s, (c) M. Boerger 2006 */
 #line 27 "strip_002.s.re"
 
 #include <stdlib.h>
index 282f00d3f0735c889c759184697c6efec98db964..9422005fe239f5f82ce87e1c226b89401054135e 100755 (executable)
@@ -1,4 +1,4 @@
-/* re2c lesson_002, strip_002.s, (c) M. Boerger 2006 */
+/* re2c lesson 002_strip_comments, strip_002.s, (c) M. Boerger 2006 */
 /*!ignore:re2c
 
 - complexity
diff --git a/lessons/readme.txt b/lessons/readme.txt
new file mode 100755 (executable)
index 0000000..2d26179
--- /dev/null
@@ -0,0 +1,20 @@
+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.
+
+       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.