Comments (8)
(1)Thank you for your reminder. I will analyze how to implement the optimization plan later.
(2)We are developing a cloud-native IDE based on the .NET platform.The official version has not been released yet.
from textmatesharp.
Hi @pengsongkun741.
The call to IGrammar.TokenizeLine(string lineText, StackElement prevState)
should allow null values for the prevState
param for those cases you want to parse a single line.
The line you are parsing should be well-formed from a lexer point of view.
If not, you should include some prev/next lines to build a well-formed text chunk, doing the following to maintain a parsing context:
StackElement ruleStack = null;
foreach (string line in linesToParse)
{
ITokenizeLineResult result = grammar.TokenizeLine(line, ruleStack);
ruleStack = result.RuleStack;
// process the result.GetTokens() for the line you're interested in
}
from textmatesharp.
Hello, I restored this scene with a simple Demo.
Read a Json file from the first line and the second line respectively, the results of the analysis of name
are different.
The result read from the second line is wrong. Is my usage wrong?
Thanks for your reply!
from textmatesharp.
Hi @pengsongkun741,
The parser behaves correctly.
When you remove the first line, the JSON is not well-formed. That means that the parser isn't able to correctly identify some json-specific rules.
As you can see, VSCode behaves in the same way (it uses the same implementation). The left file is not well formed, so the parser is not able to identify the support.type.property-name.json
scope.
from textmatesharp.
Sorry, it should be my usage method is wrong.
I found that the parsing speed of grammar.TokenizeLine() method is very fast, I can parse all the text at once through it, and then get the Token I need from it. Instead of just parsing part of the text.
What I considered before was when the text is very large, if the entire text needs to be parsed, the burden on the parser will be great.
So we generally only parse the visible area or changed text , this is a way to ensure the performance of the editor.
Thanks again for your answers. In addition, I would like to ask when the nuget package will be released for this project, which will introduce the textmate parser into the .NET ecosystem. It is very meaningful for us IDE developers!
from textmatesharp.
It takes about 300-400ms to parse a 10,000-line Json completely. Is this necessary consumption? I can't feel any performance issues when opening large json files with vscode.
Is there a way to get the correct result without parsing the entire content?
from textmatesharp.
If you're using this lib for an IDE, I think the way to go should be writing a smart tokenization support.
AFAIK VSCode is pretty well optimized.
I think it parses the viewport first (the visible editor lines), and then it parses the whole document in the background, and then updates the viewport again.
When the file is edited I think it backwards to find a good starting stack, as an starting point to parse. (I speak by heart).
This is how VSCode uses the textmate parser, and performs the tokenization:
from textmatesharp.
About building a nuget package, this is something we'll do in the short-mid term. Just out of curiosity, which IDE are you building? ;-)
from textmatesharp.
Related Issues (17)
- Unicode text is not correctly parsed HOT 2
- Operations that change non-concurrent collections must have exclusive access
- Support for XML Plist grammars? HOT 1
- Custom Grammars - Where to Start HOT 1
- Textmate thread safe HOT 3
- Cannot use Ini grammar with turkish culture
- RegistryOptions.GetScopeByExtension causes NullReferenceException HOT 4
- Switch to System.Text.Json? HOT 18
- How to parse embedded languages? HOT 1
- Support for arm32 and arm64 HOT 9
- Feature request - add rule name to ParsedThemeRule and language-configuration classes HOT 9
- Include packages for x86/x64 onigwrap.dll, and dynamic binding between them HOT 20
- Release a nuget package with the latest code changes? HOT 2
- TextMateSharp with Wasm not working? HOT 8
- Use [Flags] enum for FontStyle HOT 3
- System.Threading.Thread.Start not supported on webassembly HOT 21
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from textmatesharp.