Ejemplo n.º 1
0
        // Algo réalisé à l'aide de la grammaire formelle
        public static NodeAST MatchRegex(StringCursor stringCursor)
        {
            NodeAST node = MatchAlternative(stringCursor);

            if (node.Type == NodeASTType.Error)
            {
                return(node);
            }
            return(stringCursor.Match('\0') ? node : NodeAST.CreateError());
        }
Ejemplo n.º 2
0
        public static NodeAST MatchConstant(StringCursor stringCursor)
        {
            if (!char.IsLetterOrDigit(stringCursor.Current))
            {
                return(NodeAST.CreateError());
            }
            NodeAST node = new NodeAST(NodeASTType.Constant, stringCursor.Current);

            stringCursor.Next();
            return(node);
        }
Ejemplo n.º 3
0
        public static NodeAST MatchParenthesis(StringCursor stringCursor)
        {
            if (!stringCursor.Match('('))
            {
                return(NodeAST.CreateError());
            }
            stringCursor.Next();
            NodeAST node = MatchAlternative(stringCursor);

            if (node.Type == NodeASTType.Error)
            {
                return(node);
            }
            if (!stringCursor.Match(')'))
            {
                return(NodeAST.CreateError());
            }
            stringCursor.Next();
            return(node);
        }