view anagram/agcore/token.h @ 21:1c9dac05d040

Add lint-style FALLTHROUGH annotations to fallthrough cases. (in the parse engine and thus the output code) Document this, because the old output causes warnings with gcc10.
author David A. Holland
date Mon, 13 Jun 2022 00:04:38 -0400
parents 607e3be6bad8
children
line wrap: on
line source

/*
 * AnaGram, A System for Syntax Directed Programming
 * Copyright 1993-2002 Parsifal Software. All Rights Reserved.
 * See the file COPYING for license and usage terms.
 *
 * token.h
 */

#ifndef TOKEN_H
#define TOKEN_H

#include "register.h"
class Rule;


struct token_number_map;

class Token : public ObjectRegister<token_number_map> {
public:
  Token() {}
  Token(int x);
  Token(const Token &t);
  void operator = (const Token &);
  static Token create();
  static const int first;
  static void reset();
  class Map;
  friend class Map;
  int isLeadingToken(const Token) const;
  int isExpansionToken(const Token) const;
  int isExpansionRule(const Rule) const;
  Token leadingToken(int) const;
  Token follower(int) const ;
  Rule expansionRule(int) const;
  Rule rule(int) const;

  class Map {
  public:
    token_number_map &operator [] (unsigned x);
  };
};

extern Token::Map map_token_number;

#include "keyword.h"
#include "symbol.h"
#include "tree.h"

struct token_number_map {
  AgArray<Rule> ruleList;
  AgArray<Token> followerList;
  AgArray<Rule> expansionRuleList;
  AgArray<Token> leadingTokenList;
  //unsigned key;
  Keyword key;
  Symbol token_name;
  ParseTree parse_tree;
  unsigned
    vp_prod_number,
    value_type,
    token_set_id,
    part_number,
    precedence_level;
  unsigned sticky : 1;
  unsigned zero_length_flag : 1;
  unsigned non_terminal_flag : 1;
  unsigned sem_det_flag : 1;
  unsigned fine_structure: 1;
  unsigned left_associative: 1;
  unsigned right_associative: 1;
  unsigned rp_arg: 1;
  unsigned pure: 1;
  unsigned junky: 1;
  unsigned reserve: 1;
  unsigned reserved_word: 1;
  unsigned subgrammar: 1;
  unsigned lexeme: 1;
  unsigned lexical: 1;
  unsigned immediate_action: 1;
  unsigned operatorCandidate: 1;
  unsigned disregard: 1;

  token_number_map();
  int operator < (const token_number_map &t) const {
    return token_name < t.token_name;
  }
};

#endif /* TOKEN_H */