lezer-parser / cpp Goto Github PK
View Code? Open in Web Editor NEWC++ grammar for the Lezer parser system
License: MIT License
C++ grammar for the Lezer parser system
License: MIT License
moduleResolution: "bundler"
is a recent setting added to TypeScript to support bundler setups. It's the setting you should probably be using when bundling code. With this setting TypeScript only searches for types in the exports field of the package.json
.
It requires the following change:
"exports": {
"import": "./dist/index.js",
"require": "./dist/index.cjs",
+ "types": "./dist/index.d.ts"
},
This is issue is relevent to multiple @lezer packages I'm using.
source
void* some_function() {}
actual parse tree
FunctionDefinition: "void* some_function() {"
PrimitiveType: "void"
PointerDeclarator: "* some_function()"
FunctionDeclarator: "some_function()"
Identifier: "some_function"
ParameterList: "()"
(: "("
): ")"
CompoundStatement: "{"
{: "{"
}: "}"
actual affinity: void (* some_function)
expected affinity: (void *) some_function
actual vs expected parse tree
FunctionDefinition: "void* some_function() {"
- PrimitiveType: "void"
- PointerDeclarator: "*some_function()"
- FunctionDeclarator: "some_function()"
+ CompoundType: "void*"
+ PrimitiveType: "void"
+ PointerStar: "*"
+ FunctionDeclarator: "some_function()"
Identifier: "some_function"
ParameterList: "()"
(: "("
same bug in tree-sitter-cpp, see playground
expected parse tree per clang
{
"kind": "FunctionDecl",
"name": "some_function",
"type": {
"qualType": "void *()"
},
"inner": [
{
"kind": "CompoundStmt",
}
]
}
Hi!
Using the C++ parser in Codemirror together with a large buffer of HTML text results in a RangeError: Maximum call stack size exceeded
error.
The following code in the Try Codemirror reproduces the error:
import {basicSetup, EditorView} from "codemirror"
import { cpp } from "@codemirror/lang-cpp"
let view = new EditorView({
doc: getContent(),
extensions: [
basicSetup,
cpp(),
],
parent: document.body
})
function getContent() {
const urlStr = `<url>
<loc>https://example.org</loc>
</url>`
return `<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
${[...Array(500)].map(() => urlStr).join("\n")}
</urlset>
`;
}
I understand that this is not proper use of the C++ parser, and I don't expect it to produce good syntax highlighting for that content, but I guess that it still shouldn't throw an exception. I imagine it could cause issues for an editor that lets the user manually change the current language if they accidentally chooses C++ for a large HTML-file.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.