aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/parse_productions.h
diff options
context:
space:
mode:
authorGravatar Kurtis Rader <krader@skepticism.us>2016-05-02 15:48:57 -0700
committerGravatar Kurtis Rader <krader@skepticism.us>2016-05-02 16:03:37 -0700
commit61a614b61210ebb65f0a0c9af765d9ba8105e311 (patch)
tree4be72e53e458e227a50dd4473714982c515c73bf /src/parse_productions.h
parent3d6f995a9c07a50edd62ac61f7d6b400fa4721ec (diff)
restyle parse_productions module to match project style
Reduces lint errors from 33 to 9 (-73%). Line count from 551 to 534 (-3%). Another step in resolving issue #2902.
Diffstat (limited to 'src/parse_productions.h')
-rw-r--r--src/parse_productions.h53
1 files changed, 21 insertions, 32 deletions
diff --git a/src/parse_productions.h b/src/parse_productions.h
index e2c2dcc3..38a505d2 100644
--- a/src/parse_productions.h
+++ b/src/parse_productions.h
@@ -1,63 +1,52 @@
-/**\file parse_tree.h
-
- Programmatic representation of fish code.
-*/
+// Programmatic representation of fish code.
#ifndef FISH_PARSE_TREE_CONSTRUCTION_H
#define FISH_PARSE_TREE_CONSTRUCTION_H
-#include <sys/types.h>
#include <stdbool.h>
+#include <sys/types.h>
#include "parse_constants.h"
struct parse_token_t;
-namespace parse_productions
-{
+namespace parse_productions {
#define MAX_SYMBOLS_PER_PRODUCTION 6
-/* A production is an array of unsigned char. Symbols are encoded directly as their symbol value. Keywords are encoded with an offset of LAST_TOKEN_OR_SYMBOL + 1. So essentially we glom together keywords and symbols. */
+// A production is an array of unsigned char. Symbols are encoded directly as their symbol value.
+// Keywords are encoded with an offset of LAST_TOKEN_OR_SYMBOL + 1. So essentially we glom together
+// keywords and symbols.
typedef uint8_t production_element_t;
typedef production_element_t const production_t[MAX_SYMBOLS_PER_PRODUCTION];
-/* Resolve the type from a production element */
-inline parse_token_type_t production_element_type(production_element_t elem)
-{
- if (elem > LAST_TOKEN_OR_SYMBOL)
- {
+/// Resolve the type from a production element.
+inline parse_token_type_t production_element_type(production_element_t elem) {
+ if (elem > LAST_TOKEN_OR_SYMBOL) {
return parse_token_type_string;
- }
- else
- {
+ } else {
return static_cast<parse_token_type_t>(elem);
}
}
-/* Resolve the keyword from a production element */
-inline parse_keyword_t production_element_keyword(production_element_t elem)
-{
- if (elem > LAST_TOKEN_OR_SYMBOL)
- {
- // First keyword is LAST_TOKEN_OR_SYMBOL + 1
+/// Resolve the keyword from a production element.
+inline parse_keyword_t production_element_keyword(production_element_t elem) {
+ if (elem > LAST_TOKEN_OR_SYMBOL) {
+ // First keyword is LAST_TOKEN_OR_SYMBOL + 1.
return static_cast<parse_keyword_t>(elem - LAST_TOKEN_OR_SYMBOL - 1);
- }
- else
- {
+ } else {
return parse_keyword_none;
}
}
-/* Check if an element is valid */
-inline bool production_element_is_valid(production_element_t elem)
-{
+/// Check if an element is valid.
+inline bool production_element_is_valid(production_element_t elem) {
return elem != token_type_invalid;
}
-/* Fetch a production. We are passed two input tokens. The first input token is guaranteed to not be invalid; the second token may be invalid if there's no more tokens. We may also set flags. */
-const production_t *production_for_token(parse_token_type_t node_type, const parse_token_t &input1, const parse_token_t &input2, uint8_t *out_tag);
-
+/// Fetch a production. We are passed two input tokens. The first input token is guaranteed to not
+/// be invalid; the second token may be invalid if there's no more tokens. We may also set flags.
+const production_t *production_for_token(parse_token_type_t node_type, const parse_token_t &input1,
+ const parse_token_t &input2, uint8_t *out_tag);
}
-
#endif