示例#1
0
        protected override void visitCaseStatementAlternative(Alternative alternative)
        {
            writer.Append(KeywordEnum.WHEN.ToString()).Append(' ');

            bool first = true;

            foreach (Choice choice in alternative.Choices)
            {
                if (first)
                {
                    first = false;
                }
                else
                {
                    writer.Append(" | ");
                }
                output.writeChoice(choice);
            }
            writer.Append(" =>").NewLine();

            writer.Indent();
            output.writeSequentialStatements(alternative.Statements);
            writer.Dedent();
            writer.NewLine();
        }
        protected override void visitProcessStatement(AbstractProcessStatement statement)
        {
            appendLabel(statement);
            if (statement.Postponed)
            {
                writer.Append(KeywordEnum.POSTPONED.ToString()).Append(' ');
            }
            writer.Append(KeywordEnum.PROCESS.ToString());
            if (statement.SensitivityList.Count != 0)
            {
                writer.Append("(");
                bool first = true;
                foreach (Signal signal in statement.SensitivityList)
                {
                    if (first)
                    {
                        first = false;
                    }
                    else
                    {
                        writer.Append(", ");
                    }
                    if (signal == null)
                    {
                        writer.Append("null");
                    }
                    else
                    {
                        writer.AppendIdentifier(signal);
                    }
                }
                writer.Append(")");
            }

            OptionalIsFormat format = Annotations.getAnnotation <OptionalIsFormat>(statement);

            if (format != null && format.UseIs)
            {
                writer.Append(' ').Append(KeywordEnum.IS.ToString());
            }

            writer.NewLine().Indent();
            output.writeDeclarationMarkers(statement.Declarations);
            writer.Dedent().Append(KeywordEnum.BEGIN.ToString()).NewLine().Indent();
            output.writeSequentialStatements(statement.Statements);
            writer.Dedent().Append(KeywordEnum.END.ToString());
            if (statement.Postponed && writer.Format.RepeatLabels)
            {
                writer.Append(' ').Append(KeywordEnum.POSTPONED.ToString());
            }
            writer.Append(' ');
            writer.Append(KeywordEnum.PROCESS.ToString());
            if (statement.Label != null && writer.Format.RepeatLabels)
            {
                writer.Append(' ').Append(statement.Label);
            }
            writer.Append(";").NewLine();
        }
示例#3
0
        protected override void visitFunctionBody(FunctionBody declaration)
        {
            if (declaration.Impure)
            {
                writer.Append(KeywordEnum.IMPURE.ToString()).Append(' ');
            }
            writer.Append(KeywordEnum.FUNCTION.ToString()).Append(' ').AppendIdentifier(declaration);
            appendFunctionParameters(declaration.Parameters);
            writer.Append(' ').Append(KeywordEnum.RETURN.ToString()).Append(' ');
            output.writeSubtypeIndication(declaration.ReturnType);
            writer.Append(' ').Append(KeywordEnum.IS.ToString()).NewLine().Indent();
            output.writeDeclarationMarkers(declaration.Declarations);
            writer.Dedent().Append(KeywordEnum.BEGIN.ToString()).NewLine().Indent();
            output.writeSequentialStatements(declaration.Statements);

            //TODO: add repeated label
            writer.Dedent().Append(KeywordEnum.END.ToString()).Append(";").NewLine();
        }