コード例 #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)
 {
 }
コード例 #7
0
 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)
 {
 }
コード例 #9
0
 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
ファイル: ABnf.cs プロジェクト: alittlesail/VSIX-ALanguage
        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;
 }
コード例 #16
0
 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;
 }
コード例 #18
0
 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)
 {
 }
コード例 #21
0
 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)
 {
 }
コード例 #25
0
 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;
        }
コード例 #28
0
 public override ABnfStringElement CreateStringElement(ABnfFile file, int line, int col, int offset, string type)
 {
     return(new ALittleScriptStringElement(this, file, line, col, offset, type));
 }
コード例 #29
0
 public AProtobufServiceOptionElement(ABnfFactory factory, ABnfFile file, int line, int col, int offset, string type)
     : base(factory, file, line, col, offset, type)
 {
 }
コード例 #30
0
 public AProtobufMessageVarNameElement(ABnfFactory factory, ABnfFile file, int line, int col, int offset, string type)
     : base(factory, file, line, col, offset, type)
 {
 }