Esempio n. 1
0
        public List <TreeElement> GetTree()
        {
            _tokens = new List <TreeElement>();

            while (!_reader.IsEmpty())
            {
                var token = GetTreeElement(_reader.Read());
                if (token == null)
                {
                    break;
                }
                _tokens.Add(token);
            }

            return(_tokens);
        }
Esempio n. 2
0
        public string GetCode()
        {
            var ns =
                _file.Replace('\\', '_').Replace('/', '_').Replace(".tengri", "");

            _code += "namespace FILE_TENGRI_" + ns + " {";

            if (_inClass)
            {
                _code = "";
            }

            while (!_reader.IsEmpty())
            {
                var part = GetPart(_reader.Read());
                if (part == null)
                {
                    break;
                }

                _code += part;
            }

            if (!_inClass)
            {
                _code += "}";
                var code = _code;
                _code = "\t/* GENERATED BY TENGRI TRANSLATOR */\n// =============================================== //\n\n\n";

                foreach (var needNamespace in NeedNamespaces)
                {
                    _code += $"using {needNamespace};\n";
                }

                _code += $"\n{code}";
            }

            return(_code);
        }