Skip to content

Commit 1835028

Browse files
author
Max Schaefer
committed
JavaScript: Show character code when reporting unexpected character.
1 parent 8a69369 commit 1835028

File tree

7 files changed

+35
-9
lines changed

7 files changed

+35
-9
lines changed

javascript/extractor/src/com/semmle/jcorn/Parser.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,8 @@ protected Token getTokenFromCode(int code) {
721721
return this.finishOp(TokenType.prefix, 1);
722722
}
723723

724-
this.raise(this.pos, "Unexpected character '" + codePointToString(code) + "'");
724+
String msg = String.format("Unexpected character '%s' (U+%04X)", codePointToString(code), code);
725+
this.raise(this.pos, msg);
725726
return null;
726727
}
727728

javascript/extractor/src/com/semmle/js/extractor/AutoBuild.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,9 @@
163163
* following environment variables are available:
164164
*
165165
* <ul>
166-
* <li><code>LGTM_THREADS</code> determines how many threads are used for parallel
167-
* extraction of JavaScript files (TypeScript files cannot currently be extracted in
168-
* parallel). If left unspecified, the extractor uses a single thread.
166+
* <li><code>LGTM_THREADS</code> determines how many threads are used for parallel extraction of
167+
* JavaScript files (TypeScript files cannot currently be extracted in parallel). If left
168+
* unspecified, the extractor uses a single thread.
169169
* <li><code>LGTM_TRAP_CACHE</code> and <code>LGTM_TRAP_CACHE_BOUND</code> can be used to specify
170170
* the location and size of a trap cache to be used during extraction.
171171
* </ul>

javascript/extractor/src/com/semmle/js/extractor/Main.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class Main {
3737
* A version identifier that should be updated every time the extractor changes in such a way that
3838
* it may produce different tuples for the same file under the same {@link ExtractorConfig}.
3939
*/
40-
public static final String EXTRACTOR_VERSION = "2019-03-13";
40+
public static final String EXTRACTOR_VERSION = "2019-03-21";
4141

4242
public static final Pattern NEWLINE = Pattern.compile("\n");
4343

javascript/extractor/src/com/semmle/js/extractor/test/AutoBuildTests.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,7 @@ private Path addFile(boolean extracted, FileType fileType, Path root, String...
8484
return f;
8585
}
8686

87-
/**
88-
* Add a file with default file type.
89-
*/
87+
/** Add a file with default file type. */
9088
private Path addFile(boolean extracted, Path root, String... components) throws IOException {
9189
return addFile(extracted, null, root, components);
9290
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#10000=@"/zwsp.js;sourcefile"
2+
files(#10000,"/zwsp.js","zwsp","js",0)
3+
#10001=@"/;folder"
4+
folders(#10001,"/","")
5+
containerparent(#10001,#10000)
6+
#10002=@"loc,{#10000},0,0,0,0"
7+
locations_default(#10002,#10000,0,0,0,0)
8+
hasLocation(#10000,#10002)
9+
#20000=@"global_scope"
10+
scopes(#20000,0)
11+
#20001=@"script;{#10000},1,1"
12+
toplevels(#20001,0)
13+
#20002=@"loc,{#10000},1,1,1,1"
14+
locations_default(#20002,#10000,1,1,1,1)
15+
hasLocation(#20001,#20002)
16+
#20003=*
17+
jsParseErrors(#20003,#20001,"Error: Unexpected character '​' (U+200B)","​
18+
")
19+
hasLocation(#20003,#20002)
20+
#20004=*
21+
lines(#20004,#20001,"​","
22+
")
23+
hasLocation(#20004,#20002)
24+
numlines(#20001,1,0,0)
25+
numlines(#10000,1,0,0)
26+
filetype(#10000,"javascript")

javascript/extractor/tests/shebang/output/trap/tst.html.trap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ toplevels(#20001,1)
1414
locations_default(#20002,#10000,3,17,3,17)
1515
hasLocation(#20001,#20002)
1616
#20003=*
17-
jsParseErrors(#20003,#20001,"Error: Unexpected character '#'","#!/usr/bin/node
17+
jsParseErrors(#20003,#20001,"Error: Unexpected character '#' (U+0023)","#!/usr/bin/node
1818
")
1919
#20004=@"loc,{#10000},4,1,4,1"
2020
locations_default(#20004,#10000,4,1,4,1)

0 commit comments

Comments
 (0)