This repository was archived by the owner on Nov 4, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 164
Text parser 2
rsms edited this page Jan 5, 2011
·
22 revisions
This is a sort of scrap book for the work on text-parser2.
Research into using a universal AST (Abstract Syntax Tree) to represent a document. A complex language parser can provide a rich and complete AST while a simplistic parser can simply build a flat tree.
Current work and results are sometimes updated here: https://gist.github.com/764184
Outline:
- The text parser runs in the embedded nodejs runtime thread.
- Kod can send an "edited text" message to the parser at any given time.
- The parser can send a "tree updated" message to kod at any given time.
Kod sending a "text edited" message to the parser system:
[kod -> node] "text edited" {
document: [KDocument],
modifiedRange: [123, 4],
changeDelta: 4
}
-
document
is an object which represents the document which text was altered. This document can be queried for:- language type
- modification timestamp
- complete source text
In Mathematica frontend, a user can press a key [Ctrl+.], and the token the cursor is on will be selected (highlighted), when user presses the key again, the selection expands to highlight the next smallest semantic unit. When the key is pressed again, it extends further.