fork download
  1. lex_by_file( FileName ) :-
  2. get_input_from_file( FileName, TokenList ),
  3. lex( TokenList, OutputList ),
  4. %write_output( OutputList ), !.
  5. maplist(writeln,OutputList),!.
  6.  
  7. %{
  8. #include <stdio.h>
  9. %}
  10.  
  11. DIGIT [0-9]
  12. WORD [a-zA-Z]+
  13.  
  14. %%
  15. {DIGIT}+ { printf("Input is a number: %s\n", yytext); }
  16. {WORD} { printf("Input is a word: %s\n", yytext); }
  17. . { printf("Invalid input: %s\n", yytext); }
  18.  
  19. %%
  20.  
  21. int main() {
  22. yylex();
  23. return 0;
  24. }
  25.  
Success #stdin #stdout #stderr 0.03s 6908KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/tObLUr/prog:8:1: Syntax error: Operator expected
ERROR: /home/tObLUr/prog:24:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit