> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nemo/guardrails/llms.txt.
> For full documentation content, see https://docs.nvidia.com/nemo/guardrails/llms-full.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/nemo/guardrails/_mcp/server.

# nemoguardrails.colang.v1_0.lang.comd_parser

## Module Contents

### Functions

| Name                                                                                            | Description                                                               |
| ----------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- |
| [`_get_param_type`](#nemoguardrails-colang-v1_0-lang-comd_parser-_get_param_type)               | Helper to return the type of a parameter.                                 |
| [`_get_symbol_type`](#nemoguardrails-colang-v1_0-lang-comd_parser-_get_symbol_type)             | Helper to determine if a symbol is prefixed with its type.                |
| [`_get_typed_symbol_name`](#nemoguardrails-colang-v1_0-lang-comd_parser-_get_typed_symbol_name) | Returns the symbol name prefixed with the type, if not already.           |
| [`_record_utterance`](#nemoguardrails-colang-v1_0-lang-comd_parser-_record_utterance)           | Helper to record an utterance in the .md parsing result.                  |
| [`parse_md_file`](#nemoguardrails-colang-v1_0-lang-comd_parser-parse_md_file)                   | Parse a Markdown file for patterns.                                       |
| [`parse_md_lang`](#nemoguardrails-colang-v1_0-lang-comd_parser-parse_md_lang)                   | Returns the language of the .md file.                                     |
| [`parse_pattern`](#nemoguardrails-colang-v1_0-lang-comd_parser-parse_pattern)                   | Parses a pattern from the Markdown-friendly format to an internal format. |

### Data

[`SYMBOL_TYPES`](#nemoguardrails-colang-v1_0-lang-comd_parser-SYMBOL_TYPES)

[`__all__`](#nemoguardrails-colang-v1_0-lang-comd_parser-__all__)

### API

```python
nemoguardrails.colang.v1_0.lang.comd_parser._get_param_type(
    type_str
)
```

Helper to return the type of a parameter.

For now we use a simple heuristic:

1. If it's a primitive type, we leave it as such.

2. If it already has some sort of prefix with ":", we leave it as such.

3. If it starts with lower case and it's not one of the primitive types
   then we map it to "type:..."

4. If it starts with an upper case, then we map it to an "object:..."

:param type\_str: A string representing the type.
:return: The actual type.

```python
nemoguardrails.colang.v1_0.lang.comd_parser._get_symbol_type(
    sym
)
```

Helper to determine if a symbol is prefixed with its type.

:param sym: The name of the symbol.

```python
nemoguardrails.colang.v1_0.lang.comd_parser._get_typed_symbol_name(
    sym: str,
    symbol_type: str
)
```

Returns the symbol name prefixed with the type, if not already.

```python
nemoguardrails.colang.v1_0.lang.comd_parser._record_utterance(
    result: dict,
    sym: str,
    symbol_params: list,
    symbol_context: typing.Optional[str],
    symbol_meta: dict,
    symbol_context_meta: dict,
    data: typing.Union[str, dict]
)
```

Helper to record an utterance in the .md parsing result.

It supports both string utterances and rich utterances.

:param result: The result to append the utterance to.
:param sym: The current symbol e.g. "utterance:welcome"
:param symbol\_params: Any additional symbol parameters.
It is an array like \["\$role=admin", "channel.type=messenger"]
:param symbol\_context: An additional contextual expression that must be evaluated to True/False.
:param symbol\_meta: Meta information for the symbol in general.
:param symbol\_meta: Meta information for the symbol in this context.
:param data: The data for the utterance, either string or something "rich"
:return:

```python
nemoguardrails.colang.v1_0.lang.comd_parser.parse_md_file(
    file_name,
    content = None
)
```

Parse a Markdown file for patterns.

The content can be also passed as a parameter to skip reading it.

:param file\_name: A markdown file
:param content: The content of the file.
:return: A list of patterns.

```python
nemoguardrails.colang.v1_0.lang.comd_parser.parse_md_lang(
    file_name,
    content = None
)
```

Returns the language of the .md file.

The content can be also passed as a parameter to skip reading it.

It searches for `lang: XX` in a yaml code block.
By default it assumes the language is English.

```python
nemoguardrails.colang.v1_0.lang.comd_parser.parse_pattern(
    pattern
)
```

Parses a pattern from the Markdown-friendly format to an internal format.
E.g. parse\_pattern("show [me](user=CURRENT) the deals I've [won](deal__status)") =
(show me the deals I've \{deal\_\_status}, \{'user': 'CURRENT'}).

For patters with "assignment patterns" like "show [me](user=CURRENT) the deals" we
transform it into:
"show \{user=CURRENT} the deals" with the mapping:
\{
"user=CURRENT": "me"
}

:param pattern: The pattern in Markdown-friendly format.
:return: A tuple (pattern, params) where pattern is a pattern containing only
text and \{capture} tokens, params is a dict of 'implicit' parameter values.

```python
nemoguardrails.colang.v1_0.lang.comd_parser.SYMBOL_TYPES = ['intent', 'object', 'type', 'property', 'utterance', 'sym', 'lookup']
```

```python
nemoguardrails.colang.v1_0.lang.comd_parser.__all__ = ['parse_md_file']
```