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
DELAY PROC | |
PUSH CX | |
PUSH BX | |
MOV CX, 0FFFFH | |
B1: MOV BX, 0FFFFH | |
B2: DEC BX | |
JNZ B2 | |
LOOP B1 | |
POP BX | |
POP CX |
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
%{ | |
int wc=0,cc=0,lc=0,bc=0; | |
char infile[25]; | |
%} | |
word [^ \t\n]+ | |
eol \n | |
%% | |
{word} {wc++; cc+=yyleng;} | |
{eol} {lc++; cc++; } | |
[ ] {bc++; cc++; } |
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
%{ | |
int cc=0; | |
%} | |
%x CMNT | |
%% | |
"/*" {BEGIN CMNT; } | |
<CMNT>. ; | |
<CMNT>\n ; | |
<CMNT>"*/" {BEGIN 0; cc++;} | |
.*”//”.* {BEGIN 0; cc++;} |
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
%{ | |
int a[]={0,0,0,0},i,valid=1,opnd=0; | |
%} | |
%x OPER | |
%% | |
[a-zA-Z0-9]+ { BEGIN OPER; opnd++;} | |
<OPER>"+" { if(valid) { valid=0;i=0;} else ext();} | |
<OPER>"-" { if(valid) { valid=0;i=1;} else ext();} | |
<OPER>"*" { if(valid) { valid=0;i=2;} else ext();} | |
<OPER>"/" { if(valid) { valid=0;i=3;} else ext();} |
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
%{ | |
int flag=0; | |
%} | |
%% | |
.+[ \t]+[Aa][Nn][Dd][ \t]+.+ {flag=1;} | |
.+[ \t]+[Oo][Rr][ \t]+.+ {flag=1;} | |
.+[ \t]+[Bb][Uu][Tt][ \t]+.+ {flag=1;} | |
.+[ \t]+[Bb][eE][Cc][Aa][Uu][Ss][Ee][ \t]+.+ {flag=1;} | |
.+[ \t]+[Nn][Ee][Vv][Ee][Rr][Tt][Hh][Ee][Ll][Ee][Ss][Ss][ \t]+.+ {flag=1;} | |
. ; |
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<string.h> | |
int flag=0,cnt=0; | |
char str[50]; | |
%} | |
%% | |
(int\ )|(char\ )|(float\ )|(double\ )(short\ )(long\ )(unsigned\ ) {flag=1;} | |
[a-zA-Z_][A-Za-z0-9_]*[,=\[;] {if(flag==1) | |
{ cnt++; |
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
%{ | |
/* 4a.l Yacc Program to check the validity of an arithmetic Expression that uses operators +, -, *, / | |
*/ | |
#include "y.tab.h" | |
%} | |
%% | |
[0-9]+(\.[0-9]+)? { return NUM;} | |
[a-zA-Z_][_a-zA-Z0-9]* { return ID; } | |
[\t] ; | |
\n return 0; |
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
%{ | |
/* 4a.y Yacc Program to check the validity of an arithmetic Expression that uses operators +, -, *, / | |
*/ | |
#include<stdio.h> | |
#include<stdlib.h> | |
%} | |
%token NUM ID | |
%left '+' '-' | |
%left '*' '/' | |
%% |
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 "y.tab.h" | |
%} | |
%% | |
[a-zA-z_] {return ALPHA;} | |
[0-9]+ {return NUMBER;} | |
"\n" { return ENTER;} | |
. {return ER;} | |
%% | |
yywrap() |
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> | |
%} | |
%token ALPHA NUMBER ENTER ER | |
%% | |
var:v ENTER {printf("Valid Variable\n");exit(0);} | |
v:ALPHA exp1 | |
exp1:ALPHA exp1 | |
|NUMBER exp1 |
OlderNewer