You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Not sure what I'm doing wrong, there's no mark() method on string.
constfs=require('fs');const{ApexLexer, CommonTokenStream, CaseInsensitiveInputStream, ApexParser}=require('@apexdevtools/apex-parser');letlexer=newApexLexer(newCaseInsensitiveInputStream("public class Hello {}"))lettokens=newCommonTokenStream(lexer);letparser=newApexParser(tokens)letcontext=parser.compilationUnit()
\node_modules\@apexdevtools\apex-parser\lib\CaseInsensitiveInputStream.js:46
return this.src.mark();
^
TypeError: this.src.mark is not a function
at CaseInsensitiveInputStream.mark (XXX\node_modules\@apexdevtools\apex-parser\lib\CaseInsensitiveInputStream.js:46:25)
at ApexLexer.nextToken (XXX\node_modules\antlr4ts\Lexer.js:87:44)
at CommonTokenStream.fetch (XXX\node_modules\antlr4ts\BufferedTokenStream.js:147:38)
at CommonTokenStream.sync (XXX\node_modules\antlr4ts\BufferedTokenStream.js:133:32)
at CommonTokenStream.setup (XXX\node_modules\antlr4ts\BufferedTokenStream.js:244:14)
at CommonTokenStream.lazyInit (XXX\node_modules\antlr4ts\BufferedTokenStream.js:240:18)
at CommonTokenStream.tryLT (XXX\node_modules\antlr4ts\CommonTokenStream.js:78:14)
at CommonTokenStream.LT (XXX\node_modules\antlr4ts\BufferedTokenStream.js:198:27)
at ApexParser.enterRule (XXX\node_modules\antlr4ts\Parser.js:491:40)
at ApexParser.compilationUnit (XXX\node_modules\@apexdevtools\a
Activity
adangel commentedon Jan 10, 2025
When creating
CaseInsensitiveInputStream, you need to provide a CharStream and not a simple string:CharStreams is from antlr4ts:
import { CharStreams } from "antlr4ts";See also the test code:
apex-parser/npm/src/__tests__/SyntaxErrorCounter.ts
Lines 49 to 52 in 29a72a7
pkozuchowski commentedon Jan 10, 2025
Ok, thanks :) I was looking at example on README, it's probably outdated.
Update README.md
Update README.md