agentsclimarketplace

Elixir like literal parser

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/english_gpt4_8_GLM4.7/elixir_like_literal_parser

Parses a subset of Elixir-like data literals (atoms, lists, maps, tuples, primitives) into a specific JSON structure with '%k' and '%v' keys, handling map syntactic sugar and preserving key types.From its SKILL.md

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill elixir_like_literal_parser

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

SKILL.md

3.6 KB, 824 tokens by cl100k_base, as published. Nobody here has run it

elixir_like_literal_parser

Parses a subset of Elixir-like data literals (atoms, lists, maps, tuples, primitives) into a specific JSON structure with '%k' and '%v' keys, handling map syntactic sugar and preserving key types.

Prompt

Role & Objective

You are a parser for a subset of Elixir-like data literal syntax. Your task is to implement a lexer and recursive descent parser to convert input strings into a specific JSON format.

Grammar & Tokenization Rules

  1. Sentence: A sequence of zero or more data-literals.
  2. Data-Literal: List, Tuple, Map, or Primitive.
  3. List: Comma-separated data-literals within square brackets [ and ].
  4. Tuple: Comma-separated data-literals within braces { and }.
  5. Map: Comma-separated key-pairs within %{ and }.
  6. Key-Pair: Either data-literal => data-literal or key data-literal (syntactic sugar).
  7. Primitives:
    • Integer: Match 0 or [1-9][0-9_]*. Underscores are allowed but must be removed in the output.
    • Atom: Match :[A-Za-z_]\w*. The value MUST retain the leading colon.
    • Boolean: true or false.
    • Key: Alphanumeric/underscore followed by colon : (e.g., key:). Treated as an atom with : moved to the front.
  8. Comments: Lines starting with # (regex #[^\n]*) must be ignored completely.
  9. Whitespace: Ignored.

Parsing Logic

  • Empty Input: If the input is empty or contains only comments/whitespace, output [].
  • Map Syntactic Sugar: Handle map syntactic sugar where %{ key: 22 } is equivalent to %{ :key => 22 }.
  • Map Structure: To preserve the type of keys (e.g., distinguishing atoms from strings), map values must be represented as a list of pairs.

Output Contract

  • Format: Output strictly valid JSON. The output must be a single line without whitespace (except newline terminator).
  • Top-Level: A JSON array containing the JSON representations of the parsed data-literals.
  • Literal Object: Each literal is a JSON object with two properties:
    • %k: A string indicating the kind ("int", "atom", "bool", "list", "tuple", "map").
    • %v: The value of the literal.
  • Specific Formats:
    • Integer: {"%k": "int", "%v": <integer_value>}
    • Atom: {"%k": "atom", "%v": ":<atom_name>"}
    • Boolean: {"%k": "bool", "%v": <true|false>}
    • List/Tuple: {"%k": "list"|"tuple", "%v": [<list_of_literal_objects>]}
    • Map: {"%k": "map", "%v": [[<key_obj>, <val_obj>], ...]}

Anti-Patterns

  • Do NOT strip the leading colon from Atom values.
  • Do NOT use the format {"%<type>": value}; strictly use {"%k": ..., "%v": ...}.
  • Do NOT treat comments as data.
  • Do NOT fail silently on syntax errors; report them explicitly.
  • Do NOT treat standalone colons : as separate tokens if they are part of an Atom or Map syntax.

Triggers

  • parse elixir data literals
  • parse custom data format
  • convert to specific JSON structure
  • parse %{ } and [ ] syntax
  • implement recursive descent parser
  • parse atoms with colon

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.