File: antlr-mode.el.html

The Emacs package ANTLR-Mode provides: syntax highlighting for ANTLR grammar files, automatic indentation, menus containing rule/token definitions and supported options and various other things like running ANTLR from within Emacs. It works for ANTLR v2, v3 and v4.

For details, check <https://antlr-mode.sourceforge.net/> or, if you prefer the manual style, follow all commands mentioned in the documentation of antlr-mode. ANTLR is a LL(k)-based recognition tool which generates lexers, parsers and tree transformers in Java, C++ or other languages and can be found at <https://www.antlr.org/>.

Topics for 3.2 or later:

 * Special support for indent-region: faster and better for Python ELP
   profiling in a class init action shows half the time is spent in
   antlr-next-rule, the other half in c-guess-basic-syntax.
   Do not define a indent command, just a function to be put into
   indent-line/region-function.
 * In v4, highlight lexer commands after "->"
 * Test: in antlr-imenu-create-index-function, can we use
     (or antlr-skip-line-regexp antlr-grammar-header-regexp)
 * Use native menu bindings instead easymenu (and use :help)
 * Support v4 rule element options
 * Define minor mode for antlr-hide-actions functionality.
 * [C-c C-u]. *Help* for current rule / all rules: used-By list (at least
   for single-file grammars)
 * [C-c C-j]. Jump to generated coding.

Eventually:

 * Support for one of the multi-mode imenu extensions mentioned in
   https://www.emacswiki.org/emacs-test/ImenuMode - if necessary
 * [C-c C-w]. Produce HTML document with syntax highlighted and
   hyper-links. With htmfontify: invisible actions did not really work
   (only w/o spaces?, default invisible would be better anyway) - we need to
   set <a> tags afterwards ourselves... Firefox does not understand
   encoding via XML declaration - use HTML meta tag.
 * Support for outline-minor-mode.

The following topics and suggestions are unlikely to be implemented:

 * Some constructs of languages (in actions) which are highly un-C-ish might
   bring Emacs (and ANTLR!) out of sync: e.g. regexp literals in Perl,
   character and percent literals in Ruby.
 * Faster syntax highlighting: sectionize the buffer into Antlr and action
   code and run special highlighting functions on these regions. UNLIKELY
   due to: code size, this mode would depend on font-lock internals.
 * Set the syntax-table of the inner mode before calling the indentation
   engine of the inner mode (possible? - BUT: actions should still end at
   the same place!). Probably not worth the effort.

Bug fixes, bug reports, improvements, and suggestions for the newest version are strongly appreciated.

Defined variables (134)

antlr-action-font-lock-keywordsFont Lock keywords used for the actions in the grammar.
antlr-action-modeMajor-mode for code in actions of the grammar.
antlr-action-namesValid ANTLR action names.
antlr-action-scope-namesValid ANTLR action scope names.
antlr-action-visibilityVisibility of actions when command ‘antlr-hide-actions’ is used.
antlr-ask-about-saveIf not nil, M-x antlr-run-tool asks which buffers to save.
antlr-base-offset-alistInfluence the rule indentation of ‘antlr-indent-line’.
antlr-c-action-font-lock-keywordsValue for ‘antlr-action-font-lock-keywords’ when using language ‘antlr-c’.
antlr-c-action-modeValue for ‘antlr-action-mode’ when using language ‘antlr-c’.
antlr-c-init-cc-modeValue for ‘antlr-init-cc-mode’ when using language ‘antlr-c’.
antlr-c-language-mode-nameValue for ‘antlr-language-mode-name’ when using language ‘antlr-c’.
antlr-compilation-error-regexp-alistIf non-nil, used instead ‘compilation-error-regexp-alist’‘.
antlr-compilation-modeMode used for compile output of M-x antlr-run-tool.
antlr-cpp-action-font-lock-keywordsValue for ‘antlr-action-font-lock-keywords’ when using language ‘antlr-cpp’.
antlr-cpp-action-modeValue for ‘antlr-action-mode’ when using language ‘antlr-cpp’.
antlr-cpp-init-cc-modeValue for ‘antlr-init-cc-mode’ when using language ‘antlr-cpp’.
antlr-cpp-language-mode-nameValue for ‘antlr-language-mode-name’ when using language ‘antlr-cpp’.
antlr-delayed-mode-hookHook run after entering Antlr mode or a derived mode.
antlr-delphi-action-font-lock-keywordsValue for ‘antlr-action-font-lock-keywords’ when using language ‘antlr-delphi’.
antlr-delphi-action-modeValue for ‘antlr-action-mode’ when using language ‘antlr-delphi’.
antlr-delphi-indent-action-lineValue for ‘antlr-indent-action-line’ when using language ‘antlr-delphi’.
antlr-delphi-init-submodeValue for ‘antlr-init-submode’ when using language ‘antlr-delphi’.
antlr-delphi-language-mode-nameValue for ‘antlr-language-mode-name’ when using language ‘antlr-delphi’.
antlr-disabling-cc-syntactic-symbolsCC Mode syntactic context symbols adopting the indentation by CC Mode.
antlr-do-syntax-propertizeWhether M-x antlr-mode runs ‘syntax-propertize’ on the complete buffer.
antlr-end-of-defun-is-nextNon-nil, if rule movement commands normally jump to beginning of rule.
antlr-file-formats-alistLanguage dependent formats which specify generated files.
antlr-font-lock-additional-keywordsEarly font-lock keywords for ANTLR’s normal grammar code.
antlr-font-lock-attribute-regexpRegexp matching attributes within actions with special syntax highlighting.
antlr-font-lock-defaultsFont-lock defaults used for ANTLR syntax highlighting.
antlr-font-lock-late-keywordsLate font-lock keywords for ANTLR’s normal grammar code.
antlr-font-lock-literal-regexpRegexp matching literals with special syntax highlighting, or nil.
antlr-font-lock-maximum-decorationThe maximum decoration level for fontifying actions.
antlr-font-lock-negation-regexpRegexp whose first regexp group matches negation.
antlr-font-lock-symbol-regexpRegexp matching symbol declarations in the grammar, or nil.
antlr-font-lock-syntax-specSpecification for highlighting syntax symbols for AST creation: !, ^, ->.
antlr-grammar-fileGrammar file processed in *compilation* buffer.
antlr-grammar-header-regexpRegexp matching class headers.
antlr-help-rules-introIntroduction to use with M-x antlr-show-makefile-rules.
antlr-help-unknown-file-textString indicating the existence of unknown files in the Makefile.
antlr-imenu-nameNon-nil, if a "Index" menu should be added to the menubar.
antlr-indent-action-lineFunction which indents the current line in actions.
antlr-indent-at-bol-alistAlist of regexps matching lines are indented at column 0.
antlr-indent-commentNon-nil, if the indentation should touch lines in block comments.
antlr-indent-item-regexpRegexp matching lines which should be indented by one TAB less.
antlr-indent-styleIf non-nil, cc-mode indentation style used for ‘antlr-mode’.
antlr-init-cc-modeMajor-mode used to initialize the language variables of CC Mode.
antlr-init-submodeFunction used to initialize the action language.
antlr-java-action-font-lock-keywordsValue for ‘antlr-action-font-lock-keywords’ when using language ‘antlr-java’.
antlr-java-action-modeValue for ‘antlr-action-mode’ when using language ‘antlr-java’.
antlr-java-action-namesValid ANTLR action names in Java.
antlr-java-init-cc-modeValue for ‘antlr-init-cc-mode’ when using language ‘antlr-java’.
antlr-java-language-mode-nameValue for ‘antlr-language-mode-name’ when using language ‘antlr-java’.
antlr-js-action-font-lock-keywordsValue for ‘antlr-action-font-lock-keywords’ when using language ‘antlr-js’.
antlr-js-action-modeValue for ‘antlr-action-mode’ when using language ‘antlr-js’.
antlr-js-indent-action-lineValue for ‘antlr-indent-action-line’ when using language ‘antlr-js’.
antlr-js-init-submodeValue for ‘antlr-init-submode’ when using language ‘antlr-js’.
antlr-js-language-mode-nameValue for ‘antlr-language-mode-name’ when using language ‘antlr-js’.
antlr-languageMajor mode corresponding to ANTLR’s "language" option.
antlr-language-alistList of ANTLR’s supported languages. Variable is UNUSED.
antlr-language-limit-n-regexpUsed to set a reasonable value for ‘antlr-language’.
antlr-language-listAlist of supported action languages.
antlr-language-mode-nameThe second part of the mode name used in the mode line.
antlr-language-variablesList of variables which have a language-dependent value.
antlr-makefile-specificationVariable to specify the appearance of the generated makefile rules.
antlr-mode-abbrev-tableAbbreviation table used in ‘antlr-mode’ buffers.
antlr-mode-hookHook called by ‘antlr-mode’.
antlr-mode-mapKeymap used in ‘antlr-mode’ buffers.
antlr-mode-menuMajor mode menu.
antlr-mode-syntax-tableSyntax table used in ‘antlr-mode’ buffers.
antlr-no-action-keywordsEmpty font-lock keywords for actions.
antlr-obj-init-cc-modeValue for ‘antlr-init-cc-mode’ when using language ‘antlr-objc’.
antlr-objc-action-font-lock-keywordsValue for ‘antlr-action-font-lock-keywords’ when using language ‘antlr-objc’.
antlr-objc-action-modeValue for ‘antlr-action-mode’ when using language ‘antlr-objc’.
antlr-objc-language-mode-nameValue for ‘antlr-language-mode-name’ when using language ‘antlr-objc’.
antlr-options-alistsDefinitions for Antlr’s options of all four different kinds.
antlr-options-assign-stringString containing ‘=’ to use between option name and value.
antlr-options-auto-colonNon-nil, if ‘:’ is inserted with a rule or subrule options section.
antlr-options-headingsHeadings for the four different option kinds.
antlr-options-push-markNon-nil, if inserting an option should set & push mark.
antlr-options-styleObsolete user option.
antlr-options-use-submenusNon-nil, if the major mode menu should include option submenus.
antlr-python-action-font-lock-keywordsValue for ‘antlr-action-font-lock-keywords’ when using language ‘antlr-python’.
antlr-python-action-modeValue for ‘antlr-action-mode’ when using language ‘antlr-python’.
antlr-python-indent-action-lineValue for ‘antlr-indent-action-line’ when using language ‘antlr-python’.
antlr-python-init-submodeValue for ‘antlr-init-submode’ when using language ‘antlr-python’.
antlr-python-language-mode-nameValue for ‘antlr-language-mode-name’ when using language ‘antlr-python’.
antlr-ruby-action-font-lock-keywordsValue for ‘antlr-action-font-lock-keywords’ when using language ‘antlr-ruby’.
antlr-ruby-action-modeValue for ‘antlr-action-mode’ when using language ‘antlr-ruby’.
antlr-ruby-indent-action-lineValue for ‘antlr-indent-action-line’ when using language ‘antlr-ruby’.
antlr-ruby-init-submodeValue for ‘antlr-init-submode’ when using language ‘antlr-ruby’.
antlr-ruby-language-mode-nameValue for ‘antlr-language-mode-name’ when using language ‘antlr-ruby’.
antlr-rule-body-start-opSingle-character string which starts the rule body.
antlr-rule-postlude-skip-alistAlist of keywords after the ’;’ which still belong to the grammar rule.
antlr-rule-postlude-skip-alist--constConstant for ‘antlr-rule-postlude-skip-alist’.
antlr-rule-postlude-skip-regexpRegexp matching things after ’;’ which still belong to the grammar rule.
antlr-ruleref-assign-regexpRegexp matching rule references or their optional labels.
antlr-run-tool-on-buffer-fileNon-nil, if M-x antlr-run-tool runs on the file for the current buffer.
antlr-skip-line-regexpRegexp matching special declarations after the grammar header.
antlr-special-file-formatsLanguage independent formats which specify generated files.
antlr-syntax-propertizeSpecification used to apply \+‘syntax-table’ text properties.
antlr-tab-offset-alistAlist to determine whether to use ANTLR’s convention for TABs.
antlr-token-identifier-pFunction for syntax highlighting to distinguish token refs from rule refs.
antlr-tool-commandCommand used in M-x antlr-run-tool to run the Antlr tool.
antlr-tool-mode-nameThe first part of the mode name used in the mode line.
antlr-tool-pathExtra settings for environment variables $PATH and $LD_LIBRARY_PATH.
antlr-tool-versionThe version symbol of the Antlr tool. DO NOT CUSTOMIZE.
antlr-tool-version-variablesList of variables which have a tool-dependent value.
antlr-unknown-file-formatsFormats which specify the names of unknown files.
antlr-v2-grammar-header-regexpValue for ‘antlr-grammar-header-regexp’ when using ANTLR v2.
antlr-v2-language-listValue for ‘antlr-language-list’ when using ANTLR v2.
antlr-v2-options-alistsValue for ‘antlr-options-alist’ when using ANTLR v2.
antlr-v2-ruleref-assign-regexpValue for ‘antlr-ruleref-assign-regexp’ when using ANTLR v2.
antlr-v2-syntax-propertizeValue for ‘antlr-syntax-propertize’ when using ANTLR v2.
antlr-v2-tool-commandCommand used in M-x antlr-run-tool to run the Antlr tool.
antlr-v2-tool-mode-nameValue for ‘antlr-tool-mode-name’ when using ANTLR v2.
antlr-v3-font-lock-symbol-regexpValue for ‘antlr-font-lock-symbol-regexp’ when using ANTLR v3.
antlr-v3-language-listValue for ‘antlr-language-list’ when using ANTLR v3.
antlr-v3-options-alistsValue for ‘antlr-options-alists’ when using ANTLR v3.
antlr-v3-skip-line-regexpValue for ‘antlr-skip-line-regexp’ when using ANTLR v3.
antlr-v3-syntax-propertizeValue for ‘antlr-syntax-propertize’ when using ANTLR v3.
antlr-v3-tool-commandCommand used in M-x antlr-run-tool to run the Antlr tool.
antlr-v3-tool-mode-nameValue for ‘antlr-tool-mode-name’ when using ANTLR v3.
antlr-v4-compilation-error-regexp-alistValue for ‘antlr-compilation-error-regexp-alist’ when using ANTLR v4.
antlr-v4-font-lock-symbol-regexpValue for ‘antlr-font-lock-symbol-regexp’ when using ANTLR v4.
antlr-v4-language-listValue for ‘antlr-language-list’ when using ANTLR v4.
antlr-v4-mode-hookHook run after entering ‘antlr-v4-mode’.
antlr-v4-mode-mapKeymap for ‘antlr-v4-mode’.
antlr-v4-options-alistsValue for ‘antlr-options-alists’ when using ANTLR v4.
antlr-v4-skip-line-regexpValue for ‘antlr-skip-line-regexp’ when using ANTLR v4.
antlr-v4-syntax-propertizeValue for ‘antlr-syntax-propertize’ when using ANTLR v4.
antlr-v4-tool-commandCommand used in M-x antlr-run-tool to run the Antlr tool.
antlr-v4-tool-mode-nameValue for ‘antlr-tool-mode-name’ when using ANTLR v4.
antlr-versionANTLR major mode version number.

Defined functions (74)

antlr-beginning-of-body()
antlr-beginning-of-rule(&optional ARG)
antlr-c++-mode-extra(PHASE OPTION &rest DUMMIES)
antlr-delphi-indent-action-line(BOA)
antlr-directory-dependencies(DIRNAME)
antlr-downcase-literals(&optional TRANSFORM)
antlr-electric-character(&optional ARG)
antlr-end-of-body(&optional MSG)
antlr-end-of-rule(&optional ARG)
antlr-file-dependencies()
antlr-font-lock-checked-face(STRINGS GROUP FACE)
antlr-font-lock-keywords()
antlr-grammar-file()
antlr-grammar-tokens()
antlr-guess-language()
antlr-guess-tool-version()
antlr-hack-local-variables-hook()
antlr-hide-actions(ARG &optional SILENT)
antlr-imenu-create-index-function(&optional REFS-ONLY)
antlr-indent-command(&optional ARG)
antlr-indent-line()
antlr-init-delphi()
antlr-init-js()
antlr-init-python()
antlr-init-ruby()
antlr-insert-keyword-rule(&optional KEYWORD)
antlr-insert-makefile-rules(&optional IN-MAKEFILE)
antlr-insert-option(LEVEL OPTION &optional LOCATION)
antlr-insert-option-area(LEVEL)
antlr-insert-option-do(LEVEL OPTION OLD AREA POS)
antlr-insert-option-existing(OLD VALUE)
antlr-insert-option-interactive(ARG)
antlr-insert-option-space(AREA OLD)
antlr-inside-rule-p()
antlr-js-indent-action-line(BOA)
antlr-language-option-extra(PHASE &rest DUMMIES)
antlr-makefile-insert-variable(NUMBER PRE POST)
antlr-mode()
antlr-mode-menu(ARG1)
antlr-next-rule(ARG SKIP-COMMENT)
antlr-option-kind(REQUESTED)
antlr-option-level(REQUESTED)
antlr-option-location(ORIG MIN-VIS MAX-VIS MIN-AREA MAX-AREA WITHP)
antlr-options-menu-filter(LEVEL MENU-ITEMS)
antlr-outside-rule-p()
antlr-python-indent-action-line(BOA)
antlr-re-search-forward(REGEXP BOUND)
antlr-read-boolean(INITIAL-CONTENTS PROMPT &optional TABLE)
antlr-read-language(INITIAL-CONTENTS PROMPT)
antlr-read-value(INITIAL-CONTENTS PROMPT &optional AS-STRING TABLE TABLE-X)
antlr-ruby-indent-action-line(BOA)
antlr-run-tool(COMMAND FILE &optional SAVED)
antlr-run-tool-interactive()
antlr-search-backward(STRING &optional LINE-REGEXP)
antlr-search-forward(STRING &optional LINE-REGEXP)
antlr-search-result(LINE-REGEXP)
antlr-set-local-variables(SELECTOR-SYMBOL SELECTOR VARIABLES)
antlr-set-tabs()
antlr-set-tool-version-and-mode-line()
antlr-show-makefile-rules()
antlr-skip-file-prelude(SKIP-COMMENT)
antlr-skip-import-statement()
antlr-skip-rule-postlude(SKIP-COMMENT)
antlr-skip-sexps(COUNT)
antlr-superclasses-glibs(SUPERS CLASSES)
antlr-syntactic-context(&optional PPSS)
antlr-syntactic-grammar-depth(POS BEG &optional OUTSIDE-ACTION)
antlr-syntax-propertize-charsets(START END)
antlr-syntax-propertize-template-literals(START END)
antlr-syntax-propertize-wholerule(START END)
antlr-try-rule-or-grammar-option(REQUESTED BOR)
antlr-upcase-literals()
antlr-upcase-p(CHAR)
antlr-v4-mode()

Defined faces (11)

antlr-actionANTLR action names: @ActionName, @ActionScope::ActionName.
antlr-attributeANTLR references to attributes within actions.
antlr-defaultFace to prevent strings from language dependent highlighting. Do not change.
antlr-keywordANTLR keywords.
antlr-literalANTLR special literal tokens. It is used to highlight strings matched by the first regexp group of ‘antlr-font-lock-literal-regexp’.
antlr-ruledefANTLR parser and treeparser rule symbols (definition).
antlr-rulerefANTLR parser and treeparser rule symbols (usage).
antlr-symbolANTLR symbols (definition and usage) for things other than rules. Used for grammars, v3 scopes and v4 modes.
antlr-syntaxANTLR syntax symbols for AST creation: !, ^, ->.
antlr-tokendefANTLR scanner rule symbols (definition).
antlr-tokenrefANTLR scanner rule symbols (usage).