github.com/ronaksoft/rony@v0.16.26-0.20230807065236-1743dbfe6959/internal/parser/tokens.go (about)

     1  package parse
     2  
     3  /*
     4     Creation Time: 2020 - Aug - 17
     5     Created by:  (ehsan)
     6     Maintainers:
     7        1.  Ehsan N. Moosa (E2)
     8     Auditor: Ehsan N. Moosa (E2)
     9     Copyright Ronak Software Group 2020
    10  */
    11  
    12  // token identifies the type of lex items.
    13  type token int
    14  
    15  const (
    16  	ERROR token = iota
    17  	EOF         // End of File
    18  	SPACE       // White Space
    19  
    20  	literal_beg
    21  	TEXT
    22  	IDENT // names, variables
    23  	literal_end
    24  
    25  	operator_beg
    26  	AT_SIGN // @
    27  	COMMA   // ,
    28  	L_PAREN // (
    29  	R_PAREN // )
    30  	L_DELIM // {{
    31  	R_DELIM // }}
    32  
    33  	operator_end
    34  
    35  	keyword_beg
    36  	MODEL
    37  	TABLE
    38  	VIEW
    39  	COUNTER
    40  	keyword_end
    41  )
    42  
    43  // IsLiteral returns true for tokens corresponding to identifiers
    44  // and basic type literals; it returns false otherwise.
    45  //
    46  func (tok token) IsLiteral() bool { return literal_beg < tok && tok < literal_end }
    47  
    48  // IsOperator returns true for tokens corresponding to operators and
    49  // delimiters; it returns false otherwise.
    50  //
    51  func (tok token) IsOperator() bool { return operator_beg < tok && tok < operator_end }
    52  
    53  // IsKeyword returns true for tokens corresponding to keywords;
    54  // it returns false otherwise.
    55  //
    56  func (tok token) IsKeyword() bool { return keyword_beg < tok && tok < keyword_end }