import { createErrorForUnexpectedCharacter } from "../../Error" ; import { AnyToken } from "../Token" ; import seekComparisonCustomOperatorToken from "./seekComparisonCustomOperatorToken" ; import seekComparisonOperatorToken from "./seekComparisonOperatorToken" ; import seekLogicCanonicalOperatorToken from "./seekLogicCanonicalOperatorToken" ; import seekLogicVerboseOperatorToken from "./seekLogicVerboseOperatorToken" ; import { SeekProcessor } from "../LexerProcessor" ; import seekParenthesisToken from "./seekParenthesisToken" ; import seekQuotedToken from "./seekQuotedToken" ; import seekUnquotedToken from "./seekUnquotedToken" ; import skipWhitespace from "./skipWhitespace" ; const seekAnyToken = ( context ) => { skipWhitespace ( context ) ; if ( context . position >= context . length ) { return null ; } const char = context . buffer . charAt ( context . position ) ; let token = null ; switch ( char ) { case "'" : case '"' : token = seekQuotedToken ( context ) ; break ; case "(" : case ")" : token = seekParenthesisToken ( context ) ; break ; case "," : case ";" : token = seekLogicCanonicalOperatorToken ( context ) ; break ; case "=" : case "!" : case "~" : case "<" : case ">" : token = seekComparisonOperatorToken ( context ) ; if ( ! token && char === "=" ) { token = seekComparisonCustomOperatorToken ( context ) ; } break ; default : token = seekLogicVerboseOperatorToken ( context ) ; if ( ! token ) { token = seekUnquotedToken ( context ) ; } } if ( ! token ) { throw createErrorForUnexpectedCharacter ( context . position , context . buffer ) ; } return token ; } ; export default seekAnyToken ;