读取
Translation status: 简体中文 reader-locale proof. Term names and code fences follow the zh-Hans pack; supporting prose may still be English.
Reads input from the active input stream.
Syntax: 读取 [行]
Category#
io
Related#
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 `↦ regex` 变换 — compiling a 文本 pattern into a regex value
#
# Common mistakes:
# • Not checking is null before using the value — read may return null at end of input.
#
# See also: 行, 写入
# =============================================================================
# 读取 and regex 转换 — I/O read and compiled pattern expressions
#
# 常量 _ pattern ← "\d+" ↦ regex -- compiled regex from 文本
# 常量 _ input ← 读取 -- stdin line read
#
# GRAMMAR:
# 转换 :← stringLit '↦' 'regex'
# 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 regex pattern ← "(?i)\d+" ↦ regex
print pattern
const string ∪ none input ← read
print input
}