Is it possible to write a parser that only processes javascript import statements and ignores the rest? #1824
Replies: 2 comments
-
It would be possible in general to extract specific statements, I have done so in another language (ABAP).
|
Beta Was this translation helpful? Give feedback.
-
In addition to @bd82 said, something like |
Beta Was this translation helpful? Give feedback.
-
Hi,
I need to parse all the import / require statements from javascript and typescript files, in order to extract all the dependencies imported from the source of a package. This involves translating code to javascript / esm and using a pre-existant javascript parser to extract the imports, which is not too computationally efficient.
I'm new to the lexer / parser world and I have a question: would it be possible to write a parser that is able to parse javascript / typescript import or require statements (I don't need the assignment part) and simply ignore the rest? Or do I need to specify the whole js / ts grammar anyway?
Beta Was this translation helpful? Give feedback.
All reactions