Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>well, the "libraries" that you are referring to are just the <strong><em>language grammars</em></strong>. </p> <p>Indeed, language grammars are just <em>rule sets for divindg a document's syntax into scopes</em>. </p> <p>In other words, each rule in a grammar just assigns one or more elements of syntax to a scope.</p> <p>w/r/t the the actual <strong><em>parsing</em></strong>, for TextMate and Sublime Text, it is done by <strong><em>regular expressions</em></strong>.</p> <p>For instance, consider the python language grammar; As you know, when i put my cursor at the beginning of <em>while</em>, and do <em>ctrl-shift-P</em> (show scope), the scope will appear in the status bar:</p> <pre><code>source.python.keyword.control.flow.python </code></pre> <p>Again, this scope is defined in the python language grammar, so we can find the specific rule: </p> <pre><code>{ match = '\b(elif|else|except|finally|for|if|try|while|with|break|continue|pass|raise|return|yield)\b'; name = 'keyword.control.flow.python'; } </code></pre> <p>The first item, <strong><em>match</em></strong> is just the <em>pattern</em> that is passed into the parser.</p> <p>The second item, <strong><em>name</em></strong> is just the name given to that particular syntax element (i.e., the <em>scope</em>).</p> <p><strong>Sublime Text 2</strong> stores language grammars in the <em>Packages</em> directory with the extension <em>tmLanguage</em> as XML rather than JSON, so the rule above from the python language grammar looks like this in ST2:</p> <pre><code>&lt;dict&gt; &lt;key&gt; match &lt;/key&gt; &lt;string&gt; \b(elif|else|except|finally|for|if|try|while|with|break|....[truncated] &lt;/string&gt; &lt;key&gt; name &lt;/key&gt; &lt;string&gt; keyword.control.flow.python &lt;/string&gt; &lt;/dict&gt; </code></pre> <p>So every rule in the grammar is <em>wrapped</em> in a pair of <strong><em>dict tags</em></strong>, and each rule's <em>regexp</em> pattern is wrapped in <strong><em>string tags</em></strong>; ditto for its corresponding scope name.</p> <p>All of the language grammars are comprised entirely of these rules--with precisely this <em>match/name</em> (or <em>pattern/scope</em>) structure.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload