spudplate
Template scaffolding compiler for spudlang .spud files
Loading...
Searching...
No Matches
spudplate::AskStmt Struct Reference

An ask statement - declares a variable and prompts the user. More...

#include <ast.h>

Public Attributes

std::string name
 Variable name to bind the answer to.
 
std::string prompt
 The prompt string shown to the user.
 
VarType var_type
 Expected type of the answer.
 
std::optional< ExprPtr > default_value
 Expression evaluated when the user skips the prompt.
 
std::vector< ExprPtr > options
 Allowed literal values; empty means any.
 
std::optional< ExprPtr > when_clause
 Optional condition guarding the prompt.
 
int line
 1-based source line where this node begins.
 
int column
 1-based source column where this node begins.
 

Detailed Description

An ask statement - declares a variable and prompts the user.

Example: ask license "License?" string default "MIT"

Without a default clause the prompt is required; with one, the answer may be skipped and the default literal is used in its place.