internal VBText(VB6CodeModelFactoryContext factoryContext, ITerminalNode token) { Token = token; FactoryContext = factoryContext; RootModule = factoryContext.RootModule; ParentCodeBlock = factoryContext.ParentCodeBlock; }
public VBBaseCodeModel CreateCodeModel(ParserRuleContext context) { try { // Create code model based on context name // e.g: DeclareStmtContext will create VBDeclareStmt class var contextClassName = context.GetType().Name; var codeModelClassName = "VB" + contextClassName.Replace("Context", string.Empty); var cxt = new VB6CodeModelFactoryContext(_rootModule, _parentCodeBlock, context, _parentCodeBlock.Scope); var args = new object[] { cxt }; var t = Type.GetType($"VB6ActiveXDllConverter.CodeModels.{codeModelClassName}", true); var obj = (VBBaseCodeModel)t.Assembly.CreateInstance($"VB6ActiveXDllConverter.CodeModels.{codeModelClassName}", true, BindingFlags.Instance | BindingFlags.NonPublic, null, args, null, null); obj.BeforeVisitChild(); _parentCodeBlock.AddCodeModel(obj); obj.VisitChild(); obj.AfterVisitChild(); return(obj); } catch (Exception ex) { throw; } }
public VBText CreateCodeModel(ITerminalNode node) { try { var cxt = new VB6CodeModelFactoryContext(_rootModule, _parentCodeBlock, null, _parentCodeBlock.Scope); var obj = new VBText(cxt, node); obj.BeforeVisitChild(); _parentCodeBlock.AddCodeModel(obj); obj.AfterVisitChild(); return(obj); } catch (Exception ex) { throw; } }
/* * lockStmt * : LOCK WS valueStmt (WS? COMMA WS? valueStmt (WS TO WS valueStmt)?)? */ internal VBLockStmt(VB6CodeModelFactoryContext factoryContext) : base(factoryContext) { }
/* * enumerationStmt_Constant * : ambiguousIdentifier (WS? EQ WS? valueStmt)? NEWLINE + * * Note: * - Enum member value is optional, can be 32-bit number (VB6 Long) or constant: valueStmt can be a long literal or identifier * */ internal VBEnumerationStmt_Constant(VB6CodeModelFactoryContext factoryContext) : base(factoryContext) { }
internal VBBaseSingleLineStatement(VB6CodeModelFactoryContext factoryContext) : base(factoryContext) { }
/* * ifElseBlockStmt * : ELSE NEWLINE + (block NEWLINE +)? * */ internal VBIfElseBlockStmt(VB6CodeModelFactoryContext factoryContext) : base(factoryContext) { Scope = new VBScope(factoryContext.Scope, this, VBProgramScope.Block); }
/* * inputStmt * : INPUT WS valueStmt (WS? COMMA WS? valueStmt) + * */ internal VBInputStmt(VB6CodeModelFactoryContext factoryContext) : base(factoryContext) { }
/* * declareStmt * : (visibility WS)? DECLARE WS (FUNCTION typeHint? | SUB) WS ambiguousIdentifier typeHint? WS LIB WS STRINGLITERAL (WS ALIAS WS STRINGLITERAL)? (WS? argList)? (WS asTypeClause)? */ internal VBDeclareStmt(VB6CodeModelFactoryContext factoryContext) : base(factoryContext) { }
internal VBVariableSubStmt(VB6CodeModelFactoryContext factoryContext) : base(factoryContext) { }
/* * resumeStmt * : RESUME (WS (NEXT | ambiguousIdentifier))? */ internal VBResumeStmt(VB6CodeModelFactoryContext factoryContext) : base(factoryContext) { }
/* * arg * : (OPTIONAL WS)? ((BYVAL | BYREF) WS)? (PARAMARRAY WS)? ambiguousIdentifier typeHint? (WS? LPAREN WS? RPAREN)? (WS asTypeClause)? (WS? argDefaultValue)? * * argDefaultValue * : EQ WS? valueStmt * * Refer MSDN: https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-basic-6/aa243374(v=vs.60) * Default value: Any constant or constant expression. Valid for Optional parameters only. If the type is an Object, an explicit default value can only be Nothing. * Similar to const, can be fixed value, arithmetic, logical expression or mixed of anyone. * */ internal VBArg(VB6CodeModelFactoryContext factoryContext) : base(factoryContext) { }
/* * saveSettingStmt * : SAVESETTING WS valueStmt WS? COMMA WS? valueStmt WS? COMMA WS? valueStmt WS? COMMA WS? valueStmt */ internal VBSaveSettingStmt(VB6CodeModelFactoryContext factoryContext) : base(factoryContext) { }
/* * iCS_S_MemberCall * : WS? DOT (iCS_S_VariableOrProcedureCall | iCS_S_ProcedureOrArrayCall) * */ internal VBICS_S_MemberCall(VB6CodeModelFactoryContext factoryContext) : base(factoryContext) { }
/* * macroConstStmt * : MACRO_CONST WS ambiguousIdentifier WS? EQ WS? valueStmt * * Note: * - This is a custom rule added to grammar file, since the original open source file do not support this. * - Refer: https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-basic-6/aa262669(v=vs.60) * - Syntax is similar to Const, but one constant declaration per line. * - Expression can only be litral, other conditional compiler constant, or any combination that includes any or all arithmetic or logical operators except Is. * - Private by default * */ internal VBMacroConstStmt(VB6CodeModelFactoryContext factoryContext) : base(factoryContext) { }
internal VBBaseBlockSubStatement(VB6CodeModelFactoryContext factoryContext) : base(factoryContext) { }
/* * certainIdentifier * : IDENTIFIER (ambiguousKeyword | IDENTIFIER)* * | ambiguousKeyword (ambiguousKeyword | IDENTIFIER) + * */ internal VBCertainIdentifier(VB6CodeModelFactoryContext factoryContext) : base(factoryContext) { }
/* * valueStmt * | valueStmt WS? MINUS WS? valueStmt # vsMinus */ internal VBVsMinus(VB6CodeModelFactoryContext factoryContext) : base(factoryContext) { }
/* * argDefaultValue * : EQ WS? valueStmt * */ internal VBArgDefaultValue(VB6CodeModelFactoryContext factoryContext) : base(factoryContext) { }
/* * typeStmt_Element * : ambiguousIdentifier (WS? LPAREN (WS? subscripts)? WS? RPAREN)? (WS asTypeClause)? NEWLINE + * * Note: * - Similar to variable declaration, except no visibility & type hint. * - Must contain either subscripts or asTypeClause. VB6 compile error if both are missing. * */ internal VBTypeStmt_Element(VB6CodeModelFactoryContext factoryContext) : base(factoryContext) { }
/* * valueStmt * | valueStmt WS? EQV WS? valueStmt # vsEqv */ internal VBVsEqv(VB6CodeModelFactoryContext factoryContext) : base(factoryContext) { }
/* * propertySetStmt * : (visibility WS)? (STATIC WS)? PROPERTY_SET WS ambiguousIdentifier (WS? argList)? NEWLINE + (block NEWLINE +)? END_PROPERTY * */ internal VBPropertySetStmt(VB6CodeModelFactoryContext factoryContext) : base(factoryContext) { Scope = new VBScope(factoryContext.Scope, this, VBProgramScope.Procedure); }
internal VBBaseValueStatement(VB6CodeModelFactoryContext factoryContext) : base(factoryContext) { }
/* * asTypeClause * : AS WS (NEW WS)? type (WS fieldLength)? * * fieldLength * : MULT WS? (INTEGERLITERAL | ambiguousIdentifier) * */ internal VBAsTypeClause(VB6CodeModelFactoryContext factoryContext) : base(factoryContext) { }
/* * rmdirStmt * : RMDIR WS valueStmt */ internal VBRmdirStmt(VB6CodeModelFactoryContext factoryContext) : base(factoryContext) { }
/* * literal * : COLORLITERAL * | DATELITERAL * | DOUBLELITERAL * | FILENUMBER * | INTEGERLITERAL * | OCTALLITERAL * | STRINGLITERAL * | TRUE * | FALSE * | NOTHING * | NULL * */ internal VBLiteral(VB6CodeModelFactoryContext factoryContext) : base(factoryContext) { }
/* * implicitCallStmt_InBlock * : iCS_B_ProcedureCall * | iCS_B_MemberProcedureCall * * iCS_B_ProcedureCall * : certainIdentifier (WS argsCall)? * */ internal VBICS_B_ProcedureCall(VB6CodeModelFactoryContext factoryContext) : base(factoryContext) { }
/* * publicPrivateGlobalVisibility * : PRIVATE * | PUBLIC * | GLOBAL * */ internal VBPublicPrivateGlobalVisibility(VB6CodeModelFactoryContext factoryContext) : base(factoryContext) { }
/* * sC_Cond * : ELSE # caseCondElse * | sC_CondExpr (WS? COMMA WS? sC_CondExpr)* #caseCondExpr * */ internal VBCaseCondExpr(VB6CodeModelFactoryContext factoryContext) : base(factoryContext) { }
internal VBOutputList_Expression(VB6CodeModelFactoryContext factoryContext) : base(factoryContext) { }