Beispiel #1
0
 private MrasmInstructionTemplate[] get_instructions(string filename)
 {
     string[] lines = ResourceManager.GetResource(filename);
     MrasmInstructionTemplate[] output = new MrasmInstructionTemplate[lines.Length];
     for (int i = 0; i < output.Length; i++)
     {
         output[i] = new MrasmInstructionTemplate(lines[i]);
     }
     return(output);
 }
Beispiel #2
0
        public int Compile()
        {
            string preprocess_error, er_line;
            int    er_line_num;

            if (!try_pre_process(out preprocess_error, out er_line, out er_line_num))
            {
                write_compile_error(preprocess_error, er_line, er_line_num, input.Target);
                return((int)ErrorCode.Preprocessor);
            }
            List <string> output = new List <string>();

            for (int i = 0; i < lines.Length; i++)
            {
                string line      = lines[i];
                bool   iscomment = (line.Trim().StartsWith(comment_specifier));
                bool   isempty   = string.IsNullOrEmpty(line.Trim());
                if (!iscomment && !isempty && !is_preprocessor_line[i])
                {
                    bool found_template            = false;
                    MrasmInstructionTemplate match = null;
                    foreach (MrasmInstructionTemplate template in language)
                    {
                        if (template.CheckNameMatch(line))
                        {
                            found_template = true;
                            match          = template;
                        }
                    }

                    if (!found_template)
                    {
                        write_compile_error("found no matching command", line, i + 1, input.Target);
                        return((int)ErrorCode.Compiler);
                    }

                    string control_word;
                    string compile_error;
                    match.EnvDefs = environment_defs;
                    if (!match.CheckSyntaxMatch(line, out control_word, out compile_error))
                    {
                        write_compile_error(compile_error, line, i + 1, input.Target);
                        return((int)ErrorCode.Compiler);
                    }
                    output.Add(control_word.PadLeft(8, '0'));
                }
            }
            File.WriteAllLines(input.OutputExecutableName, output.ToArray());
            return((int)ErrorCode.Success);
        }