X-Git-Url: https://gitweb.ps.run/toc/blobdiff_plain/9f94b672a5dc32da5ad01742bd4e976315a30d9c..c6ad2948bb98d42f8e0883ef82cd14cd2d5eda60:/antlr4-cpp-runtime-4.9.2-source/runtime/src/Vocabulary.h
diff --git a/antlr4-cpp-runtime-4.9.2-source/runtime/src/Vocabulary.h b/antlr4-cpp-runtime-4.9.2-source/runtime/src/Vocabulary.h
new file mode 100644
index 0000000..e8924bf
--- /dev/null
+++ b/antlr4-cpp-runtime-4.9.2-source/runtime/src/Vocabulary.h
@@ -0,0 +1,192 @@
+/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
+#pragma once
+
+#include "antlr4-common.h"
+
+namespace antlr4 {
+namespace dfa {
+
+ /// This class provides a default implementation of the
+ /// interface.
+ class ANTLR4CPP_PUBLIC Vocabulary {
+ public:
+ /// Gets an empty instance.
+ ///
+ ///
+ /// No literal or symbol names are assigned to token types, so
+ /// returns the numeric value for all tokens
+ /// except .
+ static const Vocabulary EMPTY_VOCABULARY;
+
+ Vocabulary() {}
+ Vocabulary(Vocabulary const&) = default;
+ virtual ~Vocabulary();
+
+ ///
+ /// Constructs a new instance of from the specified
+ /// literal and symbolic token names.
+ ///
+ /// The literal names assigned to tokens, or {@code null}
+ /// if no literal names are assigned.
+ /// The symbolic names assigned to tokens, or
+ /// {@code null} if no symbolic names are assigned.
+ ///
+ ///
+ ///
+ Vocabulary(const std::vector &literalNames, const std::vector &symbolicNames);
+
+ ///
+ /// Constructs a new instance of from the specified
+ /// literal, symbolic, and display token names.
+ ///
+ /// The literal names assigned to tokens, or {@code null}
+ /// if no literal names are assigned.
+ /// The symbolic names assigned to tokens, or
+ /// {@code null} if no symbolic names are assigned.
+ /// The display names assigned to tokens, or {@code null}
+ /// to use the values in {@code literalNames} and {@code symbolicNames} as
+ /// the source of display names, as described in
+ /// .
+ ///
+ ///
+ ///
+ ///
+ Vocabulary(const std::vector &literalNames, const std::vector &symbolicNames,
+ const std::vector &displayNames);
+
+ ///
+ /// Returns a instance from the specified set of token
+ /// names. This method acts as a compatibility layer for the single
+ /// {@code tokenNames} array generated by previous releases of ANTLR.
+ ///
+ /// The resulting vocabulary instance returns {@code null} for
+ /// and , and the
+ /// value from {@code tokenNames} for the display names.
+ ///
+ /// The token names, or {@code null} if no token names are
+ /// available.
+ /// A instance which uses {@code tokenNames} for
+ /// the display names of tokens.
+ static Vocabulary fromTokenNames(const std::vector &tokenNames);
+
+ ///
+ /// Returns the highest token type value. It can be used to iterate from
+ /// zero to that number, inclusively, thus querying all stored entries.
+ /// the highest token type value
+ virtual size_t getMaxTokenType() const;
+
+ ///
+ /// Gets the string literal associated with a token type. The string returned
+ /// by this method, when not {@code null}, can be used unaltered in a parser
+ /// grammar to represent this token type.
+ ///
+ /// The following table shows examples of lexer rules and the literal
+ /// names assigned to the corresponding token types.
+ ///
+ ///
+ ///
+ /// | Rule |
+ /// Literal Name |
+ /// Java String Literal |
+ ///
+ ///
+ /// | {@code THIS : 'this';} |
+ /// {@code 'this'} |
+ /// {@code "'this'"} |
+ ///
+ ///
+ /// | {@code SQUOTE : '\'';} |
+ /// {@code '\''} |
+ /// {@code "'\\''"} |
+ ///
+ ///
+ /// | {@code ID : [A-Z]+;} |
+ /// n/a |
+ /// {@code null} |
+ ///
+ ///
+ ///
+ /// The token type.
+ ///
+ /// The string literal associated with the specified token type, or
+ /// {@code null} if no string literal is associated with the type.
+ virtual std::string getLiteralName(size_t tokenType) const;
+
+ ///
+ /// Gets the symbolic name associated with a token type. The string returned
+ /// by this method, when not {@code null}, can be used unaltered in a parser
+ /// grammar to represent this token type.
+ ///
+ /// This method supports token types defined by any of the following
+ /// methods:
+ ///
+ ///
+ /// - Tokens created by lexer rules.
+ /// - Tokens defined in a
tokens{} block in a lexer or parser
+ /// grammar.
+ /// - The implicitly defined {@code EOF} token, which has the token type
+ /// .
+ ///
+ ///
+ /// The following table shows examples of lexer rules and the literal
+ /// names assigned to the corresponding token types.
+ ///
+ ///
+ ///
+ /// | Rule |
+ /// Symbolic Name |
+ ///
+ ///
+ /// | {@code THIS : 'this';} |
+ /// {@code THIS} |
+ ///
+ ///
+ /// | {@code SQUOTE : '\'';} |
+ /// {@code SQUOTE} |
+ ///
+ ///
+ /// | {@code ID : [A-Z]+;} |
+ /// {@code ID} |
+ ///
+ ///
+ ///
+ /// The token type.
+ ///
+ /// The symbolic name associated with the specified token type, or
+ /// {@code null} if no symbolic name is associated with the type.
+ virtual std::string getSymbolicName(size_t tokenType) const;
+
+ ///
+ /// Gets the display name of a token type.
+ ///
+ /// ANTLR provides a default implementation of this method, but
+ /// applications are free to override the behavior in any manner which makes
+ /// sense for the application. The default implementation returns the first
+ /// result from the following list which produces a non-{@code null}
+ /// result.
+ ///
+ ///
+ /// - The result of
+ /// - The result of
+ /// - The result of
+ ///
+ ///
+ /// The token type.
+ ///
+ /// The display name of the token type, for use in error reporting or
+ /// other user-visible messages which reference specific token types.
+ virtual std::string getDisplayName(size_t tokenType) const;
+
+ private:
+ std::vector const _literalNames;
+ std::vector const _symbolicNames;
+ std::vector const _displayNames;
+ const size_t _maxTokenType = 0;
+ };
+
+} // namespace atn
+} // namespace antlr4