I am very new to Lex and Yacc. I have a Lex program. Example: wordcount.l
I use windows and putties.
I am just trying to run this file.
Does wordcount.l on drive C?
I compile a Lex program and generate a .c program, and then what am I running?
I tried on the command line: Lex wordcount.l
but I just get the file not found ...
wordcount.l
%{ #include <stdlib.h> #include <stdio.h> int charCount=0; int wordCount=0; int lineCount=0; %} %% \n {charCount++; lineCount++;} [^ \t\n]+ {wordCount++; charCount+=yyleng;} . {charCount++;} %% main(argc, argv) int argc; char** argv; { if (argc > 1) { FILE *file; file = fopen(argv[1], "r"); if (!file) { fprintf(stderr, "Could not open %s\n", argv[1]); exit(1); } yyin = file; } yylex(); printf("%d %d %d\n", charCount, wordCount, lineCount); }
In putty, how do I compile and run this program?
user249375
source share