-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #85 from Sparrow-lang/tools_support
Tools support
- Loading branch information
Showing
235 changed files
with
25,757 additions
and
20,727 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,53 @@ | ||
module logic.prolog; | ||
module logic.prolog | ||
|
||
import lRef; | ||
import predicates; | ||
import recurse; | ||
import lRef | ||
import predicates | ||
import recurse | ||
|
||
import prologImpl.nodes; | ||
import prologImpl.lexer; | ||
import prologImpl.parser; | ||
import prologImpl.ir; | ||
import prologImpl.sprCodeDump; | ||
import prologImpl.codeGen; | ||
import prologImpl.nodes | ||
import prologImpl.lexer | ||
import prologImpl.parser | ||
import prologImpl.ir | ||
import prologImpl.sprCodeDump | ||
import prologImpl.codeGen | ||
|
||
import meta = meta.nodeKinds; | ||
import meta = meta.nodeKinds | ||
|
||
import assert; | ||
import time = time; | ||
import assert | ||
import time = time | ||
|
||
[macro] fun compileProlog(sourceString: CompilerAstNode): CompilerAstNode | ||
{ | ||
var sourceStr: meta.AstNode = sourceString; | ||
var sourceStr: meta.AstNode = sourceString | ||
[ct] if ( (sourceString nodeKind) != meta.nkSparrowExpLiteral ) | ||
meta.report("compileProlog should take a string literal as argument", (sourceStr location)); | ||
meta.report("compileProlog should take a string literal as argument", (sourceStr location)) | ||
return CompilerAstNode() | ||
else | ||
{ | ||
sourceStr semanticCheck; | ||
var loc = sourceStr location; | ||
var ctx = sourceStr context; | ||
var str: String = astEval(sourceString clone); | ||
return handlePrologCode(str, loc, ctx); | ||
} | ||
} | ||
sourceStr semanticCheck | ||
var loc = sourceStr location | ||
var ctx = sourceStr context | ||
var str: String = astEval(sourceString clone) | ||
return handlePrologCode(str, loc, ctx) | ||
|
||
[ct] fun handlePrologCode(code: @String, location: meta.Location, context: meta.CompilationContext): meta.AstNode | ||
{ | ||
//cout << "(" << location.startLineNo << ":" << location.startColNo << " - " << location.endLineNo << ":" << location.endColNo << ')' << endl << flush; | ||
var t: time.Timer; | ||
var errorReporter: CompilerErrorReporter; | ||
var lexer = mkLexer(code.all(), errorReporter, location); | ||
var parser = mkParser(lexer, errorReporter); | ||
var sps: SparrowPrologSystem = parser.parse(); | ||
sps.semanticCheck(); | ||
var t: time.Timer | ||
var errorReporter: CompilerErrorReporter | ||
var lexer = mkLexer(code.all(), errorReporter, location) | ||
var parser = mkParser(lexer, errorReporter) | ||
var sps: SparrowPrologSystem = parser.parse() | ||
sps.semanticCheck() | ||
//dumpProlog(cout, sps); | ||
var res = genProlog(sps); | ||
res setContext context; | ||
cout << "Elapsed: " << t.elapsed() << endl << flush; | ||
return res; | ||
} | ||
var res = genProlog(sps) | ||
res setContext context | ||
cout << "Elapsed: " << t.elapsed() << endl << flush | ||
return res | ||
|
||
[ct] fun prologToString(source: @String): String | ||
{ | ||
var errorReporter = mkConsoleErrorReporter(source.all()); | ||
var lexer = mkLexer(source.all(), errorReporter); | ||
var parser = mkParser(lexer, errorReporter); | ||
var sps: SparrowPrologSystem = parser.parse(); | ||
sps.semanticCheck(); | ||
var ss: StringOutputStream; | ||
dumpProlog(ss, sps); | ||
return ss.result; | ||
} | ||
var errorReporter = mkConsoleErrorReporter(source.all()) | ||
var lexer = mkLexer(source.all(), errorReporter) | ||
var parser = mkParser(lexer, errorReporter) | ||
var sps: SparrowPrologSystem = parser.parse() | ||
sps.semanticCheck() | ||
var ss: StringOutputStream | ||
dumpProlog(ss, sps) | ||
return ss.result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import prolog; | ||
import meta.compiler; | ||
import prolog | ||
import meta.compiler | ||
|
||
[ct] var dummy1 = registerFrontendFun(".pl", "logic/prolog.spr:handlePrologCode"); | ||
[ct] var dummy1 = registerFrontendFun(".pl", "logic/prolog.spr:handlePrologCode") |
Oops, something went wrong.