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

Patch from debian #693

Closed
bastien-roucaries opened this issue May 5, 2018 · 3 comments
Closed

Patch from debian #693

bastien-roucaries opened this issue May 5, 2018 · 3 comments

Comments

@bastien-roucaries
Copy link

bastien-roucaries commented May 5, 2018

Hi,

We modified the generated regex script in order to rebuild at build time. Could you apply ?

subject: modify generate identifier in order to patch file
author: Bastien Roucariès <[email protected]>

Modify this script in order to use it in build rule: 

forwarded: yes
Index: newacorn/bin/generate-identifier-regex.js
===================================================================
--- newacorn.orig/bin/generate-identifier-regex.js
+++ newacorn/bin/generate-identifier-regex.js
@@ -51,7 +51,23 @@ function generate(chars) {
 
 var startData = generate(start), contData = generate(cont);
 
-console.log("let nonASCIIidentifierStartChars = \"" + startData.nonASCII + "\"");
-console.log("let nonASCIIidentifierChars = \"" + contData.nonASCII + "\"");
-console.log("const astralIdentifierStartCodes = " + JSON.stringify(startData.astral));
-console.log("const astralIdentifierCodes = " + JSON.stringify(contData.astral));
+
+
+if(process.argv.length != 3) {
+    console.log("let nonASCIIidentifierStartChars = \"" + startData.nonASCII + "\"");
+    console.log("let nonASCIIidentifierChars = \"" + contData.nonASCII + "\"");
+    console.log("const astralIdentifierStartCodes = " + JSON.stringify(startData.astral));
+    console.log("const astralIdentifierCodes = " + JSON.stringify(contData.astral));
+}
+else {
+    var fs = require('fs');
+    fs.readFile(process.argv[2], function(err, data) {
+    data.toString().split("\n").forEach(function(line) {
+       line = line.replace(/\s*let nonASCIIidentifierStartChars.*/, "let nonASCIIidentifierStartChars = \"" + startData.nonASCII + "\"");
+       line = line.replace(/\s*let nonASCIIidentifierChars.*/,"let nonASCIIidentifierChars = \"" + contData.nonASCII + "\"");
+        line = line.replace(/\s*const astralIdentifierStartCodes.*/,"const astralIdentifierStartCodes = " + JSON.stringify(startData.astral));
+        line = line.replace(/\s*const astralIdentifierCodes.*/,"const astralIdentifierCodes = " + JSON.stringify(contData.astral));
+       console.log(line);
+        });
+    });
+}
@bastien-roucaries
Copy link
Author

we use it like node node bin/generate-identifier-regex.js src/identifier.js > build/src/identifer.js

@marijnh
Copy link
Member

marijnh commented May 6, 2018

Could you clean this up so that it doesn't repeat the expressions? Ideally, put the lines in an array, and depending on the command line arguments, console.log them or generate a regexp from their first two words and replace on that.

@marijnh
Copy link
Member

marijnh commented Sep 10, 2018

Guess not, then. I've applied a cleaned-up version of your proposed change in 3442a80

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants