For node:
CodeMirrorGrammar = require('build/codemirror_grammar.js');For browser:
<script src="build/codemirror_grammar.js"></script>Method: clone
cloned_grammar = CodeMirrorGrammar.clone( grammar [, deep=true] );Clone (deep) a grammar
Utility to clone objects efficiently
Method: extend
extended_grammar = CodeMirrorGrammar.extend( grammar, basegrammar1 [, basegrammar2, ..] );Extend a grammar with basegrammar1, basegrammar2, etc..
This way arbitrary dialects and variations can be handled more easily
Method: pre_process
pre_processed_grammar = CodeMirrorGrammar.pre_process( grammar );This is used internally by the CodeMirrorGrammar Class parse method
In order to pre-process a JSON grammar (in-place) to transform any shorthand configurations to full object configurations and provide defaults.
It also parses PEG/BNF (syntax) notations into full (syntax) configuration objects, so merging with other grammars can be easier, if needed.
Method: parse
parsed_grammar = CodeMirrorGrammar.parse( grammar );This is used internally by the CodeMirrorGrammar Class
In order to parse a JSON grammar to a form suitable to be used by the syntax-highlight parser.
However user can use this method to cache a parsedgrammar to be used later.
Already parsed grammars are NOT re-parsed when passed through the parse method again
Method: getMode
mode = CodeMirrorGrammar.getMode( grammar [, DEFAULT, CodeMirror] );This is the main method which transforms a JSON grammar into a CodeMirror syntax-highlight parser.
DEFAULT is the default return value (null by default) for things that are skipped or not styled
In general there is no need to set this value, unless you need to return something else
The CodeMirror reference can also be passed as parameter, for example,
if CodeMirror is not already available when the add-on is first loaded (e.g via an async callback)
Parser Class: Parser
Parser = CodeMirrorGrammar.Parser;The Parser Class used to instantiate a highlight parser, is available.
The getMode method will instantiate this parser class, which can be overriden/extended if needed, as needed.
In general there is no need to override/extend the parser, unless you definately need to.