A state machine that is either DFA or NFA: is it possible? I am studying Crafting Interpreters, and although I understand the responsibility of the Scanner (or Lexer), I still cannot understand if it is a deterministic finite automaton or non-deterministic finite automaton. The code responsible for scanning the input text in the book is:
    private void scanToken() {
        char c = advance();
        switch (c) {
            case '(': addToken(LEFT_PAREN); break;
            case ')': addToken(RIGHT_PAREN); break;
            case '{': addToken(LEFT_BRACE); break;
            case '}': addToken(RIGHT_BRACE); break;
            case ',': addToken(COMMA); break;
            case '.': addToken(DOT); break;
            case '-': addToken(MINUS); break;
            case '+': addToken(PLUS); break;
            case ';': addToken(SEMICOLON); break;
            case '*': addToken(STAR); break;
            case '!':
                addToken(match('=') ? BANG_EQUAL : BANG);
                break;
            case '=':
                addToken(match('=') ? EQUAL_EQUAL : EQUAL);
                break;
            case '&lt;':
                addToken(match('=') ? LESS_EQUAL : LESS);
                break;
            case '&gt;':
                addToken(match('=') ? GREATER_EQUAL : GREATER);
                break;
            case '/':
                if (match('/')) {
                    while (!isAtEnd() &amp;&amp; peek() != '\n') {
                        advance();
                    }
                } else if (match('*')) {
                    do {
                        if (peek() == '*' &amp;&amp; peekNext() == '/') {
                            advance();
                            advance();
                        } else {
                            advance();
                        }
                    } while (!isAtEnd());
                } else {
                    addToken(SLASH);
                }
                break;
            case ' ':
            case '\r':
            case '\t':
                // Ignore whitespace.
                break;
            case '\n':
                line++;
                break;
            case '&quot;': string(); break;
            default:
                if (isDigit(c)) {
                    number();
                } else if (isAlpha(c)) {
                    identifier();
                } else {
                    Lox.error(line, &quot;Unexpected character.&quot;);
                }
                break;
        }
    }

According to several sites out there, the FA definition is:

Finite Automata(FA) is the simplest machine to recognize patterns.The
finite automata or finite state machine is an abstract machine which
have five elements or tuple. It has a set of states and rules for
moving from one state to another but it depends upon the applied input
symbol. Basically it is an abstract model of digital computer.
Following figure shows some essential features of a general
automation.

A DFS consists of the following:
Q : Finite set of states.
Σ : set of Input Symbols.
q : Initial state.
F : set of Final States.
δ : Transition Function.

and for NFA:
Q : set of all states.
Σ : set of input symbols. ( Symbols which machine takes as input )
q : Initial state. ( Starting state of a machine )
F : set of final state.
δ : Transition Function, defined as δ : Q X Σ --&gt; Q.

My lexer can start in any state, does that mean it is either DFA or NFA? How can I conclude if it is one or the other?
Any piece of code can never be non-deterministic (a non-deterministic process can &quot;multiply itself&quot; by a constant factor every step, and obviously computers can't just multiply by their own free will).
Hence it is a DFA.

Also, your lexer will start always at the initial state $s_0$, and from it, depending on what it reads - it moves to different states.