559 questions with no answers
1 vote
0 answers
26 views
Conditionally create nodes using JAVACC and JJTREE
I am having difficulty figuring out the best way to conditionally create nodes using javacc and jjtree. In my grammar there are literals, variables, operators and functions. Variables can have the ...
2 votes
0 answers
145 views
Simplify a prime factorization-like expression with optimal performance
I am working with a situation in which I need to turn an arithmetic string expression (e.g. (3/2) * (3**4 / (20 * 4))**(-1/4)) into the following prime factorization form: $\prod_{p:\text{prime}}p_i^{...
2 votes
0 answers
44 views
Get comments inside ast.CompositeLit node in golang.org/x/tools
I want to parse some ast.CompositeLit nodes and do some reordering of the fields instantiated in a struct. So, for example, imagine that I have the following struct: _ = Person{ // the name Name: &...
0 votes
0 answers
61 views
How can I programmatically detect template errors like "property does not exist"?
I have a simple Angular app: import { Component } from '@angular/core'; import { bootstrapApplication } from '@angular/platform-browser'; @Component({ selector: 'app-root', template: ` <...
0 votes
0 answers
54 views
opa ast library unable to unmarshal my json ast
Iam trying to unMarshal AST json to ast.Module structure of OPA. policy.rego: package example.authz import rego.v1 allow if { some i input.users[i].role == "admin" } use command ...
0 votes
0 answers
36 views
astor, ast, astunparse do not preserve lineno, astmonkey puts \ (backslash) everywhere
Here is the output run on a very simple urls.py from a test Django project: from django.contrib import admin from django.urls import path urlpatterns = [\ path('test_path1/', views.test_view1, ...
0 votes
0 answers
100 views
How to add a new method and method call using ast-grep in Java code
I'm working with ast-grep and trying to modify Java code by adding a new method at the end of the class (not necessarily at end, it can be anywhere in class )and inserting a method call. Despite ...
0 votes
0 answers
60 views
Reproducible Way to Create an AST from a Parse Tree
For my GameVM project I'm using ANTLR v4 to create multiple compiler frontends. Generating the lexer and parser for each language saved me a ton of work (especially since I have no background in ...
0 votes
0 answers
25 views
How do I select a variablestatement using tsquery (ast)?
I'm using @phenomnomnominal/tsquery and I seem to be having a really hard time with child selectors. Here is some demo code: import { tsquery, SyntaxKind } from '@phenomnomnominal/tsquery'; import { ...
1 vote
0 answers
50 views
How to use ast to parse javascript code and find out the execution conditions of specified methods
Issue with Parent Condition Context in Else Block During AST Traversal I’m working on a JavaScript code analysis tool that traverses the Abstract Syntax Tree (AST) to analyze function calls and their ...
0 votes
0 answers
41 views
How to check Groovy code against potential null-pointer exceptions
I have been able to use Google's errorprone on Java code along with other an extension-checker (Uber's NullAway) which catches potential errors at build time. From what I've seen searching around, it ...
0 votes
0 answers
25 views
Is it possible to prove that a given AST transformation is a perfect reversal of another?
I want to use AST transformation using jscodeshift to do a large scale refactor, changing our test runner from Jest to Bun Test. A concern that I'm trying to mitigate is that we might migrate the ...
0 votes
0 answers
71 views
Ast module for kdb sql queries
I want to analyze the code structure of a nested kdb+ queries just like what python ast module does to the python codes. I know that kdb "parse" function already does this in kdb, but how I ...
0 votes
0 answers
28 views
Typescript resolve type
I want to resolve type using typescript library. I want the type to be displayed as type typeCheck = { name: string } I am not able to find the exact typeChecker function that typescript library ...
0 votes
0 answers
113 views
Using Pydantic to define AST of boolean expressions
I'd like to use Pydantic to define and validate AST of queries that will be applied on a Pandas dataframe. Here's my code: from typing import List, Literal, Optional, Union from pydantic import ...