Giter Site home page Giter Site logo

cpp's People

Contributors

marijnh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

cpp's Issues

Update TypeScript exports to support moduleResolution bundler

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.

wrong affinity of pointer-star in function type

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",
    }
  ]
}

Large buffer of non C++ text results in RangeError: Maximum call stack size exceeded

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.

image

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.