LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-25-2014, 04:10 PM   #1
des_a
Senior Member
 
Registered: Sep 2006
Posts: 1,441
Blog Entries: 43

Rep: Reputation: 36
Portable Numbers Format: PNFHA


http://forums.techguy.org/software-d...mat-pnfha.html
 
Old 04-25-2014, 05:43 PM   #2
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,269
Blog Entries: 24

Rep: Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206
If you have a question you should post it, not post a link to another forum.

If you are sharing information it would be best to tell us what it is.
 
1 members found this post helpful.
Old 04-25-2014, 10:26 PM   #3
des_a
Senior Member
 
Registered: Sep 2006
Posts: 1,441

Original Poster
Blog Entries: 43

Rep: Reputation: 36
Perhaps I should have included some text with this link. I am trying to create a language, which this one is called PNFHA (Portable Numbers Format High Level Language A). It is not working. It doesn't like the ID or ID = expression after a print or var command. The syntax seems to describe it okay, but it doesn't work in practice. The link is where I origionally posted it, but to get faster responses, I posted it here too. It seems that this site is the one I'm getting responses on for these sets of problems for this language, so that's good, but I wasn't sure where I would get responses. If you'd rather, I could've copied the question into here.
 
Old 04-25-2014, 11:13 PM   #4
des_a
Senior Member
 
Registered: Sep 2006
Posts: 1,441

Original Poster
Blog Entries: 43

Rep: Reputation: 36
I was thinking that enabling debugging for bison when I looked at it might be a good idea. But I am having trouble enabling debugging. Here is my changed file:

Code:
%{
/* Prologue */
#include <deslib/deslib.hpp>
#include <cmath>


int main(int argc, char ** argv);
void yyerror(char const * c);
int yylex();
FILE * output;


class Var
{
 private:
  String itsname;
  double itsvalue;

 public:
  void name(String name);
  String name();

  void value(double value);
  double value();
};

void Var::name(String name)
{
 itsname = name;
}

String Var::name()
{
 return itsname;
}

void Var::value(double value)
{
 itsvalue = value;
}

double Var::value()
{
 return itsvalue;
}


Var varTable[255];
unsigned long varcount = 0;
%}
/* Bison Declarations */
%debug


%error-verbose

%right OPEQUAL
%left OPMINUS OPPLUS
%left OPTIMES OPDIV
%left OPMODULUS
%left NEG
%right OPPOWER

%token LEFTP
%token RIGHTP
%token LEFTB
%token RIGHTB
%token NUMBER
%token SEND
%token COMMA
%token OPEQUAL
%token OPPLUS
%token OPMINUS
%token OPTIMES
%token OPDIV
%token OPMODULUS
%token OPPOWER
%token ID
%token VAR

%token PRINT "print"

%%
/* Grammar Rules */

input:	// Empty
	| input line
	;

line:	'\n'
	| statement
	| error		{ yyerrok; }
	;

statement:	SEND
		| expression_statement
		| declaration_statement
		| command_statement
		| statement_block
		;

expression_statement:	expression SEND
			;

declaration_statement:	declaration SEND
			;

command_statement:	command SEND
			;

statement_block:	LEFTB temp_statement_block RIGHTB
			;

temp_statement_block:	statement
			| statement statement
			;

expression:	exp
		| expression COMMA exp
		;

exp:		number_expression
		| variable_expression
		;


number_expression:	NUMBER						{ $$ = $1; }
			| number_expression OPPLUS number_expression	{ $$ = $1 + $3; }
			| number_expression OPMINUS number_expression	{ $$ = $1 - $3; }
			| number_expression OPTIMES number_expression	{ $$ = $1 * $3; }
			| number_expression OPDIV number_expression	{ $$ = $1 / $3; }
			| number_expression OPMODULUS number_expression	{ $$ = $1 % $3; }
			| OPMINUS number_expression	%prec NEG	{ $$ = -$2; }
			| number_expression OPPOWER number_expression	{ $$ = pow($1, $3); }
			| LEFTP number_expression RIGHTP		{ $$ = $2; }
			;

variable_expression:	ID {
			 bool vfound = false;
			 for (int i = 0; i < varcount; ++i)
			 {
			  if (varTable[i].name().getString().c_str() == yytext)
			  {
			   vfound = true;
			   $$ = varTable[i].value();
			  }
			 }

			 if (vfound == false)
			  yyerrok;
			}
			;

declaration:		variable_declaration
			;

variable_declaration:	VAR ID {
			    $$ = 0;

			
			    bool vfound = false;
			    for (int i = 0; i < varcount; ++i)
                            {
                             if (varTable[i].name().getString().c_str() == yytext)
			     {
                              varTable[i].value($$);
			      vfound = true;
			     }
                            }

			    
			    if (vfound == false)
			    {
			     varTable[varcount].name(yytext);
			     varTable[varcount].value($$);
			     ++varcount;
			    }
			   }
			| VAR ID OPEQUAL expression { 
			   $$ = $4;
			   

			    bool vfound = false;
			    for (int i = 0; i < varcount; ++i)
                            {
                             if (varTable[i].name().getString().c_str() == yytext)
			     {
                              varTable[i].value($$);
			      vfound = true;
			     }
                            }

			    
			    if (vfound == false)
			    {
			     varTable[varcount].name(yytext);
			     varTable[varcount].value($$);
			     ++varcount;
			    }
			  }
			;

command:		print_command
			;

print_command:		PRINT expression { $$ = $2; cout << $$; }
			;
		

%%
/* Additional C/C++ Code */
This compiles fine and all, but when I run it, I don't see an output file and I don't see any additional error messages.
 
Old 04-25-2014, 11:20 PM   #5
des_a
Senior Member
 
Registered: Sep 2006
Posts: 1,441

Original Poster
Blog Entries: 43

Rep: Reputation: 36
Also, the changed file now produces these errors:

Code:
* ERROR: scan error
* ERROR: syntax error, unexpected NUMBER, expecting SEND or COMMA
Because of the comma part.

---------- Post added 04-25-14 at 09:21 PM ----------

Here is my file I'm trying to compile:

Code:
;
32;
33 + 2;
33, 32;
var ;
#var a;
#var b = 2;
#var c = 33 * 3;
(33 * 2);
#var d = (33 + 2) * (33 - 2);
#var d = 3;
{ ; }
{
 ;
 ;
}
a;
print ;
#print 32;
#print a;
 
Old 04-25-2014, 11:32 PM   #6
des_a
Senior Member
 
Registered: Sep 2006
Posts: 1,441

Original Poster
Blog Entries: 43

Rep: Reputation: 36
I would still like to know what I did wrong in the way of enabling debugging, but I did a hack to get it to enable debugging. Here is my hack:
 
Old 04-25-2014, 11:35 PM   #7
des_a
Senior Member
 
Registered: Sep 2006
Posts: 1,441

Original Poster
Blog Entries: 43

Rep: Reputation: 36
It won't let me post the code, so I'll just explain what I did for my hack. I inserted statements to always print to standard error, everywhere it conditionally prints to it. I said the same thing it wanted to say.

Now I get an output of:
Code:
Starting parse
Entering state 0
Entering state 1
Reading a token: Entering state 8
Entering state 14
Entering state 13
Entering state 1
Reading a token: Entering state 7
Entering state 21
Reading a token: Entering state 20
Entering state 19
Entering state 33
Entering state 15
Entering state 14
Entering state 13
Entering state 1
Reading a token: Entering state 7
Entering state 21
Reading a token: Entering state 35
Reading a token: Entering state 7
Entering state 48
Reading a token: Entering state 21
Entering state 20
Entering state 19
Entering state 33
Entering state 15
Entering state 14
Entering state 13
Entering state 1
Reading a token: Entering state 7
Entering state 21
Reading a token: * ERROR: scan error
Entering state 20
Entering state 19
* ERROR: syntax error, unexpected NUMBER, expecting SEND or COMMA
Entering state 3
Entering state 13
Entering state 1
Entering state 7
Entering state 21
Reading a token: Entering state 20
Entering state 19
Entering state 33
Entering state 15
Entering state 14
Entering state 13
Entering state 1
Reading a token: Entering state 9
Entering state 22
Entering state 20
Entering state 19
Reading a token: Entering state 33
Entering state 15
Entering state 14
Entering state 13
Entering state 1
Reading a token: Entering state 5
Reading a token: Entering state 7
Entering state 28
Reading a token: Entering state 38
Reading a token: Entering state 7
Entering state 51
Reading a token: Entering state 28
Entering state 43
Entering state 21
Reading a token: Entering state 20
Entering state 19
Entering state 33
Entering state 15
Entering state 14
Entering state 13
Entering state 1
Reading a token: Entering state 6
Reading a token: Entering state 8
Entering state 29
Reading a token: Entering state 30
Entering state 45
Entering state 18
Entering state 14
Entering state 13
Entering state 1
Reading a token: Entering state 6
Reading a token: Entering state 8
Entering state 29
Reading a token: Entering state 8
Entering state 44
Entering state 30
Reading a token: Entering state 45
Entering state 18
Entering state 14
Entering state 13
Entering state 1
Reading a token: Entering state 9
Entering state 22
Entering state 20
Entering state 19
Reading a token: Entering state 33
Entering state 15
Entering state 14
Entering state 13
Entering state 1
Reading a token: Entering state 9
Entering state 22
Entering state 20
Entering state 19
Reading a token: Entering state 33
Entering state 15
Entering state 14
Entering state 13
Entering state 1
Reading a token: Now at end of input.
Entering state 2
What does this mean the error is? How do I fix it?
 
Old 04-26-2014, 01:18 PM   #8
des_a
Senior Member
 
Registered: Sep 2006
Posts: 1,441

Original Poster
Blog Entries: 43

Rep: Reputation: 36
I found out I enabled debugging fine, and I was calling flex wrong, telling it to output, "phfha.cpp", instead of "pnfha.cpp". This enabled debugging. Now the output is as follows, with an unmodified parser/lexer:

Code:
Entering state 5
Reading a token: Next token is token NUMBER ()
Shifting token NUMBER ()
Entering state 7
Reducing stack by rule 21 (line 130):
   $1 = token NUMBER ()
-> $$ = nterm number_expression ()
Stack now 0 1 5
Entering state 28
Reading a token: Next token is token OPTIMES ()
Shifting token OPTIMES ()
Entering state 38
Reading a token: Next token is token NUMBER ()
Shifting token NUMBER ()
Entering state 7
Reducing stack by rule 21 (line 130):
   $1 = token NUMBER ()
-> $$ = nterm number_expression ()
Stack now 0 1 5 28 38
Entering state 51
Reading a token: Next token is token RIGHTP ()
Reducing stack by rule 24 (line 133):
   $1 = nterm number_expression ()
   $2 = token OPTIMES ()
   $3 = nterm number_expression ()
-> $$ = nterm number_expression ()
Stack now 0 1 5
Entering state 28
Next token is token RIGHTP ()
Shifting token RIGHTP ()
Entering state 43
Reducing stack by rule 29 (line 138):
   $1 = token LEFTP ()
   $2 = nterm number_expression ()
   $3 = token RIGHTP ()
-> $$ = nterm number_expression ()
Stack now 0 1
Entering state 21
Reading a token: Next token is token SEND ()
Reducing stack by rule 19 (line 125):
   $1 = nterm number_expression ()
-> $$ = nterm exp ()
Stack now 0 1
Entering state 20
Reducing stack by rule 17 (line 121):
   $1 = nterm exp ()
-> $$ = nterm expression ()
Stack now 0 1
Entering state 19
Next token is token SEND ()
Shifting token SEND ()
Entering state 33
Reducing stack by rule 11 (line 105):
   $1 = nterm expression ()
   $2 = token SEND ()
-> $$ = nterm expression_statement ()
Stack now 0 1
Entering state 15
Reducing stack by rule 7 (line 99):
   $1 = nterm expression_statement ()
-> $$ = nterm statement ()
Stack now 0 1
Entering state 14
Reducing stack by rule 4 (line 94):
   $1 = nterm statement ()
-> $$ = nterm line ()
Stack now 0 1
Entering state 13
Reducing stack by rule 2 (line 90):
   $1 = nterm input ()
   $2 = nterm line ()
-> $$ = nterm input ()
Stack now 0
Entering state 1
Reading a token: Next token is token LEFTB ()
Shifting token LEFTB ()
Entering state 6
Reading a token: Next token is token SEND ()
Shifting token SEND ()
Entering state 8
Reducing stack by rule 6 (line 98):
   $1 = token SEND ()
-> $$ = nterm statement ()
Stack now 0 1 6
Entering state 29
Reading a token: Next token is token RIGHTB ()
Reducing stack by rule 15 (line 117):
   $1 = nterm statement ()
-> $$ = nterm temp_statement_block ()
Stack now 0 1 6
Entering state 30
Next token is token RIGHTB ()
Shifting token RIGHTB ()
Entering state 45
Reducing stack by rule 14 (line 114):
   $1 = token LEFTB ()
   $2 = nterm temp_statement_block ()
   $3 = token RIGHTB ()
-> $$ = nterm statement_block ()
Stack now 0 1
Entering state 18
Reducing stack by rule 10 (line 102):
   $1 = nterm statement_block ()
-> $$ = nterm statement ()
Stack now 0 1
Entering state 14
Reducing stack by rule 4 (line 94):
   $1 = nterm statement ()
-> $$ = nterm line ()
Stack now 0 1
Entering state 13
Reducing stack by rule 2 (line 90):
   $1 = nterm input ()
   $2 = nterm line ()
-> $$ = nterm input ()
Stack now 0
Entering state 1
Reading a token: Next token is token LEFTB ()
Shifting token LEFTB ()
Entering state 6
Reading a token: Next token is token SEND ()
Shifting token SEND ()
Entering state 8
Reducing stack by rule 6 (line 98):
   $1 = token SEND ()
-> $$ = nterm statement ()
Stack now 0 1 6
Entering state 29
Reading a token: Next token is token SEND ()
Shifting token SEND ()
Entering state 8
Reducing stack by rule 6 (line 98):
   $1 = token SEND ()
-> $$ = nterm statement ()
Stack now 0 1 6 29
Entering state 44
Reducing stack by rule 16 (line 118):
   $1 = nterm statement ()
   $2 = nterm statement ()
-> $$ = nterm temp_statement_block ()
Stack now 0 1 6
Entering state 30
Reading a token: Next token is token RIGHTB ()
Shifting token RIGHTB ()
Entering state 45
Reducing stack by rule 14 (line 114):
   $1 = token LEFTB ()
   $2 = nterm temp_statement_block ()
   $3 = token RIGHTB ()
-> $$ = nterm statement_block ()
Stack now 0 1
Entering state 18
Reducing stack by rule 10 (line 102):
   $1 = nterm statement_block ()
-> $$ = nterm statement ()
Stack now 0 1
Entering state 14
Reducing stack by rule 4 (line 94):
   $1 = nterm statement ()
-> $$ = nterm line ()
Stack now 0 1
Entering state 13
Reducing stack by rule 2 (line 90):
   $1 = nterm input ()
   $2 = nterm line ()
-> $$ = nterm input ()
Stack now 0
Entering state 1
Reading a token: Next token is token ID ()
Shifting token ID ()
Entering state 9
Reducing stack by rule 30 (line 141):
   $1 = token ID ()
-> $$ = nterm variable_expression ()
Stack now 0 1
Entering state 22
Reducing stack by rule 20 (line 126):
   $1 = nterm variable_expression ()
-> $$ = nterm exp ()
Stack now 0 1
Entering state 20
Reducing stack by rule 17 (line 121):
   $1 = nterm exp ()
-> $$ = nterm expression ()
Stack now 0 1
Entering state 19
Reading a token: Next token is token SEND ()
Shifting token SEND ()
Entering state 33
Reducing stack by rule 11 (line 105):
   $1 = nterm expression ()
   $2 = token SEND ()
-> $$ = nterm expression_statement ()
Stack now 0 1
Entering state 15
Reducing stack by rule 7 (line 99):
   $1 = nterm expression_statement ()
-> $$ = nterm statement ()
Stack now 0 1
Entering state 14
Reducing stack by rule 4 (line 94):
   $1 = nterm statement ()
-> $$ = nterm line ()
Stack now 0 1
Entering state 13
Reducing stack by rule 2 (line 90):
   $1 = nterm input ()
   $2 = nterm line ()
-> $$ = nterm input ()
Stack now 0
Entering state 1
Reading a token: Next token is token ID ()
Shifting token ID ()
Entering state 9
Reducing stack by rule 30 (line 141):
   $1 = token ID ()
-> $$ = nterm variable_expression ()
Stack now 0 1
Entering state 22
Reducing stack by rule 20 (line 126):
   $1 = nterm variable_expression ()
-> $$ = nterm exp ()
Stack now 0 1
Entering state 20
Reducing stack by rule 17 (line 121):
   $1 = nterm exp ()
-> $$ = nterm expression ()
Stack now 0 1
Entering state 19
Reading a token: * ERROR: scan error
* ERROR: scan error
Next token is token ID ()
* ERROR: syntax error, unexpected ID, expecting SEND or COMMA
Error: popping nterm expression ()
Stack now 0 1
Shifting token error ()
Entering state 3
Reducing stack by rule 5 (line 95):
   $1 = token error ()
-> $$ = nterm line ()
Stack now 0 1
Entering state 13
Reducing stack by rule 2 (line 90):
   $1 = nterm input ()
   $2 = nterm line ()
-> $$ = nterm input ()
Stack now 0
Entering state 1
Next token is token ID ()
Shifting token ID ()
Entering state 9
Reducing stack by rule 30 (line 141):
   $1 = token ID ()
-> $$ = nterm variable_expression ()
Stack now 0 1
Entering state 22
Reducing stack by rule 20 (line 126):
   $1 = nterm variable_expression ()
-> $$ = nterm exp ()
Stack now 0 1
Entering state 20
Reducing stack by rule 17 (line 121):
   $1 = nterm exp ()
-> $$ = nterm expression ()
Stack now 0 1
Entering state 19
Reading a token: * ERROR: scan error
Next token is token SEND ()
Shifting token SEND ()
Entering state 33
Reducing stack by rule 11 (line 105):
   $1 = nterm expression ()
   $2 = token SEND ()
-> $$ = nterm expression_statement ()
Stack now 0 1
Entering state 15
Reducing stack by rule 7 (line 99):
   $1 = nterm expression_statement ()
-> $$ = nterm statement ()
Stack now 0 1
Entering state 14
Reducing stack by rule 4 (line 94):
   $1 = nterm statement ()
-> $$ = nterm line ()
Stack now 0 1
Entering state 13
Reducing stack by rule 2 (line 90):
   $1 = nterm input ()
   $2 = nterm line ()
-> $$ = nterm input ()
Stack now 0
Entering state 1
Reading a token: Now at end of input.
Shifting token $end ()
Entering state 2
Stack now 0 1 2
Cleanup: popping token $end ()
Cleanup: popping nterm input ()
This is at least a lot clearer. Lets see if I can tell what it means...
 
Old 04-26-2014, 09:34 PM   #9
des_a
Senior Member
 
Registered: Sep 2006
Posts: 1,441

Original Poster
Blog Entries: 43

Rep: Reputation: 36
I've got no idea what it means.
 
Old 04-26-2014, 11:27 PM   #10
des_a
Senior Member
 
Registered: Sep 2006
Posts: 1,441

Original Poster
Blog Entries: 43

Rep: Reputation: 36
Okay, I've been working on it and got further. Here is my new code:

bison:
Code:
%{
/* Prologue */
#include <deslib/deslib.hpp>
#include <cmath>


#define YYDEBUG 1


int main(int argc, char ** argv);
void yyerror(char const * c);
int yylex();
FILE * output;


class Var
{
 private:
  String itsname;
  double itsvalue;

 public:
  void name(String name);
  String name();

  void value(double value);
  double value();
};

void Var::name(String name)
{
 itsname = name;
}

String Var::name()
{
 return itsname;
}

void Var::value(double value)
{
 itsvalue = value;
}

double Var::value()
{
 return itsvalue;
}
%}
/* Bison Declarations */
%debug


%error-verbose

%right OPEQUAL
%left OPMINUS OPPLUS
%left OPTIMES OPDIV
%left OPMODULUS
%left NEG
%right OPPOWER

%token LEFTP
%token RIGHTP
%token LEFTB
%token RIGHTB
%token NUMBER
%token SEND
%token COMMA
%token OPEQUAL
%token OPPLUS
%token OPMINUS
%token OPTIMES
%token OPDIV
%token OPMODULUS
%token OPPOWER
%token ID
%token VAR

%token PRINT "print"

%%
/* Grammar Rules */

input:	// Empty
	| input line
	;

line:	"\n"
	| statement
	| error		{ yyerrok; }
	;

statement:	SEND
		| expression_statement
		| declaration_statement
		| command_statement
		| statement_block
		;

expression_statement:	expression SEND
			;

declaration_statement:	declaration SEND
			;

command_statement:	command SEND
			;

statement_block:	LEFTB statements RIGHTB
			;

statements:		statement
			| statement statement
			;

expression:	exp
		| expression COMMA exp
		;

exp:		number_expression
		| ID
		;


number_expression:	NUMBER						{ $$ = $1; }
			| number_expression OPPLUS number_expression	{ $$ = $1 + $3; }
			| number_expression OPMINUS number_expression	{ $$ = $1 - $3; }
			| number_expression OPTIMES number_expression	{ $$ = $1 * $3; }
			| number_expression OPDIV number_expression	{ $$ = $1 / $3; }
			| number_expression OPMODULUS number_expression	{ $$ = $1 % $3; }
			| OPMINUS number_expression	%prec NEG	{ $$ = -$2; }
			| number_expression OPPOWER number_expression	{ $$ = pow($1, $3); }
			| LEFTP number_expression RIGHTP		{ $$ = $2; }
			;

declaration:		variable_declaration SEND
			;

variable_declaration:	VAR ID 
			| VAR ID OPEQUAL expression 
			;

command:		print_command
			;

print_command:		PRINT expression { $$ = $2; cout << $$; }
			;
		

%%
/* Additional C/C++ Code */
flex:
Code:
%option yylineno


%{
/* Prologue */
#include "pnfha.tab.cpp"
%}
/* Flex Definitions */

DIGIT		[0-9]

NUMBER		{DIGIT}+|{DIGIT}+"."{DIGIT}*

TCHARACTER	.

COMMENT		#{TCHARACTER}*

SEND		";"

COMMA		","

OPPLUS		"+"

OPMINUS		"-"

OPTIMES		"*"

OPDIV		"/"

OPMODULUS	"%"

OPPOWER		"^"

OPEQUAL		"="

LEFTP		"("

RIGHTP		")"

LEFTB		"{"

RIGHTB		"}"

VAR		"var"

ID		[[:alnum:]]*


/* Flex Patterns Below %% */
%%

{NUMBER}		yylval = atof(yytext); return NUMBER;

{SEND}			yylval = 1; return SEND;

{COMMA}			yylval = 1; return COMMA;

{LEFTP}			yylval = 0; return LEFTP;

{RIGHTP}		yylval = 0; return RIGHTP;

{OPEQUAL}		yylval = 0; return OPEQUAL;

{OPPLUS}		yylval = 0; return OPPLUS;

{OPMINUS}		yylval = 0; return OPMINUS;

{OPTIMES}		yylval = 0; return OPTIMES;

{OPDIV}			yylval = 0; return OPDIV;

{OPMODULUS}		yylval = 0; return OPMODULUS;

{OPPOWER}		yylval = 0; return OPPOWER;

{VAR}			yylval = 0; return VAR;

{ID}			yylval = 0; return ID;

{LEFTB}			yylval = 0; return LEFTB;

{RIGHTB}		yylval = 0; return RIGHTB;

[\n\t ]+		/* Eat up Whitespace */

{COMMENT}		/* Eat up comment */

.			{
			 String str = "Scan error: ";
			 str += yytext;
			 yyerror(str.getString().c_str());

			 yylval = 0;
			}

%%
/* Additional Code */
int main(int argc, char ** argv)
{
 yydebug = 0;



 if (argc == 3)
 {
  FILE * input = fopen(argv[1], "r");
  if (!input)
  {
   yyerror("can't open file");
   return -1;
  }
  yyin = input;
  output = fopen(argv[2], "w");
  if (!output)
  {
   yyerror("can't open file for write");
   return -1;
  }
  fprintf(output, "VERSION TVOID 0V\n\n\n");

  
  int ret = yyparse();


  fprintf(output, "\nEND TVOID 0V");
  return ret;
 }
 else
  yyerror("can't find input file or output file.");
}

void yyerror(char const * c)
{
 cout << "* ERROR: " << yylineno << ": " << c << endl;
}
And here is the file I'm trying to compile:
Code:
;
32;
33 + 2;
33, 32;
a;
var a;
a;
#var b = 2;
#var c = 33 * 3;
#(33 * 2);
#var d = (33 + 2) * (33 - 2);
#var d = 3;
#{ ; }
#{
# ;
# ;
#}
#print ;
#print 32;
#print a;
;
The, "a", before it's declared is actually an error, but I haven't gotten that far yet. After it's been declared however, it cannot be used or it generates an error, "* ERROR: 7: syntax error, unexpected ID, expecting SEND". How do I fix this?
 
Old 05-15-2014, 04:13 PM   #11
des_a
Senior Member
 
Registered: Sep 2006
Posts: 1,441

Original Poster
Blog Entries: 43

Rep: Reputation: 36
I've gotten a little further. See the link for details.

---------- Post added 05-15-14 at 02:13 PM ----------

Perhaps next time, if I want to post to 2 forums, I shall copy & paste.
 
Old 05-17-2014, 11:37 AM   #12
ndc85430
Member
 
Registered: Apr 2014
Distribution: Slackware
Posts: 92

Rep: Reputation: Disabled
I'll repeat what I posted in your other thread: you're posting far too much code. You have to go through it yourself to work out what the problem is and then post just enough to reproduce it. I doubt anyone will read through such a large amount of code, attempt to understand it and debug it for you.
 
Old 07-18-2014, 10:47 PM   #13
des_a
Senior Member
 
Registered: Sep 2006
Posts: 1,441

Original Poster
Blog Entries: 43

Rep: Reputation: 36
I've gotten further. To see my current progress, please look at: http://www.linuxquestions.org/questi...43#post5206243. I posted another thread because this one was getting too old and too complicated to go on, so I'm marking this one solved, but am on this next step. There has been too many changes to continue with this thread...
 
Old 07-18-2014, 10:49 PM   #14
des_a
Senior Member
 
Registered: Sep 2006
Posts: 1,441

Original Poster
Blog Entries: 43

Rep: Reputation: 36
P.S. - The only reason I posted one last time, was to show the link to a more updated thread...
 
Old 07-18-2014, 10:51 PM   #15
des_a
Senior Member
 
Registered: Sep 2006
Posts: 1,441

Original Poster
Blog Entries: 43

Rep: Reputation: 36
Also, the threads on the other forum were expired...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Format numbers using bash? KClaisse Programming 21 03-30-2015 06:47 AM
[SOLVED] Portable Numbers Format: PRINT Before CRASH Doesn't Work des_a Programming 9 04-27-2014 02:40 AM
Which video format is most portable? ciden Linux - Software 1 02-02-2010 11:51 AM
question: portable char* format specifier for wprintf() ??? maxreason Programming 1 01-20-2009 07:14 PM
LXer: The Inevitability of the Universal, Portable Document Format LXer Syndicated Linux News 0 08-26-2006 09:54 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:03 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration