Install Lex on Ubuntu 16.04. Lex is in flex and Yacc in bison.
sudo apt install flex bison
Create an empty file and edit it.
digit [0-9] letter [A-Za-z] %{ int count; %} %% /* match identifier */ {letter}({letter}|{digit})* {count++; printf("number of identifiers = %d\n", count);} %%
Save it as lol.l
lex lol.l gcc lex.yy.c -lfl
And we can run it by typing
./a.out
An example
原文地址:https://www.cnblogs.com/cxxszz/p/8553608.html
时间: 2024-10-19 11:04:57