From 30de15e100ccb8a53f73f8c826902d67eced50ec Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Wed, 16 Mar 2022 16:45:24 +0100 Subject: [PATCH] [pseudo] Tweak some docs, NFC Consitently use the "nonterminal", "pseudoparser" terms. --- .../pseudo/include/clang-pseudo/Grammar.h | 14 +++++++------- .../pseudo/include/clang-pseudo/LRTable.h | 6 +++--- clang-tools-extra/pseudo/lib/Grammar.cpp | 4 ++-- clang-tools-extra/pseudo/lib/cxx.bnf | 8 ++++---- clang-tools-extra/pseudo/tool/ClangPseudo.cpp | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/clang-tools-extra/pseudo/include/clang-pseudo/Grammar.h b/clang-tools-extra/pseudo/include/clang-pseudo/Grammar.h index 7e94c4b89d85..106734b1b022 100644 --- a/clang-tools-extra/pseudo/include/clang-pseudo/Grammar.h +++ b/clang-tools-extra/pseudo/include/clang-pseudo/Grammar.h @@ -1,4 +1,4 @@ -//===--- Grammar.h - grammar used by clang pseudo parser --------*- C++-*-===// +//===--- Grammar.h - grammar used by clang pseudoparser ---------*- C++-*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -17,7 +17,7 @@ // // A grammar formally describes a language, and it is constructed by a set of // production rules. A rule is of BNF form (AAA := BBB CCC). A symbol is either -// non-terminal or terminal, identified by a SymbolID. +// nonterminal or terminal, identified by a SymbolID. // // Notions about the BNF grammar: // - "_" is the start symbol of the augmented grammar; @@ -45,8 +45,8 @@ namespace clang { namespace pseudo { -// A SymbolID uniquely identifies a terminal/non-terminal symbol in a grammar. -// Non-terminal IDs are indexes into a table of non-terminal symbols. +// A SymbolID uniquely identifies a terminal/nonterminal symbol in a grammar. +// nonterminal IDs are indexes into a table of nonterminal symbols. // Terminal IDs correspond to the clang TokenKind enum. using SymbolID = uint16_t; // SymbolID is only 12 bits wide. @@ -120,11 +120,11 @@ public: // Returns the SymbolID of the start symbol '_'. SymbolID startSymbol() const { return StartSymbol; }; - // Returns all rules of the given non-terminal symbol. + // Returns all rules of the given nonterminal symbol. llvm::ArrayRef rulesFor(SymbolID SID) const; const Rule &lookupRule(RuleID RID) const; - // Gets symbol (terminal or non-terminal) name. + // Gets symbol (terminal or nonterminal) name. // Terminals have names like "," (kw_comma) or "OPERATOR" (kw_operator). llvm::StringRef symbolName(SymbolID) const; @@ -157,7 +157,7 @@ struct GrammarTable { struct Nonterminal { std::string Name; - // Corresponding rules that construct the non-terminal, it is a [Start, End) + // Corresponding rules that construct the nonterminal, it is a [Start, End) // index range of the Rules table. struct { RuleID Start; diff --git a/clang-tools-extra/pseudo/include/clang-pseudo/LRTable.h b/clang-tools-extra/pseudo/include/clang-pseudo/LRTable.h index c31a2621b2f8..d41fca0d4b5d 100644 --- a/clang-tools-extra/pseudo/include/clang-pseudo/LRTable.h +++ b/clang-tools-extra/pseudo/include/clang-pseudo/LRTable.h @@ -18,10 +18,10 @@ // // Typically, based on the category of the grammar symbol, the LRTable is // broken into two logically separate tables: -// - ACTION table with terminals as columns -- e.g ACTION[S, a] specifies +// - ACTION table with terminals as columns -- e.g. ACTION[S, a] specifies // next action (shift/reduce/accept/error) on state S under a lookahead // terminal a -// - GOTO table with nonterminals as columns -- e.g. GOTO[S, X] specify +// - GOTO table with nonterminals as columns -- e.g. GOTO[S, X] specifies // the state which we transist to from the state S with the nonterminal X // // LRTable is *performance-critial* as it is consulted frequently during a @@ -161,7 +161,7 @@ private: // Index is nonterminal SymbolID, value is the offset into States/Actions // where the entries for this nonterminal begin. - // Give a non-terminal id, the corresponding half-open range of StateIdx is + // Give a nonterminal id, the corresponding half-open range of StateIdx is // [NontermIdx[id], NontermIdx[id+1]). std::vector NontermOffset; // Similar to NontermOffset, but for terminals, index is tok::TokenKind. diff --git a/clang-tools-extra/pseudo/lib/Grammar.cpp b/clang-tools-extra/pseudo/lib/Grammar.cpp index c362a14a51e1..563390430f52 100644 --- a/clang-tools-extra/pseudo/lib/Grammar.cpp +++ b/clang-tools-extra/pseudo/lib/Grammar.cpp @@ -1,4 +1,4 @@ -//===--- Grammar.cpp - Grammar for clang pseudo parser ----------*- C++-*-===// +//===--- Grammar.cpp - Grammar for clang pseudoparser -----------*- C++-*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -118,7 +118,7 @@ std::vector> followSets(const Grammar &G) { auto FirstSets = firstSets(G); std::vector> FollowSets( G.table().Nonterminals.size()); - // Expand the follow set of a non-terminal symbol Y by adding all from the + // Expand the follow set of a nonterminal symbol Y by adding all from the // given symbol set. auto ExpandFollowSet = [&FollowSets](SymbolID Y, const llvm::DenseSet &ToAdd) { diff --git a/clang-tools-extra/pseudo/lib/cxx.bnf b/clang-tools-extra/pseudo/lib/cxx.bnf index 45b2f616d20a..cf664b8e13e5 100644 --- a/clang-tools-extra/pseudo/lib/cxx.bnf +++ b/clang-tools-extra/pseudo/lib/cxx.bnf @@ -8,8 +8,8 @@ # It aims to align with the ISO C++ grammar as much as possible. We adjust it # to fit the need for the grammar-based parser: # - attributes are omitted, which will be handled as comments; -# - we don't allow nullable non-terminal symbols. There are few nullable -# non-terminals in the spec grammar, they are adjusted to be non-nullable; +# - we don't allow nullable nonterminal symbols. There are few nullable +# nonterminals in the spec grammar, they are adjusted to be non-nullable; # - the file merely describes the core C++ grammar. Preprocessor directives and # lexical conversions are omitted as we reuse clang's lexer and run a fake # preprocessor; @@ -18,7 +18,7 @@ # and right shift operator; # # Guidelines: -# - non-terminals are lower_case; terminals (aka tokens) correspond to +# - nonterminals are lower_case; terminals (aka tokens) correspond to # clang::TokenKind, written as "IDENTIFIER", "USING", "::" etc; # - optional symbols are supported, with a _opt suffix; # @@ -706,7 +706,7 @@ string-literal-chunk := UTF16_STRING_LITERAL string-literal-chunk := UTF32_STRING_LITERAL #! Technically, string concatenation happens at phase 6 which is before parsing, #! so it doesn't belong to the grammar. However, we extend the grammar to -#! support it, to make the pseudo parser fully functional on practical code. +#! support it, to make the pseudoparser fully functional on practical code. string-literal := string-literal-chunk string-literal := string-literal string-literal-chunk user-defined-literal := user-defined-integer-literal diff --git a/clang-tools-extra/pseudo/tool/ClangPseudo.cpp b/clang-tools-extra/pseudo/tool/ClangPseudo.cpp index 076ec5b73332..e893ed2fb03e 100644 --- a/clang-tools-extra/pseudo/tool/ClangPseudo.cpp +++ b/clang-tools-extra/pseudo/tool/ClangPseudo.cpp @@ -1,4 +1,4 @@ -//===-- ClangPseudo.cpp - Clang pseudo parser tool ------------------------===// +//===-- ClangPseudo.cpp - Clang pseudoparser tool -------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information.