Skip to content

Commit

Permalink
Commands
Browse files Browse the repository at this point in the history
- Added commands to `TypeCheckerBase!()` mixin template
- Added `TypeCheckerInit(Compiler compiler)`
- Use the template in both `compile` command and the`typecheck` command
  • Loading branch information
deavmi committed Nov 4, 2023
1 parent 2d90d01 commit e3e2fbd
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions source/tlang/commandline/commands.d
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,15 @@ mixin template EmitBase()
*/
mixin template TypeCheckerBase()
{
@ArgNamed("unusedVars|uvars", "Warn about any unused variables")
@(ArgConfig.optional)
bool warnUnusedVariables = true;

void TypeCheckerInit(Compiler compiler)
{
// Set whether to warn about unused variables
compiler.getConfig().addConfig(ConfigEntry("typecheck:warnUnusedVars", warnUnusedVariables));
}
}

/**
Expand All @@ -127,7 +135,7 @@ struct compileCommand
{
mixin BaseCommand!();


mixin TypeCheckerBase!();

mixin EmitBase!();

Expand All @@ -154,6 +162,9 @@ struct compileCommand
/* Setup general configuration parameters */
BaseCommandInit(compiler);

/* Setup all type checker related parameters */
TypeCheckerInit(compiler);

/* Perform tokenization */
compiler.doLex();
writeln("=== Tokens ===\n");
Expand Down Expand Up @@ -295,7 +306,7 @@ struct parseCommand
struct typecheckCommand
{
mixin BaseCommand!();

mixin TypeCheckerBase!();

void onExecute()
{
Expand All @@ -317,6 +328,9 @@ struct typecheckCommand
/* Setup general configuration parameters */
BaseCommandInit(compiler);

/* Setup all type checker related parameters */
TypeCheckerInit(compiler);

compiler.doLex();
writeln("=== Tokens ===\n");
writeln(compiler.getTokens());
Expand Down

0 comments on commit e3e2fbd

Please sign in to comment.