Skip to content

A newline preceding a left paren in a string acquired a prepended await #153

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

Merged
merged 1 commit into from
Aug 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion GlowScriptOffline/glowscript_libraries/compiler.3.1.min.js

Large diffs are not rendered by default.

Binary file modified GlowScriptOffline3.1.zip
Binary file not shown.
8 changes: 4 additions & 4 deletions lib/compiling/GScompiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ where compile() was called, in untrusted/run.js.
const instpatt = new RegExp('(\\w+)\\s*\\(') // find a constructor of a Python class
const defpatt = new RegExp('^def\\s+(\\w+)\\s*\\(') // find a Python def
const asyncpatt1 = new RegExp('\\Wfunction\\s*(\\w+)\\s*\\(') // find "function f(...."
const awaitpatt = new RegExp('\\W([ρσ\\w]+)\\s*\\(') // find a function call
const awaitpatt = new RegExp('\\W([ρσ\\w]+)[ ]*\\(') // find a function call

// fcts is a list of GlowScript functions that need "await" and of all user functions that are not
// classes, instances of classes, or methods of classes:
Expand Down Expand Up @@ -584,7 +584,7 @@ where compile() was called, in untrusted/run.js.
// Check whether this line contains function calls inside strings, which will not need "await"
start = 0
while (true) {
// const awaitpatt = new RegExp('\\W([ρσ\\w]+)\\s*\\(') // find a function call
// const awaitpatt = new RegExp('\\W([ρσ\\w]+)[ ]*\\(') // find a function call
var m = line.slice(start).match(awaitpatt)
if (m !== null) {
start += m.index
Expand Down Expand Up @@ -945,11 +945,11 @@ where compile() was called, in untrusted/run.js.
'ceil', 'floor', 'sign', 'round', 'max', 'min', 'random', "factorial", "combin"]

// VPython_import is the prefix of VPython objects, with value 'null' if no import statement
// const awaitpatt = new RegExp('\\W([ρσ\\w]+)\\s*\\(') // find a function call
// const awaitpatt = new RegExp('\\W([ρσ\\w]+)[ ]*\\(') // find a function call
while (true) {
m = prog.slice(start).match(awaitpatt)
var period = false
if (m === null) break
if (m === null || prog[start+m.index] == '\\') break // Check for '\n' inside a string
period = (prog[start+m.index] == '.')
name = m[1]
if (!period && no_await.indexOf(name) >= 0) {
Expand Down
2 changes: 1 addition & 1 deletion package/RScompiler.3.1.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package/compiler.3.1.min.js

Large diffs are not rendered by default.