示例#1
0
        private static TlaExpr Translate(this exprItem item, AutomatonParsingContext ctx)
        {
            TlaExpr expr;

            if (item.identifier != null)
            {
                bool constValue;

                if (bool.TryParse(item.identifier.@string, out constValue))
                {
                    expr = new TlaExpr.Const(constValue);
                }
                else
                {
                    expr = new TlaExpr.Var(ctx.Unescape(item.identifier.@string));
                }
            }
            else if (item.exprGroup != null)
            {
                expr = item.exprGroup.exprSeq.TranslateToTlaExpr(ctx);
            }
            else
            {
                throw new NotImplementedException();
            }

            if (item.not != null)
            {
                expr = new TlaExpr.Not(expr);
            }

            return(expr);
        }
        private static TransitionConditionExpr Translate(this exprItem item, AutomatonParsingContext ctx)
        {
            TransitionConditionExpr expr;

            if (item.identifier != null)
            {
                expr = new TransitionConditionExpr.VarExpr(ctx.Unescape(item.identifier.@string));
            }
            else if (item.exprGroup != null)
            {
                expr = item.exprGroup.exprSeq.TranslateToConditionExpr(ctx);
            }
            else if (item.literal != null)
            {
                expr = new TransitionConditionExpr.ConstExpr(true);
            }
            else
            {
                throw new NotImplementedException();
            }

            if (item.not != null)
            {
                expr = new TransitionConditionExpr.NotExpr(expr);
            }

            return(expr);
        }