Ejemplo n.º 1
0
        public virtual bool Filename(OMetaStream <char> inputStream, out OMetaList <HostExpression> result, out OMetaStream <char> modifiedStream)
        {
            OMetaList <HostExpression> name = null;
            OMetaList <HostExpression> ext  = null;

            modifiedStream = inputStream;
            if (!MetaRules.Apply(
                    delegate(OMetaStream <char> inputStream2, out OMetaList <HostExpression> result2, out OMetaStream <char> modifiedStream2)
            {
                modifiedStream2 = inputStream2;
                if (!MetaRules.Many1(
                        delegate(OMetaStream <char> inputStream3, out OMetaList <HostExpression> result3, out OMetaStream <char> modifiedStream3)
                {
                    modifiedStream3 = inputStream3;
                    if (!MetaRules.Apply(LetterOrDigit, modifiedStream3, out result3, out modifiedStream3))
                    {
                        return(MetaRules.Fail(out result3, out modifiedStream3));
                    }
                    return(MetaRules.Success());
                }
                        , modifiedStream2, out result2, out modifiedStream2))
                {
                    return(MetaRules.Fail(out result2, out modifiedStream2));
                }
                name = result2;
                if (!MetaRules.ApplyWithArgs(Exactly, modifiedStream2, out result2, out modifiedStream2, (".").AsHostExpressionList()))
                {
                    return(MetaRules.Fail(out result2, out modifiedStream2));
                }
                if (!MetaRules.Many1(
                        delegate(OMetaStream <char> inputStream3, out OMetaList <HostExpression> result3, out OMetaStream <char> modifiedStream3)
                {
                    modifiedStream3 = inputStream3;
                    if (!MetaRules.Apply(LetterOrDigit, modifiedStream3, out result3, out modifiedStream3))
                    {
                        return(MetaRules.Fail(out result3, out modifiedStream3));
                    }
                    return(MetaRules.Success());
                }
                        , modifiedStream2, out result2, out modifiedStream2))
                {
                    return(MetaRules.Fail(out result2, out modifiedStream2));
                }
                ext = result2;
                result2 = (name.As <string>() + "." + ext.As <string>()).AsHostExpressionList();
                return(MetaRules.Success());
            }, modifiedStream, out result, out modifiedStream))
            {
                return(MetaRules.Fail(out result, out modifiedStream));
            }
            return(MetaRules.Success());
        }
Ejemplo n.º 2
0
        public virtual bool FileStats(OMetaStream <char> inputStream, out OMetaList <HostExpression> result, out OMetaStream <char> modifiedStream)
        {
            OMetaList <HostExpression> lines = null;
            OMetaList <HostExpression> name  = null;

            modifiedStream = inputStream;
            if (!MetaRules.Apply(
                    delegate(OMetaStream <char> inputStream2, out OMetaList <HostExpression> result2, out OMetaStream <char> modifiedStream2)
            {
                modifiedStream2 = inputStream2;
                if (!MetaRules.Apply(LineStats, modifiedStream2, out result2, out modifiedStream2))
                {
                    return(MetaRules.Fail(out result2, out modifiedStream2));
                }
                lines = result2;
                if (!MetaRules.ApplyWithArgs(Exactly, modifiedStream2, out result2, out modifiedStream2, ("\t").AsHostExpressionList()))
                {
                    return(MetaRules.Fail(out result2, out modifiedStream2));
                }
                if (!MetaRules.Apply(Filename, modifiedStream2, out result2, out modifiedStream2))
                {
                    return(MetaRules.Fail(out result2, out modifiedStream2));
                }
                name = result2;
                if (!MetaRules.Apply(NewLine, modifiedStream2, out result2, out modifiedStream2))
                {
                    return(MetaRules.Fail(out result2, out modifiedStream2));
                }
                result2 = (new FileStats(lines[0].As <int>(), lines[1].As <int>(), name.As <string>())).AsHostExpressionList();
                return(MetaRules.Success());
            }, modifiedStream, out result, out modifiedStream))
            {
                return(MetaRules.Fail(out result, out modifiedStream));
            }
            return(MetaRules.Success());
        }
Ejemplo n.º 3
0
        public virtual bool SExpression(OMetaStream <char> inputStream, out OMetaList <HostExpression> result, out OMetaStream <char> modifiedStream)
        {
            OMetaList <HostExpression> a = null;
            OMetaList <HostExpression> l = null;

            modifiedStream = inputStream;
            if (!MetaRules.Or(modifiedStream, out result, out modifiedStream,
                              delegate(OMetaStream <char> inputStream2, out OMetaList <HostExpression> result2, out OMetaStream <char> modifiedStream2)
            {
                modifiedStream2 = inputStream2;
                if (!MetaRules.Apply(
                        delegate(OMetaStream <char> inputStream3, out OMetaList <HostExpression> result3, out OMetaStream <char> modifiedStream3)
                {
                    modifiedStream3 = inputStream3;
                    if (!MetaRules.Apply(Spaces, modifiedStream3, out result3, out modifiedStream3))
                    {
                        return(MetaRules.Fail(out result3, out modifiedStream3));
                    }
                    if (!MetaRules.Apply(Atom, modifiedStream3, out result3, out modifiedStream3))
                    {
                        return(MetaRules.Fail(out result3, out modifiedStream3));
                    }
                    a = result3;
                    if (!MetaRules.Apply(Spaces, modifiedStream3, out result3, out modifiedStream3))
                    {
                        return(MetaRules.Fail(out result3, out modifiedStream3));
                    }
                    result3 = (a).AsHostExpressionList();
                    return(MetaRules.Success());
                }, modifiedStream2, out result2, out modifiedStream2))
                {
                    return(MetaRules.Fail(out result2, out modifiedStream2));
                }
                return(MetaRules.Success());
            }
                              , delegate(OMetaStream <char> inputStream2, out OMetaList <HostExpression> result2, out OMetaStream <char> modifiedStream2)
            {
                modifiedStream2 = inputStream2;
                if (!MetaRules.Apply(
                        delegate(OMetaStream <char> inputStream3, out OMetaList <HostExpression> result3, out OMetaStream <char> modifiedStream3)
                {
                    modifiedStream3 = inputStream3;
                    if (!MetaRules.Apply(Spaces, modifiedStream3, out result3, out modifiedStream3))
                    {
                        return(MetaRules.Fail(out result3, out modifiedStream3));
                    }
                    if (!MetaRules.Apply(List, modifiedStream3, out result3, out modifiedStream3))
                    {
                        return(MetaRules.Fail(out result3, out modifiedStream3));
                    }
                    l = result3;
                    if (!MetaRules.Apply(Spaces, modifiedStream3, out result3, out modifiedStream3))
                    {
                        return(MetaRules.Fail(out result3, out modifiedStream3));
                    }
                    result3 = (l.As <SExprList>()).AsHostExpressionList();
                    return(MetaRules.Success());
                }, modifiedStream2, out result2, out modifiedStream2))
                {
                    return(MetaRules.Fail(out result2, out modifiedStream2));
                }
                return(MetaRules.Success());
            }
                              ))
            {
                return(MetaRules.Fail(out result, out modifiedStream));
            }
            return(MetaRules.Success());
        }