Beispiel #1
0
        public void Parse_Namespace_Definition_Keyword_And_Identifier()
        {
            const string xNamespaceDefinitionLine = "namespace DebugStub";
            const int    xExpectedTokenCount      = 2;

            var xCodePoints = mTokenMap.Parse(xNamespaceDefinitionLine);

            Assert.AreEqual(xExpectedTokenCount, xCodePoints.Count);
        }
Beispiel #2
0
        public void Emit(TextReader aIn)
        {
            try {
                LineNo = 1;
                // Do not trim it here. We need spaces for colorizing
                // and also to keep indentation in the output.
                string xText = aIn.ReadLine();
                while (xText != null)
                {
                    int i = xText.Length - xText.TrimStart().Length;
                    mNASM.Indent = Indent = xText.Substring(0, i);

                    if (string.IsNullOrWhiteSpace(xText))
                    {
                        WriteLine();
                    }
                    else if (xText == "//END")
                    {
                        // Temp hack, remove in future
                        break;
                    }
                    else
                    {
                        var xCodePoints = mTokenMap.Parse(xText);
                        var xLastToken  = xCodePoints.Last().Token;
                        if (EmitSourceCode && (xCodePoints[0].Token is Tokens.OpComment == false))
                        {
                            WriteLine("; " + xText.Trim());
                        }
                        xLastToken.Emitter(xCodePoints);
                    }

                    xText = aIn.ReadLine();
                    LineNo++;
                }
            } catch (Exception e) {
                throw new Exception("Generation error on line " + LineNo, e);
            }
        }