The PMAP System
Stop Tokens
How Pseudo knows where an expression ends and the next keyword begins.
The Problem
In a pattern like:
text
for {var:name} from {start:expr} to {end:expr}How does the matcher know where {start:expr} ends and to begins?
Answer: stop tokens. The matcher collects expression tokens until it sees a token that is a known keyword (a stop token).
How Stop Tokens Are Built
- Pseudo extracts all literal words from all patterns in the loaded
.pmap - Builds a global stop-token set from those words
- When matching
:expr, tokens are collected until a stop-token is seen, the line ends, or brackets close
Default Stop Tokens
These come from the literal tokens in default.pmap:
for, from, to, step, in, each, every, while, until, if, when,
check, given, else, otherwise, return, give, back, and, or, not,
as, is, then, loop, repeat, function, func, define, def, procedure
An Expression Stops When
- A stop-token is found (keyword boundary)
- End of line
- A colon (block opener)
- A matching closing bracket
)]}
Examples
Stop at keyword
pseudo
for i from 0 to n step 2
# ↑──────↑ start:expr = "0" - stops at "to"
# ↑ end:expr = "n" - stops at "step"
# ↑ step:expr = "2"Stop at end of line
pseudo
print arr[i] + arr[j] * 2
# ↑────────────────────↑ value:expr = "arr[i] + arr[j] * 2"
# no stop-token → collects to end of lineStop at bracket close
pseudo
$input("Enter name:") as string
# ↑─────↑ prompt:any = "Enter name:" - stops at )
# ↑ type:word = "string"Custom PMAP Expands Stop Tokens
When you add new patterns to a custom .pmap, any new literal words you introduce automatically become stop tokens:
custom.pmap
[FOR_LOOP]
count {var:name} from {start:expr} until {end:expr}
# "count" and "until" are now stop tokensBe careful with common wordsIf you add a common word like
the or of as a literal token in a pattern, it becomes a stop token and will terminate expressions that contain those words.