Module: Synthra::Parser::Tokens
Overview
Token type constants for the DSL lexer
This module defines all the token types that the lexer can produce. Each token type is a symbol that identifies the kind of syntax element.
Token types are organized into categories:
- Structural: Schema and field names, colons, question marks
- Types: Type names, Ref keyword
- Delimiters: Parentheses, commas, dots
- Values: Numbers, strings, identifiers, ranges, percentages
- Keywords: if, true, false
- Behaviors: @ prefixed behavior declarations
- Whitespace/Structure: Newlines, indentation changes
- Special: EOF, symbols
Constant Summary collapse
- SCHEMA_NAME =
Schema name at the top level (e.g., "User:") Value: String containing the schema name without the colon
:schema_name- FIELD_NAME =
Field name within a schema (e.g., "name:", "email?:") Value: String containing the field name (may include ? for optional)
:field_name- COLON =
Colon separator Value: ":" literal
:colon- QUESTION =
Question mark for optional/nullable types Value: "?" literal
:question- TYPE =
Built-in or custom type name (uuid, text, number, etc.) Value: String containing the type name
:type- REF =
Reference keyword for cross-schema references Value: "Ref" literal
:ref- LPAREN =
Left parenthesis for type arguments Value: "(" literal
:lparen- RPAREN =
Right parenthesis for type arguments Value: ")" literal
:rparen- COMMA =
Comma separator in argument lists Value: "," literal
:comma- DOT =
Dot separator in references (Schema.field) Value: "." literal
:dot- MINUS =
Minus sign for negative numbers Value: "-" literal
:minus- STAR =
Arithmetic operators (used inside formula(...) expressions)
:star- SLASH =
:slash- PLUS =
:plus- NUMBER =
Numeric literal (integer or float) Value: Integer or Float
:number- STRING =
String literal (single or double quoted) Value: String (quotes stripped)
:string- IDENTIFIER =
Identifier (unquoted name, used in enums, etc.) Value: String
:identifier- RANGE =
Range literal (min..max) Value: Range object
:range- PERCENT =
Percentage literal Value: Integer (percent without %)
:percent- IF =
Conditional keyword for field conditions Value: "if" literal
:if- TRUE_KW =
Boolean true keyword Value: true
:true- FALSE_KW =
Boolean false keyword Value: false
:false- SCHEMA_KEYWORD =
Schema definition keyword Value: "schema" literal
:schema_keyword- API_KEYWORD =
API definition keyword Value: "api" literal
:api_keyword- SCENARIO_KEYWORD =
Scenario definition keyword Value: "scenario" literal
:scenario_keyword- HTTP_METHOD =
HTTP method token Value: Symbol (:get, :post, :put, :patch, :delete, :options, :head)
:http_method- PATH =
URL path token Value: String containing the path
:path- SCHEMA_REF =
Schema reference token for explicit schema(:Name) syntax Value: String containing the schema name
:schema_ref- AT_BEHAVIOR =
Behavior annotation (@latency, @failure, etc.) Value: String containing behavior name without @
:at_behavior- NEWLINE =
Newline character Value: "\n" literal
:newline- INDENT =
Increase in indentation level Value: Integer (new indentation level)
:indent- DEDENT =
Decrease in indentation level Value: Integer (new indentation level)
:dedent- EOF =
End of file marker Value: nil
:eof- SYMBOL =
Ruby symbol literal (:function_name) Value: Symbol
:symbol- ALL =
Array of all valid token types
[ SCHEMA_NAME, FIELD_NAME, COLON, QUESTION, TYPE, REF, LPAREN, RPAREN, COMMA, DOT, MINUS, NUMBER, STRING, IDENTIFIER, RANGE, PERCENT, IF, TRUE_KW, FALSE_KW, SCHEMA_KEYWORD, API_KEYWORD, SCENARIO_KEYWORD, HTTP_METHOD, PATH, SCHEMA_REF, AT_BEHAVIOR, NEWLINE, INDENT, DEDENT, EOF, SYMBOL ].freeze