Example #1
0
        /// <summary>Registers a script block on a page.</summary>
        /// <param name="page">The page onto which to added the script.</param>
        /// <param name="script">The script to add.</param>
        /// <param name="position">Where to add the script.</param>
        /// <param name="options">Script registration options.</param>
        public static void JavaScript(this Page page, string script, ScriptPosition position, ScriptOptions options)
        {
            if (page == null) throw new ArgumentNullException("page");

            if (position == ScriptPosition.Header)
            {
                JavaScript(page, script, options);
            }
            else if (position == ScriptPosition.Bottom)
            {
                string key = script.GetHashCode().ToString();
                if (options.Is(ScriptOptions.None))
                    page.ClientScript.RegisterStartupScript(typeof(Register), key, script);
                else if (options.Is(ScriptOptions.ScriptTags))
                    page.ClientScript.RegisterStartupScript(typeof(Register), key, script, true);
                else if (options.Is(ScriptOptions.DocumentReady))
                {
                    page.JQuery();
                    page.ClientScript.RegisterStartupScript(typeof(Register), key, EmbedDocumentReady(script), true);
                }
                else if (options.Is(ScriptOptions.Include))
                    page.ClientScript.RegisterClientScriptInclude(key, Url.ResolveTokens(script));
                else
                    throw new ArgumentException("options");
            }
            else
                throw new ArgumentException("position");
        }
Example #2
0
        /// <summary>Registers a script block on a page.</summary>
        /// <param name="page">The page onto which to added the script.</param>
        /// <param name="script">The script to add.</param>
        /// <param name="position">Where to add the script.</param>
        /// <param name="options">Script registration options.</param>
        public static void JavaScript(Page page, string script, ScriptPosition position, ScriptOptions options)
        {
            if (page == null) throw new ArgumentNullException("page");

            if (position == ScriptPosition.Header)
            {
                JavaScript(page, script, options);
            }
            else if (position == ScriptPosition.Bottom)
            {
                string key = script.GetHashCode().ToString();
                if (Is(options, ScriptOptions.None))
                    page.ClientScript.RegisterClientScriptBlock(typeof (Register), key, script);
                else if (Is(options, ScriptOptions.ScriptTags))
                    page.ClientScript.RegisterClientScriptBlock(typeof (Register), key, script, true);
                else if (Is(options, ScriptOptions.DocumentReady))
                {
                    JQuery(page);
                    page.ClientScript.RegisterClientScriptBlock(typeof (Register), key, EmbedDocumentReady(script), true);
                }
                else if (Is(options, ScriptOptions.Include))
                    page.ClientScript.RegisterClientScriptInclude(key, page.Engine().ManagementPaths.ResolveResourceUrl(script));
                else
                    throw new ArgumentException("options");
            }
            else
                throw new ArgumentException("position");
        }
Example #3
0
        protected override void CallTemplate(ScriptPosition position, string template, string name, params object[] args)
        {
            StringBuilder sb = new StringBuilder();

            if (args != null && args.Length > 0)
            {
                foreach (object arg in args)
                {
                    sb.AppendFormat("{0},", JSON.Serialize(arg, JSON.ScriptConvertersInternal));
                }
            }

            string script = template.FormatWith(this.control.ClientID+".store", name, sb.ToString().LeftOfRightmostOf(','));

            switch (position)
            {
                case ScriptPosition.BeforeInit:
                    this.ResourceManager.RegisterBeforeClientInitScript(script);
                    break;
                case ScriptPosition.AfterInit:
                    this.ResourceManager.RegisterAfterClientInitScript(script);
                    break;
                default:
                    this.AddScript(script);
                    break;
            }
        }
Example #4
0
 internal SelectedScript(ScriptPosition scriptposition, string uniquename, string author, string title, string description, Action<Data.NodeBase, Object> function)
 {
     ScriptPosition = scriptposition;
     UniqueName = uniquename;
     Author = author;
     Title = title;
     Description = description;
     Function = function;
 }
Example #5
0
 internal CommandScript(ScriptPosition scriptposition, string uniquename, string author, string title, string description, Action function)
 {
     ScriptPosition = scriptposition;
     UniqueName = uniquename;
     Author = author;
     Title = title;
     Description = description;
     Function = function;
 }
Example #6
0
 internal ExportScript(ScriptPosition scriptposition, string uniquename, string author, string title, string description, string filter, Action<string> function)
 {
     ScriptPosition = scriptposition;
     UniqueName = uniquename;
     Author = author;
     Title = title;
     Description = description;
     Filter = filter;
     Function = function;
 }
 public ConsoleButtonString(EmueraConsole console, ConsoleStyledString[] strs, string inputs,ScriptPosition pos)
     : this(console, strs)
 {
     this.Inputs = inputs;
     IsButton = true;
     IsInteger = false;
     Generation = parent.NewButtonGeneration;
     console.UpdateGeneration();
     ErrPos = pos;
 }
Example #8
0
		public bool Contains(ScriptPosition position)
		{
			if (position == null)
				return false;

			ScriptPosition equivalentScriptPosition;
			if (this.position == NaryPositions.Lower)
				equivalentScriptPosition = new AbsoluteScriptPosition(Script.Sub.ToSingleton());
			else if (this.position == NaryPositions.Upper)
				equivalentScriptPosition = new AbsoluteScriptPosition(Script.Super.ToSingleton());
			else if (this.position == NaryPositions.Main)
				equivalentScriptPosition = new AbsoluteScriptPosition();
			else
				return false;

			return equivalentScriptPosition.Contains(position);
		}
Example #9
0
		/// <summary>
		///     Возвращает реальные скрипты н
		/// </summary>
		/// <param name="dialect"></param>
		/// <param name="position"></param>
		/// <param name="mode"></param>
		/// <returns></returns>
		public IEnumerable<SqlScript> GetRealScripts(DbDialect dialect, ScriptPosition position, ScriptMode mode){
			if (0 == SubScripts.Count){
				if (DbDialect == DbDialect.Ansi || dialect == DbDialect){
					if (Mode == mode){
						if (Position == position){
							yield return this;
						}
					}
				}
			}
			else{
				foreach (SqlScript subScript in SubScripts){
					foreach (SqlScript rs in subScript.GetRealScripts(dialect, position, mode)){
						yield return rs;
					}
				}
			}
		}
Example #10
0
        private void decideActualArraySize(ScriptPosition position)
        {
            _decideActualArraySize_sub(VariableCode.ABL, VariableCode.ABLNAME, CharacterIntArrayLength, position);
            _decideActualArraySize_sub(VariableCode.TALENT, VariableCode.TALENTNAME, CharacterIntArrayLength, position);
            _decideActualArraySize_sub(VariableCode.EXP, VariableCode.EXPNAME, CharacterIntArrayLength, position);
            _decideActualArraySize_sub(VariableCode.MARK, VariableCode.MARKNAME, CharacterIntArrayLength, position);
            _decideActualArraySize_sub(VariableCode.BASE, VariableCode.BASENAME, CharacterIntArrayLength, position);
            _decideActualArraySize_sub(VariableCode.SOURCE, VariableCode.SOURCENAME, CharacterIntArrayLength, position);
            _decideActualArraySize_sub(VariableCode.EX, VariableCode.EXNAME, CharacterIntArrayLength, position);
            _decideActualArraySize_sub(VariableCode.EQUIP, VariableCode.EQUIPNAME, CharacterIntArrayLength, position);
            _decideActualArraySize_sub(VariableCode.TEQUIP, VariableCode.TEQUIPNAME, CharacterIntArrayLength, position);
            _decideActualArraySize_sub(VariableCode.FLAG, VariableCode.FLAGNAME, VariableIntArrayLength, position);
            _decideActualArraySize_sub(VariableCode.TFLAG, VariableCode.TFLAGNAME, VariableIntArrayLength, position);
            _decideActualArraySize_sub(VariableCode.CFLAG, VariableCode.CFLAGNAME, CharacterIntArrayLength, position);
            _decideActualArraySize_sub(VariableCode.TCVAR, VariableCode.TCVARNAME, CharacterIntArrayLength, position);
            _decideActualArraySize_sub(VariableCode.CSTR, VariableCode.CSTRNAME, CharacterStrArrayLength, position);
            _decideActualArraySize_sub(VariableCode.STAIN, VariableCode.STAINNAME, CharacterIntArrayLength, position);
            _decideActualArraySize_sub(VariableCode.STR, VariableCode.STRNAME, VariableStrArrayLength, position);
            _decideActualArraySize_sub(VariableCode.TSTR, VariableCode.TSTRNAME, VariableStrArrayLength, position);
            _decideActualArraySize_sub(VariableCode.SAVESTR, VariableCode.SAVESTRNAME, VariableStrArrayLength, position);
            _decideActualArraySize_sub(VariableCode.GLOBAL, VariableCode.GLOBALNAME, VariableIntArrayLength, position);
            _decideActualArraySize_sub(VariableCode.GLOBALS, VariableCode.GLOBALSNAME, VariableStrArrayLength, position);

            //PALAM(JUEL込み)
            //PALAMNAMEが変わっていてかつPALAMかJUELが変わっているとき、
            if ((changedCode.Contains(VariableCode.PALAMNAME)) && (changedCode.Contains(VariableCode.PALAM) || changedCode.Contains(VariableCode.JUEL)))
            {
                int palamJuelMax = Math.Max(CharacterIntArrayLength[(int)(VariableCode.__LOWERCASE__ & VariableCode.PALAM)]
                        , CharacterIntArrayLength[(int)(VariableCode.__LOWERCASE__ & VariableCode.JUEL)]);

            }
            //PALAMかJUELが変わっていれば、そのうち大きい方にPALAMNAMEをあわせる
            if (changedCode.Contains(VariableCode.PALAM) || changedCode.Contains(VariableCode.JUEL))
            {
                int palamJuelMax = Math.Max(CharacterIntArrayLength[(int)(VariableCode.__LOWERCASE__ & VariableCode.PALAM)]
                        , CharacterIntArrayLength[(int)(VariableCode.__LOWERCASE__ & VariableCode.JUEL)]);
                //PALAMNAMEが変わっている
                if (changedCode.Contains(VariableCode.PALAMNAME))
                {
                    if (MaxDataList[paramIndex] != palamJuelMax)
                    {
                        int i = Math.Max(MaxDataList[paramIndex], palamJuelMax);
                        MaxDataList[paramIndex] = i;
                        if (CharacterIntArrayLength[(int)(VariableCode.__LOWERCASE__ & VariableCode.PALAM)] == palamJuelMax)
                            CharacterIntArrayLength[(int)(VariableCode.__LOWERCASE__ & VariableCode.PALAM)] = i;
                        if (CharacterIntArrayLength[(int)(VariableCode.__LOWERCASE__ & VariableCode.JUEL)] == palamJuelMax)
                            CharacterIntArrayLength[(int)(VariableCode.__LOWERCASE__ & VariableCode.JUEL)] = i;
                        //1803beta004 不適切な指定として警告Lv1の対象にする
                        ParserMediator.Warn("PALAMとJUELとPALAMNAMEの要素数が不適切です", position, 1);
                    }
                }
                else//PALAMNAMEの指定がないなら大きい方にPALAMNAMEをあわせる
                    MaxDataList[paramIndex] = palamJuelMax;
            }
            //PALAMとJUEL不変でPALAMNAMEが変わっている場合
            else if (changedCode.Contains(VariableCode.PALAMNAME))
            {
                //PALAMを想定のPALAMNAMEにあわせる
                CharacterIntArrayLength[(int)(VariableCode.__LOWERCASE__ & VariableCode.PALAM)] = MaxDataList[paramIndex];
                //想定のPALAMNAMEがJUELより小さければ警告出してJUELにあわせる
                if (MaxDataList[paramIndex] < CharacterIntArrayLength[(int)(VariableCode.__LOWERCASE__ & VariableCode.JUEL)])
                {
                    ParserMediator.Warn("PALAMNAMEの要素数がJUELより少なくなっています(JUELに合わせます)", position, 1);
                    MaxDataList[paramIndex] = CharacterIntArrayLength[(int)(VariableCode.__LOWERCASE__ & VariableCode.JUEL)];
                }
            }
            //CDFLAG
            //一部変更されたら双方変更されたと扱う
            bool cdflagNameLengthChanged = changedCode.Contains(VariableCode.CDFLAGNAME1) || changedCode.Contains(VariableCode.CDFLAGNAME2);
            int mainLengthIndex = (int)(VariableCode.__LOWERCASE__ & VariableCode.CDFLAG);
            Int64 length64 = CharacterIntArray2DLength[mainLengthIndex];
            int length1 = (int)(length64 >> 32);
            int length2 = (int)(length64 & 0x7FFFFFFF);
            if (changedCode.Contains(VariableCode.CDFLAG) && cdflagNameLengthChanged)
            {
                //調整が面倒なので投げる
                if ((length1 != MaxDataList[cdflag1Index]) || (length2 != MaxDataList[cdflag2Index]))
                    throw new CodeEE("CDFLAGの要素数とCDFLAGNAME1及びCDFLAGNAME2の要素数は一致していなければなりません", position);
            }
            else if (cdflagNameLengthChanged && !changedCode.Contains(VariableCode.CDFLAG))
            {
                length1 = MaxDataList[cdflag1Index];
                length2 = MaxDataList[cdflag2Index];
                if (length1 * length2 > 1000000)
                {
                    //調整が面倒なので投げる
                    throw new CodeEE("CDFLAGNAME1とCDFLAGNAME2の積が100万を超えています(CDFLAGの要素数が多すぎます)", position);
                }
                CharacterIntArray2DLength[mainLengthIndex] = (((Int64)length1) << 32) + ((Int64)length2);
            }
            else if (!cdflagNameLengthChanged && changedCode.Contains(VariableCode.CDFLAG))
            {
                MaxDataList[cdflag1Index] = length1;
                MaxDataList[cdflag2Index] = length2;
            }
            //もう使わないのでデータ破棄
            changedCode.Clear();
        }
Example #11
0
 private void _decideActualArraySize_sub(VariableCode mainCode, VariableCode nameCode, int[] arraylength, ScriptPosition position)
 {
     int nameIndex = (int)(nameCode & VariableCode.__LOWERCASE__);
     int mainLengthIndex = (int)(mainCode & VariableCode.__LOWERCASE__);
     if (changedCode.Contains(nameCode) && changedCode.Contains(mainCode))
     {
         if (MaxDataList[nameIndex] != arraylength[mainLengthIndex])
         {
             int i = Math.Max(MaxDataList[nameIndex], arraylength[mainLengthIndex]);
             arraylength[mainLengthIndex] = i;
             MaxDataList[nameIndex] = i;
             //1803beta004 不適切な指定として警告Lv1の対象にする
             ParserMediator.Warn(mainCode.ToString() + "と" + nameCode.ToString() + "の要素数が異なります(大きい方に合わせます)", position, 1);
         }
     }
     else if (changedCode.Contains(nameCode) && !changedCode.Contains(mainCode))
         arraylength[mainLengthIndex] = MaxDataList[nameIndex];
     else if (!changedCode.Contains(nameCode) && changedCode.Contains(mainCode))
         MaxDataList[nameIndex] = arraylength[mainLengthIndex];
 }
Example #12
0
 private void loadVariableSizeData(string csvPath, bool disp)
 {
     if (!File.Exists(csvPath))
         return;
     EraStreamReader eReader = new EraStreamReader();
     if (!eReader.Open(csvPath))
     {
         output.PrintError(eReader.Filename + "のオープンに失敗しました");
         return;
     }
     ScriptPosition position = null;
     if (disp)
         output.PrintLine(eReader.Filename + "読み込み中・・・");
     try
     {
         StringStream st = null;
         while ((st = eReader.ReadEnabledLine()) != null)
         {
             position = new ScriptPosition(eReader.Filename, eReader.LineNo, st.RowString);
             changeVariableSizeData(st.Substring(), position);
         }
         position = new ScriptPosition(eReader.Filename, -1, null);
     }
     catch
     {
         System.Media.SystemSounds.Hand.Play();
         if (position != null)
             ParserMediator.Warn("予期しないエラーが発生しました", position, 3);
         else
             output.PrintError("予期しないエラーが発生しました");
         return;
     }
     finally
     {
         eReader.Close();
     }
     decideActualArraySize(position);
 }
Example #13
0
 public static void Warn(string str, ScriptPosition pos, int level)
 {
     Warn(str, pos, level, null);
 }
Example #14
0
 /// <summary>
 /// emuera.config等で発生した警告
 /// Initializeより前に発生する
 /// </summary>
 /// <param name="str"></param>
 /// <param name="?"></param>
 public static void ConfigWarn(string str, ScriptPosition pos, int level, string stack)
 {
     if (level < Config.DisplayWarningLevel && !Program.AnalysisMode)
         return;
     warningList.Add(new ParserWarning(str, pos, level, stack));
 }
Example #15
0
        private bool loadHeaderFile(string filepath, string filename)
        {
            StringStream   st       = null;
            ScriptPosition position = null;
            //EraStreamReader eReader = new EraStreamReader(false);
            //1815修正 _rename.csvの適用
            //eramakerEXの仕様的には.ERHに適用するのはおかしいけど、もうEmueraの仕様になっちゃってるのでしかたないか
            EraStreamReader eReader = new EraStreamReader(true);

            if (!eReader.Open(filepath, filename))
            {
                throw new CodeEE(eReader.Filename + "のオープンに失敗しました");
                //return false;
            }
            try
            {
                while ((st = eReader.ReadEnabledLine()) != null)
                {
                    if (!noError)
                    {
                        return(false);
                    }
                    position = new ScriptPosition(filename, eReader.LineNo, st.RowString);
                    LexicalAnalyzer.SkipWhiteSpace(st);
                    if (st.Current != '#')
                    {
                        throw new CodeEE("ヘッダーの中に#で始まらない行があります", position);
                    }
                    st.ShiftNext();
                    string sharpID = LexicalAnalyzer.ReadSingleIdentifier(st);
                    if (sharpID == null)
                    {
                        ParserMediator.Warn("解釈できない#行です", position, 1);
                        return(false);
                    }
                    if (Config.ICFunction)
                    {
                        sharpID = sharpID.ToUpper();
                    }
                    LexicalAnalyzer.SkipWhiteSpace(st);
                    switch (sharpID)
                    {
                    case "DEFINE":
                        analyzeSharpDefine(st, position);
                        break;

                    case "FUNCTION":
                    case "FUNCTIONS":
                        analyzeSharpFunction(st, position, sharpID == "FUNCTIONS");
                        break;

                    case "DIM":
                    case "DIMS":
                        //1822 #DIMは保留しておいて後でまとめてやる
                    {
                        WordCollection wc = LexicalAnalyzer.Analyse(st, LexEndWith.EoL, LexAnalyzeFlag.AllowAssignment);
                        dimlines.Enqueue(new DimLineWC(wc, sharpID == "DIMS", false, position));
                    }
                        //analyzeSharpDim(st, position, sharpID == "DIMS");
                        break;

                    default:
                        throw new CodeEE("#" + sharpID + "は解釈できないプリプロセッサです", position);
                    }
                }
            }
            catch (CodeEE e)
            {
                if (e.Position != null)
                {
                    position = e.Position;
                }
                ParserMediator.Warn(e.Message, position, 2);
                return(false);
            }
            finally
            {
                eReader.Close();
            }
            return(true);
        }
Example #16
0
        private void handleException(Exception exc, LogicalLine current, bool playSound)
        {
            console.ThrowError(playSound);
            ScriptPosition  position = null;
            EmueraException ee       = exc as EmueraException;

            if ((ee != null) && (ee.Position != null))
            {
                position = ee.Position;
            }
            else if ((current != null) && (current.Position != null))
            {
                position = current.Position;
            }
            string posString = "";

            if (position != null)
            {
                if (position.LineNo >= 0)
                {
                    posString = position.Filename + "の" + position.LineNo.ToString() + "行目で";
                }
                else
                {
                    posString = position.Filename + "で";
                }
            }
            if (exc is CodeEE)
            {
                if (position != null)
                {
                    InstructionLine procline = current as InstructionLine;
                    if (procline != null && procline.FunctionCode == FunctionCode.THROW)
                    {
                        console.PrintErrorButton(posString + "THROWが発生しました", position);
                        if (position.RowLine != null)
                        {
                            console.PrintError(position.RowLine);
                        }
                        console.PrintError("THROW内容:" + exc.Message);
                    }
                    else
                    {
                        console.PrintErrorButton(posString + "エラーが発生しました:" + Program.ExeName, position);
                        if (position.RowLine != null)
                        {
                            console.PrintError(position.RowLine);
                        }
                        console.PrintError("エラー内容:" + exc.Message);
                    }
                    console.PrintError("現在の関数:@" + current.ParentLabelLine.LabelName + "(" + current.ParentLabelLine.Position.Filename + "の" + current.ParentLabelLine.Position.LineNo.ToString() + "行目)");
                    console.PrintError("関数呼び出しスタック:");
                    LogicalLine parent = null;
                    int         depth  = 0;
                    while ((parent = state.GetReturnAddressSequensial(depth++)) != null)
                    {
                        if (parent.Position != null)
                        {
                            console.PrintErrorButton("↑" + parent.Position.Filename + "の" + parent.Position.LineNo.ToString() + "行目(関数@" + parent.ParentLabelLine.LabelName + "内)", parent.Position);
                        }
                    }
                }
                else
                {
                    console.PrintError(posString + "エラーが発生しました:" + Program.ExeName);
                    console.PrintError(exc.Message);
                }
            }
            else if (exc is ExeEE)
            {
                console.PrintError(posString + "Emueraのエラーが発生しました:" + Program.ExeName);
                console.PrintError(exc.Message);
            }
            else
            {
                console.PrintError(posString + "予期しないエラーが発生しました:" + Program.ExeName);
                console.PrintError(exc.GetType().ToString() + ":" + exc.Message);
                string[] stack = exc.StackTrace.Split('\n');
                for (int i = 0; i < stack.Length; i++)
                {
                    console.PrintError(stack[i]);
                }
            }
        }
Example #17
0
        /// <summary>
        /// Creates an InformationalRecord from an instance serialized as a PSObject by ToPSObjectForRemoting.
        /// </summary>
        internal InvocationInfo(PSObject psObject)
        {
            CommandOrigin    = (CommandOrigin)SerializationUtilities.GetPsObjectPropertyBaseObject(psObject, "InvocationInfo_CommandOrigin");
            ExpectingInput   = (bool)SerializationUtilities.GetPropertyValue(psObject, "InvocationInfo_ExpectingInput");
            _invocationName  = (string)SerializationUtilities.GetPropertyValue(psObject, "InvocationInfo_InvocationName");
            HistoryId        = (long)SerializationUtilities.GetPropertyValue(psObject, "InvocationInfo_HistoryId");
            PipelineLength   = (int)SerializationUtilities.GetPropertyValue(psObject, "InvocationInfo_PipelineLength");
            PipelinePosition = (int)SerializationUtilities.GetPropertyValue(psObject, "InvocationInfo_PipelinePosition");

            string scriptName       = (string)SerializationUtilities.GetPropertyValue(psObject, "InvocationInfo_ScriptName");
            int    scriptLineNumber = (int)SerializationUtilities.GetPropertyValue(psObject, "InvocationInfo_ScriptLineNumber");
            int    offsetInLine     = (int)SerializationUtilities.GetPropertyValue(psObject, "InvocationInfo_OffsetInLine");
            string line             = (string)SerializationUtilities.GetPropertyValue(psObject, "InvocationInfo_Line");
            var    scriptPosition   = new ScriptPosition(scriptName, scriptLineNumber, offsetInLine, line);

            ScriptPosition scriptEndPosition;

            if (!string.IsNullOrEmpty(line))
            {
                int endColumn = line.Length + 1;
                scriptEndPosition = new ScriptPosition(scriptName, scriptLineNumber, endColumn, line);
            }
            else
            {
                scriptEndPosition = scriptPosition;
            }

            _scriptPosition = new ScriptExtent(scriptPosition, scriptEndPosition);

            MyCommand = RemoteCommandInfo.FromPSObjectForRemoting(psObject);

            //
            // Arrays are de-serialized as ArrayList so we need to convert the deserialized
            // object into an int[] before assigning to pipelineIterationInfo.
            //
            var list = (ArrayList)SerializationUtilities.GetPsObjectPropertyBaseObject(psObject, "InvocationInfo_PipelineIterationInfo");

            if (list != null)
            {
                PipelineIterationInfo = (int[])list.ToArray(typeof(int));
            }
            else
            {
                PipelineIterationInfo = Array.Empty <int>();
            }

            //
            // Dictionaries are de-serialized as Hashtables so we need to convert the deserialized object into a dictionary
            // before assigning to CommandLineParameters.
            //
            Hashtable hashtable = (Hashtable)SerializationUtilities.GetPsObjectPropertyBaseObject(psObject, "InvocationInfo_BoundParameters");

            Dictionary <string, object> dictionary = new Dictionary <string, object>();

            if (hashtable != null)
            {
                foreach (DictionaryEntry entry in hashtable)
                {
                    dictionary.Add((string)entry.Key, entry.Value);
                }
            }

            _boundParameters = dictionary;

            //
            // The unbound parameters are de-serialized as an ArrayList, which we need to convert to a List
            //
            var unboundArguments = (ArrayList)SerializationUtilities.GetPsObjectPropertyBaseObject(psObject, "InvocationInfo_UnboundArguments");

            _unboundArguments = new List <object>();

            if (unboundArguments != null)
            {
                foreach (object o in unboundArguments)
                {
                    _unboundArguments.Add(o);
                }
            }

            object value           = SerializationUtilities.GetPropertyValue(psObject, "SerializeExtent");
            bool   serializeExtent = false;

            if (value != null)
            {
                serializeExtent = (bool)value;
            }

            if (serializeExtent)
            {
                DisplayScriptPosition = ScriptExtent.FromPSObjectForRemoting(psObject);
            }
        }
    private void CheckFile(string file)
    {
        StreamReader sr = new StreamReader(file);

        string line = "";
        int    n    = 0;

        bool oneline = false;

        if (ss.Length == 1)
        {
            oneline = true;
        }

        List <string> total = new List <string>();

        while ((line = sr.ReadLine()) != null)
        {
            if (oneline)
            {
                n++;
                if (line.Contains(keyword))
                {
                    ScriptPosition sp = new ScriptPosition(file, n, line);
                    results.Add(sp);
                }
            }
            else
            {
                total.Add(line);
            }
        }

        if (oneline)
        {
            return;
        }

        while (n < total.Count)
        {
            line = total[n];
            if (LineEquals(line, ss[0], 0))
            {
                StringBuilder sb = new StringBuilder();
                sb.Append(line + "\r\n");

                int i = 1;
                for (; i < ss.Length - 1; i++)
                {
                    line = total[n + i];

                    // 文章读完
                    if (line == null)
                    {
                        break;
                    }

                    // 中间行不匹配
                    if (!LineEquals(line, ss[i], 2))
                    {
                        break;
                    }

                    // 都通过
                    sb.Append(line + "\r\n");
                }

                // 文章读完
                if (line == null)
                {
                    break;
                }
                // 中间行不对,回到读完第一行的起始
                if (i != ss.Length - 1)
                {
                    n++;
                }
                else
                {
                    line = total[n + i];

                    // 没有最后一行,文章结束,跳出大循环
                    if (line == null)
                    {
                        break;
                    }
                    // 最后一行不匹配
                    else if (!LineEquals(line, ss[i], 1))
                    {
                        n++;
                    }
                    // 最后一行匹配
                    else
                    {
                        sb.AppendLine(line);
                        ScriptPosition sp = new ScriptPosition(file, n + 1, sb.ToString());
                        results.Add(sp);
                        n += ss.Length;
                    }
                }
            }
            else
            {
                n++;
            }
        }
    }
Example #19
0
 public virtual void Call(ScriptPosition mode, string name, params object[] args)
 {
     this.CallTemplate(mode, XControl.CALLTEMPLATE, name, args);
 }
Example #20
0
 public virtual void Set(ScriptPosition position, string name, object value)
 {
     this.CallTemplate(position, XControl.SETEMPLATE, name, value);
 }
Example #21
0
        public static LogicalLine ParseLine(StringStream stream, ScriptPosition position, EmueraConsole console)
        {
            int    lineNo = position.LineNo;
            string errMes = "";

            LexicalAnalyzer.SkipWhiteSpace(stream);            //先頭のホワイトスペースを読み飛ばす
            if (stream.EOS)
            {
                return(null);
            }
            //コメント行かどうかはここに来る前に判定しておく
            try
            {
                #region 前置インクリメント、デクリメント行
                if (stream.Current == '+' || stream.Current == '-')
                {
                    char           op   = stream.Current;
                    WordCollection wc   = LexicalAnalyzer.Analyse(stream, LexEndWith.EoL, LexAnalyzeFlag.None);
                    OperatorWord   opWT = wc.Current as OperatorWord;
                    if ((opWT == null) || ((opWT.Code != OperatorCode.Increment) && (opWT.Code != OperatorCode.Decrement)))
                    {
                        if (op == '+')
                        {
                            errMes = "行が\'+\'から始まっていますが、インクリメントではありません";
                        }
                        else
                        {
                            errMes = "行が\'-\'から始まっていますが、デクリメントではありません";
                        }
                        goto err;
                    }
                    wc.ShiftNext();
                    //token = EpressionParser.単語一個分取得(wc)
                    //token非変数
                    //token文字列形
                    //token変更不可能
                    //if (wc != EOS)
                    //
                    return(new InstructionLine(position, FunctionIdentifier.SETFunction, opWT.Code, wc, null));
                }
                #endregion
                IdentifierWord idWT = LexicalAnalyzer.ReadFirstIdentifierWord(stream);
                if (idWT != null)
                {
                    FunctionIdentifier func = GlobalStatic.IdentifierDictionary.GetFunctionIdentifier(idWT.Code);
                    //命令文
                    if (func != null)                    //関数文
                    {
                        if (stream.EOS)                  //引数の無い関数
                        {
                            return(new InstructionLine(position, func, stream));
                        }
                        if ((stream.Current != ';') && (stream.Current != ' ') && (stream.Current != '\t') && (!Config.SystemAllowFullSpace || (stream.Current != ' ')))
                        {
                            if (stream.Current == ' ')
                            {
                                errMes = "命令で行が始まっていますが、命令の直後に半角スペース・タブ以外の文字が来ています(この警告はシステムオプション「" + Config.GetConfigName(ConfigCode.SystemAllowFullSpace) + "」により無視できます)";
                            }
                            else
                            {
                                errMes = "命令で行が始まっていますが、命令の直後に半角スペース・タブ以外の文字が来ています";
                            }
                            goto err;
                        }
                        stream.ShiftNext();
                        return(new InstructionLine(position, func, stream));
                    }
                }
                LexicalAnalyzer.SkipWhiteSpace(stream);
                if (stream.EOS)
                {
                    errMes = "解釈できない行です";
                    goto err;
                }
                //命令行ではない→代入行のはず
                stream.Seek(0, System.IO.SeekOrigin.Begin);
                OperatorCode   assignOP = OperatorCode.NULL;
                WordCollection wc1      = LexicalAnalyzer.Analyse(stream, LexEndWith.Operator, LexAnalyzeFlag.None);
                //if (idWT != null)
                //	wc1.Collection.Insert(0, idWT);
                try
                {
                    assignOP = LexicalAnalyzer.ReadAssignmentOperator(stream);
                }
                catch (CodeEE)
                {
                    errMes = "解釈できない行です";
                    goto err;
                }
                //eramaker互換警告
                //stream.Jump(-1);
                //if ((stream.Current != ' ') && (stream.Current != '\t'))
                //{
                //	errMes = "変数で行が始まっていますが、演算子の直前に半角スペースまたはタブがありません";
                //	goto err;
                //}
                //stream.ShiftNext();


                if (assignOP == OperatorCode.Equal)
                {
                    if (console != null)
                    {
                        ParserMediator.Warn("代入演算子に\"==\"が使われています", position, 0);
                    }
                    //"=="を代入文に使うのは本当はおかしいが結構使われているので仕様にする
                    assignOP = OperatorCode.Assignment;
                }
                return(new InstructionLine(position, FunctionIdentifier.SETFunction, assignOP, wc1, stream));

err:
                return(new InvalidLine(position, errMes));
            }
            catch (CodeEE e)
            {
                uEmuera.Media.SystemSounds.Hand.Play();
                return(new InvalidLine(position, e.Message));
            }
        }
Example #22
0
        public static LogicalLine ParseLabelLine(StringStream stream, ScriptPosition position, EmueraConsole console)
        {
            bool   isFunction = (stream.Current == '@');
            int    lineNo     = position.LineNo;
            string labelName  = "";
            string errMes     = "";

            try
            {
                int warnLevel = -1;
                stream.ShiftNext();//@か$を除去
                WordCollection wc = LexicalAnalyzer.Analyse(stream, LexEndWith.EoL, LexAnalyzeFlag.AllowAssignment);
                if (wc.EOL || !(wc.Current is IdentifierWord))
                {
                    errMes = "関数名が不正であるか存在しません";
                    goto err;
                }
                labelName = ((IdentifierWord)wc.Current).Code;
                wc.ShiftNext();
                if (Config.ICVariable)
                {
                    labelName = labelName.ToUpper();
                }
                GlobalStatic.IdentifierDictionary.CheckUserLabelName(ref errMes, ref warnLevel, isFunction, labelName);
                if (warnLevel >= 0)
                {
                    if (warnLevel >= 2)
                    {
                        goto err;
                    }
                    ParserMediator.Warn(errMes, position, warnLevel);
                }
                if (!isFunction)                //$ならこの時点で終了
                {
                    if (!wc.EOL)
                    {
                        ParserMediator.Warn("$で始まるラベルに引数が設定されています", position, 1);
                    }
                    return(new GotoLabelLine(position, labelName));
                }



                //labelName = LexicalAnalyzer.ReadString(stream, StrEndWith.LeftParenthesis_Bracket_Comma_Semicolon);
                //labelName = labelName.Trim();
                //if (Config.ICVariable)
                //    labelName = labelName.ToUpper();
                //GlobalStatic.IdentifierDictionary.CheckUserLabelName(ref errMes, ref warnLevel, isFunction, labelName);
                //if(warnLevel >= 0)
                //{
                //    if (warnLevel >= 2)
                //        goto err;
                //    ParserMediator.Warn(errMes, position, warnLevel);
                //}
                //if (!isFunction)//$ならこの時点で終了
                //{
                //    LexicalAnalyzer.SkipWhiteSpace(stream);
                //    if (!stream.EOS)
                //        ParserMediator.Warn("$で始まるラベルに引数が設定されています", position, 1);
                //    return new GotoLabelLine(position, labelName);
                //}

                ////関数名部分に_renameを使えないように変更
                //if (ParserMediator.RenameDic != null && ((stream.ToString().IndexOf("[[") >= 0) && (stream.ToString().IndexOf("]]") >= 0)))
                //{
                //    string line = stream.ToString();
                //    foreach (KeyValuePair<string, string> pair in ParserMediator.RenameDic)
                //        line = line.Replace(pair.Key, pair.Value);
                //    stream = new StringStream(line);
                //}
                //WordCollection wc = null;
                //wc = LexicalAnalyzer.Analyse(stream, LexEndWith.EoL, LexAnalyzeFlag.AllowAssignment);
                if (Program.AnalysisMode)
                {
                    console.PrintC("@" + labelName, false);
                }
                FunctionLabelLine funclabelLine = new FunctionLabelLine(position, labelName, wc);
                if (IdentifierDictionary.IsEventLabelName(labelName))
                {
                    funclabelLine.IsEvent  = true;
                    funclabelLine.IsSystem = true;
                    funclabelLine.Depth    = 0;
                }
                else if (IdentifierDictionary.IsSystemLabelName(labelName))
                {
                    funclabelLine.IsSystem = true;
                    funclabelLine.Depth    = 0;
                }
                return(funclabelLine);
            }
            catch (CodeEE e)
            {
                errMes = e.Message;
            }
err:
            uEmuera.Media.SystemSounds.Hand.Play();
            if (isFunction)
            {
                if (labelName.Length == 0)
                {
                    labelName = "<Error>";
                }
                return(new InvalidLabelLine(position, labelName, errMes));
            }
            return(new InvalidLine(position, errMes));
        }
Example #23
0
        public static bool ParseSharpLine(FunctionLabelLine label, StringStream st, ScriptPosition position, List <string> OnlyLabel)
        {
            st.ShiftNext();                                          //'#'を飛ばす
            string token = LexicalAnalyzer.ReadSingleIdentifier(st); //#~自体にはマクロ非適用

            if (Config.ICFunction)
            {
                token = token.ToUpper();
            }
            //#行として不正な行でもAnalyzeに行って引っかかることがあるので、先に存在しない#~は弾いてしまう
            if (token == null || (token != "SINGLE" && token != "LATER" && token != "PRI" && token != "ONLY" && token != "FUNCTION" && token != "FUNCTIONS" &&
                                  token != "LOCALSIZE" && token != "LOCALSSIZE" && token != "DIM" && token != "DIMS"))
            {
                ParserMediator.Warn("解釈できない#行です", position, 1);
                return(false);
            }
            try
            {
                WordCollection wc = LexicalAnalyzer.Analyse(st, LexEndWith.EoL, LexAnalyzeFlag.AllowAssignment);
                switch (token)
                {
                case "SINGLE":
                    if (label.IsMethod)
                    {
                        ParserMediator.Warn("式中関数では#SINGLEは機能しません", position, 1);
                        break;
                    }
                    else if (!label.IsEvent)
                    {
                        ParserMediator.Warn("イベント関数以外では#SINGLEは機能しません", position, 1);
                        break;
                    }
                    else if (label.IsSingle)
                    {
                        ParserMediator.Warn("#SINGLEが重複して使われています", position, 1);
                        break;
                    }
                    else if (label.IsOnly)
                    {
                        ParserMediator.Warn("#ONLYが指定されたイベント関数では#SINGLEは機能しません", position, 1);
                        break;
                    }
                    label.IsSingle = true;
                    break;

                case "LATER":
                    if (label.IsMethod)
                    {
                        ParserMediator.Warn("式中関数では#LATERは機能しません", position, 1);
                        break;
                    }
                    else if (!label.IsEvent)
                    {
                        ParserMediator.Warn("イベント関数以外では#LATERは機能しません", position, 1);
                        break;
                    }
                    else if (label.IsLater)
                    {
                        ParserMediator.Warn("#LATERが重複して使われています", position, 1);
                        break;
                    }
                    else if (label.IsOnly)
                    {
                        ParserMediator.Warn("#ONLYが指定されたイベント関数では#LATERは機能しません", position, 1);
                        break;
                    }
                    else if (label.IsPri)
                    {
                        ParserMediator.Warn("#PRIと#LATERが重複して使われています(この関数は2度呼ばれます)", position, 1);
                    }
                    label.IsLater = true;
                    break;

                case "PRI":
                    if (label.IsMethod)
                    {
                        ParserMediator.Warn("式中関数では#PRIは機能しません", position, 1);
                        break;
                    }
                    else if (!label.IsEvent)
                    {
                        ParserMediator.Warn("イベント関数以外では#PRIは機能しません", position, 1);
                        break;
                    }
                    else if (label.IsPri)
                    {
                        ParserMediator.Warn("#PRIが重複して使われています", position, 1);
                        break;
                    }
                    else if (label.IsOnly)
                    {
                        ParserMediator.Warn("#ONLYが指定されたイベント関数では#PRIは機能しません", position, 1);
                        break;
                    }
                    else if (label.IsLater)
                    {
                        ParserMediator.Warn("#PRIと#LATERが重複して使われています(この関数は2度呼ばれます)", position, 1);
                    }
                    label.IsPri = true;
                    break;

                case "ONLY":
                    if (label.IsMethod)
                    {
                        ParserMediator.Warn("式中関数では#ONLYは機能しません", position, 1);
                        break;
                    }
                    else if (!label.IsEvent)
                    {
                        ParserMediator.Warn("イベント関数以外では#ONLYは機能しません", position, 1);
                        break;
                    }
                    else if (label.IsOnly)
                    {
                        ParserMediator.Warn("#ONLYが重複して使われています", position, 1);
                        break;
                    }
                    else if (OnlyLabel.Contains(label.LabelName))
                    {
                        ParserMediator.Warn("このイベント関数\"@" + label.LabelName + "\"にはすでに#ONLYが宣言されています(この関数は実行されません)", position, 1);
                    }
                    OnlyLabel.Add(label.LabelName);
                    label.IsOnly = true;
                    if (label.IsPri)
                    {
                        ParserMediator.Warn("このイベント関数には#PRIが宣言されていますが無視されます", position, 1);
                        label.IsPri = false;
                    }
                    if (label.IsLater)
                    {
                        ParserMediator.Warn("このイベント関数には#LATERが宣言されていますが無視されます", position, 1);
                        label.IsLater = false;
                    }
                    if (label.IsSingle)
                    {
                        ParserMediator.Warn("このイベント関数には#SINGLEが宣言されていますが無視されます", position, 1);
                        label.IsSingle = false;
                    }
                    break;

                case "FUNCTION":
                case "FUNCTIONS":
                    if (!string.IsNullOrEmpty(label.LabelName) && char.IsDigit(label.LabelName[0]))
                    {
                        ParserMediator.Warn("#" + token + "属性は関数名が数字で始まる関数には指定できません", position, 1);
                        label.IsError = true;
                        label.ErrMes  = "関数名が数字で始まっています";
                        break;
                    }
                    if (label.IsMethod)
                    {
                        if ((label.MethodType == typeof(Int64) && token == "FUNCTION") || (label.MethodType == typeof(string) && token == "FUNCTIONS"))
                        {
                            ParserMediator.Warn("関数" + label.LabelName + "にはすでに#" + token + "が宣言されています(この行は無視されます)", position, 1);
                            return(false);
                        }
                        if (label.MethodType == typeof(Int64) && token == "FUNCTIONS")
                        {
                            ParserMediator.Warn("関数" + label.LabelName + "にはすでに#FUNCTIONが宣言されています", position, 2);
                        }
                        else if (label.MethodType == typeof(string) && token == "FUNCTION")
                        {
                            ParserMediator.Warn("関数" + label.LabelName + "にはすでに#FUNCTIONSが宣言されています", position, 2);
                        }
                        return(false);
                    }
                    if (label.Depth == 0)
                    {
                        ParserMediator.Warn("システム関数に#" + token + "が指定されています", position, 2);
                        return(false);
                    }
                    label.IsMethod = true;
                    label.Depth    = 0;
                    if (token == "FUNCTIONS")
                    {
                        label.MethodType = typeof(string);
                    }
                    else
                    {
                        label.MethodType = typeof(Int64);
                    }
                    if (label.IsPri)
                    {
                        ParserMediator.Warn("式中関数では#PRIは機能しません", position, 1);
                        label.IsPri = false;
                    }
                    if (label.IsLater)
                    {
                        ParserMediator.Warn("式中関数では#LATERは機能しません", position, 1);
                        label.IsLater = false;
                    }
                    if (label.IsSingle)
                    {
                        ParserMediator.Warn("式中関数では#SINGLEは機能しません", position, 1);
                        label.IsSingle = false;
                    }
                    if (label.IsOnly)
                    {
                        ParserMediator.Warn("式中関数では#ONLYは機能しません", position, 1);
                        label.IsOnly = false;
                    }
                    break;

                case "LOCALSIZE":
                case "LOCALSSIZE":
                {
                    if (wc.EOL)
                    {
                        ParserMediator.Warn("#" + token + "の後に有効な数値が指定されていません", position, 2);
                        break;
                    }
                    //イベント関数では指定しても無視される
                    if (label.IsEvent)
                    {
                        ParserMediator.Warn("イベント関数では#" + token + "による" + token.Substring(0, token.Length - 4) + "のサイズ指定は無視されます", position, 1);
                        break;
                    }
                    IOperandTerm arg      = ExpressionParser.ReduceIntegerTerm(wc, TermEndWith.EoL);
                    SingleTerm   sizeTerm = arg.Restructure(null) as SingleTerm;
                    if ((sizeTerm == null) || (sizeTerm.GetOperandType() != typeof(Int64)))
                    {
                        ParserMediator.Warn("#" + token + "の後に有効な定数式が指定されていません", position, 2);
                        break;
                    }
                    if (sizeTerm.Int <= 0)
                    {
                        ParserMediator.Warn("#" + token + "に0以下の値(" + sizeTerm.Int.ToString() + ")が与えられました。設定は無視されます", position, 1);
                        break;
                    }
                    if (sizeTerm.Int >= Int32.MaxValue)
                    {
                        ParserMediator.Warn("#" + token + "に大きすぎる値(" + sizeTerm.Int.ToString() + ")が与えられました。設定は無視されます", position, 1);
                        break;
                    }
                    int size = (int)sizeTerm.Int;
                    if (token == "LOCALSIZE")
                    {
                        if (GlobalStatic.IdentifierDictionary.getLocalIsForbid("LOCAL"))
                        {
                            ParserMediator.Warn("#" + token + "が指定されていますが変数LOCALは使用禁止されています", position, 2);
                            break;
                        }
                        if (label.LocalLength > 0)
                        {
                            ParserMediator.Warn("この関数にはすでに#LOCALSIZEが定義されています。(以前の定義は無視されます)", position, 1);
                        }
                        label.LocalLength = size;
                    }
                    else
                    {
                        if (GlobalStatic.IdentifierDictionary.getLocalIsForbid("LOCALS"))
                        {
                            ParserMediator.Warn("#" + token + "が指定されていますが変数LOCALSは使用禁止されています", position, 2);
                            break;
                        }
                        if (label.LocalsLength > 0)
                        {
                            ParserMediator.Warn("この関数にはすでに#LOCALSSIZEが定義されています。(以前の定義は無視されます)", position, 1);
                        }
                        label.LocalsLength = size;
                    }
                }
                break;

                case "DIM":
                case "DIMS":
                {
                    UserDefinedVariableData data = UserDefinedVariableData.Create(wc, token == "DIMS", true, position);
                    if (!label.AddPrivateVariable(data))
                    {
                        ParserMediator.Warn("変数名" + data.Name + "は既に使用されています", position, 2);
                        return(false);
                    }
                    break;
                }

                default:
                    ParserMediator.Warn("解釈できない#行です", position, 1);
                    break;
                }
                if (!wc.EOL)
                {
                    ParserMediator.Warn("#の識別子の後に余分な文字があります", position, 1);
                }
            }
            catch (Exception e)
            {
                ParserMediator.Warn(e.Message, position, 2);
                goto err;
            }
            return(true);

err:
            return(false);
        }
Example #24
0
        private void loadDataTo(string csvPath, int targetIndex, Int64[] targetI, bool disp)
        {
            if (!File.Exists(csvPath))
                return;
            string[] target = names[targetIndex];
            List<int> defined = new List<int>();
            EraStreamReader eReader = new EraStreamReader();
            if (!eReader.Open(csvPath))
            {
                output.PrintError(eReader.Filename + "のオープンに失敗しました");
                return;
            }
            ScriptPosition position = null;

            if (disp || Program.AnalysisMode)
                output.PrintLine(eReader.Filename + "読み込み中・・・");
            try
            {
                StringStream st = null;
                while ((st = eReader.ReadEnabledLine()) != null)
                {
                    position = new ScriptPosition(eReader.Filename, eReader.LineNo, st.RowString);
                    string[] tokens = st.Substring().Split(',');
                    if (tokens.Length < 2)
                    {
                        ParserMediator.Warn("\",\"が必要です", position, 1);
                        continue;
                    }
                    int index = 0;
                    if (!Int32.TryParse(tokens[0], out index))
                    {
                        ParserMediator.Warn("一つ目の値を整数値に変換できません", position, 1);
                        continue;
                    }
                    if ((index < 0) || (target.Length <= index))
                    {
                        ParserMediator.Warn(index.ToString() + "は配列の範囲外です", position, 1);
                        continue;
                    }
                    if (defined.Contains(index))
                        ParserMediator.Warn(index.ToString() + "番目の要素はすでに定義されています(新しい値で上書きされます)", position, 1);
                    else
                        defined.Add(index);
                    target[index] = tokens[1];
                    if ((targetI != null) && (tokens.Length >= 3))
                    {
                        Int64 price;

                        if (!Int64.TryParse(tokens[2].TrimEnd(), out price))
                        {
                            ParserMediator.Warn("金額が読み取れません", position, 1);
                            continue;
                        }

                        targetI[index] = price;
                    }
                }
            }
            catch
            {
                System.Media.SystemSounds.Hand.Play();
                if (position != null)
                    ParserMediator.Warn("予期しないエラーが発生しました", position, 3);
                else
                    output.PrintError("予期しないエラーが発生しました");
                return;
            }
            finally
            {
                eReader.Close();
            }
        }
Example #25
0
 public virtual void Call(ScriptPosition mode, string name, params object[] args)
 {
     this.CallTemplate(mode, XControl.CALLTEMPLATE, name, args);
 }
Example #26
0
        public static UserDefinedVariableData Create(WordCollection wc, bool dims, bool isPrivate, ScriptPosition sc)
        {
            var dimtype = dims ? "#DIM" : "#DIMS";
            var ret     = new UserDefinedVariableData();

            ret.TypeIsStr = dims;

            IdentifierWord idw           = null;
            var            staticDefined = false;

            ret.Const = false;
            var keyword  = dimtype;
            var keywords = new List <string>();

            while (!wc.EOL && (idw = wc.Current as IdentifierWord) != null)
            {
                wc.ShiftNext();
                keyword = idw.Code;
                if (Config.ICVariable)
                {
                    keyword = keyword.ToUpper();
                }
                //TODO ifの数があたまわるい なんとかしたい
                switch (keyword)
                {
                case "CONST":
                    if (ret.CharaData)
                    {
                        throw new CodeEE(keyword + "とCHARADATAキーワードは同時に指定できません", sc);
                    }
                    if (ret.Global)
                    {
                        throw new CodeEE(keyword + "とGLOBALキーワードは同時に指定できません", sc);
                    }
                    if (ret.Save)
                    {
                        throw new CodeEE(keyword + "とSAVEDATAキーワードは同時に指定できません", sc);
                    }
                    if (ret.Reference)
                    {
                        throw new CodeEE(keyword + "とREFキーワードは同時に指定できません", sc);
                    }
                    if (!ret.Static)
                    {
                        throw new CodeEE(keyword + "とDYNAMICキーワードは同時に指定できません", sc);
                    }
                    if (ret.Const)
                    {
                        throw new CodeEE(keyword + "キーワードが二重に指定されています", sc);
                    }
                    ret.Const = true;
                    break;

                case "REF":
                    //throw new CodeEE("未実装の機能です", sc);
                    //if (!isPrivate)
                    //	throw new CodeEE("広域変数の宣言に" + keyword + "キーワードは指定できません", sc);
                    if (staticDefined && ret.Static)
                    {
                        throw new CodeEE(keyword + "とSTATICキーワードは同時に指定できません", sc);
                    }
                    if (ret.CharaData)
                    {
                        throw new CodeEE(keyword + "とCHARADATAキーワードは同時に指定できません", sc);
                    }
                    if (ret.Global)
                    {
                        throw new CodeEE(keyword + "とGLOBALキーワードは同時に指定できません", sc);
                    }
                    if (ret.Save)
                    {
                        throw new CodeEE(keyword + "とSAVEDATAキーワードは同時に指定できません", sc);
                    }
                    if (ret.Const)
                    {
                        throw new CodeEE(keyword + "とCONSTキーワードは同時に指定できません", sc);
                    }
                    if (ret.Reference)
                    {
                        throw new CodeEE(keyword + "キーワードが二重に指定されています", sc);
                    }
                    ret.Reference = true;
                    ret.Static    = true;
                    break;

                case "DYNAMIC":
                    if (!isPrivate)
                    {
                        throw new CodeEE("広域変数の宣言に" + keyword + "キーワードは指定できません", sc);
                    }
                    if (ret.CharaData)
                    {
                        throw new CodeEE(keyword + "とCHARADATAキーワードは同時に指定できません", sc);
                    }
                    if (ret.Const)
                    {
                        throw new CodeEE(keyword + "とCONSTキーワードは同時に指定できません", sc);
                    }
                    if (staticDefined)
                    {
                        if (ret.Static)
                        {
                            throw new CodeEE("STATICとDYNAMICキーワードは同時に指定できません", sc);
                        }
                        else
                        {
                            throw new CodeEE(keyword + "キーワードが二重に指定されています", sc);
                        }
                    }
                    staticDefined = true;
                    ret.Static    = false;
                    break;

                case "STATIC":
                    if (!isPrivate)
                    {
                        throw new CodeEE("広域変数の宣言に" + keyword + "キーワードは指定できません", sc);
                    }
                    if (ret.CharaData)
                    {
                        throw new CodeEE(keyword + "とCHARADATAキーワードは同時に指定できません", sc);
                    }
                    if (staticDefined)
                    {
                        if (!ret.Static)
                        {
                            throw new CodeEE("STATICとDYNAMICキーワードは同時に指定できません", sc);
                        }
                        else
                        {
                            throw new CodeEE(keyword + "キーワードが二重に指定されています", sc);
                        }
                    }
                    if (ret.Reference)
                    {
                        throw new CodeEE(keyword + "とREFキーワードは同時に指定できません", sc);
                    }
                    staticDefined = true;
                    ret.Static    = true;
                    break;

                case "GLOBAL":
                    if (isPrivate)
                    {
                        throw new CodeEE("ローカル変数の宣言に" + keyword + "キーワードは指定できません", sc);
                    }
                    if (ret.CharaData)
                    {
                        throw new CodeEE(keyword + "とCHARADATAキーワードは同時に指定できません", sc);
                    }
                    if (ret.Reference)
                    {
                        throw new CodeEE(keyword + "とREFキーワードは同時に指定できません", sc);
                    }
                    if (ret.Const)
                    {
                        throw new CodeEE(keyword + "とCONSTキーワードは同時に指定できません", sc);
                    }
                    if (staticDefined)
                    {
                        if (ret.Static)
                        {
                            throw new CodeEE("STATICとGLOBALキーワードは同時に指定できません", sc);
                        }
                        else
                        {
                            throw new CodeEE("DYNAMICとGLOBALキーワードは同時に指定できません", sc);
                        }
                    }
                    ret.Global = true;
                    break;

                case "SAVEDATA":
                    if (isPrivate)
                    {
                        throw new CodeEE("ローカル変数の宣言に" + keyword + "キーワードは指定できません", sc);
                    }
                    if (staticDefined)
                    {
                        if (ret.Static)
                        {
                            throw new CodeEE("STATICとSAVEDATAキーワードは同時に指定できません", sc);
                        }
                        else
                        {
                            throw new CodeEE("DYNAMICとSAVEDATAキーワードは同時に指定できません", sc);
                        }
                    }
                    if (ret.Reference)
                    {
                        throw new CodeEE(keyword + "とREFキーワードは同時に指定できません", sc);
                    }
                    if (ret.Const)
                    {
                        throw new CodeEE(keyword + "とCONSTキーワードは同時に指定できません", sc);
                    }
                    if (ret.Save)
                    {
                        throw new CodeEE(keyword + "キーワードが二重に指定されています", sc);
                    }
                    ret.Save = true;
                    break;

                case "CHARADATA":
                    if (isPrivate)
                    {
                        throw new CodeEE("ローカル変数の宣言に" + keyword + "キーワードは指定できません", sc);
                    }
                    if (ret.Reference)
                    {
                        throw new CodeEE(keyword + "とREFキーワードは同時に指定できません", sc);
                    }
                    if (ret.Const)
                    {
                        throw new CodeEE(keyword + "とCONSTキーワードは同時に指定できません", sc);
                    }
                    if (staticDefined)
                    {
                        if (ret.Static)
                        {
                            throw new CodeEE(keyword + "とSTATICキーワードは同時に指定できません", sc);
                        }
                        else
                        {
                            throw new CodeEE(keyword + "とDYNAMICキーワードは同時に指定できません", sc);
                        }
                    }
                    if (ret.Global)
                    {
                        throw new CodeEE(keyword + "とGLOBALキーワードは同時に指定できません", sc);
                    }
                    if (ret.CharaData)
                    {
                        throw new CodeEE(keyword + "キーワードが二重に指定されています", sc);
                    }
                    ret.CharaData = true;
                    break;

                default:
                    ret.Name = keyword;
                    goto whilebreak;
                }
            }
whilebreak:
            if (ret.Name == null)
            {
                throw new CodeEE(keyword + "の後に有効な変数名が指定されていません", sc);
            }
            var errMes   = "";
            var errLevel = -1;

            if (isPrivate)
            {
                GlobalStatic.IdentifierDictionary.CheckUserPrivateVarName(ref errMes, ref errLevel, ret.Name);
            }
            else
            {
                GlobalStatic.IdentifierDictionary.CheckUserVarName(ref errMes, ref errLevel, ret.Name);
            }
            if (errLevel >= 0)
            {
                if (errLevel >= 2)
                {
                    throw new CodeEE(errMes, sc);
                }
                ParserMediator.Warn(errMes, sc, errLevel);
            }


            var sizeNum = new List <int>();

            if (wc.EOL) //サイズ省略
            {
                if (ret.Const)
                {
                    throw new CodeEE("CONSTキーワードが指定されていますが初期値が設定されていません");
                }
                sizeNum.Add(1);
            }
            else if (wc.Current.Type == ',') //サイズ指定
            {
                while (!wc.EOL)
                {
                    if (wc.Current.Type == '=') //サイズ指定解読完了&初期値指定
                    {
                        break;
                    }
                    if (wc.Current.Type != ',')
                    {
                        throw new CodeEE("書式が間違っています", sc);
                    }
                    wc.ShiftNext();
                    if (ret.Reference) //参照型の場合は要素数不要
                    {
                        sizeNum.Add(0);
                        if (wc.EOL)
                        {
                            break;
                        }
                        if (wc.Current.Type == ',')
                        {
                            continue;
                        }
                    }
                    if (wc.EOL)
                    {
                        throw new CodeEE("カンマの後に有効な定数式が指定されていません", sc);
                    }
                    var arg      = ExpressionParser.ReduceIntegerTerm(wc, TermEndWith.Comma_Assignment);
                    var sizeTerm = arg.Restructure(null) as SingleTerm;
                    if (sizeTerm == null || sizeTerm.GetOperandType() != typeof(long))
                    {
                        throw new CodeEE("カンマの後に有効な定数式が指定されていません", sc);
                    }
                    if (ret.Reference) //参照型には要素数指定不可(0にするか書かないかどっちか
                    {
                        if (sizeTerm.Int != 0)
                        {
                            throw new CodeEE("参照型変数にはサイズを指定できません(サイズを省略するか0を指定してください)", sc);
                        }

                        continue;
                    }
                    if (sizeTerm.Int <= 0 || sizeTerm.Int > 1000000)
                    {
                        throw new CodeEE("ユーザー定義変数のサイズは1以上1000000以下でなければなりません", sc);
                    }
                    sizeNum.Add((int)sizeTerm.Int);
                }
            }


            if (wc.Current.Type != '=') //初期値指定なし
            {
                if (ret.Const)
                {
                    throw new CodeEE("CONSTキーワードが指定されていますが初期値が設定されていません");
                }
            }
            else //初期値指定あり
            {
                if (((OperatorWord)wc.Current).Code != OperatorCode.Assignment)
                {
                    throw new CodeEE("予期しない演算子を発見しました");
                }
                if (ret.Reference)
                {
                    throw new CodeEE("参照型変数には初期値を設定できません");
                }
                if (sizeNum.Count >= 2)
                {
                    throw new CodeEE("多次元変数には初期値を設定できません");
                }
                if (ret.CharaData)
                {
                    throw new CodeEE("キャラ型変数には初期値を設定できません");
                }
                var size = 0;
                if (sizeNum.Count == 1)
                {
                    size = sizeNum[0];
                }
                wc.ShiftNext();
                var terms = ExpressionParser.ReduceArguments(wc, ArgsEndWith.EoL, false);
                if (terms.Length == 0)
                {
                    throw new CodeEE("配列の初期値は省略できません");
                }
                if (size > 0)
                {
                    if (terms.Length > size)
                    {
                        throw new CodeEE("初期値の数が配列のサイズを超えています");
                    }
                    if (ret.Const && terms.Length != size)
                    {
                        throw new CodeEE("定数の初期値の数が配列のサイズと一致しません");
                    }
                }
                if (dims)
                {
                    ret.DefaultStr = new string[terms.Length];
                }
                else
                {
                    ret.DefaultInt = new long[terms.Length];
                }

                for (var i = 0; i < terms.Length; i++)
                {
                    if (terms[i] == null)
                    {
                        throw new CodeEE("配列の初期値は省略できません");
                    }
                    terms[i] = terms[i].Restructure(GlobalStatic.EMediator);
                    var sTerm = terms[i] as SingleTerm;
                    if (sTerm == null)
                    {
                        throw new CodeEE("配列の初期値には定数のみ指定できます");
                    }
                    if (dims != sTerm.IsString)
                    {
                        throw new CodeEE("変数の型と初期値の型が一致していません");
                    }
                    if (dims)
                    {
                        ret.DefaultStr[i] = sTerm.Str;
                    }
                    else
                    {
                        ret.DefaultInt[i] = sTerm.Int;
                    }
                }
                if (sizeNum.Count == 0)
                {
                    sizeNum.Add(terms.Length);
                }
            }
            if (!wc.EOL)
            {
                throw new CodeEE("書式が間違っています", sc);
            }

            if (sizeNum.Count == 0)
            {
                sizeNum.Add(1);
            }

            ret.Private   = isPrivate;
            ret.Dimension = sizeNum.Count;
            if (ret.Const && ret.Dimension > 1)
            {
                throw new CodeEE("CONSTキーワードが指定された変数を多次元配列にはできません");
            }
            if (ret.CharaData && ret.Dimension > 2)
            {
                throw new CodeEE("3次元以上のキャラ型変数を宣言することはできません", sc);
            }
            if (ret.Dimension > 3)
            {
                throw new CodeEE("4次元以上の配列変数を宣言することはできません", sc);
            }
            ret.Lengths = new int[sizeNum.Count];
            if (ret.Reference)
            {
                return(ret);
            }
            long totalBytes = 1;

            for (var i = 0; i < sizeNum.Count; i++)
            {
                ret.Lengths[i] = sizeNum[i];
                totalBytes    *= ret.Lengths[i];
            }
            if (totalBytes <= 0 || totalBytes > 1000000)
            {
                throw new CodeEE("ユーザー定義変数のサイズは1以上1000000以下でなければなりません", sc);
            }
            if (!isPrivate && ret.Save && !Config.SystemSaveInBinary)
            {
                if (dims && ret.Dimension > 1)
                {
                    throw new CodeEE("文字列型の多次元配列変数にSAVEDATAフラグを付ける場合には「バイナリ型セーブ」オプションが必須です", sc);
                }
                else if (ret.CharaData)
                {
                    throw new CodeEE("キャラ型変数にSAVEDATAフラグを付ける場合には「バイナリ型セーブ」オプションが必須です", sc);
                }
            }
            return(ret);
        }
Example #27
0
 public static void Warn(string str, ScriptPosition pos, int level, string stack)
 {
     if (level < Config.DisplayWarningLevel && !Program.AnalysisMode)
         return;
     if (console != null && !console.RunERBFromMemory)
         warningList.Add(new ParserWarning(str, pos, level, stack));
 }
Example #28
0
        //#define FOO (~~)     id to wc
        //#define BAR($1) (~~)     idwithargs to wc(replaced)
        //#diseble FOOBAR
        //#dim piyo, i
        //#dims puyo, j
        //static List<string> keywordsList = new List<string>();

        private void analyzeSharpDefine(StringStream st, ScriptPosition position)
        {
            //LexicalAnalyzer.SkipWhiteSpace(st);呼び出し前に行う。
            string srcID = LexicalAnalyzer.ReadSingleIdentifier(st);

            if (srcID == null)
            {
                throw new CodeEE("置換元の識別子がありません", position);
            }
            if (Config.ICVariable)
            {
                srcID = srcID.ToUpper();
            }

            //ここで名称重複判定しないと、大変なことになる
            string errMes   = "";
            int    errLevel = -1;

            idDic.CheckUserMacroName(ref errMes, ref errLevel, srcID);
            if (errLevel >= 0)
            {
                ParserMediator.Warn(errMes, position, errLevel);
                if (errLevel >= 2)
                {
                    noError = false;
                    return;
                }
            }

            bool hasArg = st.Current == '(';//引数を指定する場合には直後に(が続いていなければならない。ホワイトスペースも禁止。
            //1808a3 代入演算子許可(関数宣言用)
            WordCollection wc = LexicalAnalyzer.Analyse(st, LexEndWith.EoL, LexAnalyzeFlag.AllowAssignment);

            if (wc.EOL)
            {
                //throw new CodeEE("置換先の式がありません", position);
                //1808a3 空マクロの許可
                DefineMacro nullmac = new DefineMacro(srcID, new WordCollection(), 0);
                idDic.AddMacro(nullmac);
                return;
            }

            List <string> argID = new List <string>();

            if (hasArg)            //関数型マクロの引数解析
            {
                wc.ShiftNext();    //'('を読み飛ばす
                if (wc.Current.Type == ')')
                {
                    throw new CodeEE("関数型マクロの引数を0個にすることはできません", position);
                }
                while (!wc.EOL)
                {
                    IdentifierWord word = wc.Current as IdentifierWord;
                    if (word == null)
                    {
                        throw new CodeEE("置換元の引数指定の書式が間違っています", position);
                    }
                    word.SetIsMacro();
                    string id = word.Code;
                    if (argID.Contains(id))
                    {
                        throw new CodeEE("置換元の引数に同じ文字が2回以上使われています", position);
                    }
                    argID.Add(id);
                    wc.ShiftNext();
                    if (wc.Current.Type == ',')
                    {
                        wc.ShiftNext();
                        continue;
                    }
                    if (wc.Current.Type == ')')
                    {
                        break;
                    }
                    throw new CodeEE("置換元の引数指定の書式が間違っています", position);
                }
                if (wc.EOL)
                {
                    throw new CodeEE("')'が閉じられていません", position);
                }

                wc.ShiftNext();
            }
            if (wc.EOL)
            {
                throw new CodeEE("置換先の式がありません", position);
            }
            WordCollection destWc = new WordCollection();

            while (!wc.EOL)
            {
                destWc.Add(wc.Current);
                wc.ShiftNext();
            }
            if (hasArg)            //関数型マクロの引数セット
            {
                while (!destWc.EOL)
                {
                    IdentifierWord word = destWc.Current as IdentifierWord;
                    if (word == null)
                    {
                        destWc.ShiftNext();
                        continue;
                    }
                    for (int i = 0; i < argID.Count; i++)
                    {
                        if (string.Equals(word.Code, argID[i], Config.SCVariable))
                        {
                            destWc.Remove();
                            destWc.Insert(new MacroWord(i));
                            break;
                        }
                    }
                    destWc.ShiftNext();
                }
                destWc.Pointer = 0;
            }
            if (hasArg)            //1808a3 関数型マクロの封印
            {
                throw new CodeEE("関数型マクロは宣言できません", position);
            }
            DefineMacro mac = new DefineMacro(srcID, destWc, argID.Count);

            idDic.AddMacro(mac);
        }
Example #29
0
 public static void Warn(string str, ScriptPosition pos, int level)
 {
     Warn(str, pos, level, null);
 }
Example #30
0
 public ConsoleButtonString(EmueraConsole console, AConsoleDisplayPart[] strs, string inputs, ScriptPosition pos)
     : this(console, strs)
 {
     Inputs    = inputs;
     IsButton  = true;
     IsInteger = false;
     if (console != null)
     {
         Generation = parent.NewButtonGeneration;
         console.UpdateGeneration();
     }
     ErrPos = pos;
 }
Example #31
0
 public ParserWarning(string mes, ScriptPosition pos, int level, string stackTrace)
 {
     WarningMes = mes;
     WarningPos = pos;
     WarningLevel = level;
     StackTrace = stackTrace;
 }
Example #32
0
        private bool loadConfig(string confPath, bool fix)
        {
            if (!File.Exists(confPath))
            {
                return(false);
            }
            EraStreamReader eReader = new EraStreamReader(false);

            if (!eReader.Open(confPath))
            {
                return(false);
            }
            ScriptPosition pos = null;

            try
            {
                string line = null;
                //bool defineIgnoreWarningFiles = false;
                while ((line = eReader.ReadLine()) != null)
                {
                    if ((line.Length == 0) || (line[0] == ';'))
                    {
                        continue;
                    }
                    pos = new ScriptPosition(eReader.Filename, eReader.LineNo, line);
                    string[] tokens = line.Split(new char[] { ':' });
                    if (tokens.Length < 2)
                    {
                        continue;
                    }
                    var         token_0 = tokens[0].Trim();
                    AConfigItem item    = GetConfigItem(token_0);
                    if (item == null)
                    {
                        token_0 = uEmuera.Utils.SHIFTJIS_to_UTF8(token_0);
                        if (!string.IsNullOrEmpty(token_0))
                        {
                            item = GetConfigItem(token_0);
                        }
                    }
                    if (item != null)
                    {
                        //1806beta001 CompatiDRAWLINEの廃止、CompatiLinefeedAs1739へ移行
                        if (item.Code == ConfigCode.CompatiDRAWLINE)
                        {
                            item = GetConfigItem(ConfigCode.CompatiLinefeedAs1739);
                        }
                        //if ((item.Code == ConfigCode.IgnoreWarningFiles))
                        //{
                        //    if (!defineIgnoreWarningFiles)
                        //        (item.GetValue<List<string>>()).Clear();
                        //    defineIgnoreWarningFiles = true;
                        //    if ((item.Fixed) && (fix))
                        //        item.Fixed = false;
                        //}

                        if (item.Code == ConfigCode.TextEditor)
                        {
                            //パスの関係上tokens[2]は使わないといけない
                            if (tokens.Length > 2)
                            {
                                if (tokens[2].StartsWith("\\"))
                                {
                                    tokens[1] += ":" + tokens[2];
                                }
                                if (tokens.Length > 3)
                                {
                                    for (int i = 3; i < tokens.Length; i++)
                                    {
                                        tokens[1] += ":" + tokens[i];
                                    }
                                }
                            }
                        }
                        if (item.Code == ConfigCode.EditorArgument)
                        {
                            //半角スペースを要求する引数が必要なエディタがあるので別処理で
                            ((ConfigItem <string>)item).Value = tokens[1];
                            continue;
                        }
                        if (item.Code == ConfigCode.MaxLog && Program.AnalysisMode)
                        {
                            //解析モード時はここを上書きして十分な長さを確保する
                            tokens[1] = "10000";
                        }
                        if ((item.TryParse(tokens[1])) && (fix))
                        {
                            item.Fixed = true;
                        }
                    }
#if UEMUERA_DEBUG
                    //else
                    //	throw new Exception("コンフィグファイルが変");
#endif
                }
            }
            catch (EmueraException ee)
            {
                ParserMediator.ConfigWarn(ee.Message, pos, 1, null);
            }
            catch (Exception exc)
            {
                ParserMediator.ConfigWarn(exc.GetType().ToString() + ":" + exc.Message, pos, 1, exc.StackTrace);
            }
            finally { eReader.Dispose(); }
            return(true);
        }
Example #33
0
        //1756 Process.Load.csより移動
        public static void LoadEraExRenameFile(string filepath)
        {
            if (RenameDic != null)
                RenameDic.Clear();
            //とにかく辞書を作る。辞書がnullのときは UseRenameFileがNOの時のみ
            RenameDic = new Dictionary<string, string>();
            EraStreamReader eReader = new EraStreamReader();
            if ((!File.Exists(filepath)) || (!eReader.Open(filepath)))
            {
                return;
            }
            string line = null;
            ScriptPosition pos = null;
            Regex reg = new Regex(@"\\,", RegexOptions.Compiled);
            try
            {
                while ((line = eReader.ReadLine()) != null)
                {
                    if (line.Length == 0)
                        continue;
                    if (line.StartsWith(";"))
                        continue;
                    string[] baseTokens = reg.Split(line);
                    if (!baseTokens[baseTokens.Length - 1].Contains(","))
                        continue;
                    string[] last = baseTokens[baseTokens.Length - 1].Split(',');
                    baseTokens[baseTokens.Length - 1] = last[0];
                    string[] tokens = new string[2];
                    tokens[0] = string.Join(",", baseTokens);
                    tokens[1] = last[1];
                    pos = new ScriptPosition(eReader.Filename, eReader.LineNo, line);
                    //右がERB中の表記、左が変換先になる。
                    string value = tokens[0].Trim();
                    string key = string.Format("[[{0}]]", tokens[1].Trim());
                    RenameDic[key] = value;
                    pos = null;
                }
            }
            catch (Exception e)
            {
                if (pos != null)
                    throw new CodeEE(e.Message, pos);
                else
                    throw new CodeEE(e.Message);

            }
            finally
            {
                eReader.Close();
            }
        }
Example #34
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="position"></param>
 /// <param name="name"></param>
 /// <param name="value"></param>
 /// <returns></returns>
 public virtual TBuilder Set(ScriptPosition position, string name, object value)
 {
     this.ToComponent().CallTemplate(position, BaseControl.SETEMPLATE, name, value);
     return(this as TBuilder);
 }
Example #35
0
	    public ScriptElement(string url, ScriptPosition position, string assembly, string resource) {
	        Url = url;
	        Position = position;
	        Assembly = assembly;
	        Resource = resource;
	    }
Example #36
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="mode"></param>
 /// <param name="name"></param>
 /// <param name="args"></param>
 /// <returns></returns>
 public virtual TBuilder Call(ScriptPosition mode, string name, params object[] args)
 {
     this.ToComponent().CallTemplate(mode, BaseControl.CALLTEMPLATE, name, args);
     return(this as TBuilder);
 }
Example #37
0
        private void toCharacterTemplate(GameBase gamebase, ScriptPosition position, CharacterTemplate chara, string[] tokens)
        {
            if (chara == null)
                return;
            int length = -1;
            Int64 p1 = -1;
            Int64 p2 = -1;
            Dictionary<int, Int64> intArray = null;
            Dictionary<int, string> strArray = null;
            Dictionary<string, int> namearray = null;

            string errPos = null;
            string varname = tokens[0].ToUpper();
            switch (varname)
            {
                case "NAME":
                case "名前":
                    chara.Name = tokens[1];
                    return;
                case "CALLNAME":
                case "呼び名":
                    chara.Callname = tokens[1];
                    return;
                case "NICKNAME":
                case "あだ名":
                    chara.Nickname = tokens[1];
                    return;
                case "MASTERNAME":
                case "主人の呼び方":
                    chara.Mastername = tokens[1];
                    return;
                case "MARK":
                case "刻印":
                    length = CharacterIntArrayLength[(int)(VariableCode.__LOWERCASE__ & VariableCode.MARK)];
                    intArray = chara.Mark;
                    namearray = nameToIntDics[markIndex];
                    errPos = "mark.csv";
                    break;
                case "EXP":
                case "経験":
                    length = CharacterIntArrayLength[(int)(VariableCode.__LOWERCASE__ & VariableCode.EXP)];
                    intArray = chara.Exp;
                    namearray = nameToIntDics[expIndex];//ExpName;
                    errPos = "exp.csv";
                    break;
                case "ABL":
                case "能力":
                    length = CharacterIntArrayLength[(int)(VariableCode.__LOWERCASE__ & VariableCode.ABL)];
                    intArray = chara.Abl;
                    namearray = nameToIntDics[ablIndex];//AblName;
                    errPos = "abl.csv";
                    break;
                case "BASE":
                case "基礎":
                    length = CharacterIntArrayLength[(int)(VariableCode.__LOWERCASE__ & VariableCode.MAXBASE)];
                    intArray = chara.Maxbase;
                    namearray = nameToIntDics[baseIndex];//BaseName;
                    errPos = "base.csv";
                    break;
                case "TALENT":
                case "素質":
                    length = CharacterIntArrayLength[(int)(VariableCode.__LOWERCASE__ & VariableCode.TALENT)];
                    intArray = chara.Talent;
                    namearray = nameToIntDics[talentIndex];//TalentName;
                    errPos = "talent.csv";
                    break;
                case "RELATION":
                case "相性":
                    length = CharacterIntArrayLength[(int)(VariableCode.__LOWERCASE__ & VariableCode.RELATION)];
                    intArray = chara.Relation;
                    namearray = null;
                    break;
                case "CFLAG":
                case "フラグ":
                    length = CharacterIntArrayLength[(int)(VariableCode.__LOWERCASE__ & VariableCode.CFLAG)];
                    intArray = chara.CFlag;
                    namearray = nameToIntDics[cflagIndex];//CFlagName;
                    errPos = "cflag.csv";
                    break;
                case "EQUIP":
                case "装着物":
                    length = CharacterIntArrayLength[(int)(VariableCode.__LOWERCASE__ & VariableCode.EQUIP)];
                    intArray = chara.Equip;
                    namearray = nameToIntDics[equipIndex];//EquipName;
                    errPos = "equip.csv";
                    break;
                case "JUEL":
                case "珠":
                    length = CharacterIntArrayLength[(int)(VariableCode.__LOWERCASE__ & VariableCode.JUEL)];
                    intArray = chara.Juel;
                    namearray = nameToIntDics[paramIndex];//ParamName;
                    errPos = "palam.csv";
                    break;
                case "CSTR":
                    length = CharacterStrArrayLength[(int)(VariableCode.__LOWERCASE__ & VariableCode.CSTR)];
                    strArray = chara.CStr;
                    namearray = nameToIntDics[cstrIndex];//CStrName;
                    errPos = "cstr.csv";
                    break;
                default:
                    ParserMediator.Warn("\"" + tokens[0] + "\"は解釈できない識別子です", position, 1);
                    return;
            }
            if (length < 0)
            {
                ParserMediator.Warn("プログラムミス", position, 3);
                return;
            }
            bool p1isNumeric = tryToInt64(tokens[1].TrimEnd(), out p1);
            if (p1isNumeric && ((p1 < 0) || (p1 >= length)))
            {
                ParserMediator.Warn(p1.ToString() + "は配列の範囲外です", position, 1);
                return;
            }
            int index = (int)p1;
            if ((!p1isNumeric) && (namearray != null))
            {
                if (!namearray.TryGetValue(tokens[1], out index))
                {
                    ParserMediator.Warn(errPos + "に\"" + tokens[1] + "\"の定義がありません", position, 1);
                    //ParserMediator.Warn("\"" + tokens[1] + "\"は解釈できない識別子です", position, 1);
                    return;
                }
                else if (index >= length)
                {
                    ParserMediator.Warn("\"" + tokens[1] + "\"は配列の範囲外です", position, 1);
                    return;
                }
            }

            if ((index < 0) || (index >= length))
            {
                if (p1isNumeric)
                    ParserMediator.Warn(index.ToString() + "は配列の範囲外です", position, 1);
                else if (tokens[1].Length == 0)
                    ParserMediator.Warn("二つ目の識別子がありません", position, 1);
                else
                    ParserMediator.Warn("\"" + tokens[1] + "\"は解釈できない識別子です", position, 1);
                return;
            }
            if (strArray != null)
            {
                if (tokens.Length < 3)
                    ParserMediator.Warn("三つ目の識別子がありません", position, 1);
                if (strArray.ContainsKey(index))
                    ParserMediator.Warn(varname + "の" + index.ToString() + "番目の要素は既に定義されています(上書きします)", position, 1);
                strArray[index] = tokens[2];
            }
            else
            {
                if ((tokens.Length < 3) || !tryToInt64(tokens[2], out p2))
                    p2 = 1;
                if (intArray.ContainsKey(index))
                    ParserMediator.Warn(varname + "の" + index.ToString() + "番目の要素は既に定義されています(上書きします)", position, 1);
                intArray[index] = p2;
            }
        }
Example #38
0
        private bool loadConfig(string confPath, bool fix)
        {
            if (!File.Exists(confPath))
            {
                return(false);
            }
            var eReader = new EraStreamReader(false);

            if (!eReader.Open(confPath))
            {
                return(false);
            }
            ScriptPosition pos = null;

            try
            {
                string line = null;
                //bool defineIgnoreWarningFiles = false;
                while ((line = eReader.ReadLine()) != null)
                {
                    if (line.Length == 0 || line[0] == ';')
                    {
                        continue;
                    }
                    pos = new ScriptPosition(eReader.Filename, eReader.LineNo, line);
                    var tokens = line.Split(':');
                    if (tokens.Length < 2)
                    {
                        continue;
                    }
                    var item = GetConfigItem(tokens[0].Trim());
                    if (item != null)
                    {
                        //1806beta001 CompatiDRAWLINEの廃止、CompatiLinefeedAs1739へ移行
                        if (item.Code == ConfigCode.CompatiDRAWLINE)
                        {
                            item = GetConfigItem(ConfigCode.CompatiLinefeedAs1739);
                        }
                        //if ((item.Code == ConfigCode.IgnoreWarningFiles))
                        //{
                        //    if (!defineIgnoreWarningFiles)
                        //        (item.GetValue<List<string>>()).Clear();
                        //    defineIgnoreWarningFiles = true;
                        //    if ((item.Fixed) && (fix))
                        //        item.Fixed = false;
                        //}

                        if (item.Code == ConfigCode.TextEditor)
                        {
                            if (tokens.Length > 2)
                            {
                                if (tokens[2].StartsWith("\\"))
                                {
                                    tokens[1] += ":" + tokens[2];
                                }
                                if (tokens.Length > 3)
                                {
                                    for (var i = 3; i < tokens.Length; i++)
                                    {
                                        tokens[1] += ":" + tokens[i];
                                    }
                                }
                            }
                        }
                        if (item.Code == ConfigCode.EditorArgument)
                        {
                            //半角スペースを要求する引数が必要なエディタがあるので別処理で
                            ((ConfigItem <string>)item).Value = tokens[1];
                            continue;
                        }
                        if (item.TryParse(tokens[1]) && fix)
                        {
                            item.Fixed = true;
                        }
                    }
#if DEBUG
                    //else
                    //	throw new Exception("コンフィグファイルが変");
#endif
                }
            }
            catch (EmueraException ee)
            {
                ParserMediator.ConfigWarn(ee.Message, pos, 1, null);
            }
            catch (Exception exc)
            {
                ParserMediator.ConfigWarn(exc.GetType() + ":" + exc.Message, pos, 1, exc.StackTrace);
            }
            finally
            {
                eReader.Dispose();
            }
            return(true);
        }
Example #39
0
        private void changeVariableSizeData(string line, ScriptPosition position)
        {
            string[] tokens = line.Split(',');
            if (tokens.Length < 2)
            {
                ParserMediator.Warn("\",\"が必要です", position, 1);
                return;
            }
            string idtoken = tokens[0].Trim();
            VariableIdentifier id = VariableIdentifier.GetVariableId(idtoken);
            if (id == null)
            {
                ParserMediator.Warn("一つ目の値を変数名として認識できません", position, 1);
                return;
            }
            if ((!id.IsArray1D) && (!id.IsArray2D) && (!id.IsArray3D))
            {
                ParserMediator.Warn("配列変数でない変数" + id.ToString() + "のサイズを変更できません", position, 1);
                return;
            }
            int length = 0;
            int length2 = 0;
            int length3 = 0;
            if (!int.TryParse(tokens[1], out length))
            {
                ParserMediator.Warn("二つ目の値を整数値として認識できません", position, 1);
                return;
            }
            //__CALC__は弾かないと変更できないエラーが表示できない
            if (id.IsArray1D && !id.IsCalc)
            {
                if (tokens.Length > 2 && tokens[2].Length > 0 && tokens[2].Trim().Length > 0 && char.IsDigit((tokens[2].Trim())[0]))
                {
                    ParserMediator.Warn("一次元配列のサイズ指定に不必要なデータは無視されます", position, 0);
                }
                if (id.IsLocal && length < 1)
                {
                    ParserMediator.Warn("ローカル変数のサイズを1未満にはできません", position, 1);
                    return;
                }
                else if (!id.IsLocal && length < 100)
                {
                    ParserMediator.Warn("ローカル変数でない一次元配列のサイズを100未満にはできません", position, 1);
                    return;
                }
                if (length > 1000000)
                {
                    ParserMediator.Warn("一次元配列のサイズを1000000より大きくすることはできません", position, 1);
                    return;
                }
            }
            else if (id.IsArray2D)
            {
                if (tokens.Length < 3)
                {
                    ParserMediator.Warn("二次元配列のサイズ指定には2つの数値が必要です", position, 1);
                    return;
                }
                if (tokens.Length > 3 && tokens[3].Length > 0 && tokens[3].Trim().Length > 0 && char.IsDigit((tokens[3].Trim())[0]))
                {
                    ParserMediator.Warn("二次元配列のサイズ指定に不必要なデータは無視されます", position, 0);
                }
                if (!int.TryParse(tokens[2], out length2))
                {
                    ParserMediator.Warn("三つ目の値を整数値として認識できません", position, 1);
                    return;
                }
                if ((length < 1) || (length2 < 1))
                {
                    ParserMediator.Warn("配列サイズを1未満にはできません", position, 1);
                    return;
                }
                if ((length > 1000000) || (length2 > 1000000))
                {
                    ParserMediator.Warn("配列サイズを1000000より大きくすることはできません", position, 1);
                    return;
                }
                if (length * length2 > 1000000)
                {
                    ParserMediator.Warn("二次元配列の要素数は最大で100万個までです", position, 1);
                    return;
                }
            }
            else if (id.IsArray3D)
            {
                if (tokens.Length < 4)
                {
                    ParserMediator.Warn("三次元配列のサイズ指定には3つの数値が必要です", position, 1);
                    return;
                }
                if (tokens.Length > 4 && tokens[4].Length > 0 && tokens[4].Trim().Length > 0 && char.IsDigit((tokens[4].Trim())[0]))
                {
                    ParserMediator.Warn("三次元配列のサイズ指定に不必要なデータは無視されます", position, 0);
                }
                if (!int.TryParse(tokens[2], out length2))
                {
                    ParserMediator.Warn("三つ目の値を整数値として認識できません", position, 1);
                    return;
                }
                if (!int.TryParse(tokens[3], out length3))
                {
                    ParserMediator.Warn("四つ目の値を整数値として認識できません", position, 1);
                    return;
                }
                if ((length < 1) || (length2 < 1) || (length3 < 1))
                {
                    ParserMediator.Warn("配列サイズを1未満にはできません", position, 1);
                    return;
                }
                //1802 サイズ保存の都合上、2^20超えるとバグる
                if ((length > 1000000) || (length2 > 1000000) || (length3 > 1000000))
                {
                    ParserMediator.Warn("配列サイズを1000000より大きくすることはできません", position, 1);
                    return;
                }
                if (length * length2 * length3 > 10000000)
                {
                    ParserMediator.Warn("三次元配列の要素数は最大で1000万個までです", position, 1);
                    return;
                }
            }
            switch (id.Code)
            {
                //1753a PALAMだけ仕様が違うのはかえって問題なので、変数と要素文字列配列数の同期は全部バックアウト
                //基本的には旧来の処理に戻しただけ
                case VariableCode.ITEMNAME:
                case VariableCode.ITEMPRICE:
                    VariableIntArrayLength[(int)(VariableCode.__LOWERCASE__ & VariableCode.ITEMPRICE)] = length;
                    MaxDataList[itemIndex] = length;
                    break;
                case VariableCode.STR:
                    VariableStrArrayLength[(int)(VariableCode.__LOWERCASE__ & VariableCode.STR)] = length;
                    MaxDataList[strIndex] = length;
                    break;
                case VariableCode.ABLNAME:
                case VariableCode.TALENTNAME:
                case VariableCode.EXPNAME:
                case VariableCode.MARKNAME:
                case VariableCode.PALAMNAME:
                case VariableCode.TRAINNAME:
                case VariableCode.BASENAME:
                case VariableCode.SOURCENAME:
                case VariableCode.EXNAME:
                case VariableCode.EQUIPNAME:
                case VariableCode.TEQUIPNAME:
                case VariableCode.FLAGNAME:
                case VariableCode.TFLAGNAME:
                case VariableCode.CFLAGNAME:
                case VariableCode.TCVARNAME:
                case VariableCode.CSTRNAME:
                case VariableCode.STAINNAME:
                case VariableCode.CDFLAGNAME1:
                case VariableCode.CDFLAGNAME2:
                case VariableCode.TSTRNAME:
                case VariableCode.SAVESTRNAME:
                case VariableCode.STRNAME:
                case VariableCode.GLOBALNAME:
                case VariableCode.GLOBALSNAME:
                    MaxDataList[(int)(id.Code & VariableCode.__LOWERCASE__)] = length;
                    break;
                default:
                    {
                        if ((id.IsCalc) || (id.Code == VariableCode.RANDDATA))
                        {
                            ParserMediator.Warn(id.ToString() + "のサイズは変更できません", position, 1);
                        }

                        else if (id.IsCharacterData)
                        {
                            if (id.IsArray2D)
                            {
                                Int64 length64 = (((Int64)length) << 32) + ((Int64)length2);
                                if (id.IsInteger)
                                    CharacterIntArray2DLength[id.CodeInt] = length64;
                                else if (id.IsString)
                                    CharacterStrArray2DLength[id.CodeInt] = length64;
                            }
                            else
                            {
                                if (id.IsInteger)
                                    CharacterIntArrayLength[id.CodeInt] = length;
                                else if (id.IsString)
                                    CharacterStrArrayLength[id.CodeInt] = length;
                            }
                        }
                        else if (id.IsArray2D)
                        {
                            Int64 length64 = (((Int64)length) << 32) + ((Int64)length2);
                            if (id.IsInteger)
                                VariableIntArray2DLength[id.CodeInt] = length64;
                            else if (id.IsString)
                                VariableStrArray2DLength[id.CodeInt] = length64;
                        }
                        else if (id.IsArray3D)
                        {
                            //Int64 length3d = ((Int64)length << 32) + ((Int64)length2 << 16) + (Int64)length3;
                            Int64 length3d = ((Int64)length << 40) + ((Int64)length2 << 20) + (Int64)length3;
                            if (id.IsInteger)
                                VariableIntArray3DLength[id.CodeInt] = length3d;
                            else
                                VariableStrArray3DLength[id.CodeInt] = length3d;
                        }
                        else
                        {
                            if (id.IsInteger)
                                VariableIntArrayLength[id.CodeInt] = length;
                            else if (id.IsString)
                                VariableStrArrayLength[id.CodeInt] = length;
                        }
                    }
                    break;
            }
            //1803beta004 二重定義を警告対象に
            if (changedCode.Contains(id.Code))
                ParserMediator.Warn(id.Code.ToString() + "の要素数は既に定義されています(上書きします)", position, 1);
            else
                changedCode.Add(id.Code);
        }
Example #40
0
        public bool LoadDebugConfig()
        {
            if (!File.Exists(configdebugPath))
            {
                goto err;
            }
            var eReader = new EraStreamReader(false);

            if (!eReader.Open(configdebugPath))
            {
                goto err;
            }
            ScriptPosition pos = null;

            try
            {
                string line = null;
                while ((line = eReader.ReadLine()) != null)
                {
                    if (line.Length == 0 || line[0] == ';')
                    {
                        continue;
                    }
                    pos = new ScriptPosition(eReader.Filename, eReader.LineNo, line);
                    var tokens = line.Split(':');
                    if (tokens.Length < 2)
                    {
                        continue;
                    }
                    var item = GetDebugItem(tokens[0].Trim());
                    if (item != null)
                    {
                        item.TryParse(tokens[1]);
                    }
#if DEBUG
                    //else
                    //	throw new Exception("コンフィグファイルが変");
#endif
                }
            }
            catch (EmueraException ee)
            {
                ParserMediator.ConfigWarn(ee.Message, pos, 1, null);
                goto err;
            }
            catch (Exception exc)
            {
                ParserMediator.ConfigWarn(exc.GetType() + ":" + exc.Message, pos, 1, exc.StackTrace);
                goto err;
            }
            finally
            {
                eReader.Dispose();
            }
            Config.SetDebugConfig(this);
            return(true);

err:
            Config.SetDebugConfig(this);
            return(false);
        }
Example #41
0
 private void loadCharacterDataFile(string csvPath, string csvName, bool disp)
 {
     CharacterTemplate tmpl = null;
     EraStreamReader eReader = new EraStreamReader();
     if (!eReader.Open(csvPath, csvName))
     {
         output.PrintError(eReader.Filename + "のオープンに失敗しました");
         return;
     }
     ScriptPosition position = null;
     if (disp)
         output.PrintLine(eReader.Filename + "読み込み中・・・");
     try
     {
         Int64 index = -1;
         StringStream st = null;
         while ((st = eReader.ReadEnabledLine()) != null)
         {
             position = new ScriptPosition(eReader.Filename, eReader.LineNo, st.RowString);
             string[] tokens = st.Substring().Split(',');
             if (tokens.Length < 2)
             {
                 ParserMediator.Warn("\",\"が必要です", position, 1);
                 continue;
             }
             if (tokens[0].Length == 0)
             {
                 ParserMediator.Warn("\",\"で始まっています", position, 1);
                 continue;
             }
             if ((tokens[0].Equals("NO", Config.SCVariable))
                 || (tokens[0].Equals("番号", Config.SCVariable)))
             {
                 if (tmpl != null)
                 {
                     ParserMediator.Warn("番号が二重に定義されました", position, 1);
                     continue;
                 }
                 if (!Int64.TryParse(tokens[1].TrimEnd(), out index))
                 {
                     ParserMediator.Warn(tokens[1] + "を整数値に変換できません", position, 1);
                     continue;
                 }
                 tmpl = new CharacterTemplate(index, this);
                 string no = eReader.Filename.ToUpper();
                 no = no.Substring(no.IndexOf("CHARA") + 5);
                 StringBuilder sb = new StringBuilder();
                 StringStream ss = new StringStream(no);
                 while (!ss.EOS && char.IsDigit(ss.Current))
                 {
                     sb.Append(ss.Current);
                     ss.ShiftNext();
                 }
                 if (sb.Length > 0)
                     tmpl.csvNo = Convert.ToInt64(sb.ToString());
                 else
                     tmpl.csvNo = 0;
                 //tmpl.csvNo = index;
                 CharacterTmplList.Add(tmpl);
                 continue;
             }
             if (tmpl == null)
             {
                 ParserMediator.Warn("番号が定義される前に他のデータが始まりました", position, 1);
                 continue;
             }
             toCharacterTemplate(gamebase, position, tmpl, tokens);
         }
     }
     catch
     {
         System.Media.SystemSounds.Hand.Play();
         if (position != null)
             ParserMediator.Warn("予期しないエラーが発生しました", position, 3);
         else
             output.PrintError("予期しないエラーが発生しました");
         return;
     }
     finally
     {
         eReader.Dispose();
     }
 }
Example #42
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="str"></param>
        /// <param name="position"></param>
        /// <param name="level">警告レベル.0:軽微なミス.1:無視できる行.2:行が実行されなければ無害.3:致命的</param>
        public void PrintWarning(string str, ScriptPosition position, int level)
        {
            if (level < Config.DisplayWarningLevel && !Program.AnalysisMode)
                return;
            //警告だけは強制表示
            bool b = force_temporary;
            force_temporary = false;
            if (position != null)
            {
                if(position.LineNo >= 0)
                {
                    PrintErrorButton(string.Format("警告Lv{0}:{1}:{2}行目:{3}", level, position.Filename, position.LineNo, str), "openFileWithDebug", position);
                    if (position.RowLine != null)
                        PrintError(position.RowLine);
                }
                else
                    PrintErrorButton(string.Format("警告Lv{0}:{1}:{2}", level, position.Filename, str), "openFileWithDebug", position);

            }
            else
            {
                PrintError(string.Format("警告Lv{0}:{1}", level, str));
            }
            force_temporary = b;
        }
Example #43
0
 public virtual void Set(ScriptPosition position, string name, object value)
 {
     this.CallTemplate(position, XControl.SETEMPLATE, name, value);
 }
Example #44
0
 public void PressEnterKey(bool mesSkip, string str, ScriptPosition pos)
 {
     if ((state == ConsoleState.Running) || (state == ConsoleState.Initializing) || (state == ConsoleState.WaitKeyWithTimerF))
         return;
     else if ((state == ConsoleState.Quit))
     {
         window.Close();
         return;
     }
     else if (state == ConsoleState.Error)
     {
         if (str == "openFileWithDebug" && pos != null)
         {
             ProcessStartInfo pInfo = new ProcessStartInfo();
             pInfo.FileName = Config.TextEditor;
             string fname = pos.Filename.ToUpper();
             if (fname.EndsWith(".CSV"))
             {
                 if (fname.Contains(Program.CsvDir.ToUpper()))
                     fname = fname.Replace(Program.CsvDir.ToUpper(), "");
                 fname = Program.CsvDir + fname;
             }
             else
             {
                 //解析モードの場合は見ているファイルがERB\の下にあるとは限らないかつフルパスを持っているのでこの補正はしなくてよい
                 if (!Program.AnalysisMode)
                 {
                     if (fname.Contains(Program.ErbDir.ToUpper()))
                         fname = fname.Replace(Program.ErbDir.ToUpper(), "");
                     fname = Program.ErbDir + fname;
                 }
             }
             if (Config.EditorArg != "" && Config.EditorArg != null)
                 pInfo.Arguments = Config.EditorArg + pos.LineNo.ToString() + " \"" + fname + "\"";
             else
                 pInfo.Arguments = fname;
             try
             {
                 System.Diagnostics.Process.Start(pInfo);
             }
             catch (System.ComponentModel.Win32Exception)
             {
                 System.Media.SystemSounds.Hand.Play();
                 PrintError("エディタを開くことができませんでした");
                 forceUpdateGeneration();
             }
             return;
         }
         else
         {
             window.Close();
             return;
         }
     }
     else if (state == ConsoleState.WaitKeyWithTimer)
         stopTimer();
     if (str.StartsWith("@") && !IsWaintingOnePhrase)
     {
         doSystemCommand(str);
         return;
     }
     if (((state == ConsoleState.WaitInteger) || (state == ConsoleState.WaitIntegerWithTimer) || (state == ConsoleState.WaitOneIntegerWithTimer) || (state == ConsoleState.WaitOneInteger) || (state == ConsoleState.WaitSystemInteger)
         || (state == ConsoleState.WaitString) || (state == ConsoleState.WaitStringWithTimer) || (state == ConsoleState.WaitOneStringWithTimer) || (state == ConsoleState.WaitOneString))
         && str.Contains("("))
     {
         StringStream st = new StringStream(str);
         str = parseInput(st, false);
     }
     string[] text = str.Split(spliter, StringSplitOptions.None);
     inProcess = (text.Length > 1);
     //右クリックでのスキップ時のみtrueになる
     inMouseSkip = mesSkip;
     for (int i = 0; i < text.Length; i++)
     {
         string inputs = text[i];
         if (inputs.IndexOf("\\e") >= 0)
         {
             inputs = inputs.Replace("\\e", "");//\eの除去
             mesSkip = true;
             //マクロによるスキップの方を優先
             if (inMouseSkip)
                 inMouseSkip = false;
         }
         if (IsWaintingOnePhrase && inputs.Length > 1)
             inputs = inputs.Remove(1);
         if (state == ConsoleState.WaitKeyWithTimer || state == ConsoleState.WaitKeyWithTimerF)
             stopTimer();
         //強制待ちWAITは入力を受け付けないので次に回す必要がある。
         if (state != ConsoleState.WaitKeyWithTimerF)
             callEmueraProgram(inputs);
         else
         {
             i--;
             callEmueraProgram("");
         }
         if (mesSkip)
         {
             while ((state == ConsoleState.WaitKey && !isForceWait) || state == ConsoleState.WaitKeyWithTimer || state == ConsoleState.WaitKeyWithTimerF || state == ConsoleState.WaitAnyKey)
             {
                 if (state == ConsoleState.WaitKeyWithTimer || state == ConsoleState.WaitKeyWithTimerF)
                     stopTimer();
                 callEmueraProgram("");
             }
         }
         mesSkip = false;
         inMouseSkip = false;
         isForceWait = false;
         if (state == ConsoleState.Error || state == ConsoleState.Quit)
             break;
         //マクロループ時は待ち処理が起こらないのでここでシステムキューを捌く
         Application.DoEvents();
     }
     RefreshStrings(true);
     inProcess = false;
 }
Example #45
0
        protected virtual void CallTemplate(ScriptPosition position, string template, string name, params object[] args)
        {
            StringBuilder sb = new StringBuilder();

            if (args != null && args.Length > 0)
            {
                foreach (object arg in args)
                {
                    if (arg is string)
                    {
                        sb.AppendFormat("{0},", TokenUtils.ParseAndNormalize(arg.ToString(), this.SafeResourceManager  ));
                    }
                    else
                    {
                        sb.AppendFormat("{0},", JSON.Serialize(arg, JSON.AltConvertersInternal));
                    }
                }
            }

            string script = template.FormatWith(this.CallID, name, sb.ToString().LeftOfRightmostOf(','));

            switch (position)
            {
                case ScriptPosition.BeforeInit:
                    this.ResourceManager.RegisterBeforeClientInitScript(script);
                    break;
                case ScriptPosition.AfterInit:
                    this.ResourceManager.RegisterAfterClientInitScript(script);
                    break;
                default:
                    this.AddScript(script);
                    break;
            }
        }
Example #46
0
        public static Ast GetContainingAstOfPosition(Ast fullAst, int line, int column)
        {
            var position = new ScriptPosition(scriptName: null, line, column, line: null);

            return(GetContainingAstOfPosition(fullAst, position));
        }
Example #47
0
        public bool LoadGameBaseCsv(string basePath)
        {
            if (!File.Exists(basePath))
            {
                return(true);
            }
            ScriptPosition  pos     = null;
            EraStreamReader eReader = new EraStreamReader(false);

            if (!eReader.Open(basePath))
            {
                //output.PrintLine(eReader.Filename + "のオープンに失敗しました");
                return(true);
            }
            try
            {
                StringStream st = null;
                while ((st = eReader.ReadEnabledLine()) != null)
                {
                    string[] tokens = st.Substring().Split(',');
                    if (tokens.Length < 2)
                    {
                        continue;
                    }
                    string param = tokens[1].Trim();
                    pos = new ScriptPosition(eReader.Filename, eReader.LineNo, st.RowString);
                    switch (tokens[0])
                    {
                    case "コード":
                        if (tryatoi(tokens[1], out ScriptUniqueCode))
                        {
                            if (ScriptUniqueCode == 0L)
                            {
                                ParserMediator.Warn("コード:0のセーブデータはいかなるコードのスクリプトからも読めるデータとして扱われます", pos, 0);
                            }
                        }
                        break;

                    case "バージョン":
                        ScriptVersionDefined = tryatoi(tokens[1], out ScriptVersion);
                        break;

                    case "バージョン違い認める":
                        tryatoi(tokens[1], out ScriptCompatibleMinVersion);
                        break;

                    case "最初からいるキャラ":
                        tryatoi(tokens[1], out DefaultCharacter);
                        break;

                    case "アイテムなし":
                        tryatoi(tokens[1], out DefaultNoItem);
                        break;

                    case "タイトル":
                        ScriptTitle = tokens[1];
                        break;

                    case "作者":
                        ScriptAutherName = tokens[1];
                        break;

                    case "製作年":
                        ScriptYear = tokens[1];
                        break;

                    case "追加情報":
                        ScriptDetail = tokens[1];
                        break;

                    case "ウィンドウタイトル":
                        ScriptWindowTitle = tokens[1];
                        break;

                    case "動作に必要なEmueraのバージョン":
                        Compatible_EmueraVer = tokens[1];
                        if (!Regex.IsMatch(Compatible_EmueraVer, @"^\d+\.\d+\.\d+\.\d+$"))
                        {
                            ParserMediator.Warn("バージョン指定を読み取れなかったので処理を省略します", pos, 0);
                            break;
                        }
                        Version curerntVersion = new Version(GlobalStatic.MainWindow.InternalEmueraVer);
                        Version targetVersoin  = new Version(Compatible_EmueraVer);
                        if (curerntVersion < targetVersoin)
                        {
                            ParserMediator.Warn("このバリアント動作させるにはVer. " + GlobalStatic.MainWindow.EmueraVerText + "以降のバージョンのEmueraが必要です", pos, 2);
                            return(false);
                        }
                        break;
                    }
                }
            }
            catch
            {
                ParserMediator.Warn("GAMEBASE.CSVの読み込み中にエラーが発生したため、読みこみを中断します", pos, 1);
                return(true);
            }
            finally
            {
                eReader.Close();
            }
            if (ScriptWindowTitle == null)
            {
                if (string.IsNullOrEmpty(ScriptTitle))
                {
                    ScriptWindowTitle = "Emuera";
                }
                else
                {
                    ScriptWindowTitle = ScriptTitle + " " + ScriptVersionText;
                }
            }
            return(true);
        }
Example #48
0
        protected virtual void CallTemplate(ScriptPosition position, string template, string name, params object[] args)
        {
            IDMode mode = this.IDMode;
            if (((mode == Ext.Net.IDMode.Explicit || mode == Ext.Net.IDMode.Static) && !this.IsIdRequired) || mode == Ext.Net.IDMode.Ignore)
            {
                throw new Exception("You have to set widget's ID to call its methods");
            }
            
            StringBuilder sb = new StringBuilder();

            if (args != null && args.Length > 0)
            {
                foreach (object arg in args)
                {
                    if (arg is string)
                    {
                        sb.AppendFormat("{0},", TokenUtils.ParseAndNormalize(arg.ToString(), this.SafeResourceManager  ));
                    }
                    else
                    {
                        sb.AppendFormat("{0},", JSON.Serialize(arg, JSON.ScriptConvertersInternal));
                    }
                }
            }

            string script = template.FormatWith(this.CallID, name, sb.ToString().LeftOfRightmostOf(','));

            switch (position)
            {
                case ScriptPosition.BeforeInit:
                    this.ResourceManager.RegisterBeforeClientInitScript(script);
                    break;
                case ScriptPosition.AfterInit:
                    this.ResourceManager.RegisterAfterClientInitScript(script);
                    break;
                default:
                    this.AddScript(script);
                    break;
            }
        }
Example #49
0
 public ConsoleDisplayLine AppendAndFlushErrButton(string str, StringStyle style, string input, ScriptPosition pos, StringMeasure sm)
 {
     fromCssToButton();
     m_stringList.Add(new ConsoleStyledString(str, style));
     if (m_stringList.Count == 0)
     {
         return(null);
     }
     m_buttonList.Add(createButton(m_stringList, input, pos));
     m_stringList.Clear();
     return(FlushSingleLine(sm, false));
 }
Example #50
0
        //1756 Process.Load.csより移動
        public static void LoadEraExRenameFile(string filepath)
        {
            if (RenameDic != null)
            {
                RenameDic.Clear();
            }
            //とにかく辞書を作る。辞書がnullのときは UseRenameFileがNOの時のみ
            RenameDic = new Dictionary <string, string>();
            EraStreamReader eReader = new EraStreamReader(false);

            if ((!File.Exists(filepath)) || (!eReader.Open(filepath)))
            {
                return;
            }
            string         line = null;
            ScriptPosition pos  = null;
            Regex          reg  = new Regex(@"\\,", RegexOptions.None);

            try
            {
                string[] tokens = new string[2];
                while ((line = eReader.ReadLine()) != null)
                {
                    if (line.Length == 0)
                    {
                        continue;
                    }
                    if (line.StartsWith(";"))
                    {
                        continue;
                    }
                    string[] baseTokens = reg.Split(line);
                    if (!baseTokens[baseTokens.Length - 1].Contains(","))
                    {
                        continue;
                    }
                    string[] last = baseTokens[baseTokens.Length - 1].Split(',');
                    baseTokens[baseTokens.Length - 1] = last[0];
                    //string[] tokens = new string[2];
                    tokens[0] = string.Join(",", baseTokens);
                    tokens[1] = last[1];
                    pos       = new ScriptPosition(eReader.Filename, eReader.LineNo, line);
                    //右がERB中の表記、左が変換先になる。
                    string value = tokens[0].Trim();
                    string key   = string.Format("[[{0}]]", tokens[1].Trim());
                    RenameDic[key] = value;
                    pos            = null;
                }
            }
            catch (Exception e)
            {
                if (pos != null)
                {
                    throw new CodeEE(e.Message, pos);
                }
                else
                {
                    throw new CodeEE(e.Message);
                }
            }
            finally
            {
                eReader.Close();
            }
        }
Example #51
0
 internal void PrintErrorButton(string str, string p, ScriptPosition pos)
 {
     if (string.IsNullOrEmpty(str))
         return;
     ConsoleDisplayLine dispLine = printBuffer.AppendErrButton(str, Style, p, pos, new StringMeasure(getGraphics(), this.bgColor, Config.TextDrawingMode));
     if (dispLine == null)
         return;
     DisplayLineAlignment curAlignment = alignment;
     addDisplayLine(dispLine);
     alignment = curAlignment;
     RefreshStrings(false);
     if (Program.DebugMode)
     {
         this.DebugPrint(str);
         this.DebugNewLine();
     }
 }
Example #52
0
        private ConsoleButtonString createButton(List <AConsoleDisplayPart> cssList, string input, ScriptPosition pos)
        {
            var cssArray = new AConsoleDisplayPart[cssList.Count];

            cssList.CopyTo(cssArray);
            cssList.Clear();
            return(new ConsoleButtonString(parent, cssArray, input, pos));
        }
        public static UserDefinedVariableData Create(WordCollection wc, bool dims, bool isPrivate, ScriptPosition sc)
        {
            string dimtype = dims ? "#DIM" : "#DIMS";
            UserDefinedVariableData ret = new UserDefinedVariableData();
            ret.TypeStr = dims;

            IdentifierWord idw = null;
            bool staticDefined = false;
            string keyword = dimtype;
            while (!wc.EOL && (idw = wc.Current as IdentifierWord) != null)
            {
                wc.ShiftNext();
                keyword = idw.Code;
                if (Config.ICVariable)
                    keyword = keyword.ToUpper();
                switch (keyword)
                {
                    case "REF":
                        //TODO 1808beta009
                        throw new CodeEE("未実装の機能です", sc);
                        if (!isPrivate)
                            throw new CodeEE("広域変数の宣言に" + keyword + "キーワードは指定できません", sc);
                        if (staticDefined && ret.Static)
                            throw new CodeEE("STATICとREFキーワードは同時に指定できません", sc);
                        if (ret.Reference)
                            throw new CodeEE(keyword + "キーワードが二重に指定されています", sc);
                        ret.Reference = true;
                        ret.Static = true;
                        break;
                    case "DYNAMIC":
                        if (!isPrivate)
                            throw new CodeEE("広域変数の宣言に" + keyword + "キーワードは指定できません", sc);
                        if (staticDefined)
                            if (ret.Static)
                                throw new CodeEE("STATICとDYNAMICキーワードは同時に指定できません", sc);
                            else
                                throw new CodeEE(keyword + "キーワードが二重に指定されています", sc);
                        staticDefined = true;
                        ret.Static = false;
                        break;
                    case "STATIC":
                        if (!isPrivate)
                            throw new CodeEE("広域変数の宣言に" + keyword + "キーワードは指定できません", sc);
                        if (staticDefined)
                            if (!ret.Static)
                                throw new CodeEE("STATICとDYNAMICキーワードは同時に指定できません", sc);
                            else
                                throw new CodeEE(keyword + "キーワードが二重に指定されています", sc);
                        if (ret.Reference)
                            throw new CodeEE("STATICとREFキーワードは同時に指定できません", sc);
                        staticDefined = true;
                        ret.Static = true;
                        break;
                    case "GLOBAL":
                        if (isPrivate)
                            throw new CodeEE("ローカル変数の宣言に" + keyword + "キーワードは指定できません", sc);
                        if (ret.Global)
                            throw new CodeEE(keyword + "キーワードが二重に指定されています", sc);
                        ret.Global = true;
                        break;
                    case "SAVEDATA":
                        if (isPrivate)
                            throw new CodeEE("ローカル変数の宣言に" + keyword + "キーワードは指定できません", sc);
                        if (ret.Save)
                            throw new CodeEE(keyword + "キーワードが二重に指定されています", sc);
                        ret.Save = true;
                        break;
                    case "CHARDATA":
                        throw new CodeEE("キャラ変数の宣言は実装されていません", sc);
                    default:
                        ret.Name = keyword;
                        goto whilebreak;
                }
            }
            whilebreak:
            if (ret.Name == null)
                throw new CodeEE(keyword + "の後に有効な変数名が指定されていません", sc);
            string errMes = "";
            int errLevel = -1;
            if (isPrivate)
                GlobalStatic.IdentifierDictionary.CheckUserPrivateVarName(ref errMes, ref errLevel, ret.Name);
            else
                GlobalStatic.IdentifierDictionary.CheckUserVarName(ref errMes, ref errLevel, ret.Name);
            if (errLevel >= 0)
            {
                if (errLevel >= 2)
                    throw new CodeEE(errMes, sc);
                ParserMediator.Warn(errMes, sc, errLevel);
            }
            List<int> sizeNum = new List<int>();
            while (!wc.EOL)
            {
                if (wc.Current.Type != ',')
                    throw new CodeEE("書式が間違っています", sc);
                wc.ShiftNext();
                if (ret.Reference)//参照型の場合は要素数不要
                {
                    if (wc.EOL)
                        break;
                    if (wc.Current.Type == ',')
                    {
                        sizeNum.Add(0);
                        continue;
                    }
                }
                if (wc.EOL)
                    throw new CodeEE("カンマの後に有効な定数式が指定されていません", sc);
                IOperandTerm arg = ExpressionParser.ReduceIntegerTerm(wc, TermEndWith.Comma);
                SingleTerm sizeTerm = arg.Restructure(null) as SingleTerm;
                if ((sizeTerm == null) || (sizeTerm.GetOperandType() != typeof(Int64)))
                    throw new CodeEE("カンマの後に有効な定数式が指定されていません", sc);
                if (ret.Reference)//参照型には要素数指定不可(0にするか書かないかどっちか
                {
                    if (sizeTerm.Int != 0)
                        throw new CodeEE("参照型変数にはサイズを指定できません(サイズを省略するか0を指定してください)", sc);
                    continue;
                }
                else if ((sizeTerm.Int <= 0) || (sizeTerm.Int > 1000000))
                    throw new CodeEE("ユーザー定義変数のサイズは1以上1000000以下でなければなりません", sc);
                sizeNum.Add((int)sizeTerm.Int);
            }
            if (sizeNum.Count == 0)
                sizeNum.Add(1);
            ret.Private = isPrivate;
            ret.Dimension = sizeNum.Count;
            if (ret.Dimension > 3)
                throw new CodeEE("4次元以上の配列変数を宣言することはできません", sc);
            ret.Lengths = new int[sizeNum.Count];
            if (ret.Reference)
                return ret;
            Int64 totalBytes = 1;
            for (int i = 0; i < sizeNum.Count; i++)
            {
                ret.Lengths[i] = sizeNum[i];
                totalBytes *= ret.Lengths[i];
            }
            if ((totalBytes <= 0) || (totalBytes > 1000000))
                throw new CodeEE("ユーザー定義変数のサイズは1以上1000000以下でなければなりません", sc);
            if (!isPrivate && dims && ret.Dimension > 1 && ret.Save && !Config.SystemSaveInBinary)
                throw new CodeEE("文字列型の多次元配列変数にSAVEDATAフラグを付ける場合には「バイナリ型セーブ」オプションが必要です", sc);

            return ret;
        }
Example #54
0
            internal void AddKeyword(string token, string token2, ScriptPosition position)
            {
                var token2Enabled = (token2?.Length == 0);

                if (!token2Enabled)
                {
                    ParserMediator.Warn(token + "に余分な引数があります", position, 1);
                }
                else
                {
                    switch (token)
                    {
                    case "SKIPSTART":
                        if (skip)
                        {
                            ParserMediator.Warn("[SKIPSTART]が重複して使用されています", position, 1);
                            break;
                        }

                        ppMatch.Push("SKIPEND");
                        disabledStack.Push(Disabled);
                        doneStack.Push(done);

                        done     = false;
                        Disabled = skip = true;
                        break;

                    case "IF_DEBUG":
                        ppMatch.Push("ELSEIF");
                        disabledStack.Push(Disabled);
                        doneStack.Push(done);

                        Disabled = !Program.DebugMode;
                        done     = !Disabled;
                        break;

                    case "IF_NDEBUG":
                        ppMatch.Push("ELSEIF");
                        disabledStack.Push(Disabled);
                        doneStack.Push(done);

                        Disabled = Program.DebugMode;
                        done     = !Disabled;
                        break;

                    case "IF":
                        ppMatch.Push("ELSEIF");
                        disabledStack.Push(Disabled);
                        doneStack.Push(done);

                        Disabled = GlobalStatic.IdentifierDictionary.GetMacro(token2) == null;
                        done     = !Disabled;
                        break;

                    case "ELSEIF":
                        if (ppMatch.Count == 0 || ppMatch.Pop() != "ELSEIF")
                        {
                            ParserMediator.Warn("不適切な[ELSEIF]です", position, 1);
                            break;
                        }
                        ppMatch.Push("ELSEIF");

                        Disabled = done || (GlobalStatic.IdentifierDictionary.GetMacro(token2) == null);
                        done    |= !Disabled;
                        break;

                    case "ELSE":
                        if (!string.IsNullOrEmpty(token2))
                        {
                            ParserMediator.Warn(token + "に余分な引数があります", position, 1);
                            break;
                        }
                        if (ppMatch.Count == 0 || ppMatch.Pop() != "ELSEIF")
                        {
                            ParserMediator.Warn("不適切な[ELSE]です", position, 1);
                            break;
                        }
                        ppMatch.Push("ENDIF");

                        Disabled = done;
                        done     = true;
                        break;

                    case "SKIPEND":
                    {
                        string match = ppMatch.Count == 0 ? "" : ppMatch.Pop();
                        if (match != "SKIPEND")
                        {
                            ParserMediator.Warn("[SKIPSTART]と対応しない[SKIPEND]です", position, 1);
                            break;
                        }
                        skip     = false;
                        Disabled = disabledStack.Pop();
                        done     = doneStack.Pop();
                    }
                    break;

                    case "ENDIF":
                    {
                        string match = ppMatch.Count == 0 ? "" : ppMatch.Pop();
                        if (match != "ENDIF" && match != "ELSEIF")
                        {
                            ParserMediator.Warn("対応する[IF]のない[ENDIF]です", position, 1);
                            break;
                        }
                        Disabled = disabledStack.Pop();
                        done     = doneStack.Pop();
                    }
                    break;

                    default:
                        ParserMediator.Warn("認識できないプリプロセッサです", position, 1);
                        break;
                    }
                }

                if (skip)
                {
                    Disabled = true;
                }
            }