Пример #1
0
        private static void Process_ModuleOpenParen_For(string ItemText)
        {
            switch (ItemText)
            {
            case "":
                // ignoring trimmed spaces / blanks
                thisModuleDeclarationText += " ";
                break;

            case ")":
                BuildHoverState = BuildHoverStates.ModuleCloseParen;
                break;

            case "input":
            case "output":
            case "inout":
            case "wire":
            case "reg":
            case "parameter":
                // the same keywords could be used for module parameters, or variables:
                BuildHoverState         = BuildHoverStates.ModuleParameterNaming;
                thisModuleParameterText = ItemText;
                break;

            default:
                BuildHoverState = BuildHoverStates.UndefinedState;
                break;
            }
        }
Пример #2
0
        /// <summary>
        ///   InitHoverBuilder - prep for another refresh of hover item lookup
        /// </summary>
        public static void InitHoverBuilder()
        {
            // re-initialize variables to above values
            VerilogVariableHoverText = new Dictionary <string, Dictionary <string, string> >
                                       // e.g. ["led"] = "An LED."
            {
                {
                    "global",
                    new Dictionary <string, string> {
                    }
                }
            };


            VerilogVariables = new Dictionary <string, Dictionary <string, VerilogTokenTypes> >
                               // e.g. ["module name"]["led"] = VerilogTokenTypes.Verilog_Variable,
            {
                {
                    "global",
                    new Dictionary <string, VerilogTokenTypes> {
                    }
                }
            };
            thisHoverName = "";

            thisVariableDeclarationText = ""; // this is only variable declaration, even if inside a module declaration

            thisModuleDeclarationText = "";   // this is the full module declaration
            thisModuleParameterText   = "";
            thisModuleName            = "";

            BuildHoverState = BuildHoverStates.UndefinedState;
        }
Пример #3
0
 /// <summary>
 ///    Process_XXX_For - template
 /// </summary>
 /// <param name="ItemText"></param>
 private static void Process_XXX_For(string ItemText)
 {
     if (1 == 1)
     {
         BuildHoverState = BuildHoverStates.UndefinedState;
     }
     else
     {
         //syntax error
     }
 }
Пример #4
0
        /// <summary>
        ///    Process_ModuleNamed_For
        /// </summary>
        /// <param name="ItemText"></param>
        private static void Process_ModuleNamed_For(string ItemText)
        {
            switch (ItemText)
            {
            case "":
                // trimming blanks to a single space
                thisModuleDeclarationText += " ";
                break;

            case "(":
                thisModuleDeclarationText += ItemText;
                BuildHoverState            = BuildHoverStates.ModuleOpenParen;
                break;

            default:
                thisModuleDeclarationText += ItemText;
                // BuildHoverState = BuildHoverStates.ModuleNamed; no state change
                break;
            }
        }
Пример #5
0
        /// <summary>
        ///    Process_ModuleStart_For
        /// </summary>
        /// <param name="ItemText"></param>
        private static void Process_ModuleStart_For(string ItemText)
        {
            // we've found the "module" keyword, the next word should be the module name
            // TODO - flag syntax error for non-variable names found
            switch (ItemText)
            {
            case "":
                // trimming blanks to a single space
                thisModuleDeclarationText += " ";
                break;

            default:
                thisModuleName             = ItemText;
                thisModuleDeclarationText += ItemText;
                //editingBufferModuleAttributes.Add(new BufferModuleAttribute { LineStart = 0,
                //                                                               ModuleName = thisModuleName });
                BuildHoverState = BuildHoverStates.ModuleNamed;
                break;
            }
        }
Пример #6
0
        /// <summary>
        ///    Process_VariableMimicNaming_For
        /// </summary>
        /// <param name="ItemText"></param>
        private static void Process_VariableMimicNaming_For(string ItemText)
        {
            // once we are naming a module parameter, we only end with a closing parenthesis, or a comman
            switch (ItemText)
            {
            case "":
                if ((lastHoverItem == "") || (lastHoverItem == "\t") || (lastHoverItem == ","))
                {
                    // we'll ignore sequentual tabs, or alternating table-space, commas mean we are mimicing prior definition
                    // only one space will be used
                }
                else
                {
                    thisVariableDeclarationText += " ";
                }
                break;

            case ",":
                AddHoverItem(thisModuleName, thisHoverName, thisVariableDeclarationText);
                thisVariableDeclarationText = thisVariableDeclarationText.Replace(thisHoverName, "");
                break;

            case ";":
                AddHoverItem(thisModuleName, thisHoverName, thisVariableDeclarationText);
                thisVariableDeclarationText = "";
                BuildHoverState             = BuildHoverStates.UndefinedState;
                break;

            case "endmodule":
                BuildHoverState = BuildHoverStates.UndefinedState;
                // we're done naming a module
                //AddHoverItem(thisModuleName, thisHoverName, thisModuleParameterText);
                //BuildHoverState = BuildHoverStates.ModuleNamed;
                //thisHoverName = "";
                //thisVariableDeclarationText = "";
                //thisModuleName = "";
                //thisModuleParameterText = "";
                break;

            default:
                // if we encounter a NamerKeyword during a sequence of comma-delimited vars, then this is a new type!
                // e.g.  input a,b,  // this is input a; input b;
                //       output c    // this is output c;
                if (IsVerilogNamerKeyword(ItemText))
                {
                    Process_UndefinedState_For(ItemText);
                }
                else
                {
                    if (IsVerilogBracket(ItemText) || IsNumeric(ItemText) || IsVerilogValue(ItemText) || IsDelimiter(ItemText))
                    {
                        SetBracketContentStatus_For(ItemText);
                        // nothing at this time; we are still bulding the declaration part
                        thisVariableDeclarationText += ItemText;
                    }
                    else
                    {
                        thisHoverName = ItemText;
                        thisVariableDeclarationText += ItemText;
                    }
                }
                break;
            }
        }
Пример #7
0
        /// <summary>
        ///    Process_VariableNaming_For
        /// </summary>
        /// <param name="ItemText"></param>
        private static void Process_VariableNaming_For(string ItemText)
        {
            if (thisHoverName == "")
            {
                string a = "breakpoint";
                // TODO - how did we wend up here? (seen during multi-thread)
                //return;
            }
            // once we are naming a module parameter, we only end with a closing parenthesis, or a comman
            switch (ItemText)
            {
            case "":
                if ((lastHoverItem == "") || (lastHoverItem == "\t"))
                {
                    // we'll ignore sequentual tabs, or alternating table-space
                    // only one space will be used
                }
                else
                {
                    thisVariableDeclarationText += " ";
                }

                break;

            case ";":
                AddHoverItem(thisModuleName, thisHoverName, thisVariableDeclarationText);
                thisVariableDeclarationText = "";     // reminder we do this manually, as AddHoverItem does not know *what* it is adding
                BuildHoverState             = BuildHoverStates.UndefinedState;
                break;

            case ",":
                if (thisHoverName == "")
                {
                    string a = "breakpoint";
                    // no hovername = nothing to do

                    BuildHoverState = BuildHoverStates.VariableMimicNaming;     // Mimic naming is the same declaration but comma-delimited (e.g. input a,b // b has the input "mimic'd" )
                }
                else
                {
                    if (IsInsideSquigglyBracket)
                    {
                        thisVariableDeclarationText += ItemText;
                        // BuildHoverState remains variable building
                    }
                    else
                    {
                        AddHoverItem(thisModuleName, thisHoverName, thisVariableDeclarationText);
                        // since we en countered a comma, we will use the same declaration text for a new name, so replace this name with a blank
                        thisVariableDeclarationText = thisVariableDeclarationText.Replace(thisHoverName, "");

                        BuildHoverState = BuildHoverStates.VariableMimicNaming;     // Mimic naming is the same declaration but comma-delimited (e.g. input a,b // b has the input "mimic'd" )
                    }
                }
                break;

            case "reg":
            case "integer":
                thisVariableDeclarationText += ItemText;
                break;

            case "endmodule":
                // we're done naming a module
                AddHoverItem(thisModuleName, thisHoverName, thisModuleParameterText);
                BuildHoverState             = BuildHoverStates.UndefinedState;
                thisHoverName               = "";
                thisVariableDeclarationText = "";
                thisModuleName              = "";
                thisModuleParameterText     = "";
                break;

            default:
                // TODO implement IsVerilogAssignment
                if ((thisHoverName != "") || (ItemText == "=") || IsVerilogBracket(ItemText) || IsNumeric(ItemText) || IsVerilogValue(ItemText) || Is_BracketContent_For(thisModuleName, ItemText) || IsDelimiter(ItemText) || IsVerilogVariableSigner(ItemText))
                {
                    // we continue building the declaration text
                    SetBracketContentStatus_For(ItemText);

                    // nothing at this time; we are still bulding the declaration part for the given thisHoverName (aka variable name)
                    thisVariableDeclarationText += ItemText;
                }
                else
                {
                    // we found a new hover name to assign declaration text
                    thisHoverName = ItemText;
                    thisVariableDeclarationText += ItemText;
                }
                break;
            }
        }
Пример #8
0
        /// <summary>
        ///   Process_ModuleParameterMimicNaming_For
        /// </summary>
        /// <param name="ItemText"></param>
        private static void Process_ModuleParameterMimicNaming_For(string ItemText)
        {
            // once we are naming a module parameter, we only end with a closing parenthesis, or a comman
            switch (ItemText)
            {
            case "":
                if ((lastHoverItem == "") || (lastHoverItem == "\t"))
                {
                    // we'll ignore sequentual tabs, or alternating table-space
                    // only one space will be used
                }
                else
                {
                    thisModuleDeclarationText += " ";
                }

                // thisModuleParameterText += " ";
                break;

            case "\t":
                if ((lastHoverItem == "") || (lastHoverItem == "\t"))
                {
                    // we'll ignore sequentual tabs, or alternating table-space
                    // only one space will be used
                }
                else
                {
                    thisModuleParameterText += " ";
                }
                break;

            case ")":
                thisModuleDeclarationText += ItemText;
                AddHoverItem(thisModuleName, thisModuleName, thisModuleDeclarationText);

                // also add an individual parameter as needed
                AddHoverItem(thisModuleName, thisHoverName, thisModuleParameterText);
                thisModuleParameterText = "";                              // upon the close parenthesis, no more module parameters. we might try to re-add the last param during syntax errot (e.g. traling comma immediately followed by closing parenthesis
                BuildHoverState         = BuildHoverStates.UndefinedState; // and no more module definition
                break;

            case ",":
                thisModuleDeclarationText += ItemText;     // only the module declaration will include the comment
                thisModuleDeclarationText += System.Environment.NewLine;

                // add the module parameter
                AddHoverItem(thisModuleName, thisHoverName, thisModuleParameterText);
                thisModuleParameterText = thisModuleParameterText.Replace(thisHoverName, "");
                break;

            case ";":
                thisModuleDeclarationText += ItemText;     // only the module declaration will include the comment
                thisModuleDeclarationText += System.Environment.NewLine;

                // add the module parameter
                AddHoverItem(thisModuleName, thisHoverName, thisModuleParameterText);
                thisModuleParameterText = "";
                BuildHoverState         = BuildHoverStates.ModuleParameterNaming; // certainly not mimic naming after a semi-colon!
                break;

            default:
                // thisModuleParameterText += ItemText;
                thisModuleDeclarationText += ItemText;

                if (IsVerilogNamerKeyword(ItemText) || IsVerilogBracket(ItemText) || IsNumeric(ItemText) || IsVerilogValue(ItemText) || IsDelimiter(ItemText))
                {
                    SetBracketContentStatus_For(ItemText);

                    // no longer mimic naming
                    BuildHoverState         = BuildHoverStates.ModuleParameterNaming;
                    thisModuleParameterText = ItemText;     // start over for the module parameter
                }
                else
                {
                    thisHoverName            = ItemText;
                    thisModuleParameterText += ItemText;
                }
                break;
            }
        }
Пример #9
0
        /// <summary>
        ///    Process_ModuleParameterNaming_For
        /// </summary>
        /// <param name="ItemText"></param>
        private static void Process_ModuleParameterNaming_For(string ItemText)
        {
            // once we are naming a module parameter, we only end with a closing parenthesis, or a comman
            switch (ItemText)
            {
            case "":
                // only append whitespace when not found at beginning
                if (thisModuleParameterText != "")
                {
                    if ((lastHoverItem == "") || (lastHoverItem == "\t"))
                    {
                        // we'll ignore sequentual tabs, or alternating table-space
                        // only one space will be used
                    }
                    else
                    {
                        thisModuleDeclarationText += " ";
                        thisModuleParameterText   += " ";
                    }
                }
                break;

            case "\t":
                if ((lastHoverItem == "") || (lastHoverItem == "\t"))
                {
                    // we'll ignore sequentual tabs, or alternating table-space
                    // only one space will be used
                }
                else
                {
                    thisModuleDeclarationText += " ";
                    thisModuleParameterText   += " ";
                }
                break;

            case ")":

                // also add an indivisual parameter as needed
                // note all module parameters have test appended: "module [modulename]" + {}  + ")"
                AddHoverItem(thisModuleName, thisHoverName, thisModuleParameterText);
                thisModuleParameterText = "";                              // upon the colose parenthesis, no more module parameters
                BuildHoverState         = BuildHoverStates.UndefinedState; // and no more module definition

                // we add the module definition afterwards to avoid any additional, manually added closing ")" that is included for *every( module parameter, but not actually in the text
                thisModuleDeclarationText += ItemText;
                if (lastNonblankHoverItem == ",")
                {
                    // we won't try to add a duplicate if there's a trailing ",)" syntax error
                }
                else
                {
                    AddHoverItem(thisModuleName, thisModuleName, thisModuleDeclarationText);
                }
                break;

            case ",":
                thisModuleDeclarationText += ItemText;     // only the module declaration will include the comment
                thisModuleDeclarationText += System.Environment.NewLine;

                // add the module parameter
                AddHoverItem(thisModuleName, thisHoverName, thisModuleParameterText);
                thisModuleParameterText = thisModuleParameterText.Replace(thisHoverName, "");     // TODO - use a placeholder here, not an empty string

                // the next parameter after the comma will use the same definition
                BuildHoverState = BuildHoverStates.ModuleParameterMimicNaming;
                break;

            case ";":
                thisModuleDeclarationText += ItemText;     // only the module declaration will include the comment
                thisModuleDeclarationText += System.Environment.NewLine;

                // add the module parameter
                AddHoverItem(thisModuleName, thisHoverName, thisModuleParameterText);
                thisModuleParameterText = "";                                     // we can't use the same parameter def after a semicolon
                BuildHoverState         = BuildHoverStates.ModuleParameterNaming; // certainly not mimic naming after a semi-colon!
                break;

            case "=":
                thisModuleParameterText   += ItemText;
                thisModuleDeclarationText += ItemText;
                break;

            default:
                thisModuleParameterText   += ItemText;
                thisModuleDeclarationText += ItemText;

                if (IsVerilogNamerKeyword(ItemText) || IsVerilogBracket(ItemText) || IsNumeric(ItemText) || IsVerilogValue(ItemText) || IsDelimiter(ItemText))
                {
                    SetBracketContentStatus_For(ItemText);
                    // nothing at this time; we are still bulding the declaration part
                    // thisModuleParameterText += ItemText;
                }
                else
                {
                    thisHoverName = ItemText;
                }
                break;
            }
        }
Пример #10
0
        /// <summary>
        ///   Process_UndefinedState_For
        /// </summary>
        /// <param name="ItemText"></param>
        private static void Process_UndefinedState_For(string ItemText)
        {
            switch (ItemText)
            {
            case "":
                // ignoring trimmed spaces / blanks
                break;

            case "module":
                // we're naming a module
                BuildHoverState           = BuildHoverStates.ModuleStart;
                thisModuleDeclarationText = ItemText;
                break;

            case "input":
            case "output":
            case "inout":
            case "wire":
            case "reg":
            case "localparam":
            case "parameter":
                // the same keywords could be used for module parameters, or variables:
                switch (BuildHoverState)
                {
                case BuildHoverStates.ModuleStart:
                    BuildHoverState = BuildHoverStates.ModuleParameterNaming;
                    break;

                case BuildHoverStates.VariableMimicNaming:         // comma-delimited types have the type copied (mimic) into hover text for each variable
                    BuildHoverState             = BuildHoverStates.VariableNaming;
                    thisVariableDeclarationText = ItemText;
                    thisHoverName = "";         // we are no longer using the same type declaration, so reset to blank
                    break;

                default:
                    BuildHoverState             = BuildHoverStates.VariableNaming;
                    thisVariableDeclarationText = ItemText;
                    break;
                }

                thisVariableType = VerilogGlobals.VerilogTypes["variable_" + ItemText];
                break;

            case "endmodule":
                // we're naming a module
                BuildHoverState = BuildHoverStates.UndefinedState;
                // this is likely a syntax error
                break;

            default:
                if (VerilogVariables.ContainsKey(ItemText))
                {
                    // a scope-level module name is defined, so treat it like a variable type
                    BuildHoverState = BuildHoverStates.VariableNaming;     // actually, we are module naming. TODO different color for modules?

                    // a module instantiation will have the work "module" manually prepended
                    thisVariableDeclarationText = "module " + ItemText;
                }
                else
                {
                    BuildHoverState = BuildHoverStates.UndefinedState;
                }
                break;
            }
        }