GPT умеет и стейт машины писать
What would be a Ragel machine for parsing ipv4 address?
Here is an example of a Ragel machine for parsing an IPv4 address:
%%{
machine ipv4;
main := (octet '.' octet '.' octet '.' octet) @done;
octet := digit{1,3};
digit := [0-9];
}%%
This machine has four states: main, octet, and digit. The main state is the starting point for the machine, and it defines the overall structure of an IPv4 address. The octet state is used to parse each of the four octets in the address, and the digit state is used to parse the individual digits that make up each octet.
To use this machine to parse an IPv4 address, you would feed it the input string and it would use the transitions between states to identify the individual components of the address. For example, if the input string was 192.168.1.1, the machine would first enter the main state, then it would transition to the octet state to parse the first octet (192), then it would transition back to the main state and then to the octet state again to parse the second octet (168), and so on. Once all four octets have been parsed, the machine would reach the done state, indicating that the input string has been successfully parsed.