Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guard identifier on compiled JS #9

Open
pveyes opened this issue Oct 21, 2018 · 1 comment
Open

Guard identifier on compiled JS #9

pveyes opened this issue Oct 21, 2018 · 1 comment
Labels
good first issue Good for newcomers scope: compiler-js Affecting JS compiler type: bug Something isn't working

Comments

@pveyes
Copy link
Owner

pveyes commented Oct 21, 2018

Currently we can use any reserved word/token (such as var, if, etc) as identifier in naskah which won't be valid JS. The simplest thing we can do is add underscore before printing the identifier if it's a reserved word in JS

So that:

misal x = 3;
misal var = 2;

jika while benar {
} 

should be compiled to

var x = 3;
var _var = 2;

if (_while == true) {
}
@pveyes pveyes added type: bug Something isn't working good first issue Good for newcomers scope: compiler-js Affecting JS compiler labels Oct 21, 2018
@andraantariksa
Copy link

I think the solution depends on the goal itself. If the transpiler goal is to create an optimized javascript code, it is better to create a shorter identifier to reduce the parsing time (?). For another case, why don't make all of the javascript keyword a reserved keyword? Adding something to the identifier is more counter-intuitive for me and it will be a special case that people might have to remember if they wants to interact with the generated code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers scope: compiler-js Affecting JS compiler type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants