1.2.8 Compiling
Generating C++ Files
C++ source code and resource files can be generated from files referenced in a lexer .slg project file by running the lexer generator 'slg':
C:\minilang>slg -v minilang.slg
> C:/minilang/minilang.slg
generating lexers for project 'minilang.slg'...
> C:/minilang/minilang.token
==> C:/minilang/minilang.token.cppm
> C:/minilang/minilang.keyword
> C:/minilang/minilang.expr
> C:/minilang/minilang_lexer.lexer
==> C:/minilang/minilang.lexer.classmap
==> C:/minilang/minilang.lexer.classmap.compressed
==> C:/minilang/minilang.lexer.classmap.rc
==> C:/minilang/minilang_lexer.cppm
==> C:/minilang/minilang_lexer.cpp
lexers for project 'minilang.slg' generated successfully.
Adding the Generated Files
To add the generated files to the project:
-
Right-click your project in the Solution Explorer and select 'Add | Existing Item...'
-
Add the following files to the project:
- minilang.token.cppm contains a module interface unit of a token module
- minilang_lexer.cppm contains a module interface unit of a lexer module
- minilang_lexer.cpp contains a module implementation unit of a lexer module
- minilang.lexer.classmap.rc is a Windows resource file that embeds a compressed lexer classmap as a Windows resource.
This will need to be added to each executable C++ project that uses this kind of lexer.
The lexer initialization code will read and decompress the classmap for the first lexer of this kind. Subsequent lexer instances of the same kind
will use the same classmap instance.
Adding Support for Soul
At the moment probably the easiest way to add support for Soul is to add the required Soul library projects to the solution and then add references to the required Soul libraries.
-
Right-click the solution in the Solution Explorer and select 'Add | Existing Project...'
-
Navigate to the C:\soul-4.0.0\soul\ast folder and add the ast.vcxproj to the solution.
-
Do the same for
- C:\soul-4.0.0\soul\lexer,
- C:\soul-4.0.0\soul\parser and
- C:\soul-4.0.0\util
projects.
- Expand your project in the Solution Explorer, right-click 'References' and select 'Add Reference...'
- Add a reference to the
- ast,
- lexer,
- parser and
- util
module.
Compiling the Solution
- Select the 64 | Debug configuration.
- Select the Build | Build Solution command.
- The required Soul libraries and then your project should compile successfully.
- Select the 64 | Release configuration
- Select the Build | Build Solution command.
- The required Soul libraries and then your project should compile successfully.