public override IElement CreateCopy() { UsingDef e = new UsingDef((int)ImportantCharIndex, (int)ImportantCharLength, (int)ImportantLineIndex); e._usingInfo = _usingInfo; e.AddChildren(this.CopyChildren()); return(e); }
private static void Parse(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo) { int startIndex = parentInfo.CurrentIndex; MoveInfo moveInfo = new MoveInfo(parentInfo); // modifier MemberAccess access; AccessModifier modifier = AccessModifier.GetModifier(moveInfo, out access); if (modifier != null) { startIndex = moveInfo.CurrentIndex; } // name moveInfo = new MoveInfo(parentInfo); IElement tryName = moveInfo.FindNextBlack(SearchDirection.LeftToRight); if (tryName == null || !tryName.IsTT(TokenType.Word)) { throw new SyntaxException("Could not find using name", parentInfo.GetErrorInfo()); } string name = tryName.ToString(); UsingDef usingDef = new UsingDef(moveInfo.Current.CharIndex, moveInfo.Current.CharLength, moveInfo.Current.LineIndex); // assign moveInfo.FindNextBlack(SearchDirection.LeftToRight); // = moveInfo.FindNextBlack(SearchDirection.LeftToRight); // behind = // expression Path pathTry = Path.Parse(moveInfo, parsingInfo, scriptInfo); if (pathTry == null) { throw new SyntaxException("Could not find using path", parentInfo.GetErrorInfo()); } // terminal IElement terminalTry = moveInfo.FindNextBlack(SearchDirection.LeftToRight); if (terminalTry == null || !(terminalTry.IsTT(TokenType.SemiColon))) { throw new SyntaxException("Missing directive ';'?", parentInfo.GetErrorInfo()); } int length = (moveInfo.CurrentIndex + 1) - startIndex; usingDef.AddChildren(parentInfo.CurrentElements.GetRange(startIndex, length)); parentInfo.MoveToIndex(startIndex); parentInfo.Replace(length, usingDef); // info // add const def to list parsingInfo.UsingDefList.Add(usingDef); /*if (scriptInfo.Constants.FindIndex(a => a.Name == name) != -1) * ErrorManager.Semantic("Constant '" + name + "' already defined", new ErrorInfo(parentInfo.ErrorInfo)); * else * {*/ UsingInfo usingInfo = new UsingInfo(scriptInfo.SF, name, pathTry.ToString(), access, usingDef); scriptInfo.AddUsing(usingInfo); usingDef._usingInfo = usingInfo; //} }