— No reviews yet
0 installs
11 views
0.0% view→install
Install
$ agentstack add skill-jimmc414-claude-code-plugin-marketplace-tokenize-then-parse ✓ scanned · ✓ verified — works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ✓ Environment & secrets No
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
Are you the author of Tokenize Then Parse? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claimAbout
tokenize-then-parse
When to Use
- Building interpreters or compilers
- Processing parenthesized expressions
- Structured text with clear token boundaries
- Multi-stage processing pipeline
When NOT to Use
- Simple fixed format (just split)
- Very complex grammar (use parser generator)
- No clear token boundaries
The Pattern
Tokenize text into a stream of tokens, then parse tokens into a structure.
def tokenize(s):
"""Convert string to list of tokens."""
return s.replace('(', ' ( ').replace(')', ' ) ').split()
def parse(tokens):
"""Parse tokens into nested structure."""
token = tokens.pop(0)
if token == '(':
result = []
while tokens[0] != ')':
result.append(parse(tokens))
tokens.pop(0) # Remove ')'
return result
else:
return atom(token)
def atom(token):
"""Convert token to appropriate type."""
try:
return int(token)
except ValueError:
try:
return float(token)
except ValueError:
return token
Example (from pytudes lis.py)
def tokenize(s):
"""Convert a string into a list of tokens."""
return s.replace('(', ' ( ').replace(')', ' ) ').split()
def read_from_tokens(tokens):
"""Read an expression from a sequence of tokens."""
if len(tokens) == 0:
raise SyntaxError('unexpected EOF')
token = tokens.pop(0)
if token == '(':
L = []
while tokens[0] != ')':
L.append(read_from_tokens(tokens))
tokens.pop(0) # Remove ')'
return L
elif token == ')':
raise SyntaxError('unexpected )')
else:
return atom(token)
def atom(token):
"""Numbers become numbers; every other token is a symbol."""
try:
return int(token)
except ValueError:
try:
return float(token)
except ValueError:
return Symbol(token)
def parse(program):
"""Read a Scheme expression from a string."""
return read_from_tokens(tokenize(program))
# Usage
parse("(+ 2 (* 3 4))")
# Returns: ['+', 2, ['*', 3, 4]]
parse("(define square (lambda (x) (* x x)))")
# Returns: ['define', 'square', ['lambda', ['x'], ['*', 'x', 'x']]]
Key Principles
- Tokenize first: Separate lexing from parsing
- pop(0) consumes: Mutable token list, pop as you parse
- Recursive descent: Parse nested structures recursively
- Error on malformed: Raise SyntaxError for bad input
- atom() for literals: Handle number conversion
Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: jimmc414
- Source: jimmc414/claude-code-plugin-marketplace
- License: MIT
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet — be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.