Skip to content

Commit

Permalink
Merge branch 'dev' into tech/actions
Browse files Browse the repository at this point in the history
* dev:
  cleaning UT
  cleaning
  cleaning
  cleaning
  cleaning
  clean todos
  • Loading branch information
b3b00 committed Oct 8, 2021
2 parents de9b92e + cd59b69 commit 0c4769c
Show file tree
Hide file tree
Showing 14 changed files with 19 additions and 111 deletions.
81 changes: 0 additions & 81 deletions .github/workflows/codesee-arch-diagram.yml

This file was deleted.

10 changes: 0 additions & 10 deletions Directory.Build.props

This file was deleted.

1 change: 0 additions & 1 deletion ParserTests/Issue164/TestOption164Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ public class TestOption164Parser
[Production("root: INT [PLUS|MINUS|TIMES|DIVIDE] INT")]
public int root(Token<TestOption164Lexer> left, Token<TestOption164Lexer> op, Token<TestOption164Lexer> right)
{
int res = 0;
int l = left.IntValue;
int r = right.IntValue;
switch (op.TokenID)
Expand Down
1 change: 0 additions & 1 deletion ParserTests/IssuesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ public static void Issue218()
n++;
count++;
}
Console.WriteLine(dump);
Assert.Equal(1, count);
var eoss = tokens.Where(x => x.IsEOS);
Assert.Single(eoss);
Expand Down
2 changes: 1 addition & 1 deletion ParserTests/samples/IndentedWhileTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public void TestFactorialProgramExecAsIL()
i := i + 1
return r";
var compiler = new IndentedWhileCompiler();
var func = compiler.CompileToFunction(program);
var func = compiler.CompileToFunction(program,true);
Assert.NotNull(func);
var f = func();
Assert.Equal(3628800, f);
Expand Down
2 changes: 1 addition & 1 deletion ParserTests/samples/WhileTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public void TestFactorialProgramExecAsIL()
return r
)";
var compiler = new WhileCompiler();
var func = compiler.CompileToFunction(program);
var func = compiler.CompileToFunction(program,true);
Assert.NotNull(func);
var f = func();
Assert.Equal(3628800, f);
Expand Down
5 changes: 2 additions & 3 deletions samples/IndentedWhile/IndentedWhileCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public string TranspileToCSharp(string whileCode)
}


public Func<int> CompileToFunction(string whileCode)
public Func<int> CompileToFunction(string whileCode, bool isQuiet = false)
{
Func<int> function = null;

Expand All @@ -93,15 +93,14 @@ public Func<int> CompileToFunction(string whileCode)

var checker = new SemanticChecker();

var context = checker.SemanticCheck(ast);
var context = checker.SemanticCheck(ast,isQuiet);

var emiter = Emit<Func<int>>.NewDynamicMethod("Method" + Guid.NewGuid());

emiter = ast.EmitByteCode(context, emiter);
//emiter.LoadConstant(42);
//emiter.Return();
function = emiter.CreateDelegate();
object res = function.Invoke();
}
}
catch
Expand Down
4 changes: 2 additions & 2 deletions samples/ParserExample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ private static void TestFactorial()

var compiler = new WhileCompiler();
var code = compiler.TranspileToCSharp(program);
var f = compiler.CompileToFunction(program);
var f = compiler.CompileToFunction(program,false);
int r = f();
if (r != 3628800)
{
Expand Down Expand Up @@ -206,7 +206,7 @@ private static void TestIndentedFactorial()

var compiler = new IndentedWhileCompiler();
var code = compiler.TranspileToCSharp(program);
var f = compiler.CompileToFunction(program);
var f = compiler.CompileToFunction(program,false);
Console.WriteLine("***********************************");
Console.WriteLine("***********************************");
Console.WriteLine("***********************************");
Expand Down
1 change: 1 addition & 0 deletions samples/while/compiler/CompilerContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public CompilerContext()
CurrentScope = RootScope;
}

public bool IsQuiet { get; set; }

public Scope RootScope { get; protected set; }

Expand Down
6 changes: 4 additions & 2 deletions samples/while/compiler/SemanticChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ public class SemanticChecker
{
private ExpressionTyper expressionTyper;

public CompilerContext SemanticCheck(WhileAST ast)
public CompilerContext SemanticCheck(WhileAST ast, bool isQuiet = false)
{
expressionTyper = new ExpressionTyper();
return SemanticCheck(ast, new CompilerContext());
var context = new CompilerContext();
context.IsQuiet = isQuiet;
return SemanticCheck(ast, context);
}

private CompilerContext SemanticCheck(WhileAST ast, CompilerContext context)
Expand Down
5 changes: 2 additions & 3 deletions samples/while/compiler/WhileCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public string TranspileToCSharp(string whileCode)
}


public Func<int> CompileToFunction(string whileCode)
public Func<int> CompileToFunction(string whileCode, bool isQuiet)
{
Func<int> function = null;

Expand All @@ -91,15 +91,14 @@ public Func<int> CompileToFunction(string whileCode)

var checker = new SemanticChecker();

var context = checker.SemanticCheck(ast);
var context = checker.SemanticCheck(ast, isQuiet);

var emiter = Emit<Func<int>>.NewDynamicMethod("Method" + Guid.NewGuid());

emiter = ast.EmitByteCode(context, emiter);
//emiter.LoadConstant(42);
//emiter.Return();
function = emiter.CreateDelegate();
object res = function.Invoke();
}
}
catch
Expand Down
10 changes: 6 additions & 4 deletions samples/while/model/PrintStatement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ public string Transpile(CompilerContext context)

public Emit<Func<int>> EmitByteCode(CompilerContext context, Emit<Func<int>> emiter)
{
var mi = typeof(Console).GetMethod("WriteLine", new[] {typeof(string)});

emiter = Value.EmitByteCode(context, emiter);
emiter.Call(mi);
if (!context.IsQuiet)
{
var mi = typeof(Console).GetMethod("WriteLine", new[] { typeof(string) });
emiter = Value.EmitByteCode(context, emiter);
emiter.Call(mi);
}

return emiter;
}
Expand Down
1 change: 0 additions & 1 deletion sly/lexer/fsm/FSMLexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,6 @@ private FSMMatch<N> ConsumeIndents(ReadOnlyMemory<char> source, LexerPosition le
while (i < currentIndentations.Count && indentPosition < indents.Count)
{
var current = currentIndentations[currentIndentations.Count-i-1];
bool ok = true;
int j = 0;
if (indentPosition + current.Length > indents.Count)
{
Expand Down
1 change: 0 additions & 1 deletion sly/parser/parser/llparser/RecursiveDescentSyntaxParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,6 @@ public SyntaxParseResult<IN> ParseTerminal(IList<Token<IN>> tokens, TerminalClau
int currentPosition)
{
var startPosition = currentPosition;
var endingPosition = 0;
var nt = Configuration.NonTerminals[nonTermClause.NonTerminalName];
var errors = new List<UnexpectedTokenSyntaxError<IN>>();

Expand Down

0 comments on commit 0c4769c

Please sign in to comment.