public static byte[] BuildScript(IEnumerable <string> lines)
        {
            IEnumerable <Semanteme> semantemes = null;

            try
            {
                semantemes = Semanteme.ProcessLines(lines);
            }
            catch (Exception e)
            {
                throw new Exception("Error parsing the script" + e.ToString());
            }

            var       sb = new ScriptBuilder();
            Semanteme tmp;

            byte[] script = null;

            try
            {
                foreach (var entry in semantemes)
                {
                    tmp = entry;
                    entry.Process(sb);
                }
                script = sb.ToScript();
            }
            catch (Exception e)
            {
                throw new Exception("Error assembling the script: " + e.ToString());
            }

            return(script);
        }
        public static byte[] BuildScript(IEnumerable <string> lines, string fileName, out DebugInfo debugInfo, out Dictionary <string, int> labels)
        {
            Semanteme[] semantemes;
            try
            {
                semantemes = Semanteme.ProcessLines(lines);
            }
            catch (Exception e)
            {
                throw new Exception("Error parsing the script" + e.ToString());
            }

            var       sb = new ScriptBuilder();
            Semanteme tmp;

            byte[] script;

            var debugRanges = new List <DebugRange>();

            try
            {
                foreach (var entry in semantemes)
                {
                    var startOffset = sb.CurrentSize;

                    tmp = entry;
                    entry.Process(sb);

                    var endOffset = sb.CurrentSize;

                    if (endOffset > startOffset)
                    {
                        endOffset--;
                    }

                    debugRanges.Add(new DebugRange(entry.LineNumber, startOffset, endOffset));
                }
                script = sb.ToScript(out labels);
            }
            catch (Exception e)
            {
                throw new Exception("Error assembling the script: " + e.ToString());
            }

            if (fileName != null)
            {
                debugInfo = new DebugInfo(fileName, debugRanges);
            }
            else
            {
                debugInfo = null;
            }

            return(script);
        }