Update README and file headers

This commit is contained in:
Victor Fernandes 2017-05-10 13:46:04 -04:00
parent 57a7fa3e43
commit 8a8188e07d
13 changed files with 64 additions and 55 deletions

View File

@ -1,5 +1,5 @@
# PLATYPUS
*Buffer Descriptor for the PLATYPUS language specification*
*Frontend compiler for the PLATYPUS language specification*
## Building
@ -8,12 +8,12 @@
*gcc (tested in version 6.3.x) or clang (tested under LLVM clang-0800.0.42.1)*
- `make [gcc | clang]`
- Default is to build both versions (this is an aftermath of testing behaviour from different compilers)
- It is safe to modify the default to either gcc or clang if you don't have one of them
- **NOTE: I haven't tested or created make targets for the scanner yet.**
- No argument will build both versions (this is an aftermath of having to check behaviour in the binary from multiple compilers)
- It is safe to modify the default to either gcc or clang if you wish. ** SEE NOTES BELOW **
- **NOTE: I haven't tested or created make targets for the final implementation yet. This is somewhat buried deep into the backburner**
### Windows
#### Requires
- `msvc` (tested under Visual Studio 2015 with Update 3, however VS2013 shouldn't behave abnormally either, nor should 2017)
- `msvc` (tested under Visual Studio 2015 with Update 3, however VS 2012 and 2013 shouldn't behave abnormally either, nor should 2017)
- Disable language extensions (use ANSI C)
---
## Running
@ -31,10 +31,10 @@
# Notes
This is in no way complete, it is missing a scanner implementation, parser, symbol table, etc.
**This is in no way complete, or ready for production in any shape or form.** It works up to the parser, but still contains incorrect grammar parsing and some edge cases that causes crashes.
You can modify the initial capacity and increment factor defined in `platy_bt.c` (should really make that a command line parameter in a future release)
You can modify the initial capacity and increment factor defined in `platy.c` (should really make that a command line parameter in a future release)
- Increment factor range for additive mode: `1 - 255`. (setting this to 0 implies fixed mode, regardless of the mode given in the command line)
- Initial capacity range (in bytes): `0 - 32767 (SHRT_MAX)`
- This is due to my environment's install locations for the C include libraries:
- **Inside `buffer.h`, there is a `#DEFINE` line for `MACOS_DEP`. If you are using a Linux system or Windows and your malloc.h is actually named malloc.h, you can leave `#undef MACOS_DEP` alone, otherwise comment it out.**
- This is an issue caused by my environment's install locations for the C include libraries:
- **`buffer.h` contains an `#ifdef` directive checking if `WIN32` exists. Due to an upgrade issue with GCC in macOS (possibly only in my machine), `malloc.h` is actually named `mm_maloc.h`. If your system uses `malloc.h`, you can safely delete the check and use the regular filename instead.**

View File

@ -4,7 +4,7 @@
* Author: Victor Fernandes, 040772243
* Course: CST8152 - Compilers, Lab Section: 011
* Date: February 1, 2017
* Professor: Svillen Ranev
* Professor: S^R
* A character buffer utility with three modes of self-incrementation
through dynamic memory allocation, and ability to set a mark flag.
* Function list: b_create, b_isfull, b_isempty, b_size, b_capacity,

View File

@ -1,6 +1,7 @@
/* File Name: parser.c
* The PLATYPUS parsing program for the final assignment of
How To Train Your Dragon (AKA Compilers)
* Compiler: GNU GCC 6
* Author: Victor Fernandes, 040772243
* Course: CST8152 - Compilers, Lab Section: 011
* Date: April 21, 2017
@ -11,14 +12,14 @@
#include "parser.h"
/* Global variables for the parser */
Token lookahead;
extern int synerrno; /* Error counter */
extern char* kw_table[]; /* Keyword table with matching enum */
extern STD sym_table; /* The symbol table */
extern Buffer* sc_buf; /* Scanner buffer */
extern Buffer* str_LTBL; /* String literal table */
extern int line /* Line position of the Scanner */
Token lookahead;
int synerrno; /* Error counter */
Buffer *sc_buf; /* Scanner buffer */
extern char *kw_table[]; /* Keyword table with matching enum */
extern STD sym_table; /* The symbol table */
extern Buffer *str_LTBL; /* String literal table */
extern int line; /* Line position of the Scanner */
extern Token malar_next_token(Buffer *); /* Scanner function to get the next token */
/* Begins the source file parsing
* Author: Victor Fernandes, 040772243
@ -29,6 +30,7 @@
*/
void parser(pBuffer in_buf)
{
synerrno = 0;
sc_buf = in_buf;
lookahead = malar_next_token(sc_buf);
program();
@ -68,7 +70,7 @@ void match(int pr_token_code, int pr_token_attribute)
lookahead = malar_next_token(sc_buf);
if (lookahead.code == ERR_T)
{
synerrno++;
++synerrno;
syn_printe();
lookahead = malar_next_token(sc_buf);
}
@ -90,7 +92,7 @@ void match(int pr_token_code, int pr_token_attribute)
void syn_eh(int pr_token_code)
{
syn_printe();
synerrno++;
++synerrno;
while (lookahead.code != SEOF_T)
{
@ -117,7 +119,7 @@ void syn_eh(int pr_token_code)
*/
void syn_printe()
{
printf("PLATY: Syntax error: Line:%3d\n" + "***** Token code: %3d Attribute: ", line, lookahead.code);
printf("PLATY: Syntax error: Line:%3d\n***** Token code: %3d Attribute: ", line, lookahead.code);
switch (lookahead.code)
{
case ERR_T:
@ -196,7 +198,6 @@ void gen_incode(char *code)
* Grammar functions ahoy
*/
/*
* <additive_arithmetic_expression> ->
<multiplicative_arithmetic_expression> <additive_arithmetic_expression_prime>
@ -215,7 +216,7 @@ void additive_arithmetic_expression()
*/
void additive_arithmetic_expression_prime()
{
if (lookahead.code == ART_OP &&
if (lookahead.code == ART_OP_T &&
lookahead.attribute.arr_op != MULT &&
lookahead.attribute.arr_op != DIV)
{
@ -233,6 +234,9 @@ void additive_arithmetic_expression_prime()
*/
void arithmetic_expression()
{
/* GCC complains that PLUS and MINUS enums aren't handled,
but this is automatically handled in additive_arithmetic_expression()
*/
switch (lookahead.code)
{
case ART_OP_T:
@ -389,7 +393,7 @@ void logical_or_expression()
.OR. <logical_and_expression> <logical_or_expression_prime>
FIRST Set = { .OR., E }
*/
voic logical_or_expression_prime()
void logical_or_expression_prime()
{
if (lookahead.code == LOG_OP_T &&
lookahead.attribute.log_op == OR)
@ -450,7 +454,8 @@ void opt_statements()
}
case AVID_T:
case SVID_T:
statements() : break;
statements();
break;
default:
gen_incode("PLATY: Opt_statements parsed");
}
@ -522,18 +527,18 @@ void primary_arithmetic_expression()
{
switch (lookahead.code)
{
case AVID_T:
case FPL_T:
case INL_T:
match(lookahead.code, lookahead.attribute.arr_op);
break;
case LPR_T:
match(lookahead.code, lookahead.attribute,arr_op);
arithmetic_expression();
match(RPR_T, NO_ATTR);
default:
syn_printe();
return;
case AVID_T:
case FPL_T:
case INL_T:
match(lookahead.code, lookahead.attribute.arr_op);
break;
case LPR_T:
match(lookahead.code, lookahead.attribute.arr_op);
arithmetic_expression();
match(RPR_T, NO_ATTR);
default:
syn_printe();
return;
}
gen_incode("PLATY: Primary arithmetic expression parsed");
}
@ -661,7 +666,7 @@ void relational_expression_prime_string()
case NE:
case GT:
case LT:
match(lookahead.codem, lookahead.attribute.arr_op);
match(lookahead.code, lookahead.attribute.arr_op);
primary_s_relational_expression();
return;
}
@ -791,7 +796,7 @@ void string_expression_prime()
{
match(SCC_OP_T, NO_ATTR);
primary_string_expression();
stirng_expression_prime();
string_expression_prime();
}
}
@ -803,6 +808,7 @@ void string_expression_prime()
*/
void unary_arithmetic_expression()
{
/* Again, GCC complains about PLUS and MINUS enums */
switch (lookahead.code)
{
case ART_OP_T:

View File

@ -3,7 +3,7 @@
* Author: Victor Fernandes, 040772243
* Course: CST8152 - Compilers, Lab Section: 011
* Date: April 17, 2017
* Professor: Svillen Ravev
* Professor: S^R
* Version: 0.1
*/
#ifndef PARSER_H_
@ -63,6 +63,7 @@ void statement(void);
void statements(void);
void statements_prime(void);
void string_expression(void);
void string_expression_prime(void);
void unary_arithmetic_expression(void);
void variable_identifier(void);
void variable_list(void);

View File

@ -2,7 +2,7 @@
* Purpose:This is the main program for Assignment#4 - Platypus Parser
* CST8152 - Compilers
* Version: 1.17.01
* Author: Svillen Ranev
* Author: S^R
* Date: 18 March 2017
*/

View File

@ -1,7 +1,7 @@
/* File name: platy_bt.c
* Purpose:This is the main program for Assignment #1, CST8152, Winter 17
* Version: 1.17.1
* Author: Svillen Ranev
* Author: S^R
* Date: 9 January 2017
*/

View File

@ -2,7 +2,7 @@
* Purpose:This is the main program for Assignment #2 - Scanner
* CST8152 - Compilers
* Version: 1.17.1
* Author: Svillen Ranev
* Author: S^R
* Date: 30 January 2017
*/

View File

@ -2,7 +2,7 @@
* Purpose:This is the main program for Assignment #3 - Symbol Table
* CST8152 - Compilers
* Version: 1.17.01
* Author: Svillen Ranev
* Author: S^R
* Date: 1 March 2017
*/

View File

@ -5,7 +5,7 @@
* scanner_init() must be called before using the scanner.
* The file is incomplete;
* Author: Victor Fernandes, 040772243
* Provided by: Svillen Ranev
* Provided by: S^R
* Version: 1.17.1
* Date: 30 January 2017
* Function list: scanner_init, malar_next_token, get_next_state, char_class,
@ -45,7 +45,7 @@
It is defined in platy_st.c */
extern Buffer * str_LTBL; /*String literal table */
int line; /* current line number of the source code */
extern int scerrnum; /* defined in platy_st.c - run-time error number */
extern int synerrno; /* defined in platy_st.c - run-time error number */
extern STD sym_table; /* symbol table */
/* Local(file) global objects - variables */
static Buffer *lex_buf; /*pointer to temporary lexeme buffer*/
@ -74,7 +74,7 @@ int scanner_init(Buffer * sc_buf) {
b_reset(str_LTBL);
line = 1;
return EXIT_SUCCESS;/*0*/
/* scerrnum = 0; *//*no need - global ANSI C */
/* synerrno = 0; *//*no need - global ANSI C */
}
/* Reads the source code buffer and generates a token
* Author: Victor Fernandes
@ -107,7 +107,8 @@ Token malar_next_token(Buffer * sc_buf)
pBuffer err_lex_buf;
if (sc_buf == NULL) {
scerrnum = 1;
synerrno
= 1;
return aa_table[ES]("RUN TIME ERROR: "); /* WHOOPS */
}
@ -279,7 +280,8 @@ Token malar_next_token(Buffer * sc_buf)
t = aa_table[state](b_setmark(lex_buf, 0));
}
else {
scerrnum = 1;
synerrno
= 1;
t = aa_table[ES]("RUN TIME ERROR: ");
return t;
}

View File

@ -2,7 +2,7 @@
* Compiler: msvc (Visual Studio 2015)
* Store and provide functions for the symbol table database
* CST8152, Assignment #3
* Professor: Svillen Ranev
* Professor: S^R
* Author: Victor Fernandes, 040772243
* Version: 0.1
* Date: 24 March 2017
@ -13,7 +13,7 @@
#define PLSBD_INC 64
#define DEBUG
#undef DEBUG*/
#undef DEBUG
/* Forward function declarations */
static void st_setsize(void);

View File

@ -1,8 +1,8 @@
/* Filename: stable.h
* Compiler: msvc (Visual Studio 2015)
* Function declarations for the symbol table
* CST8152, Assignment #3
* Professor: Svillen Ranev
* CST8152, Assignment #3
* Professor: S^R
* Author: Victor Fernandes, 040772243
* Version: 0.1
* Date: 24 March 2017

View File

@ -4,7 +4,7 @@
* Author: Victor Fernandes, 040772243
* Version: 1.17.1
* Date: 30 January 2017
* Provided by: Svillen Ranev
* Provided by: S^R
*/
#ifndef TABLE_H_

View File

@ -4,7 +4,7 @@
* Author: Victor Fernandes, 040772243
* Version: 1.17.1
* Date: 30 January 2017
* Provided by: Svillen Ranev
* Provided by: S^R
* The file is complete and MUST NOT be modified.
*/
#ifndef TOKEN_H_