Created
February 25, 2020 10:07
-
-
Save meldsza/5ca59988b0bff3f1434261518a229985 to your computer and use it in GitHub Desktop.
CD LAB 25-02-2020 no of id
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%{ | |
#include <stdio.h> | |
#include <stdlib.h> | |
int nc=0; | |
%} | |
%option noyywrap | |
%% | |
[a-zA-Z_][a-zA-Z_0-9]* {nc++;} | |
.|\n { } | |
%% | |
int main(int argc, char* argv[]){ | |
if(argc != 2) | |
{ | |
puts("Invalid arguments provided"); | |
return 1; | |
} | |
yyin = fopen(argv[1], "r"); | |
yylex(); | |
printf("No of identifiers: %d\n", nc); | |
fclose(yyin); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment