/**
 * Block Tokens
 */
var FUNCTION_BLOCK_START_TKN   = "FUNCTION_BLOCK"
var FUNCTION_BLOCK_END_TKN     = "END_FUNCTION_BLOCK"
var VAR_INPUT_BLOCK_START_TKN  = "VAR_INPUT"
var VAR_OUTPUT_BLOCK_START_TKN = "VAR_OUTPUT"
var VAR_BLOCK_START_TKN        = "VAR"
var VAR_BLOCK_END_TKN          = "END_VAR"
var FUZZIFY_BLOCK_START_TKN    = "FUZZIFY"
var FUZZIFY_BLOCK_END_TKN      = "END_FUZZIFY"
var DEFUZZIFY_BLOCK_START_TKN  = "DEFUZZIFY"
var DEFUZZIFY_BLOCK_END_TKN    = "END_DEFUZZIFY"
var RULEBLOCK_BLOCK_START_TKN  = "RULEBLOCK"
var RULEBLOCK_BLOCK_END_TKN    = "END_RULEBLOCK"

/**
 * Symbol Tokens
 */
var LEFT_PAREN_TKN             = "("
var RIGHT_PAREN_TKN            = ")"
var ASSIGN_TKN                 = ":="
var COLON_TKN                  = ":"
var COMMA_TKN                  = ","
var SEMICOLON_TKN              = ";"
var RANGE_DOT_TKN              = ".."

/**
 * Var Tokens
 */
var REAL_VAR_TKN               = "REAL"

/**
 * Fuzzification Block Tokens
 */
var TERM_TKN                   = "TERM"
var TRIAN_TKN                  = "TRIAN"
var TRAPE_TKN                  = "TRAPE"
var GAUSS_TKN                  = "GAUSS"
var GBELL_TKN                  = "GBELL"
var SIGM_TKN                   = "SIGM"
var SINGLETON_TKN              = "SINGLETON"
var PIECEWISE_TKN              = "PIECEWISE"
var FUNC_TKN                   = "FUNCTION"

/**
 * Defuzzification Block Tokens
 */
var METHOD_TKN                 = "METHOD"
var COG_METHOD_TKN             = "COG"
var COGS_METHOD_TKN            = "COGS"
var COA_METHOD_TKN             = "COA"
var LM_METHOD_TKN              = "LM"
var RM_METHOD_TKN              = "RM"

var DEFAULT_TKN                = "DEFAULT"
var DEFAULT_NC_TKN             = "NC"

var RANGE_TKN                  = "RANGE"

/**
 * Ruleblock Tokens
 */
// Tokens that are used in multiple contexts
var AND_TKN                    = "AND"
var OR_TKN                     = "OR"
var MAX_TKN                    = "MAX"
var MIN_TKN                    = "MIN"
var PROD_TKN                   = "PROD"
var BSUM_TKN                   = "BSUM"

var ACTIVATION_METHOD_TKN      = "ACT"

var ACCUMULATION_METHOD_TKN    = "ACCU"
var ACCUM_METHOD_NSUM_TKN      = "NSUM"

var AND_METHOD_BDIF_TKN        = "BDIF"

var OR_METHOD_ASUM_TKN         = "ASUM"

var RULE_TKN                   = "RULE"
var IF_CONDITION_TKN           = "IF"
var THEN_CONDITION_TKN         = "THEN"
var WITH_CONDITION_TKN         = "WITH"
var IS_LOGIC_TKN               = "IS"
var NOT_LOGIC_TKN              = "NOT"

/**
 * Misc Tokens
 */
var SINGLELINE_COMMENT_START_TKN   = "//"
var MULTILINE_COMMENT_START_TKN= /^\/\*+$/ // /*
var MULTILINE_COMMENT_END_TKN  = /^\*+\/$/ // */
var NEWLINE_TKN                = /[\f\n\r]+/g

var NAME_ARRAY = [
  'SINGLELINE_COMMENT_START_TKN',
  'FUNCTION_BLOCK_START_TKN',
  'FUNCTION_BLOCK_END_TKN',
  'VAR_INPUT_BLOCK_START_TKN',
  'VAR_OUTPUT_BLOCK_START_TKN',
  'VAR_BLOCK_START_TKN',
  'VAR_BLOCK_END_TKN',
  'FUZZIFY_BLOCK_START_TKN',
  'FUZZIFY_BLOCK_END_TKN',
  'DEFUZZIFY_BLOCK_START_TKN',
  'DEFUZZIFY_BLOCK_END_TKN',
  'RULEBLOCK_BLOCK_START_TKN',
  'RULEBLOCK_BLOCK_END_TKN',
  'LEFT_PAREN_TKN',
  'RIGHT_PAREN_TKN',
  'ASSIGN_TKN',
  'COLON_TKN',
  'COMMA_TKN',
  'SEMICOLON_TKN',
  'RANGE_DOT_TKN',
  'REAL_VAR_TKN',
  'TERM_TKN',
  'TRIAN_TKN',
  'TRAPE_TKN',
  'GAUSS_TKN',
  'GBELL_TKN',
  'SIGM_TKN',
  'SINGLETON_TKN',
  'PIECEWISE_TKN',
  'FUNC_TKN',
  'METHOD_TKN',
  'COG_METHOD_TKN',
  'COGS_METHOD_TKN',
  'COA_METHOD_TKN',
  'LM_METHOD_TKN',
  'RM_METHOD_TKN',
  'DEFAULT_TKN',
  'DEFAULT_NC_TKN',
  'RANGE_TKN',
  'AND_TKN',
  'OR_TKN',
  'MAX_TKN',
  'MIN_TKN',
  'PROD_TKN',
  'BSUM_TKN',
  'ACTIVATION_METHOD_TKN',
  'ACCUMULATION_METHOD_TKN',
  'ACCUM_METHOD_NSUM_TKN',
  'AND_METHOD_BDIF_TKN',
  'OR_METHOD_ASUM_TKN',
  'RULE_TKN',
  'IF_CONDITION_TKN',
  'THEN_CONDITION_TKN',
  'WITH_CONDITION_TKN',
  'IS_LOGIC_TKN',
  'NOT_LOGIC_TKN'
]

var TOKEN_ARRAY = [
  SINGLELINE_COMMENT_START_TKN,
  FUNCTION_BLOCK_START_TKN,
  FUNCTION_BLOCK_END_TKN,
  VAR_INPUT_BLOCK_START_TKN,
  VAR_OUTPUT_BLOCK_START_TKN,
  VAR_BLOCK_START_TKN,
  VAR_BLOCK_END_TKN,
  FUZZIFY_BLOCK_START_TKN,
  FUZZIFY_BLOCK_END_TKN,
  DEFUZZIFY_BLOCK_START_TKN,
  DEFUZZIFY_BLOCK_END_TKN,
  RULEBLOCK_BLOCK_START_TKN,
  RULEBLOCK_BLOCK_END_TKN,
  LEFT_PAREN_TKN,
  RIGHT_PAREN_TKN,
  ASSIGN_TKN,
  COLON_TKN,
  COMMA_TKN,
  SEMICOLON_TKN,
  RANGE_DOT_TKN,
  REAL_VAR_TKN,
  TERM_TKN,
  TRIAN_TKN,
  TRAPE_TKN,
  GAUSS_TKN,
  GBELL_TKN,
  SIGM_TKN,
  SINGLETON_TKN,
  PIECEWISE_TKN,
  FUNC_TKN,
  METHOD_TKN,
  COG_METHOD_TKN,
  COGS_METHOD_TKN,
  COA_METHOD_TKN,
  LM_METHOD_TKN,
  RM_METHOD_TKN,
  DEFAULT_TKN,
  DEFAULT_NC_TKN,
  RANGE_TKN,
  AND_TKN,
  OR_TKN,
  MAX_TKN,
  MIN_TKN,
  PROD_TKN,
  BSUM_TKN,
  ACTIVATION_METHOD_TKN,
  ACCUMULATION_METHOD_TKN,
  ACCUM_METHOD_NSUM_TKN,
  AND_METHOD_BDIF_TKN,
  OR_METHOD_ASUM_TKN,
  RULE_TKN,
  IF_CONDITION_TKN,
  THEN_CONDITION_TKN,
  WITH_CONDITION_TKN,
  IS_LOGIC_TKN,
  NOT_LOGIC_TKN
]

var TOKENS = {
  SINGLELINE_COMMENT_START_TKN: SINGLELINE_COMMENT_START_TKN,
  FUNCTION_BLOCK_START_TKN: FUNCTION_BLOCK_START_TKN,
  FUNCTION_BLOCK_END_TKN: FUNCTION_BLOCK_END_TKN, 
  VAR_INPUT_BLOCK_START_TKN: VAR_INPUT_BLOCK_START_TKN, 
  VAR_OUTPUT_BLOCK_START_TKN: VAR_OUTPUT_BLOCK_START_TKN,
  VAR_BLOCK_START_TKN: VAR_BLOCK_START_TKN,
  VAR_BLOCK_END_TKN: VAR_BLOCK_END_TKN,
  FUZZIFY_BLOCK_START_TKN: FUZZIFY_BLOCK_START_TKN,
  FUZZIFY_BLOCK_END_TKN: FUZZIFY_BLOCK_END_TKN,  
  DEFUZZIFY_BLOCK_START_TKN: DEFUZZIFY_BLOCK_START_TKN,
  DEFUZZIFY_BLOCK_END_TKN: DEFUZZIFY_BLOCK_END_TKN,
  RULEBLOCK_BLOCK_START_TKN: RULEBLOCK_BLOCK_START_TKN,
  RULEBLOCK_BLOCK_END_TKN: RULEBLOCK_BLOCK_END_TKN,
  LEFT_PAREN_TKN: LEFT_PAREN_TKN, 
  RIGHT_PAREN_TKN: RIGHT_PAREN_TKN,
  ASSIGN_TKN: ASSIGN_TKN,
  COLON_TKN: COLON_TKN,
  COMMA_TKN: COMMA_TKN,
  SEMICOLON_TKN: SEMICOLON_TKN,
  RANGE_DOT_TKN: RANGE_DOT_TKN,
  REAL_VAR_TKN: REAL_VAR_TKN,
  TERM_TKN: TERM_TKN,
  TRIAN_TKN: TRIAN_TKN,
  TRAPE_TKN: TRAPE_TKN,
  GAUSS_TKN: GAUSS_TKN,
  GBELL_TKN: GBELL_TKN,
  SIGM_TKN: SIGM_TKN,
  SINGLETON_TKN: SINGLETON_TKN,
  PIECEWISE_TKN: PIECEWISE_TKN,
  FUNC_TKN: FUNC_TKN,
  METHOD_TKN: METHOD_TKN,
  COG_METHOD_TKN: COG_METHOD_TKN,
  COGS_METHOD_TKN: COGS_METHOD_TKN,
  COA_METHOD_TKN: COA_METHOD_TKN,
  LM_METHOD_TKN: LM_METHOD_TKN,
  RM_METHOD_TKN: RM_METHOD_TKN,
  DEFAULT_TKN: DEFAULT_TKN,
  DEFAULT_NC_TKN: DEFAULT_NC_TKN,
  RANGE_TKN: RANGE_TKN,
  AND_TKN: AND_TKN,
  OR_TKN: OR_TKN,
  MAX_TKN: MAX_TKN,
  MIN_TKN: MIN_TKN,
  PROD_TKN: PROD_TKN,
  BSUM_TKN: BSUM_TKN,
  ACTIVATION_METHOD_TKN: ACTIVATION_METHOD_TKN,
  ACCUMULATION_METHOD_TKN: ACCUMULATION_METHOD_TKN,
  ACCUM_METHOD_NSUM_TKN: ACCUM_METHOD_NSUM_TKN,
  AND_METHOD_BDIF_TKN: AND_METHOD_BDIF_TKN,
  OR_METHOD_ASUM_TKN: OR_METHOD_ASUM_TKN,
  RULE_TKN: RULE_TKN,
  IF_CONDITION_TKN: IF_CONDITION_TKN,
  THEN_CONDITION_TKN: THEN_CONDITION_TKN,
  WITH_CONDITION_TKN: WITH_CONDITION_TKN,
  IS_LOGIC_TKN: IS_LOGIC_TKN,
  NOT_LOGIC_TKN: NOT_LOGIC_TKN
}

var REGEX_ARRAY = [
  MULTILINE_COMMENT_START_TKN,
  MULTILINE_COMMENT_END_TKN,
  NEWLINE_TKN
]

module.exports.tokens = TOKENS
module.exports.nameArray = NAME_ARRAY
module.exports.tokenArray = TOKEN_ARRAY
module.exports.regexArray = REGEX_ARRAY
