3,047 questions
0
votes
2
answers
72
views
How to reliably map glibc dynamic symbols (e.g., open@glibc) to kernel syscalls (e.g., openat)?
I am trying to build a mapping between the dynamic symbols in ELF files (from glibc) and the actual kernel syscalls they invoke.
My environment is x86_64 Ubuntu 22.04.
What I've Tried
Parsing man 2 ...
1
vote
0
answers
18
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 ...
1
vote
1
answer
87
views
How to represent a potentially infinite list of computation as an algebraic datatype
Let's say I want to define a potentially infinite list of computation as a data type. So that the computation could be
fun a -> a' =
Just a' || fun (a -> a')
|| fun (a -> b) &...
2
votes
0
answers
43
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
50
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 ...
2
votes
1
answer
92
views
How to resolve command name and parameters from a CommandAst
With writing custom PSSA rules and just parsing PowerShell scripts, I find myself often in the same use case where I would like to resolve command name (which is not that difficult) and the parameters ...
1
vote
1
answer
120
views
ast-grep `files` and `ignores` configuration not filtering properly in pattern detector
I'm using ast-grep to detect patterns in Java files, but the files and ignores filter configuration isn't working as expected.
According to the documentation, we can apply pattern matching to specific ...
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
96
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
21
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 { ...
2
votes
1
answer
84
views
How to use AST to understand how a golang struct field is created?
First time asking a question here, apologies if this isn't sufficiently clear :)
I have a list of Foos, where Foo is some struct type imported upstream. Foo has some field Bar that is a bit ...
0
votes
0
answers
35
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
1
answer
84
views
How to get AST representation from the result of `script.runInContext` (loseless)?
I am doing something like
let p = `(function (X) {
var q = 0;
for (; q < 5; ) {
// do some stuff
anotherfunc = function (a) {
while (X === "somestring") {
X += &...
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 ...
0
votes
0
answers
210
views
How to make LLM update code in the code editor seamlessly
So I have a project I'm working on and it will require an LLM to update existing code and write it back to the editor,where I'm having issues is finding a good way to update anywhere within the code ...
0
votes
1
answer
55
views
BigQuery dialect grammar file PEG
I'm working on an SQL query dialect converter. For example, given a MySQL query, it can convert it to Postgres or BigQuery. It was easy to find MySQL, SQLite, and part of the PostgreSQL grammar file, ...
1
vote
1
answer
78
views
How to match std::stringstream through AST?
Target code block:
int age = 5;
std::stringstream q;
q << "my name "
<< "is Tom, "
<< "my age is " << age;
I'm trying to create a matcher to ...
1
vote
0
answers
45
views
undefined references building clang ast ToolTemplate.cpp
I'm trying to build my first clang AST tool on windows 10. I want develop on visual studio code in c++ - I can live with any compiler that works...
I've looked at the clang documentation , YouTube ...
2
votes
2
answers
65
views
How to Exclude Tagless Structs Using ASTMatcher?
I'm currently working with Clang's ASTMatcher to extract struct declarations and exclude tagless structs. Here's an example of the kind of struct I want to avoid matching:
#include <stdlib.h>
...
1
vote
0
answers
38
views
How to get the member function that contains a specific varDeclRef through AST?
Example code:
#include <string>
class DBFetcher {
public:
void findByName(std::string name) {}
void findByNameV2(std::string name) {}
}
DBFetcher getFetcher() {
return FBFetcher();
...
0
votes
1
answer
131
views
LibCST matcher for detecting nested f-string expressions in Python AST
I want to create a transformer that converts all quotes of f-strings from a single quote to triple quotes, but leaves nested f-strings intact.
For example, the next expression left intact.
f"&...
3
votes
1
answer
72
views
How to convert Python List into ast.List?
How can I convert Python object - a list, into an ast.List object, so I can appent it to the main AST tree as a node
huge_list [ 1, "ABC", 4.5 ]
object = ast.Assign([ast.Name(...
2
votes
1
answer
124
views
Error: unknown type name 'ASTNode' in Bison parser when integrating with Flex lexer
I'm working on a project where I'm using Bison to generate a parser and Flex to generate a lexer. My parser is meant to generate an Abstract Syntax Tree (AST), and I've defined the ASTNode structure ...