mirror of
https://github.com/RustyRaptor/compilers.git
synced 2026-12-03 15:15:17 -07:00
modified some files not sure what happened
This commit is contained in:
1 parent
1df0a0f271
commit
e38a95e6a8
21 files changed
+31
-3473
No files matched your search
Binary file not shown.
|
After Width: | Height: | Size: 45 KiB |
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 3.6 KiB |
@@ -0,0 +1 @@
|
||||
# Ziad Arafat
|
||||
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 9.9 KiB |
@@ -0,0 +1,11 @@
|
||||
# Ziad Arafat
|
||||
|
||||
| State | a | b | a + $\epsilon$ | b + $\epsilon$ |
|
||||
|---------|-------|---------|----------------|----------------|
|
||||
| A:{0} | {1,2} | {1} | {1,2,3} | {1,3} |
|
||||
| B:{1,2,3} | {1} | {3,4} | {1,3} | {3,4,2} |
|
||||
| C:{1,3} | {} | {3,4} | {} | {3,4,2} |
|
||||
| D:{3,4,2} | {0,1} | {4} | {0,1,3} | {4,2,3} |
|
||||
| E:{0,1,3} | {1,2} | {1,3,4} | {1,2,3} | {3,4,2} |
|
||||
|
||||

|
||||
Binary file not shown.
|
After Width: | Height: | Size: 105 KiB |
+1
-1
@@ -28,7 +28,7 @@ int yylex();VAR
|
||||
[ \t] {
|
||||
if (mydebug) fprintf(stderr,"Whitespace found\n");
|
||||
}
|
||||
[=\-+*/%&|()] {
|
||||
[=\-+*/%&|()\^] {
|
||||
if (mydebug) fprintf(stderr,"return a token %c\n",*yytext);
|
||||
return (*yytext);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
%{
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <math.h>
|
||||
int yylex();
|
||||
|
||||
int regs[26];
|
||||
@@ -24,6 +25,7 @@ void yyerror (s) /* Called by yyparse on error */
|
||||
%left '|'
|
||||
%left '&'
|
||||
%left '+' '-'
|
||||
%left '^'
|
||||
|
||||
%left '*' '/' '%' '(' /*add a opening parenthesis */
|
||||
%left UMINUS
|
||||
@@ -64,6 +66,8 @@ expr : '(' expr ')'
|
||||
{ $$ = $1 % $3; }
|
||||
| expr '&' expr
|
||||
{ $$ = $1 & $3; }
|
||||
| expr '^' expr
|
||||
{ $$ = pow($1, $3); }
|
||||
| expr '|' expr
|
||||
{ $$ = $1 | $3; }
|
||||
| expr '*' expr { $$ = $1 * $3; }
|
||||
|
||||
-1841
File diff suppressed because it is too large.
Load diff
-1550
File diff suppressed because it is too large.
Load diff
@@ -1,70 +0,0 @@
|
||||
/* A Bison parser, made by GNU Bison 3.0.4. */
|
||||
|
||||
/* Bison interface for Yacc-like parsers in C
|
||||
|
||||
Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* As a special exception, you may create a larger work that contains
|
||||
part or all of the Bison parser skeleton and distribute that work
|
||||
under terms of your choice, so long as that work isn't itself a
|
||||
parser generator using the skeleton or a modified version thereof
|
||||
as a parser skeleton. Alternatively, if you modify or redistribute
|
||||
the parser skeleton itself, you may (at your option) remove this
|
||||
special exception, which will cause the skeleton and the resulting
|
||||
Bison output files to be licensed under the GNU General Public
|
||||
License without this special exception.
|
||||
|
||||
This special exception was added by the Free Software Foundation in
|
||||
version 2.2 of Bison. */
|
||||
|
||||
#ifndef YY_YY_Y_TAB_H_INCLUDED
|
||||
# define YY_YY_Y_TAB_H_INCLUDED
|
||||
/* Debug traces. */
|
||||
#ifndef YYDEBUG
|
||||
# define YYDEBUG 0
|
||||
#endif
|
||||
#if YYDEBUG
|
||||
extern int yydebug;
|
||||
#endif
|
||||
|
||||
/* Token type. */
|
||||
#ifndef YYTOKENTYPE
|
||||
# define YYTOKENTYPE
|
||||
enum yytokentype
|
||||
{
|
||||
INTEGER = 258,
|
||||
VARIABLE = 259,
|
||||
UMINUS = 260
|
||||
};
|
||||
#endif
|
||||
/* Tokens. */
|
||||
#define INTEGER 258
|
||||
#define VARIABLE 259
|
||||
#define UMINUS 260
|
||||
|
||||
/* Value type. */
|
||||
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
||||
typedef int YYSTYPE;
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
# define YYSTYPE_IS_DECLARED 1
|
||||
#endif
|
||||
|
||||
|
||||
extern YYSTYPE yylval;
|
||||
|
||||
int yyparse (void);
|
||||
|
||||
#endif /* !YY_YY_Y_TAB_H_INCLUDED */
|
||||
Binary file not shown.
+2
-2
@@ -2,7 +2,7 @@
|
||||
|
||||
# the gcc options so I don't have to copy paste them everywhere
|
||||
# any time I make changes to them.
|
||||
FLAGS = -O0 -Wextra -pedantic
|
||||
FLAGS = -O0 -Wextra -pedantic
|
||||
|
||||
# Entry point target
|
||||
all: lab4
|
||||
@@ -11,7 +11,7 @@ all: lab4
|
||||
lab4: lab4docalc.l lab4docalc.y symtable.c symtable.h
|
||||
lex lab4docalc.l
|
||||
yacc -d lab4docalc.y
|
||||
gcc $(FLAGS) y.tab.c lex.yy.c symtable.c -o lab4
|
||||
gcc $(FLAGS) y.tab.c lex.yy.c symtable.c -o lab4 -lm
|
||||
|
||||
# remove the binary and other generated stuff
|
||||
clean:
|
||||
|
||||
Binary file not shown.
@@ -1,7 +0,0 @@
|
||||
int fuck;
|
||||
int hoe;
|
||||
fuck = 5
|
||||
hoe = 6
|
||||
fuck + hoe
|
||||
hoe + 8
|
||||
9 + 9
|
||||
+1
-1
@@ -41,7 +41,7 @@ int yylex();
|
||||
if (mydebug) fprintf(stderr,"Whitespace found\n");
|
||||
}
|
||||
|
||||
[=\-+*/%&|();] {
|
||||
[=\-+*/%&|();^] {
|
||||
if (mydebug) fprintf(stderr,"return a token %c\n",*yytext);
|
||||
return (*yytext);
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ void yyerror (s) /* Called by yyparse on error */
|
||||
%left '|'
|
||||
%left '&'
|
||||
%left '+' '-'
|
||||
%left '^'
|
||||
|
||||
%left '*' '/' '%' '(' /*add a opening parenthesis */
|
||||
%left UMINUS
|
||||
@@ -118,6 +119,8 @@ expr : '(' expr ')'
|
||||
{ $$ = $1 % $3; }
|
||||
| expr '&' expr
|
||||
{ $$ = $1 & $3; }
|
||||
| expr '^' expr
|
||||
{ $$ = powfuck($1, $3); }
|
||||
| expr '|' expr
|
||||
{ $$ = $1 | $3; }
|
||||
| expr '*' expr { $$ = $1 * $3; }
|
||||
|
||||
+5
-1
@@ -26,7 +26,7 @@
|
||||
* another instance of SymTab so it is recursive in the sense that the struct
|
||||
* uses a pointer to an instance of itself.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include "symtable.h"
|
||||
|
||||
int size = 0; // stores the current size of the symtable
|
||||
@@ -252,3 +252,7 @@ int FetchAddress(char *s)
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int powfuck(int x, int y) {
|
||||
return pow(x, y);
|
||||
}
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
#ifndef SYMTABLE_H
|
||||
#define SYMTABLE_H
|
||||
|
||||
@@ -30,6 +31,8 @@ void Display(); // Display the symboltable
|
||||
|
||||
int FetchAddress(char *s); // added FetchAddress prototype
|
||||
|
||||
int powfuck(int x, int y);
|
||||
|
||||
/*
|
||||
* Delete()
|
||||
* Input char sym: a pointer to the symbol char array we want to remove
|
||||
|
||||
Reference in new issue
Block a user