I am adding my own js library to monaco. I want AST of code typed in editor to validate with my code.Is there any way to get AST from monaco
I need to access AST of code typed from editor
Related
In our web application, we are using the react-ace code editor with language mode python. We are trying to implement python linting in our code editor.
Ace editor doesn't have any python linting. So we tried to explore for pylint packages and integrate them into ace worker (Ace syntax validation). In our exploration, we got a few inputs like using Skulpt, Pyodide. But these two packages compile the python code and even if the error is in multiple lines, they give the 1st error line as a result.
Means for example ace editor already have javascript linting. In
this image the warning is shown for both the lines.
But when we use Skulpt, Pyodide it gives only one error/warning message, check this image. In this image both a and b are not defined but output gives only a is not defined. What we are expecting is python linting should show for every line of code.
Are there any other packages for python linting to use in web environment?
There is a ESTree spec describing JavaScript AST format, which is used in several libraries for JS code transformations (refactoring, transpiling, minification, etc).
Are there any tools/libraries with API focused on generating the ESTree AST from scratch (not from existing JS code) and manipulate it? Preferably in TypeScript to get the advantage of static typing of ESTree nodes.
In the docx4js GitHub page it is illustrated how to open a docx file and parse it. Is it possible to use this library to parse clipboard data obtained from copying some part of ms-word docx?
PS 1I think that this library is a node application for server-side use, but I want to use it in client-side!
PS 2: I partially wrote some parser for this purpose but there are many different types of structure and styling and this task is rather complicated and error prone! Is there any (javascript) library simplifying this parsing?
I've converted syntax parser part of Roslyn project into javascript (Typescript) and it's worked, and now i want to find a javascript-based code editor which can integrate with Roslyn lexer/parser for highlighting
So far, I've found 2 editor:
With ace editor, looks like it only supports highlight with regular expression rules
With codemirror(_https://codemirror.net/), it does support if your lexer can be processed as a sream with state, but i dont know when/which parts of text codemirror will trigger lexer to reparsed as user typing (Roslyn parser already has mechanism to detect change, so i want to reuse it)
(Both ace editor, code mirror support mark text,but i'm not sure if it's good for perfomance, because you may have to clear marks before set a new mark again)
So how can i achieve this, any other code editor should I choose, any idea? Thank you
CodeMirror will re-run its mode on pieces of the document that are changed, you do not need your own change detection. Read this blog post for an explanation of CodeMirror modes.
I am very very new to Spidermonkey Parser and I have two questions. The first one is to have a good documentation (for beginners) about how to generate the AST of a Javascript file with spidermonkeyParser. And the second one is to know how to traverse the AST. My goal is to use the information in the AST to do some static analysis of the JS files (Type analysis, String analysis).
Thank you
The AST of Spidermonkey is exposed as Javascript objects. That means you should write a small Javascript script, use that script to read and parse the actual Javascript source file your want to parse and obtain the AST as Javascript objects.
This feature is available in the standalone SpiderMonkey shell (probably not in the version that comes with Firefox). You need to download the full Spidermonkey source and build it using the bundled python scripts. A Shell will be built along with your standalone Spidermonkey Javascript engine. This shell is just a small console program accepting user commands. The shell can read and execute standalone Javascript scripts. In particular, those Javascript scripts executed by this Shell have access to an extra global object called Reflect which has a method called parse(). The Shell also support extra file I/O functions which is the way you read in the target Javascript source you want to parse.
The description of the full AST is here:
https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API