New "Project" for Scanner
This commit is contained in:
parent
73adc465b4
commit
0b5fb5befa
10
buffer.c
10
buffer.c
|
@ -177,7 +177,7 @@ size_t b_incfactor(Buffer* const pBD) {
|
||||||
*/
|
*/
|
||||||
short b_mark(Buffer* const pBD) {
|
short b_mark(Buffer* const pBD) {
|
||||||
if (!pBD) { return R_FAIL1; }
|
if (!pBD) { return R_FAIL1; }
|
||||||
return pBD->mark_coffset;
|
return pBD->mark_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reports if the character buffer's memory space was relocated after resizing
|
/* Reports if the character buffer's memory space was relocated after resizing
|
||||||
|
@ -431,7 +431,7 @@ int b_reset(Buffer* const pBD) {
|
||||||
|
|
||||||
pBD->addc_offset = OFFSET_RESET;
|
pBD->addc_offset = OFFSET_RESET;
|
||||||
pBD->getc_offset = OFFSET_RESET;
|
pBD->getc_offset = OFFSET_RESET;
|
||||||
pBD->mark_coffset = OFFSET_RESET;
|
pBD->mark_offset = OFFSET_RESET;
|
||||||
pBD->eob = UNSET_EOB_FLAG;
|
pBD->eob = UNSET_EOB_FLAG;
|
||||||
pBD->r_flag = UNSET_R_FLAG;
|
pBD->r_flag = UNSET_R_FLAG;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -448,11 +448,11 @@ int b_reset(Buffer* const pBD) {
|
||||||
short b_retract_to_mark(Buffer* const pBD) {
|
short b_retract_to_mark(Buffer* const pBD) {
|
||||||
/* Check if any offsets are out of bounds */
|
/* Check if any offsets are out of bounds */
|
||||||
if(!pBD ||
|
if(!pBD ||
|
||||||
pBD->mark_coffset < OFFSET_RESET ||
|
pBD->mark_offset < OFFSET_RESET ||
|
||||||
pBD->mark_coffset > pBD->capacity){
|
pBD->mark_offset > pBD->capacity){
|
||||||
return R_FAIL1;
|
return R_FAIL1;
|
||||||
}
|
}
|
||||||
pBD->getc_offset = pBD->mark_coffset;
|
pBD->getc_offset = pBD->mark_offset;
|
||||||
return pBD->getc_offset;
|
return pBD->getc_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@ VisualStudioVersion = 14.0.25420.1
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "buffer", "buffer\buffer.vcxproj", "{034E0E4B-DAFA-45D4-882B-1815AC73DA9E}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "buffer", "buffer\buffer.vcxproj", "{034E0E4B-DAFA-45D4-882B-1815AC73DA9E}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "scanner", "scanner\scanner.vcxproj", "{C53261F2-8A2D-4F75-8E54-DBFD16A621BB}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|x64 = Debug|x64
|
Debug|x64 = Debug|x64
|
||||||
|
@ -21,6 +23,14 @@ Global
|
||||||
{034E0E4B-DAFA-45D4-882B-1815AC73DA9E}.Release|x64.Build.0 = Release|x64
|
{034E0E4B-DAFA-45D4-882B-1815AC73DA9E}.Release|x64.Build.0 = Release|x64
|
||||||
{034E0E4B-DAFA-45D4-882B-1815AC73DA9E}.Release|x86.ActiveCfg = Release|Win32
|
{034E0E4B-DAFA-45D4-882B-1815AC73DA9E}.Release|x86.ActiveCfg = Release|Win32
|
||||||
{034E0E4B-DAFA-45D4-882B-1815AC73DA9E}.Release|x86.Build.0 = Release|Win32
|
{034E0E4B-DAFA-45D4-882B-1815AC73DA9E}.Release|x86.Build.0 = Release|Win32
|
||||||
|
{C53261F2-8A2D-4F75-8E54-DBFD16A621BB}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{C53261F2-8A2D-4F75-8E54-DBFD16A621BB}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{C53261F2-8A2D-4F75-8E54-DBFD16A621BB}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{C53261F2-8A2D-4F75-8E54-DBFD16A621BB}.Debug|x86.Build.0 = Debug|Win32
|
||||||
|
{C53261F2-8A2D-4F75-8E54-DBFD16A621BB}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{C53261F2-8A2D-4F75-8E54-DBFD16A621BB}.Release|x64.Build.0 = Release|x64
|
||||||
|
{C53261F2-8A2D-4F75-8E54-DBFD16A621BB}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{C53261F2-8A2D-4F75-8E54-DBFD16A621BB}.Release|x86.Build.0 = Release|Win32
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
11
scanner.c
11
scanner.c
|
@ -116,13 +116,14 @@ which is being processed by the scanner.
|
||||||
case '/': t.code = ART_OP_T; t.attribute.arr_op = DIV; return t; /* Devision operator */
|
case '/': t.code = ART_OP_T; t.attribute.arr_op = DIV; return t; /* Devision operator */
|
||||||
case '>': t.code = REL_OP_T; t.attribute.rel_op = GT; return t; /* Greater-than relational operator */
|
case '>': t.code = REL_OP_T; t.attribute.rel_op = GT; return t; /* Greater-than relational operator */
|
||||||
case '<':
|
case '<':
|
||||||
|
/* MSVC will complain about this assignment inside a conditional expression*/
|
||||||
if (c = b_getc(sc_buf) == '>') {
|
if (c = b_getc(sc_buf) == '>') {
|
||||||
t.code = REL_OP_T;
|
t.code = REL_OP_T;
|
||||||
t.attribute.rel_op = NE; /* Negation operator */
|
t.attribute.rel_op = NE; /* Negation operator */
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
else if (c == '<') {
|
else if (c == '<') {
|
||||||
t.code == SCC_OP_T; /* String concatenation operator */
|
t.code = SCC_OP_T; /* String concatenation operator */
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
t.code = REL_OP_T;
|
t.code = REL_OP_T;
|
||||||
|
@ -441,6 +442,7 @@ Token aa_func02(char lexeme[]) {
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* Floating point*/
|
/* Floating point*/
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return t;
|
return t;
|
||||||
|
@ -466,15 +468,13 @@ REPLACE XX WITH THE CORRESPONDING ACCEPTING STATE NUMBER
|
||||||
*/
|
*/
|
||||||
Token aa_func03(char lexeme[]) {
|
Token aa_func03(char lexeme[]) {
|
||||||
Token t;
|
Token t;
|
||||||
int offset;
|
|
||||||
int i;
|
|
||||||
char* temp_str;
|
char* temp_str;
|
||||||
if ((temp_str = (char*)calloc(VID_LEN + 2, sizeof(char))) == NULL) {
|
if ((temp_str = (char*)calloc(VID_LEN + 2, sizeof(char))) == NULL) {
|
||||||
return aa_table[ES]("RUN TIME ERROR");
|
return aa_table[ES]("RUN TIME ERROR");
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(temp_str, lexeme, VID_LEN);
|
strncpy(temp_str, lexeme, VID_LEN);
|
||||||
temp_str[strlen(temp_str)] = "#"; /* Append # to end of the SVID */
|
temp_str[strlen(temp_str)] = '#'; /* Add# to end of the SVID */
|
||||||
|
|
||||||
strncpy(t.attribute.vid_lex, temp_str, VID_LEN);
|
strncpy(t.attribute.vid_lex, temp_str, VID_LEN);
|
||||||
free(temp_str);
|
free(temp_str);
|
||||||
|
@ -491,7 +491,6 @@ Token aa_func03(char lexeme[]) {
|
||||||
AND THEN THE # CHARACTER IS APPENDED TO THE NAME.
|
AND THEN THE # CHARACTER IS APPENDED TO THE NAME.
|
||||||
ADD \0 AT THE END TO MAKE A C-type STRING.
|
ADD \0 AT THE END TO MAKE A C-type STRING.
|
||||||
*/
|
*/
|
||||||
return t;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*ACCEPTING FUNCTION FOR THE integer literal(IL)-decimal constant(DIL)*/
|
/*ACCEPTING FUNCTION FOR THE integer literal(IL)-decimal constant(DIL)*/
|
||||||
|
|
Loading…
Reference in New Issue