

Finally we skip all the trailing characters until a newline character is encountered. Then we print all the characters of the first word. First we skip all leading whitespace characters, if any.

5 Object-oriented programming relationshipĬonsider the task of reading a text from standard input line-by-line and writing the first word of each line to standard output.4 Comparison with imperative and procedural programming.
#Finite state automata in java code
The whole execution of the automata-based code is a cycle of the automaton steps.Īnother reason for using the notion of automata-based programming is that the programmer's style of thinking about the program in this technique is very similar to the style of thinking used to solve mathematical tasks using Turing machines, Markov algorithms, etc. That is, the state of the whole program, taken at any two moments of entering an automaton step, can only differ in the values of the variables being considered as the automaton state. Between any two steps, the program cannot have implicit components of its state, such as local variables' values, return addresses, the current instruction pointer, etc. Any communication between the automaton steps is only possible via the explicitly noted set of variables named the automaton state.That section might be divided down to subsections to be executed depending on different states, although this is not necessary. Each step is effectively an execution of a code section (same for all the steps) which has a single entry point. The time period of the program's execution is clearly separated down to the automaton steps.The following properties are key indicators for automata-based programming: Sometimes a potentially infinite set of possible states is introduced, and such a set can have a complicated structure, not just an enumeration.įinite-state machine-based programming is generally the same, but, formally speaking, does not cover all possible variants, as FSM stands for finite-state machine, and automata-based programming does not necessarily employ FSMs in the strict sense. Programming paradigmsĪutomata-based programming is a programming paradigm in which the program or part of it is thought of as a model of a finite-state machine (FSM) or any other (often more complicated) formal automaton (see automata theory). For other uses, see Automata-based programming (Shalyto's approach).
