public void SetContext() { if (ParseState.hasOpenDoubleQuote) { Context = VerilogTokenContextType.DoubleQuoteOpen; } else { if (ParseState.hasOpenSquareBracket && !IsDelimiter(ParseState.thisChar)) { Context = VerilogTokenContextType.SquareBracketContents; } else { if (ParseState.hasOpenRoundBracket && !IsDelimiter(ParseState.thisChar)) { Context = VerilogTokenContextType.RoundBracketContents; } else { if (ParseState.hasOpenRoundBracket && !IsDelimiter(ParseState.thisChar)) { Context = VerilogTokenContextType.SquigglyBracketContents; } else { Context = VerilogTokenContextFromString(ParseState.thisChar); } } } } }
/// <summary> /// Verilog Token Initializer /// </summary> /// <param name="p"></param> /// <param name="c"></param> public VerilogToken(string p = "", VerilogTokenContextType c = VerilogTokenContextType.Undetermined) { ParseState = new VerilogParseState(0); Part = p ?? ""; // ensure Part is never null (empty string if p is null) if (c == VerilogTokenContextType.Undetermined && Part.Length > 0) { Context = VerilogTokenContextFromString(p); // we'll figure out the context from the first character } else { Context = c; // unless otherwise specified } }