Jump to content
  • Advertisement
Sign in to follow this  
Zotoaster

MSVC++ Express problems

This topic is 4043 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I just compiled my project, and for some reason, out of the blue, nothing works. It can't seem to find any functions that I've made, it doesn't recognise objects, even of very common classes like vector, it gives me errors when I create constructors, when I include things, all that stuff. Hasnt happened until now. I dont now what the problem is. Here is the error list:
Compiling...
JemScript Library.cpp
.\JemScript Library.cpp(10) : error C2143: syntax error : missing ';' before 'using'
c:\documents and settings\zotoaster\my documents\visual studio 2005\projects\jemscript library\jemscript library\JCompiler.h(54) : error C2059: syntax error : 'inline function header'
c:\documents and settings\zotoaster\my documents\visual studio 2005\projects\jemscript library\jemscript library\JCompiler.h(54) : error C2143: syntax error : missing ';' before '{'
c:\documents and settings\zotoaster\my documents\visual studio 2005\projects\jemscript library\jemscript library\JCompiler.h(54) : error C2447: '{' : missing function header (old-style formal list?)
c:\documents and settings\zotoaster\my documents\visual studio 2005\projects\jemscript library\jemscript library\JCompiler.h(323) : error C3861: '_opName': identifier not found
c:\documents and settings\zotoaster\my documents\visual studio 2005\projects\jemscript library\jemscript library\JCompiler.h(324) : error C3861: '_printData': identifier not found
c:\documents and settings\zotoaster\my documents\visual studio 2005\projects\jemscript library\jemscript library\JCompiler.h(387) : error C3861: '_isFloat': identifier not found
c:\documents and settings\zotoaster\my documents\visual studio 2005\projects\jemscript library\jemscript library\JCompiler.h(427) : error C3861: '_callFunc': identifier not found
c:\documents and settings\zotoaster\my documents\visual studio 2005\projects\jemscript library\jemscript library\JCompiler.h(431) : error C2664: 'void jemscript::JObjectCode::add(jemscript::JOpcode)' : cannot convert parameter 1 from 'jemscript::JData' to 'jemscript::JOpcode'
        No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
c:\documents and settings\zotoaster\my documents\visual studio 2005\projects\jemscript library\jemscript library\JCompiler.h(439) : error C3861: '_isOpT': identifier not found
c:\documents and settings\zotoaster\my documents\visual studio 2005\projects\jemscript library\jemscript library\JCompiler.h(447) : error C3861: '_isOpO': identifier not found
c:\documents and settings\zotoaster\my documents\visual studio 2005\projects\jemscript library\jemscript library\JCompiler.h(502) : error C3861: '_callFunc': identifier not found
c:\documents and settings\zotoaster\my documents\visual studio 2005\projects\jemscript library\jemscript library\JCompiler.h(517) : error C3861: '_callFunc': identifier not found
c:\documents and settings\zotoaster\my documents\visual studio 2005\projects\jemscript library\jemscript library\JCompiler.h(531) : error C3861: '_callFunc': identifier not found
c:\documents and settings\zotoaster\my documents\visual studio 2005\projects\jemscript library\jemscript library\JCompiler.h(545) : error C2601: '_isFloat' : local function definitions are illegal
c:\documents and settings\zotoaster\my documents\visual studio 2005\projects\jemscript library\jemscript library\JCompiler.h(560) : error C2601: '_isOpO' : local function definitions are illegal
c:\documents and settings\zotoaster\my documents\visual studio 2005\projects\jemscript library\jemscript library\JCompiler.h(574) : error C2601: '_isOpT' : local function definitions are illegal
c:\documents and settings\zotoaster\my documents\visual studio 2005\projects\jemscript library\jemscript library\JCompiler.h(588) : error C2601: '_callFunc' : local function definitions are illegal
c:\documents and settings\zotoaster\my documents\visual studio 2005\projects\jemscript library\jemscript library\JCompiler.h(607) : error C2601: '_isBuiltInFunc' : local function definitions are illegal
c:\documents and settings\zotoaster\my documents\visual studio 2005\projects\jemscript library\jemscript library\JCompiler.h(617) : error C2601: '_builtInFunc' : local function definitions are illegal
c:\documents and settings\zotoaster\my documents\visual studio 2005\projects\jemscript library\jemscript library\JCompiler.h(627) : error C2601: '_printData' : local function definitions are illegal
c:\documents and settings\zotoaster\my documents\visual studio 2005\projects\jemscript library\jemscript library\JCompiler.h(658) : error C2601: '_opName' : local function definitions are illegal
c:\documents and settings\zotoaster\my documents\visual studio 2005\projects\jemscript library\jemscript library\JCompiler.h(561) : error C2082: redefinition of formal parameter 'op'
c:\documents and settings\zotoaster\my documents\visual studio 2005\projects\jemscript library\jemscript library\JCompiler.h(567) : error C2440: '=' : cannot convert from 'bool' to 'jemscript::JOpcode'
        Conversion to enumeration type requires an explicit cast (static_cast, C-style cast or function-style cast)
c:\documents and settings\zotoaster\my documents\visual studio 2005\projects\jemscript library\jemscript library\JCompiler.h(590) : error C3861: '_isBuiltInFunc': identifier not found
c:\documents and settings\zotoaster\my documents\visual studio 2005\projects\jemscript library\jemscript library\JCompiler.h(592) : error C2065: '_oc' : undeclared identifier
c:\documents and settings\zotoaster\my documents\visual studio 2005\projects\jemscript library\jemscript library\JCompiler.h(592) : error C2228: left of '.add' must have class/struct/union
        type is ''unknown-type''
c:\documents and settings\zotoaster\my documents\visual studio 2005\projects\jemscript library\jemscript library\JCompiler.h(592) : error C3861: '_findFunc': identifier not found
c:\documents and settings\zotoaster\my documents\visual studio 2005\projects\jemscript library\jemscript library\JCompiler.h(598) : error C2065: '_bfunc' : undeclared identifier
c:\documents and settings\zotoaster\my documents\visual studio 2005\projects\jemscript library\jemscript library\JCompiler.h(598) : error C2228: left of '.at' must have class/struct/union
        type is ''unknown-type''
c:\documents and settings\zotoaster\my documents\visual studio 2005\projects\jemscript library\jemscript library\JCompiler.h(598) : error C3861: '_builtInFunc': identifier not found
c:\documents and settings\zotoaster\my documents\visual studio 2005\projects\jemscript library\jemscript library\JCompiler.h(598) : error C2228: left of '.add' must have class/struct/union
        type is ''unknown-type''
c:\documents and settings\zotoaster\my documents\visual studio 2005\projects\jemscript library\jemscript library\JCompiler.h(599) : error C2228: left of '.at' must have class/struct/union
        type is ''unknown-type''
c:\documents and settings\zotoaster\my documents\visual studio 2005\projects\jemscript library\jemscript library\JCompiler.h(599) : error C3861: '_builtInFunc': identifier not found
c:\documents and settings\zotoaster\my documents\visual studio 2005\projects\jemscript library\jemscript library\JCompiler.h(599) : error C2228: left of '.add' must have class/struct/union
        type is ''unknown-type''
c:\documents and settings\zotoaster\my documents\visual studio 2005\projects\jemscript library\jemscript library\JCompiler.h(600) : error C2228: left of '.at' must have class/struct/union
        type is ''unknown-type''
c:\documents and settings\zotoaster\my documents\visual studio 2005\projects\jemscript library\jemscript library\JCompiler.h(600) : error C3861: '_builtInFunc': identifier not found
c:\documents and settings\zotoaster\my documents\visual studio 2005\projects\jemscript library\jemscript library\JCompiler.h(600) : error C2228: left of '.add' must have class/struct/union
        type is ''unknown-type''
c:\documents and settings\zotoaster\my documents\visual studio 2005\projects\jemscript library\jemscript library\JCompiler.h(608) : error C2228: left of '.size' must have class/struct/union
        type is ''unknown-type''
c:\documents and settings\zotoaster\my documents\visual studio 2005\projects\jemscript library\jemscript library\JCompiler.h(610) : error C2228: left of '.at' must have class/struct/union
        type is ''unknown-type''
c:\documents and settings\zotoaster\my documents\visual studio 2005\projects\jemscript library\jemscript library\JCompiler.h(618) : error C2228: left of '.size' must have class/struct/union
        type is ''unknown-type''
c:\documents and settings\zotoaster\my documents\visual studio 2005\projects\jemscript library\jemscript library\JCompiler.h(620) : error C2228: left of '.at' must have class/struct/union
        type is ''unknown-type''
.\JemScript Library.cpp(10) : error C2059: syntax error : ';'
.\JemScript Library.cpp(64) : fatal error C1075: end of file found before the left brace '{' at 'c:\documents and settings\zotoaster\my documents\visual studio 2005\projects\jemscript library\jemscript library\JCompiler.h(10)' was matched

So what on Earth is going on here?! I tried starting a new project and copying all the source files over, but to no avail. I tried making a new project with a simple vector, and it worked fine! I don't want to have to start this project again guys, so is there anything you can recommend? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Looks like either you are declaring a function within a function or have forgotten a semicolon at the end of your class definition. It will be hard to help you until you post some code.

Share this post


Link to post
Share on other sites
Well, since I've got nothing to lose, might aswell..

All the errors seem to be across JemScript Library.cpp and JCompiler.h,
so, here it the source for those two:

JemScript Library.cpp:

#include <iostream>
using namespace std;

#include "JFile.h"
#include "JLexer.h"
#include "JSyntaxErrors.h"
#include "JData.h"
#include "JVirtualMachine.h"
#include "JCompiler.h"
using namespace jemscript;


//Main
int main()
{

//Source
JFile fl;
fl.set("test.jem");
fl.read();
string src = fl.get();
//cout << src << endl;

//Lexer
JLexer lex;
lex = src;

//Error checking
JSyntax err;
err.set(lex);
err.scan();
err.showErrors();

//Proceed with no errors
if (err.get().size() == 0)
{

//Compiler
JCompiler comp;
comp.set(lex);
comp.call("main");
comp.compile();
comp.show();

//Virtual Machine
JVirtualMachine vm;
vm.set(comp.get());
vm.call("main");
vm.execute();

}

//Pause
system("PAUSE");

}


/*
Notes:


*/





JCompiler.h:

#pragma once

#include "JData.h"
#include "JVirtualMachine.h"
#include "JLexer.h"
#include <string>
#include <vector>

//Jemscript
namespace jemscript
{


//Var creation
struct JAddVar
{
JAddVar()
{
}
JAddVar(string Name, size_t Add)
{
name = Name;
add = Add;
}
string name;
size_t add;
};

//Function list
struct JFList
{
JFList() : start(0), end(0)
{
}

JFList(string Name, size_t Start, size_t End)
{
name = Name;
start = Start;
end = End;
}

string name;
size_t start;
size_t end;
};


//Compiler
class JCompiler
{

public:

JCompiler()
{

//Add built in functions
_bfunc.push_back("int");
_bfunc.push_back("float");
_bfunc.push_back("string");

}

//Call function
void call(string call)
{
_funcCall = call;
}

//Set token stream
void set(JLexer Tokens)
{
_tok = Tokens;
}


//Compile
void compile()
{

//Current tokens
token prev, cur, next;

//Depths
size_t bdepth(0);
size_t depth(0);

//If statement data
size_t ifD1(0);
size_t ifD2(0);

//Loop through tokens
for (size_t t=0; t<_tok.count(); t++)
{

//Set current tokens
cur = _tok.get(t);
if (t > 0) prev = _tok.get(t - 1);
if (t < _tok.count() - 1) next = _tok.get(t + 1);

//Code symbols
//------------------------------------------------------------

//Create braces
if (cur.type == BRACE_O)
{

//Add opcode and inc depth
_oc.add(LB);
depth++;

}
if (cur.type == BRACE_C)
{

//Add opcode and dec depth
_oc.add(RB);
depth--;
}

//Brackets
if (cur.type == BRACKET_O) bdepth++;
if (cur.type == BRACKET_C) bdepth--;

//Assign
if (cur.type == EQ_SET)
{

//Convert data to RPN
_infixRPN(t + 1, _tok.findNext(t, ENDST));

//Write variable
_oc.add(Write, prev.tok);
}

//------------------------------------------------------------


//Variables
//------------------------------------------------------------

//Find variables
if (cur.tok == "var")
{

//If in brackets
if (bdepth > 0)
{

//Add to list
_vAdd.push_back(JAddVar(next.tok, _tok.findNext(t, BRACE_O)));

}
else
{

//Add variable
_oc.add(Var, next.tok);
}

}

//Skim through list
for (size_t s=0; s<_vAdd.size(); s++)
{
//If corrent location, add as parameter
if (_vAdd.at(s).add == t)
{
_oc.add(Var, _vAdd.at(s).name);
_oc.add(Par);

//Remove from list and break
//_vAdd.erase( _vAdd.get_allocator() + (int)s );
//_vAdd.pop_back();
//break;
}
}

//------------------------------------------------------------


//Control structures
//------------------------------------------------------------

//If statements
if (cur.tok == "if")
{

//Convert data
_infixRPN(t+2, _tok.findNext(t, BRACE_O)-1);

//Record positions
ifD1 = t+2;
ifD2 = _tok.findNext(t, BRACE_O)-1;

//Add opcode
_oc.add(If);
}

//Else
if (cur.tok == "else")
{

//Convert data
_infixRPN(ifD1, ifD2);

//Add opcode
_oc.add(Else);
}

//Do loops
if (cur.tok == "do")
{
_oc.add(Do);
}

//Break from loop
if (cur.tok == "break")
{
_oc.add(Break);
}

//------------------------------------------------------------


//Functions
//------------------------------------------------------------

//Declare function
if (cur.tok == "function")
{

//Add opcode
_oc.add(Func, next.tok);

//Add to list (if not main function)
_fList.push_back( JFList(next.tok, t, _tok.findParenthesis(_tok.findNext(t, BRACE_O), BRACE_O, BRACE_C)-1) );

}

//Return (with no data)
if (_fList.size() > 0)
{
if ((t == _fList.at(_fList.size()-1).end) && (_fList.at(_fList.size()-1).name != _funcCall))
{

//Add return and pop
_oc.add(RetFunc);
//_fList.pop_back();
}
}

//Return (with data)
if (cur.tok == "return")
{
_infixRPN(t + 1, _tok.findNext(t, ENDST));
_oc.add(Return);
}

//Call no-return function
if ((cur.type == IDENT) && (next.type == BRACKET_O)
&&(cur.tok != "if") && (cur.tok != "return") && (cur.tok != "print")
&& (prev.tok != "function")
)
{

if ((prev.type == LP) || (prev.type == ENDST))
{

//cout << "-----------" << (prev.type) << endl;
//Parameters
if ((_tok.findNext(t, ENDST) - t) > 2)
{
_infixRPN(t+2, _tok.findNext(t, ENDST)-1);
}

_oc.add(FCall, (int)_findFunc(cur.tok));

}
}

//------------------------------------------------------------


//Built in procedures
//------------------------------------------------------------

//Print
if (cur.tok == "print")
{

//Get data
_infixRPN(t+1, _tok.findNext(t, ENDST));

//Add opcode
_oc.add(Print);
}

//End current line
if (cur.tok == "endl")
{
_oc.add(Endl);
}

//------------------------------------------------------------

}

}

//Get object code
JObjectCode get()
{
return _oc;
}


//Show opcodes
void show()
{
for (size_t o=0; o<_oc.opCount(); o++)
{
cout << _opName(_oc.get(o).get()) << " ";
_printData(_oc.get(o).getData());
cout << endl;
}
}

private:

//Function called
string _funcCall;

//Token stream
JLexer _tok;

//Output
JObjectCode _oc;

//Built in functions
vector<string> _bfunc;

//Variable creation
vector<JAddVar> _vAdd;

//Function list
vector<JFList> _fList;


//Find function
size_t _findFunc(string func)
{
size_t loc(0);
for (size_t f=0; f<_fList.size(); f++)
{
//cout << "> " << f << endl;
if (_fList.at(f).name == func)
{
loc = f;
break;
}
}
return loc;
}

//Infix to RPN Conversion
void _infixRPN(size_t a, size_t b)
{

//Current tokens
token cur, next;

//Stack
vector<JData> stack;

//Loop through tokens
for (size_t t=a; t<b; t++)
{

//Set current tokens
cur = _tok.get(t);
if (t < b-1) next = _tok.get(t + 1);

//If number, add to output queue
if (cur.type == NUM)
{
if (!_isFloat(cur.tok))
{
_oc.add(Push, atoi(cur.tok.c_str()));
}
else
{
_oc.add(Push, (float)atof(cur.tok.c_str()));
}
}

//If string, add to output queue
if (cur.type == STR)
{
_oc.add(Push, cur.tok);
}

//If variable, load value into stack
if ((cur.type == IDENT) && (next.type != BRACKET_O))
{
_oc.add(Read, next.tok);
}

//If function, add to stack
if ((cur.type == IDENT) && (next.type == BRACKET_O))
{
stack.push_back(JData(Func, next.tok));
}

//If comma
if (cur.type == COMMA)
{
//Loop through stack
for (size_t s=0; s<stack.size(); s++)
{
//If left parenthesis, break
if (stack.at(stack.size()-1).getOp() == LP) break;

//Pop into output
if (stack.at(stack.size()-1).getOp() == Func)
{
_callFunc(stack.at(stack.size()-1).getString());
}
else
{
_oc.add(stack.at(stack.size()-1));
}
stack.pop_back();

}
}

//If operator, o1
if (_isOpT(cur.type))
{

//If stack has data
if (stack.size() > 0)
{

//If there is an operator at the top of the stack
if (_isOpO(stack.at(stack.size()-1).getOp()))
{

//If lower precedence
if ((stack.at(stack.size()-1).getOp() == Plus)||(stack.at(stack.size()-1).getOp() == Minus))
{

//Pop into output
_oc.add(stack.at(stack.size()-1).getOp());
stack.pop_back();

}
}

}

//Push onto stack
if (cur.type == PLUS) stack.push_back(Plus);
if (cur.type == MINUS) stack.push_back(Minus);
if (cur.type == MULT) stack.push_back(Mult);
if (cur.type == DIVIDE) stack.push_back(Div);
if (cur.type == EQ_IS) stack.push_back(BEq);
//if (cur.type == Plus) stack.push_back(BNot);
if (cur.type == LESS) stack.push_back(BLess);
if (cur.type == MORE) stack.push_back(BMore);
if (cur.type == EQ_LESS) stack.push_back(BEqL);
if (cur.type == EQ_MORE) stack.push_back(BEqM);
if (cur.type == AND) stack.push_back(BAnd);
if (cur.type == OR) stack.push_back(BOr);

}

//If left parenthesis, push onto stack
if (cur.type == BRACKET_O)
{
stack.push_back(LB);
}

//If right parenthesis
if (cur.type == BRACKET_C)
{

//Loop through stack
for (size_t s=0; s<stack.size(); s++)
{
//If left parenthesis, pop and break
if (stack.at(stack.size()-1).getOp() == LP)
{
stack.pop_back();
break;
}

//Pop into output
if (stack.at(stack.size()-1).getOp() == Func)
{
_callFunc(stack.at(stack.size()-1).getString());
}
else
{
_oc.add(stack.at(stack.size()-1).getOp());
}
stack.pop_back();

}

//If function, pop into output
if (stack.size() > 0)
{
if (stack.at(stack.size()-1).getOp() == Func)
{
_callFunc(stack.at(stack.size()-1).getString());
}
}

}

//Pop rest of stack into output
if (stack.size() > 0)
{
for (size_t s=0; s<stack.size(); s++)
{
//Pop into output
if (stack.at(stack.size()-1).getOp() == Func)
{
_callFunc(stack.at(stack.size()-1).getString());
}
else
{
_oc.add(stack.at(stack.size()-1).getOp());
}
stack.pop_back();
}
}

}

//Check if float number
bool _isFloat(string tok)
{
bool flt = false;
for (size_t t=0; t<tok.size(); t++)
{
if (tok.at(t) == '.')
{
flt = true;
break;
}
}
return flt;
}

//Check if op is operator
bool _isOpO(JOpcode op)
{
bool op = false;
if ((op == Plus)||(op == Minus)||(op == Mult)||(op == Div)||
(op == BEq)||(op == BNot)||(op == BLess)||(op == BMore)||
(op == BEqL)||(op == BEqM)||(op == BAnd)||(op == BOr)
)
{
op = true;
}
return op;
}

//Check if token operator
bool _isOpT(token cur)
{
bool op = false;
if ((cur.tok == "+")||(cur.tok == "-")||(cur.tok == "*")||(cur.tok == "/")||
(cur.tok == "==")||(cur.tok == "!=")||(cur.tok == "<")||(cur.tok == ">")||
(cur.tok == "<=")||(cur.tok == ">=")||(cur.tok == "&&")||(cur.tok == "||")
)
{
op = true;
}
return op;
}

//Call function
void _callFunc(string func)
{
//Not built in
if (!_isBuiltInFunc(func))
{
_oc.add(FCall, (int)_findFunc(func));
}
else
{

//Typecast
if (_bfunc.at(_builtInFunc(func)) == "int") _oc.add(TCInt);
if (_bfunc.at(_builtInFunc(func)) == "float") _oc.add(TCFloat);
if (_bfunc.at(_builtInFunc(func)) == "string") _oc.add(TCString);

}
}

//Check if identifier is a built in function
bool _isBuiltInFunc(string func)
{
for (size_t f=0; f<_bfunc.size(); f++)
{
if (_bfunc.at(f) == func) return true;
}
return false;
}

//Check which built in function identifier is
size_t _builtInFunc(string func)
{
for (size_t f=0; f<_bfunc.size(); f++)
{
if (_bfunc.at(f) == func) return f;
}
return 0;
}

//Print data
void _printData(JData data)
{
JDataType type = data.getType();

//Int
if (type == tInt)
{
cout << data.getInt();
}

//Float
if (type == tFloat)
{
cout << data.getFloat();
}

//String
if (type == tString)
{
cout << data.getString();
}

//Opcode
if (type == tOpcode)
{
cout << data.getOp();
}

}

//Get opcode string
string _opName(JOpcode Op)
{
if (Op == LB) return "{";
if (Op == RB) return "}";
if (Op == LP) return "(";
if (Op == RP) return ")";

if (Op == Push) return "Push";
if (Op == Pop) return "Pop";
if (Op == Mov) return "Mov";
if (Op == ToReg) return "ToReg";
if (Op == ToStack) return "ToStack";
if (Op == RInc) return "RInc";
if (Op == RStack) return "RStack";

if (Op == Do) return "Do";
if (Op == Break) return "Break";
if (Op == If) return "If";

if (Op == TCInt) return "TCInt";
if (Op == TCFloat) return "TCFloat";
if (Op == TCString) return "TCString";

if (Op == Var) return "Var";
if (Op == Write) return "Write";
if (Op == Read) return "Read";
if (Op == Par) return "Par";

if (Op == Func) return "Function";
if (Op == FCall) return "Call";
if (Op == RetFunc) return "RetFunc";
if (Op == Return) return "Return";

if (Op == Plus) return "+";
if (Op == Minus) return "-";
if (Op == Mult) return "*";
if (Op == Div) return "/";
if (Op == BEq) return "==";
if (Op == BNot) return "!=";
if (Op == BLess) return "<";
if (Op == BMore) return ">";
if (Op == BEqL) return "<=";
if (Op == BEqM) return ">=";
if (Op == BAnd) return "&&";
if (Op == BOr) return "||";

if (Op == Print) return "Print";
if (Op == Endl) return "Endl";


return "";
}

};

}

Share this post


Link to post
Share on other sites
Ctrl+A followed by Ctrl+K, Ctrl+F (or Edit->Advanced->Format Selection) and check the code again. The function _infixRPN is not properly balanced with curly bracers. There's a missing } somewhere.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!