Skip to content

Statements and Blocks

mmaness edited this page Oct 5, 2011 · 9 revisions

A simple statement is a logical line of code which performs a calculation and/or changes state. Sequences of simple statements are called blocks. These block provide context for the individual simple statements. A collection of blocks make up a Survenity survey.

Simple Statement

A simple statement is comprised of one logical line of code. Only one statement may exist on a physical line.

A statement may be an expression, assignment, comment statement, question statement, question trait, choice experiment statement, or choice experiment trait.

Expression

Expressions are covered in the expressions section of the language specification.

Assignment

Assignment statements are used to bind identifiers (or variable names) to values. Only one assignment may be performed per line. Assignment is not a type of expression, so assignments do not evaluate to a value. Assignment is performed using the equals sign, '='. The identifier is placed on the left side of the assignment operator while the expression, whose value will bind to identifier (variable name), is placed on the right side of the assignment operator.

assignment ::= identifier '=' expression

Question Statements

Question statements are statements which represent the creation of a particular type of question. Question statements always begin with a capitalized token corresponding to a question type. See question types for more information.

Question Traits

Question traits are statements which are intended to modify a question. Question traits are placed in blocks which bind question types to question traits. See question traits for more information.

Choice Experiment Statement

Choice experiment statements are statements which represent the creation of a choice experiment. Currently, choice experiment statements always begin with the ChoiceExperiment token.

Choice Experiment Traits

Choice experiment traits are statements which are intended to modify a choice experiment. Choice experiment traits are placed in blocks which bind choice experiments to choice experiment traits. See choice experiment traits for more information.

Blocks

A block is comprised of a sequence of simple statements. Block statements generally begin with a question statement or calculation statement and terminate at the start of a new block statement. For calculation statements, termination ends at a matching end keyword.

Following this first statement, a sequence of additional statements constitute the block. These statements generally are required to be related to the first statement in the block. The parser is set to know which statements are appropriate for each type of statement that can start a block.

All statements between the first statement and the start of the next block are bound to the start statement. For example, if a Multiple Choice question named Cars is created followed by a statement which declares a question's text as "How many cars do you own?", then that question text will be associated with the Cars question.

A more thorough treatment of blocks is covered on the pages for question types and choice experiments.

Compound Statement

Compound statements are similar to blocks but deal with the execution of calculations, functions, and object creation. Compound statements are not currently implemented in Survenity.


Go back to Survenity Language Reference

Home | JULIE Intro | Getting Started with JULIE | JULIE References | JULIE Development | Survenity Language