PMAP System › Placeholder Typesv0.1
The PMAP System

Placeholder Types

Every placeholder in a pattern must have a type. No generic untyped placeholders allowed.

Syntax: {name:type} where name is the capture variable and type controls what tokens are accepted.

{var:name} - Single Identifier

Matches a single word that is a valid identifier.

MatchesRejects
x, arr, myVar, counterarr[i], x+y, len(arr), 5

Usage in pattern

text
for {var:name} from {start:expr} to {end:expr}
#         ↑ must be a single identifier like: i, j, counter

Example

pseudo
for i from 0 to 10
#   ↑ captured as {var} = "i"

{value:expr} - Full Expression

Greedy - collects tokens until a stop-token, keyword, end of line, or bracket closes.

Matches
arr[i]+1, len(arr)-1, x*y+z, 5, "hello", true

Example

pseudo
set result to arr[i] + arr[j] * 2
#           ↑ captured as {value} = "arr[i] + arr[j] * 2"

print len(arr) - 1
#     ↑ captured as {value} = "len(arr) - 1"

{n:number} - Numeric Literal Only

Accepts only a numeric literal. Rejects expressions, variables, and function calls.

MatchesRejects
5, 3.14, -1, 0x, arr[i], len(arr)

Example pattern use

text
[FOR_LOOP]
for {var:name} from {start:expr} to {end:expr} step {step:expr}
# step here uses :expr to allow negative steps like -1

{condition:expr} - Boolean Expression

Same as :expr but semantically signals a boolean context. Stops at a colon at the end of the line.

pseudo
if x > 5 and y != 0
#  ↑ captured as {condition} = "x > 5 and y != 0"

while arr[i] == target
#     ↑ captured as {condition} = "arr[i] == target"

{type:word} - Single Type Keyword

Matches a single keyword indicating a type. Used with $input.

Accepted values
number, string, list, bool, int, float, text
pseudo
$input as number
#          ↑ captured as {type} = "number"

$input("Enter age:") as int
#                      ↑ captured as {type} = "int"

{collection:expr} - Iterable Expression

Anything that resolves to an iterable. Functionally identical to :expr but signals iteration context.

pseudo
for each item in arr
#                 ↑ {collection} = "arr"

for each x in [1, 2, 3]
#             ↑ {collection} = "[1, 2, 3]"

loop through range(10) as i
#            ↑ {collection} = "range(10)"

{text:any} - Everything to End of Line

Matches everything remaining on the line as a raw string. Used for comments, prompts, and free-form text.

pseudo
# this is a comment about the algorithm
# ↑ captured as {text} = "this is a comment about the algorithm"

$input("Enter your full name:")
#       ↑ captured as {prompt} = "Enter your full name:"

Summary Table

TypeWhat it matchesTypical use
:nameSingle valid identifierVariable names, loop vars, function names
:exprFull expression (greedy)Values, conditions, arithmetic
:numberNumeric literal onlyConstants, exact counts
:condition (= :expr)Boolean expressionif/while conditions
:wordSingle keyword tokenType hints in $input
:collection (= :expr)Iterable expressionfor-each collections
:anyRaw text to end of lineComments, prompts