예제 #1
0
        public bool PreCheck(ABnfFile file, int offset)
        {
            if (pre_check_value == null)
            {
                return(true);
            }

            for (int i = 0; i < pre_check_value.value.Length; ++i)
            {
                if (i + offset >= file.m_text.Length)
                {
                    return(false);
                }
                if (pre_check_value.value[i] != file.m_text[i + offset])
                {
                    return(false);
                }
            }
            return(true);
        }
예제 #2
0
        // 更新FileItem对象
        public void UpdateFileItem(uint item_id, ABnfFile file, bool need_analysis)
        {
            if (!m_id_map_node.TryGetValue(item_id, out FileItem value))
            {
                return;
            }

            // 设置所在工程
            file.SetProjectInfo(this);
            // 先移除,解析
            RemoveAnalysis(value);
            // 更新文件对象
            value.SetFile(file);
            if (need_analysis)
            {
                file.UpdateAnalysis();
            }
            // 再添加,解析
            AddAnalysis(value);
        }
예제 #3
0
        // 创建分析对象
        protected FileItem CreatFileItem(ABnf abnf, string full_path, uint node)
        {
            // 读取文件
            var text = File.ReadAllText(full_path);

            // 创建ABnfFile
            var file = m_factory.CreateABnfFile(full_path, abnf, text);

            if (file == null)
            {
                file = new ABnfFile(full_path, abnf, text);
            }
            file.SetProjectInfo(this);

            // 创建item
            var file_item = m_factory.CreateFileItem(this, abnf, full_path, node, file);

            if (file_item == null)
            {
                file_item = new FileItem(this, abnf, full_path, node, file);
            }
            return(file_item);
        }
 public ALittleScriptAccessModifierElement(ABnfFactory factory, ABnfFile file, int line, int col, int offset, string type)
     : base(factory, file, line, col, offset, type)
 {
 }
예제 #5
0
 public FileItem(ProjectInfo project, ABnf abnf, string full_path, uint item_id, ABnfFile file)
 {
     m_project   = project;
     m_abnf      = abnf;
     m_full_path = full_path;
     m_item_id   = item_id;
     m_file      = file;
 }
 public ALittleScriptPropertyValueMethodTemplateElement(ABnfFactory factory, ABnfFile file, int line, int col, int offset, string type)
     : base(factory, file, line, col, offset, type)
 {
 }
 public override ABnfRegexElement CreateRegexElement(ABnfFile file, int line, int col, int offset, string type, Regex regex)
 {
     return(new ALittleScriptRegexElement(this, file, line, col, offset, type, regex));
 }
예제 #8
0
 public ALittleScriptReflectCustomTypeElement(ABnfFactory factory, ABnfFile file, int line, int col, int offset, string type)
     : base(factory, file, line, col, offset, type)
 {
 }
 public AProtobufEnumBodyElement(ABnfFactory factory, ABnfFile file, int line, int col, int offset, string type)
     : base(factory, file, line, col, offset, type)
 {
 }
 public ALittleScriptPrimitiveTypeElement(ABnfFactory factory, ABnfFile file, int line, int col, int offset, string type)
     : base(factory, file, line, col, offset, type)
 {
 }
예제 #11
0
 public ALittleScriptValueFactorStatElement(ABnfFactory factory, ABnfFile file, int line, int col, int offset, string type)
     : base(factory, file, line, col, offset, type)
 {
 }
예제 #12
0
 public ALittleScriptTemplateExtendsClassDecElement(ABnfFactory factory, ABnfFile file, int line, int col, int offset, string type)
     : base(factory, file, line, col, offset, type)
 {
 }
예제 #13
0
        public ABnfNodeElement Analysis(ABnfFile file)
        {
            if (m_root == null)
            {
                return(null);
            }

            // 清空缓存
            m_regex_skip.Clear();
            m_line_comment_skip.Clear();
            m_block_comment_skip.Clear();
            // m_stat = new ABnfRuleStat();
            // 保存字符串
            m_file = file;

            // 初始化位置
            int  line       = 0;
            int  col        = 0;
            int  offset     = 0;
            int  pin_offset = -1;
            bool not_key    = false;

            m_stop_stack.Clear();

            // 创建跟节点,然后开始解析
            var node = CreateNodeElement(line, col, offset, m_root.id.value);

            while (true)
            {
                if (!AnalysisABnfNode(m_root, m_root.node, node, not_key
                                      , ref line, ref col, ref offset
                                      , ref pin_offset, false))
                {
                    if (offset >= m_file.m_text.Length && m_file.m_text.Length > 0)
                    {
                        --offset;
                    }
                }
                else
                {
                    AnalysisSkip(ref line, ref col, ref offset);
                    if (offset >= m_file.m_text.Length)
                    {
                        break;
                    }
                }
                node.AddChild(new ABnfErrorElement(m_factory, m_file, line, col, offset, "语法错误", null));

                // 跳到下一行
                if (!JumpToNextLine(ref line, ref col, ref offset))
                {
                    break;
                }
            }

            if (m_stat != null)
            {
                StatElement(node);
                m_stat.CalcRate();
            }

            // 清空缓存
            m_regex_skip.Clear();
            m_line_comment_skip.Clear();
            m_block_comment_skip.Clear();
            m_stat = null;
            m_file = null;

            // 返回结果
            return(node);
        }
예제 #14
0
 public ABnfRegexElement(ABnfFactory factory, ABnfFile file, int line, int col, int offset, string value, Regex regex)
     : base(factory, file, line, col, offset, value)
 {
     m_regex = regex;
 }
예제 #15
0
 public ABnfLeafElement(ABnfFactory factory, ABnfFile file, int line, int col, int offset, string value)
     : base(factory, file, line, col, offset)
 {
     m_value = value;
 }
 public AProtobufRegexElement(ABnfFactory factory, ABnfFile file, int line, int col, int offset, string type, Regex regex)
     : base(factory, file, line, col, offset, type, regex)
 {
 }
예제 #17
0
 // 设置文件对象
 public void SetFile(ABnfFile file)
 {
     m_file = file;
 }
 public ABnfStringElement(ABnfFactory factory, ABnfFile file, int line, int col, int offset, string value)
     : base(factory, file, line, col, offset, value)
 {
 }
 public ALittleScriptMethodReturnTailDecElement(ABnfFactory factory, ABnfFile file, int line, int col, int offset, string type)
     : base(factory, file, line, col, offset, type)
 {
 }
예제 #20
0
 public ALittleScriptDoWhileConditionElement(ABnfFactory factory, ABnfFile file, int line, int col, int offset, string type)
     : base(factory, file, line, col, offset, type)
 {
 }
 public override FileItem CreateFileItem(ProjectInfo project, ABnf abnf, string full_path, uint item_id, ABnfFile file)
 {
     return(new AProtobufFileItem(project, abnf, full_path, item_id, file));
 }
 public ALittleScriptStructOptionNameDecElement(ABnfFactory factory, ABnfFile file, int line, int col, int offset, string type)
     : base(factory, file, line, col, offset, type)
 {
 }
 public ALittleScriptOpAssignExprElement(ABnfFactory factory, ABnfFile file, int line, int col, int offset, string type)
     : base(factory, file, line, col, offset, type)
 {
 }
예제 #24
0
 public ALittleScriptGenericFunctorParamTailElement(ABnfFactory factory, ABnfFile file, int line, int col, int offset, string type)
     : base(factory, file, line, col, offset, type)
 {
 }
 public ALittleScriptForPairDecElement(ABnfFactory factory, ABnfFile file, int line, int col, int offset, string type)
     : base(factory, file, line, col, offset, type)
 {
 }
예제 #26
0
 public override ABnfKeyElement CreateKeyElement(ABnfFile file, int line, int col, int offset, string type)
 {
     return(new AProtobufKeyElement(this, file, line, col, offset, type));
 }
예제 #27
0
        protected List <ABnfElement> m_childs = new List <ABnfElement>(); // 节点列表

        public ABnfNodeElement(ABnfFactory factory, ABnfFile file, int line, int col, int offset, string type)
            : base(factory, file, line, col, offset)
        {
            m_type = type;
        }
 public override ABnfStringElement CreateStringElement(ABnfFile file, int line, int col, int offset, string type)
 {
     return(new ALittleScriptStringElement(this, file, line, col, offset, type));
 }
 public AProtobufServiceOptionElement(ABnfFactory factory, ABnfFile file, int line, int col, int offset, string type)
     : base(factory, file, line, col, offset, type)
 {
 }
 public AProtobufMessageVarNameElement(ABnfFactory factory, ABnfFile file, int line, int col, int offset, string type)
     : base(factory, file, line, col, offset, type)
 {
 }