Ejemplo n.º 1
0
int DSNLEXER::NeedSYMBOL() throw( IO_ERROR )
{
    int tok = NextTok();
    if( !IsSymbol( tok ) )
        Expecting( DSN_SYMBOL );
    return tok;
}
Ejemplo n.º 2
0
 bool Read()
 {
     bool result = false;
     
     EatSpace();
     if (index < length)
     {
         result = true;
         char c = Current();
         
         if (IsAlpha(c) || c == '_')
             ParseIdentifier();
         else if (IsDigit(c))
             ParseIntegerLiteral();
         else if (c == '"')
             ParseStringLiteral();
         else if (c == '\'')
             ParseCodePointLiteral();
         else if (IsSymbol(c))
             ParseSymbols();
         else
             result = false;
     }
     
     return result;
 }
Ejemplo n.º 3
0
int DSNLEXER::NeedSYMBOLorNUMBER() throw( IO_ERROR )
{
    int  tok = NextTok();
    if( !IsSymbol( tok ) && tok!=DSN_NUMBER )
        Expecting( "symbol|number" );
    return tok;
}
Ejemplo n.º 4
0
void flext_base::cb_anything(flext_hdr *c,const t_symbol *s,int argc,t_atom *argv)
{
    Locker lock(c);
    if(UNLIKELY(!s)) {
        // apparently, this happens only in one case... object is a DSP object, but has no main DSP inlet...

        // interpret tag from args
        if(!argc)
            s = sym_bang;
        else if(argc == 1) {
            if(IsFloat(*argv))
                s = sym_float;
            else if(IsSymbol(*argv))
                s = sym_symbol;
            else if(IsPointer(*argv))
                s = sym_pointer;
            else
                FLEXT_ASSERT(false);
        }
        else
            s = sym_list;
    }

    thisObject(c)->CbMethodHandler(0,s,argc,argv);
}
Ejemplo n.º 5
0
int Expression::parse( const char * pParse )
{
	release();

	const char * pStart = pParse;
	const char * pEnd = pStart + strlen( pParse );
	while( *pParse && pParse < pEnd )
	{
		// skip whitespaces
		if( *pParse && isspace( *pParse ) )
		{ 
			pParse++;
			continue;
		}
		
		Token token;
		token.nType = TOKEN_ERROR;

		char ch = *pParse++;
		if ( IsSymbol( ch ) )
		{
			token.nType = TOKEN_SYMBOL;
			token.sToken += ch;

			while( IsSymbol( *pParse ) )
				token.sToken += *pParse++;
		}
		else 
		{
			for(unsigned int i=0;i<sizeof(TOKENS)/sizeof(TOKENS[0]);i++)
			{
				if ( TOKENS[i].cBegin == ch )
				{
					token.nType = TOKENS[i].nType;
					if ( TOKENS[i].cEnd != 0 )
						pParse = CopyToken( pParse, TOKENS[i].cEnd, token );
					break;
				}
			}
		}

		// push the new token
		m_Tokens.push( token );
	}

	return (int)m_Tokens.size();
}
Ejemplo n.º 6
0
/*! \todo there is probably also a shortcut for Max and jMax
    \todo size checking
*/
FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext))::GetAString(const t_atom &a,char *buf,size_t szbuf)
{ 
#if FLEXT_SYS == FLEXT_SYS_PD
	atom_string(const_cast<t_atom *>(&a),buf,(int)szbuf);
#else
    if(IsSymbol(a)) STD::strncpy(buf,GetString(a),szbuf);
	else if(IsFloat(a)) STD::snprintf(buf,szbuf,"%f",GetFloat(a));
	else if(IsInt(a)) STD::snprintf(buf,szbuf,"%i",GetInt(a));
    else *buf = 0;
#endif
}  
Ejemplo n.º 7
0
    std::string SEXPR::AsString( size_t aLevel )
    {
        std::string result;

        if( IsList() )
        {
            if( aLevel != 0 )
            {
                result = "\n";
            }

            result.append( aLevel* 4, ' ' );
            aLevel++;
            result += "(";

            SEXPR_VECTOR const* list = GetChildren();

            for( std::vector<SEXPR *>::const_iterator it = list->begin(); it != list->end(); ++it )
            {
                result += (*it)->AsString( aLevel );

                if( it != list->end() - 1 )
                {
                    result += " ";
                }
            }
            result += ")";

            aLevel--;
        }
        else if( IsString() )
        {
            result += "\"" + GetString() + "\"";
        }
        else if( IsSymbol() )
        {
            result += GetSymbol();
        }
        else if( IsInteger() )
        {
            std::stringstream out;
            out << GetInteger();
            result += out.str();
        }
        else if( IsDouble() )
        {
            std::stringstream out;
            out << std::setprecision( 16 ) << GetDouble();
            result += out.str();
        }

        return result;
    }
Ejemplo n.º 8
0
 void ParseSymbols()
 {
     StartToken();
     
     switch (Previous())
     {
         case '/':
             if (Current() == '/')
             {
                 ParseLineComment();
                 break;
             }
             else if (Current() == '*')
             {
                 ParseBlockComment();
                 break;
             }
             
             // Yes. No break. This is deliberate.
             
         default:
         {
             String4 tinySource = {};
             tinySource.Append(Previous());
             lastSourceToken.tokenType = TokenType::Reserved;
             lastSourceToken.tokenIndex = FindOperator(tinySource);
             
             for (int i = index; i < length && IsSymbol(source[i]); ++i)
             {
                 tinySource.Append(source[i]);
                 auto tokenIndex = FindOperator(tinySource);
                 
                 if (tokenIndex != -1)
                 {
                     lastSourceToken.tokenIndex = tokenIndex;
                     lastSourceToken.length = i - index + 2;
                 }
             }
             
             int offset = lastSourceToken.length - 1;
             index += offset;
             position.column += offset;
             
             break;
         }
     }
 }
Ejemplo n.º 9
0
/*
  Determine if a the value of a string is constantly known
  (symbolic or numeric)
  */
bool ValueKnown  (const string& o_formula)
{
	bool result = true;
	
	string formula        = StripParens (o_formula);
	list<string> operands = SeparateOperands (formula);
    
    // one operand only 
    if (operands.size() == 1)  
    {
		    	
        ///////////////////////////// Literal
        if (IsNumber (operands.front()))
          return true;
        
        ///////////////////////////// Literal
        if (IsSymbol (operands.front()))
          return true;

        ///////////////////////////// Value Request

        
        ///////////////////////////// Function Call
        if (IsFunctionCall (operands.front()))
          return ValueKnown (SeparateArguments (GetArguments  (operands.front())));
        
        
        return false;
    } /* if */
    
    // multiple operands  
    else
    {
    	operands = OperandsOnly (operands);
    
        for (list<string>::iterator o = operands.begin(); o != operands.end(); o++)	
        { 
        
          if (!ValueKnown (*o))
             return false;          
          
        } /* for */
    return true;
    } /* else */

} /* circuit_t::ValueKnown */
Ejemplo n.º 10
0
    inline MsgBundle &Add(flext_base *th,int o,const t_atom &a) 
    { 
        const t_symbol *sym;
        if(IsSymbol(a))
            sym = sym_symbol;
        else if(IsFloat(a))
            sym = sym_float;
#if FLEXT_SYS == FLEXT_SYS_MAX
        else if(IsInt(a))
            sym = sym_int;
#endif
#if FLEXT_SYS == FLEXT_SYS_PD
        else if(IsPointer(a))
            sym = sym_pointer;
#endif
        else {
            error("atom type not supported");
            return *this;
        }
        return Add(th,o,sym,1,&a);
    }
Ejemplo n.º 11
0
void flext_base::ToSysAtom(int n,const t_atom &at) const 
{ 
    outlet *o = GetOut(n); 
    if(LIKELY(o)) { 
        CRITON(); 
        if(IsSymbol(at))
            outlet_symbol((t_outlet *)o,const_cast<t_symbol *>(GetSymbol(at))); 
        else if(IsFloat(at))
            outlet_float((t_outlet *)o,GetFloat(at)); 
#if FLEXT_SYS == FLEXT_SYS_MAX
        else if(IsInt(at))
            outlet_flint((t_outlet *)o,GetInt(at));
#endif
#if FLEXT_SYS == FLEXT_SYS_PD
        else if(IsPointer(at))
            outlet_pointer((t_outlet *)o,GetPointer(at)); 
#endif
        else
            error("Atom type not supported");
        CRITOFF(); 
    } 
}
Ejemplo n.º 12
0
bool GetToken(wxInputStream& input, wxString& result, unsigned int& lineNumber)
{

    result.Empty();

    SkipWhitespace(input, lineNumber);

    // Reached the end of the file.
    if (input.Eof())
    {
        return false;
    }

    char c = input.GetC();

    if (c == '\"')
    {

        // Quoted string, search for the end quote.

        do
        {
            result += c;
            c = input.GetC();
        }
        while (input.IsOk() && c != '\"');

        result += c;
        return true;

    }

    char n = input.Peek();

    if (IsDigit(c) || (c == '.' && IsDigit(n)) || (c == '-' && IsDigit(n)))
    {

        bool hasDecimal = false;

        while (!IsSpace(c))
        {

            result.Append(c);

            if (input.Eof())
            {
                return true;
            }

            c = input.Peek();

            if (!IsDigit(c) && c != '.')
            {
                return true;
            }

            input.GetC();

            if (c == '\n')
            {
                ++lineNumber;
                return true;
            }

        }

    }
    else
    {

        if (IsSymbol(c))
        {
            result = c;
            return true;
        }

        while (!IsSpace(c) && !input.Eof())
        {

            result.Append(c);

            if (IsSymbol(input.Peek()))
            {
                break;
            }

            c = input.GetC();

            if (c == '\n')
            {
                ++lineNumber;
                return true;
            }

        }

    }

    return true;

}
Ejemplo n.º 13
0
    virtual bool CbMethodResort(int inlet,const t_symbol *sym,int argc,const t_atom *argv)
    {
		const char *dst = GetString(sym);
		if(*dst != '/')
			return false;
		
		FLEXT_ASSERT(packet);

        {
            // treat destination string
            const char *var = strchr(dst,'%');
            *packet << osc::BeginMessage(var?Convert(dst,var,argc,argv).c_str():dst);
        }

        while(argc) {
            if(IsSymbol(*argv)) {
                const char *hdr = GetString(*argv++); --argc;

                const char *var = strchr(hdr,'%');
                if(var) {
                    // variable found in string
                    char typetag = var[1];
                    if(!typetag) 
                        // % is only character
                        *packet << "%";
                    else if(hdr != var || var[2])
                        // variable not in front, or string more than 2 chars long -> substitute variables
                        *packet << Convert(hdr,var,argc,argv).c_str();
                    else {
                        // standalone
                        switch(typetag) {
                            case osc::TRUE_TYPE_TAG: *packet << true; break;
                            case osc::FALSE_TYPE_TAG: *packet << false; break;
                            case osc::NIL_TYPE_TAG: *packet << osc::Nil; break;
                            case osc::INFINITUM_TYPE_TAG: *packet << osc::Infinitum; break;
                            case osc::INT32_TYPE_TAG: {
                                osc::int32 z = (argc--)?GetAInt(*argv++):0;
                                *packet << z;
                                break;
                            }
                            case osc::FLOAT_TYPE_TAG: {
                                float z = (argc--)?GetAFloat(*argv++):0;
                                *packet << z;
                                break;
                            }
                            case osc::CHAR_TYPE_TAG: {
                                Symbol s = (argc--)?GetASymbol(*argv++):NULL;
                                *packet << (s?*GetString(s):'\0');
                                break;
                            }
                            case osc::RGBA_COLOR_TYPE_TAG: {
                                osc::uint32 r = (argc--)?(GetAInt(*argv++)&0xff):0;
                                osc::uint32 g = (argc--)?(GetAInt(*argv++)&0xff):0;
                                osc::uint32 b = (argc--)?(GetAInt(*argv++)&0xff):0;
                                osc::uint32 a = (argc--)?(GetAInt(*argv++)&0xff):0;
                                *packet << osc::RgbaColor((r<<24)+(g<<16)+(b<<8)+a);
                                break;
                            }
                            case osc::MIDI_MESSAGE_TYPE_TAG: {
                                osc::uint32 channel = (argc--)?(GetAInt(*argv++)&0xff):0;
                                osc::uint32 status = (argc--)?(GetAInt(*argv++)&0xff):0;
                                osc::uint32 data1 = (argc--)?(GetAInt(*argv++)&0xff):0;
                                osc::uint32 data2 = (argc--)?(GetAInt(*argv++)&0xff):0;
                                *packet << osc::MidiMessage((channel<<24)+(status<<16)+(data1<<8)+data2);
                                break;
                            }
                            case osc::INT64_TYPE_TAG: {
                                osc::int64 z = 0;
                                if(argc--) z += GetAInt(*argv++);
                                if(argc--) z += GetAInt(*argv++);
                                *packet << z;
                                break;
                            }
                            case osc::TIME_TAG_TYPE_TAG: {
                                double z = 0;
                                if(argc--) z += GetAFloat(*argv++);
                                if(argc--) z += GetAFloat(*argv++);
                                *packet << osc::TimeTag(GetTimetag(z));
                                break;
                            }
                            case osc::DOUBLE_TYPE_TAG: {
                                double z = 0;
                                if(argc--) z += GetAFloat(*argv++);
                                if(argc--) z += GetAFloat(*argv++);
                                *packet << z;
                                break;
                            }
                            case osc::STRING_TYPE_TAG: {
                                Symbol s = (argc--)?GetASymbol(*argv++):NULL;
                                *packet << (s?GetString(s):"");
                                break;
                            }
                            case osc::SYMBOL_TYPE_TAG: {
                                Symbol s = (argc--)?GetASymbol(*argv++):NULL;
                                *packet << osc::Symbol(s?GetString(s):"");
                                break;
                            }
                            case osc::BLOB_TYPE_TAG:
                                post("%s %s - Blob type not supported",thisName(),GetString(thisTag()));
                                break;
                            default:
                                post("%s %s - Unknown type tag %s",thisName(),GetString(thisTag()),typetag);
                        }
                    }
                }
                else
                    *packet << osc::Symbol(hdr);
            }
            else if(CanbeFloat(*argv))
                *packet << GetAFloat(*argv++),--argc;
            else {
                post("%s %s - Invalid atom type",thisName(),GetString(thisTag()));
                ++argv,--argc;
            }
        }
        *packet << osc::EndMessage;

        if(!bundle && autosend) Send(true);

        return true;
    }
Ejemplo n.º 14
0
void SymbolParserThread::ParseFileSymbols(wxInputStream& input, std::vector<Symbol*>& symbols)
{

    if (!input.IsOk())
    {
        return;
    }

    wxString token;

    unsigned int lineNumber = 1;

    Symbol *return_symbol = nullptr;

    wxStack<Symbol *> symStack;
    symStack.push(nullptr);

    std::vector<Token> tokens;
    while (GetToken(input, token, lineNumber))
    {
      tokens.emplace_back(token, lineNumber);
    }

    for (unsigned current_token = 0; current_token < tokens.size(); ++current_token)
    {
      token = tokens[current_token].token;
      lineNumber = tokens[current_token].lineNumber;

      if (token == "function")
      {
        unsigned int defLineNumber = lineNumber;
        Symbol *function = nullptr;

        // Lua functions can have these forms:
        //    function (...)
        //    function Name (...)
        //    function Module.Function (...)
        //    function Class:Method (...)

        wxString t1;
        if (!GetNextToken(tokens, t1, lineNumber, current_token)) break;

        if (t1 == "(")
        {
          // The form function (...) which doesn't have a name. If we
          // were being really clever we could check to see what is being
          // done with this value, but we're not.
          continue;
        }

        wxString t2;

        if (!GetNextToken(tokens, t2, lineNumber, current_token)) break;

        if (t2 == "(")
        {
          function = new Symbol(symStack.top(), t1, defLineNumber);

          if (return_symbol)
          {
            function->typeSymbol = return_symbol;
            return_symbol = nullptr;
          }

          // The form function Name (...).
          symbols.push_back(function);
        }
        else
        {

          wxString t3;
          if (!GetNextToken(tokens, t3, lineNumber, current_token)) break;

          if (t2 == "." || t2 == ":")
          {
            Symbol *module = GetSymbol(t1, symbols);
            if (module == nullptr)
            {
              module = new Symbol(symStack.top(), t1, defLineNumber, SymbolType::Module);
              symbols.push_back(module);
            }

            function = new Symbol(module, t3, defLineNumber);
            if (return_symbol)
            {
              function->typeSymbol = return_symbol;
              return_symbol = nullptr;
            }

            symbols.push_back(function);
          }

        }


        if (function)
          symStack.push(function);

      }
      else if (token == "decodadef")
      {
        //A decodadef will be in the form:
        //decodadef name { Definitions }
        //decodadef name ret

        unsigned int defLineNumber = lineNumber;

        wxString moduleName;
        if (!GetNextToken(tokens, moduleName, lineNumber, current_token)) break;

        wxString t1 = PeekNextToken(tokens, current_token, lineNumber);
        if (t1 == "{")
        {
          if (!GetNextToken(tokens, t1, lineNumber, current_token)) break;
          //outputWin->OutputMessage("Processing " + moduleName);

          Symbol *module = GetSymbol(moduleName, symbols);
          if (module == nullptr)
          {
            module = new Symbol(symStack.top(), moduleName, lineNumber, SymbolType::Type);
            symbols.push_back(module);
          }

          DecodaDefRecursive(symbols, lineNumber, module, tokens, current_token);
        }
        else
        {
          DecodaDefFunction(symbols, lineNumber, nullptr, tokens, current_token, moduleName);
        }
      }
      else if (token == "end")
      {
        if (symStack.size() > 1)
          symStack.pop();
      }
      else if (token == "decodaprefix")
      {
        //A decodaprefix will be in the form:
        //decodaprefix Module name

        /*
        decodaprefix this __FILENAME__
        decodaprefix this { Weapon nil }

        */

        unsigned int defLineNumber = lineNumber;

        wxString moduleName;
        if (!GetNextToken(tokens, moduleName, lineNumber, current_token)) break;


        Symbol *module = GetSymbol(moduleName, symbols, SymbolType::Prefix);
        if (module == nullptr)
        {
          module = new Symbol(nullptr, moduleName, defLineNumber, SymbolType::Prefix);
          symbols.push_back(module);
        }

        wxString t1;
        if (!GetNextToken(tokens, t1, lineNumber, current_token)) break;

        //List of 
        if (t1 == "{")
        {
          DecodaPrefixRecursive(symbols, lineNumber, module, tokens, current_token);
        }
        else
        {
          Symbol *sym_prefix = new Symbol(module, t1, defLineNumber, SymbolType::Prefix);
          sym_prefix->requiredModule = moduleName;
          symbols.push_back(sym_prefix);
        }
      }
      else if (token == "decodareturn")
      {
        //A decodaprefix will be in the form:
        //decodareturn Module

        unsigned int defLineNumber = lineNumber;

        wxString moduleName;
        if (!GetNextToken(tokens, moduleName, lineNumber, current_token)) break;

        Symbol *module = GetSymbol(moduleName, symbols);
        if (module == nullptr)
        {
          module = new Symbol(symStack.top(), moduleName, lineNumber, SymbolType::Type);
          symbols.push_back(module);
        }

        return_symbol = module;
      }
      else if (token == "=")
      {
        unsigned int defLineNumber = lineNumber;

        //If we find an equal sign, we need to find the left and right hand side
        unsigned start = current_token;

        //First handle +=, -=, *=, /=
        wxString prev = PeekPrevToken(tokens, current_token, lineNumber);
        if (prev == "+" || prev == "-" || prev == "*" || prev == "/")
          GetPrevToken(tokens, prev, lineNumber, current_token);

        wxStack<wxString> lhs_stack;
        wxString lhs;
        if (!GetPrevToken(tokens, lhs, lineNumber, current_token)) break;
        
        lhs_stack.push(lhs);

        int currentLine = lineNumber;

        prev = PeekPrevToken(tokens, current_token, lineNumber);
        while ((prev == "." || prev == ":" || prev == ")" || prev == "]") && lineNumber == currentLine)
        {
          if (prev == "." || prev == ":")
          {
            GetPrevToken(tokens, prev, lineNumber, current_token);
            lhs_stack.push(prev);

            wxString part;
            if (!GetPrevToken(tokens, part, lineNumber, current_token)) return;
            if (part == ")" || part == "]")
            {
              current_token++;
              prev = part;
              continue;
            }

            lhs_stack.push(part);
          }
          else if (prev == ")" || prev == "]")
          {
            GetPrevToken(tokens, prev, lineNumber, current_token);
            lhs_stack.push(prev);

            wxString open;
            wxString close;

            if (prev == ")")
            {
              open = "(";
              close = ")";
            }
            else if (prev == "]")
            {
              open = "[";
              close = "]";
            }


            int parenStack = 0;
            wxString part;
            if (!GetPrevToken(tokens, part, lineNumber, current_token)) return;
            for (;;)
            {
              if (part == close)
                parenStack++;
              if (part == open)
              {
                if (parenStack == 0)
                  break;
                parenStack--;
              }

              lhs_stack.push(part);
              if (!GetPrevToken(tokens, part, lineNumber, current_token)) return;
            }
            lhs_stack.push(part);

            if (!GetPrevToken(tokens, part, lineNumber, current_token)) return;
            lhs_stack.push(part);
          }

          prev = PeekPrevToken(tokens, current_token, lineNumber);
        }

        //Parse rhs
        current_token = start;

        //First handle +=, -=, *=, /=
        wxString next = PeekNextToken(tokens, current_token, lineNumber);
        bool valid = true;
        for (int i = 0; i < next.size(); ++i)
        {
          if (IsSymbol(next[i]) || IsSpace(next[i]))
          {
            valid = false;
            break;
          }
        }

        wxString rhs;

        if (valid)
        {
          GetNextToken(tokens, next, lineNumber, current_token);
          rhs.Append(next);

          next = PeekNextToken(tokens, current_token, lineNumber);
          while ((next == "." || next == ":" || next == "(" || next == "[") && lineNumber == currentLine)
          {
            if (next == "." || next == ":")
            {
              GetNextToken(tokens, next, lineNumber, current_token);
              rhs.Append(next);

              wxString part;
              if (!GetNextToken(tokens, part, lineNumber, current_token)) return;
              rhs.Append(part);
            }
            else if (next == "(" || next == "[")
            {
              GetNextToken(tokens, next, lineNumber, current_token);
              rhs.Append(next);

              wxString open;
              wxString close;

              if (next == "(")
              {
                open = "(";
                close = ")";
              }
              else if (next == "[")
              {
                open = "[";
                close = "]";
              }


              int parenStack = 0;
              wxString part;
              if (!GetNextToken(tokens, part, lineNumber, current_token)) return;
              for (;;)
              {
                if (part == open)
                  parenStack++;
                if (part == close)
                {
                  if (parenStack == 0)
                    break;
                  parenStack--;
                }

                rhs.Append(part);
                if (!GetNextToken(tokens, part, lineNumber, current_token)) return;
              }
              rhs.Append(part);
            }

            next = PeekNextToken(tokens, current_token, lineNumber);
          }
        }

        //Build up the strings with the stacks
        if (lhs_stack.size() > 0 && rhs.size() > 0)
        {
          lhs.Empty();

          while (!lhs_stack.empty())
          {
            lhs.Append(lhs_stack.top());
            lhs_stack.pop();
          }

          Symbol *assignment = new Symbol(symStack.top(), lhs, defLineNumber, SymbolType::Assignment);
          assignment->rhs = rhs;
          symbols.push_back(assignment);
        }

        //Reset token
        current_token = start;
      }
    }
}
Ejemplo n.º 15
0
// function that tokenizes the input, using a structure of conscell's, where each conscell has a car and a cdr,
// each car has two values, the type and the actual value.
ConsCell* tokenize(char *expression) {
  ConsCell *current =malloc(sizeof(ConsCell));
  ConsCell *Head = current;
  int i = 0;
  for (int i = 0; expression[i]; i++) {
    if (expression[i]==' ') continue;
      else if (expression[i] == '\n'){
        continue;
      }
    if (expression[i]== '\t'){
      continue;
    }
    Value *carVar = malloc(sizeof(Value));
    Value *cdrVar = malloc(sizeof(Value));
    if (expression[i]=='(') {
      carVar->type = 6;
      carVar->openValue = '(';
    }

    else if (expression[i]==')') {
      carVar->type=7;
      carVar->closeValue = ')';
    }
    else {
      
      if (IsAnInt(expression, i)) {
        carVar->type=2;
        carVar->intValue=GiveInt(expression, i);
        i = getNextTerminal(expression, i);
        i -=1;
      }
      else if(IsSymbol(expression, i)) {
        int symbolLength=returnSymbolLength(expression, i);
        carVar->type=5;
        carVar->symbolValue=returnSymbol(expression, i, symbolLength);
        if (IsId(carVar->symbolValue)){
          carVar->type = 9;
          carVar->idValue = carVar->symbolValue;
        }
        else if (IsPrimitive(carVar->symbolValue)) {
          carVar->type = 13;
          carVar->primValue = carVar->symbolValue;
        }
        i+=symbolLength;
      }
      else if(IsString(expression, i)) {
        carVar->type=4;
        carVar->stringValue=returnString(expression, i);
        int lengthOfString = findLengthOfString(carVar->stringValue);
        i+=lengthOfString;
      }
      else if(IsBoolean(expression,i)){
        carVar->type = 1;
        carVar->boolValue=returnBoolean(expression,i);
        i +=1;
      }
      else if(IsFloat(expression, i)) {
        carVar->type=3;
        carVar->floatValue=GiveFloat(expression, i);
        i = getNextTerminal(expression, i);
        i -=1;
      }
      else if(expression[i] == ';') {
        free(carVar);
        free(cdrVar);
        break;
      }
      else {
        free(carVar);
        free(cdrVar);
        printf("Error: Bad syntax.\n");
        ConsCell *emptyCons =malloc(sizeof(ConsCell));
        Value *Val = malloc(sizeof(Value));
        Val->type = 0;
        Val->intValue= 1;
        emptyCons->car = Val;
        Value *cdrVal = malloc(sizeof(Value));
        cdrVal->type = 0;
        cdrVal->intValue = 0;
        current->car = cdrVal;
        cleanupCCLL(Head);
        return emptyCons;
        break;
      }
      
      


    }
    ConsCell *newCell = malloc(sizeof(ConsCell));
    cdrVar->type = 8;
    cdrVar->cons = newCell;
    current = insertCC(current, carVar, cdrVar);
    current = newCell;

  }
  Value *cdrVal = malloc(sizeof(Value));
  cdrVal->type = 0;
  cdrVal->intValue = 0;
  current->car = cdrVal;
  return Head;

}