vehre / aspa_cscc Goto Github PK
View Code? Open in Web Editor NEWConvert ASP pages to "pure" html/JS/PHP pages. Based on ASPA with conversion of client side VBscript to Javascript
License: Other
Convert ASP pages to "pure" html/JS/PHP pages. Based on ASPA with conversion of client side VBscript to Javascript
License: Other
Interprete and include to become import "foo.js";
Output filename before processing file. Trivial patch to make errors and warnings actually useful for something.
VBScript:
"0" + "1" = 1
"0" + 1 = 1
"0" & 1 = "01"
Solution:
Implement add(a,b), concat(a,b) and change emitted code to use function calls instead of operators.
<% if x = true then %>
<% endif %>
Will error out with cannot cast to integer for function returns.
Reverting commit b6591c3 fixes this.
Function returns should not be initialized, because by default nothing is returned if the function does not set a return value.
unexpected char: 0xFFFD
test case was a Big5 encoded asp file
select case
case "01","02","03"
doX
case "04","05","06"
doY
....
case content body will get cut off
Those get stripped totaly, which is not desired.
msgbox rNode.selectsingleNode("description").text,,"foobarbaz"
<script language=vbscript>
sHtml=sHtml&"<td width='10%'>"&objNode.selectSingleNode("SpendTime").text&"</td></tr>"
</script>
Error: unexpected char: 'b'
Adding spaces between the "&"s is a workaround.
Some files throw an AST node error, unknown AST node
ERROR AspParser - Failed to produce code from vb :
<AST>:0:0: unexpected AST node: ubound
at gr.omadak.leviathan.asp.VbsJsGenerator.expression(VbsJsGenerator.java:1325)
at gr.omadak.leviathan.asp.VbsJsGenerator.expression(VbsJsGenerator.java:989)
at gr.omadak.leviathan.asp.VbsJsGenerator.expr(VbsJsGenerator.java:822)
at gr.omadak.leviathan.asp.VbsJsGenerator.nested(VbsJsGenerator.java:710)
at gr.omadak.leviathan.asp.VbsJsGenerator.statement(VbsJsGenerator.java:187)
at gr.omadak.leviathan.asp.VbsJsGenerator.statements(VbsJsGenerator.java:103)
at gr.omadak.leviathan.asp.VbsJsGenerator.function(VbsJsGenerator.java:515)
at gr.omadak.leviathan.asp.VbsJsGenerator.nested(VbsJsGenerator.java:633)
at gr.omadak.leviathan.asp.VbsJsGenerator.statement(VbsJsGenerator.java:187)
at gr.omadak.leviathan.asp.VbsJsGenerator.statements(VbsJsGenerator.java:103)
at gr.omadak.leviathan.asp.VbsJsGenerator.generate(VbsJsGenerator.java:60)
at gr.omadak.leviathan.asp.AspParser.produceCode(AspParser.java:424)
at gr.omadak.leviathan.asp.AspParser.parseFile(AspParser.java:378)
at gr.omadak.leviathan.asp.AspParser.parseFile(AspParser.java:493)
at gr.omadak.leviathan.asp.AspParser.parseDir(AspParser.java:568)
at gr.omadak.leviathan.asp.AspParser.main(AspParser.java:666)
As an example, xmlhttp.send() can take one optional parameter. However, you cannot declare send to be both
send()
and
send(parameter)
This will cause them to emit nothing.
This is possible:
send(parameter), send( param1, param2, param3 ) ...
Add command line switch '-nm' to switch of comments for unknown objects and methods.
Sub subroutine(param)
param = 3
end sub
Emitting a JS comment (and/or a debugger breakpoint) when parameters are set would make the conversion process easier:
function subroutine(param) {
param = 3; debugger; //PARAMETER MODIFIED BY REFERENCE
}
Ideally this would be handled automatically, but that would be non-trivial, and in some cases may behave differently than intended or introduce performance penalties.
Issue Overview:
So far, definite assignment analysis (useBeforeInit) has issues that make it impractical and it isn't completely reliable.
So, implementing add(a,b), minus(a,b), concat(a,b) and compareTo(a,b), and etc seems to be the only automated solution.
This can also benefit by fixing problems with primitive type coercion, which is different in VBScript and Javascript.
eg: 0 + "1" is 1 in VBScript
Performance and Work time:
Overhead should not be too much of an issue in modern browsers, and after using Closure Compiler (which can inline many of these calls with type analysis in Rhino).
Functions should be trivial, and only needs to check for typeof === "undefined", and replace with corresponding value. Undefined wrapper may not even be necessary.
This can also be used to fix issue #26
VBScript Behavior:
Undefined variable behavior in VBScript:
undefined == 0
undefined == ""
10 + undefined == 10
"" + undefined == ""
undefined - 10 == -10
undefined is nothing
Solution:
Translate
a + b to add(a,b)
if a = b then to if(compareTo(a,b))
a & b to concat(a,b)
Use typeof a === "undefined" to handle behavior.
aspa doesn't currently attach the line/col number properly to the tree. It's always 0.
Filename should also be attached to the tree.
Useful links:
http://stackoverflow.com/questions/9954882/antlr-preserve-line-number-and-position-in-tree-grammar
http://stackoverflow.com/questions/19787204/antlr-getting-the-line-number-in-the-parservisitor
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.