public static BinFile CompileToBinFile(CompilerSections aSecs, bool aOptimize = false) { var bytes = RawCompile(aSecs, aOptimize); return(new BinFile(bytes)); }
public static byte[] RawCompile(CompilerIns[] aIns, bool aOptimize = false) { var compSecs = new CompilerSections(); compSecs.CodeSectionData.AddRange(aIns); return (new Compiler(compSecs, null, aOptimize).Compile()); }
public CompilerSections Parse(string aInput) { var newLineSkip = Environment.NewLine.Length - 1; var lineNo = 0; var isLine = false; var inString = false; BinSections?section = null; var compSec = new CompilerSections(); var skipChars = 0; var startPos = 0; var endPos = 0; var span = new ReadOnlySpan <char>(aInput.ToCharArray()); var len = span.Length; for (var i = 0; i < len; i++) { var c = span[i]; // Do we have a string? if (c == '"') { // Yes, ensure that new lines are not treated as // separators while we are within it. inString = !inString; } // Do we have a line delimiter? if (!inString && c == '\n') { // Was the last character before the new line // break a line continuation operator? // If so we do not want to perform the line break // here. var contPos = i - newLineSkip - 1; if (contPos < 0 || span[contPos] != '\\') { // Yes, update the end point of our range // to account for it. endPos = i - 1; skipChars = newLineSkip; isLine = true; } } // Are we are the end of the string? if (i == len - 1) { // Always ensure that we take the contents of the // last line. endPos = i + 1; isLine = true; } // We do not have a complete line yet. // Move on to the next character. if (!isLine) { continue; } // We should not be attempting to push a line // that has an unmatched string. Assert(inString, ExIDs.MismatchedString, lineNo, i); // We have a line. // Pass the span into the next stage of the parser. if (span[startPos] == '.') { // The line is a section identifier. section = ParseSectionLine(span[startPos..endPos]);
public static byte[] RawCompile(CompilerSections aSecs, bool aOptimize = false) { return(new Compiler(aSecs, null, aOptimize).Compile()); }