コード例 #1
0
ファイル: Program.cs プロジェクト: LexouDuck/Event-Assembler
        public static void Preprocess(string originalFile, string outputFile, string game, ILog messageLog)
        {
            EACodeLanguage eaCodeLanguage = Program.Languages [game];

            using (IPreprocessor preprocessor = (IPreprocessor) new Preprocessor(messageLog)) {
                preprocessor.AddReserved(eaCodeLanguage.GetCodeNames());
                preprocessor.AddDefined(new string[] { "_" + game + "_", "_EA_" });

                using (StreamReader streamReader = File.OpenText(originalFile)) {
                    using (IInputStream inputStream = (IInputStream) new PreprocessingInputStream((TextReader)streamReader, preprocessor)) {
                        StringWriter stringWriter = new StringWriter();

                        while (true)
                        {
                            string str = inputStream.ReadLine();

                            if (str != null)
                            {
                                stringWriter.WriteLine(str);
                            }
                            else
                            {
                                break;
                            }
                        }

                        messageLog.AddMessage("Processed code:\n" + stringWriter.ToString() + "\nEnd processed code");
                    }
                }
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: LexouDuck/Event-Assembler
        // Used by Emblem Magic (and could potentially be used by other external software)
        public static void Assemble(EACodeLanguage language,
                                    TextReader input, BinaryWriter output, ILog log)
        {
            List <string> stringList = new List <string>();

            stringList.Add("_" + language.Name + "_");
            stringList.Add("_EA_");
            using (IPreprocessor preprocessor = new Preprocessor(log))
            {
                preprocessor.AddReserved(language.GetCodeNames());
                preprocessor.AddDefined(stringList.ToArray());
                using (IInputStream inputStream = new PreprocessingInputStream(input, preprocessor))
                {
                    new EAExpressionAssembler(language.CodeStorage,
                                              new TokenParser <int>(new Func <string, int>(StringExtensions.GetValue))).Assemble(inputStream, output, log);
                }
            }
        }
コード例 #3
0
        private static void Assemble(EACodeLanguage language, TextReader input, BinaryWriter output, ILog log)
        {
            var predefined = new List<string>
            {
                "_" + language.Name + "_",
                "_EA_"
            };
            using (IPreprocessor preprocessor = new Preprocessor(log))
            {
                preprocessor.AddReserved(language.GetCodeNames());
                preprocessor.AddDefined(predefined.ToArray());

                IInputStream stream = new PreprocessingInputStream(input, preprocessor);

                language.Assemble(stream, output, log);
            }
        }
コード例 #4
0
 public static void GetNotepadPlusPluslanguageDoc(EACodeLanguage language, string outputFile)
 {
     using (XmlWriter writer = XmlWriter.Create(outputFile, new XmlWriterSettings()
     {
         Encoding = Encoding.ASCII,
         Indent = true,
         OmitXmlDeclaration = true,
         IndentChars = "    "
     }))
     {
         writer.WriteStartElement("NotepadPlus");
         writer.WriteStartElement("UserLang");
         writer.WriteAttributeString("name", language.Name + " Event Assembly");
         writer.WriteAttributeString("ext", "event");
         writer.WriteStartElement("Settings");
         writer.WriteStartElement("Global");
         writer.WriteAttributeString("caseIgnored", "yes");
         writer.WriteEndElement();
         writer.WriteStartElement("TreatAsSymbol");
         writer.WriteAttributeString("comment", "yes");
         writer.WriteAttributeString("commentLine", "yes");
         writer.WriteEndElement();
         writer.WriteStartElement("Prefix");
         writer.WriteAttributeString("words1", "no");
         writer.WriteAttributeString("words2", "no");
         writer.WriteAttributeString("words3", "no");
         writer.WriteAttributeString("words4", "no");
         writer.WriteEndElement();
         writer.WriteEndElement();
         writer.WriteStartElement("KeywordLists");
         HighlightingHelper.NotepadPlusPlus.WriteKeywords(writer, "Delimiters", new string[1] {
             "<>"
         });
         HighlightingHelper.NotepadPlusPlus.WriteKeywords(writer, "Folder+", new string[1] {
             "{"
         });
         HighlightingHelper.NotepadPlusPlus.WriteKeywords(writer, "Folder-", new string[1] {
             "}"
         });
         HighlightingHelper.NotepadPlusPlus.WriteKeywords(writer, "Operators", "(", ")", "[", "]", "+", "-", "*", "/", "%", ">>", "<<", "&", "|", "^", ",", ";");
         HighlightingHelper.NotepadPlusPlus.WriteKeywords(writer, "Comment", "1/*", "2*/", "0//");
         HighlightingHelper.NotepadPlusPlus.WriteKeywords(writer, "Words1", language.GetCodeNames());
         HighlightingHelper.NotepadPlusPlus.WriteKeywords(writer, "Words2");
         HighlightingHelper.NotepadPlusPlus.WriteKeywords(writer, "Words3", "#ifdef", "#define", "#pool", "#else", "#endif", "#ifndef", "#include", "#incbin", "#undef");
         HighlightingHelper.NotepadPlusPlus.WriteKeywords(writer, "Words4");
         writer.WriteEndElement();
         writer.WriteStartElement("Styles");
         HighlightingHelper.NotepadPlusPlus.WriteStyle(writer, "DEFAULT", 11, Color.Black, Color.White, "", 0, new int?());
         HighlightingHelper.NotepadPlusPlus.WriteStyle(writer, "FOLDEROPEN", 12, Color.Black, Color.White, "", 0, new int?());
         HighlightingHelper.NotepadPlusPlus.WriteStyle(writer, "FOLDERCLOSE", 13, Color.Black, Color.White, "", 0, new int?());
         HighlightingHelper.NotepadPlusPlus.WriteStyle(writer, "KEYWORD1", 5, Color.FromArgb(0, 0, (int)byte.MaxValue), Color.White, "", 0, new int?());
         HighlightingHelper.NotepadPlusPlus.WriteStyle(writer, "KEYWORD2", 6, Color.FromArgb(0, 128, (int)byte.MaxValue), Color.White, "", 0, new int?());
         HighlightingHelper.NotepadPlusPlus.WriteStyle(writer, "KEYWORD3", 7, Color.FromArgb(0, 64, 128), Color.White, "", 1, new int?());
         HighlightingHelper.NotepadPlusPlus.WriteStyle(writer, "KEYWORD4", 8, Color.FromArgb(64, 128, 128), Color.White, "", 0, new int?());
         HighlightingHelper.NotepadPlusPlus.WriteStyle(writer, "COMMENT", 1, Color.FromArgb(0, 159, 0), Color.White, "", 0, new int?());
         HighlightingHelper.NotepadPlusPlus.WriteStyle(writer, "COMMENT LINE", 2, Color.FromArgb(0, 128, 0), Color.White, "", 0, new int?());
         HighlightingHelper.NotepadPlusPlus.WriteStyle(writer, "NUMBER", 4, Color.FromArgb(128, 0, 128), Color.White, "", 0, new int?());
         HighlightingHelper.NotepadPlusPlus.WriteStyle(writer, "OPERATOR", 10, Color.FromArgb((int)byte.MaxValue, 0, 0), Color.White, "", 1, new int?());
         HighlightingHelper.NotepadPlusPlus.WriteStyle(writer, "DELIMINER1", 14, Color.FromArgb((int)byte.MaxValue, 0, (int)byte.MaxValue), Color.White, "", 0, new int?());
         HighlightingHelper.NotepadPlusPlus.WriteStyle(writer, "DELIMINER2", 15, Color.FromArgb((int)byte.MaxValue, 0, 128), Color.White, "", 0, new int?());
         HighlightingHelper.NotepadPlusPlus.WriteStyle(writer, "DELIMINER3", 16, Color.Black, Color.White, "", 0, new int?());
         writer.WriteEndElement();
         writer.WriteEndElement();
         writer.WriteEndElement();
     }
 }