渲染zh-Hant

讀取

Translation status: 繁體中文 reader-locale proof. Term names and code fences follow the zh-Hant pack; supporting prose may still be English.

Reads input from the active input stream.

Syntax: 讀取 [行]

Category#

io

Examples#

radix/corpus/lege/lege.fab (canonical · keyword)#

Reads input from the active input stream.

# =============================================================================
# 讀取 — Reads input from the active input stream.
# =============================================================================
#
# What this teaches:
#   • stdin input with `讀取` — reads one line from the active input stream
#   • the `↦ 正規表示式` 變換 — compiling a 文字 pattern into a 正規表示式 value
#
# Common mistakes:
#   • Not checking is null before using the value — read may return null at end of input.
#
# See also: 行, 寫出
# =============================================================================

# 讀取 and 正規表示式 轉換 — I/O read and compiled pattern expressions
#
# 定值 _ pattern ← "\d+" ↦ 正規表示式   -- compiled 正規表示式 from 文字
# 定值 _ input ← 讀取                  -- stdin line read
#
# GRAMMAR:
#   轉換 :← stringLit '↦' '正規表示式'
#   readExpr :← '讀取'
#
# EXPECTED OUTPUT:
#   Regex pattern diagnostic, then one stdin line (no .expected — interactive).
#
# BACKEND: Rust/Go/roundtrip e2e whitelist — 讀取 not yet lowered for Rust/Go
# (whitelist: 讀取/lege.fab).

main {
    const 正規表示式 pattern ← "(?i)\d+" ↦ 正規表示式
    print pattern
    const string ∪ none input ← read
    print input
}