Пример #1
0
 public void addVariable(VariableRecord variable)
 {
     variableTable.Add(variable);
 }
 bool variable_declaration_4(ref VariableRecord record)
 {
     if (checkIndex && tokens[tokenIndex].classpart.name == "direct-assignment-operator")
     {
         tokenIndex++;
         if (checkIndex && isExpression())
             return true;
         else return false;
     }
     else return false;
 }
 bool variable_declaration_3(ref VariableRecord record)
 {
     if (checkIndex && tokens[tokenIndex].classpart.name == ":")
     {
         tokenIndex++;
         if (checkIndex && (tokens[tokenIndex].classpart.name == "data-type" || tokens[tokenIndex].classpart.name == "identifier"))
         {
             record.type = tokens[tokenIndex].valuepart;
             tokenIndex++;
             int _tokenIndex = tokenIndex;
             if (checkIndex && variable_declaration_4(ref record))
                 return true;
             else return (tokenIndex == _tokenIndex);
         }
         else return false;
     }
     else return false;
 }
        bool variable_declaration_2(ref VariableRecord record)
        {
            if (checkIndex && tokens[tokenIndex].classpart.name == "identifier")
            {
                record.identifier = tokens[tokenIndex].valuepart;
                tokenIndex++;
                int _tokenIndex = tokenIndex;
                if (checkIndex && variable_declaration_3(ref record))
                {
                    variableTable.Add(record);
                    if (checkIndex && tokens[tokenIndex].classpart.name == ",")
                    {
                        tokenIndex++;
                        
                        VariableRecord _record = new VariableRecord();
                        _record.scope = currentScope;
                        _record.constant = record.constant;

                        return (checkIndex && variable_declaration_2(ref _record));
                    }
                    else return true;
                }
                else if ((tokenIndex == _tokenIndex) && checkIndex && variable_declaration_4(ref record))
                {
                    variableTable.Add(record);
                    if (checkIndex && tokens[tokenIndex].classpart.name == ",")
                    {
                        tokenIndex++;

                        VariableRecord _record = new VariableRecord();
                        _record.scope = currentScope;
                        _record.constant = record.constant;

                        return (checkIndex && variable_declaration_2(ref _record));
                    }
                    else return true;
                }
                else return false;
            }
            else return false;
        }
        bool variable_declaration()
        {
            if (checkIndex && tokens[tokenIndex].classpart.name == "variable")
            {
                VariableRecord record = new VariableRecord();
                record.constant = (tokens[tokenIndex].valuepart == "firm");
                record.scope = currentScope;

                tokenIndex++;
                #region Terminator
                /*if (checkIndex && variable_declaration_2())
                {
                    if (checkIndex && tokens[tokenIndex].classpart.name == "line-terminator")
                    {
                        tokenIndex++;
                        return true;
                    }
                    else return false;
                }
                else return false;*/
                #endregion
                return (checkIndex && variable_declaration_2(ref record));
            }
            else return false;
        }
 public void addVariable(VariableRecord variable)
 {
     variableTable.Add(variable);
 }