Skip to content

binhtran432k/ungrammar-language-features

Repository files navigation

Language Features for Ungrammar files

VSCode Version VSCode Installs VSCode Downloads VSCode Stars CI Status

Ungrammar is a novel data format for defining concrete syntax trees. This project aims to integrate Ungrammar language support into VS Code, providing features to streamline the creation and modification of .ungram files. By offering a dedicated language experience within the editor, we aim to simplify the development process for users working with this syntax definition format.

Ungrammar within VS Code

Features

IntelliSense and Validation

We offer up node name suggestions as you type with IntelliSense. You can also manually see suggestions with the Trigger Suggestions command (Ctrl+Space).

We also perform structural and value verification giving you red squiggles. To disable validation, use the ungrammar.validate.enable setting.

IntelliSense

Quick Navigation

Ungrammar files can get large and we support quick navigation to properties using the Go to Symbol command (Ctrl+Shift+O).

Quick Navigation

Hovers

When hovering over nodes within an Ungrammar data structure, detailed context-specific information is displayed, aiding in understanding the code's structure and relationships.

Hover

Formatting

You can format your Ungrammar document using Shift+Alt+F or Format Document from the context menu. To disable validation, use the ungrammar.format.enable setting.

Before formatting:

Before Formatting

After formatting:

After Formatting

Folding

You can fold regions of source code using the folding icons on the gutter between line numbers and line start. Folding regions are available for all object and array elements.

Before folding:

Before Folding

After folding:

After Folding

Annotations

We provide informative annotations displayed above code elements to aid in code comprehension. These annotations offer quick access to references, implementation details, and other relevant context, enhancing code navigability and understanding.

Annotation

Expand and Shrink Selection

You can extend (Alt+Shift+→) or shrink (Alt+Shift+←) the current selection to the encompassing syntactic construct (node, alternative, sequence, group, etc). It works with multiple cursors.

Expand 1 Expand 2 Expand 3 Expand 4 Expand 5

Find All References

You can find all references using Shift+Alt+F12 to show all references of the item at the cursor location.

Find All References

Go to Definition

You can navigate to the definition of an node using F12.

Before Go to Definition, we are at line 657:

Before Go to Definition

After Go to Definition, we are at line 588:

After Go to Definition

Highlight Related

You can highlight related constructs upon hovering over a node. This feature displays all references to the selected node within the current file, enhancing code navigation and understanding.

Highlight Related

Rename

You can efficiently rename symbols across your codebase using the F2. This powerful feature automatically updates all references to the selected symbol, ensuring consistency and reducing the potential for errors.

Rename

Code Actions

You can enhance your code formatting with our powerful code actions. Quickly and easily rename nodes to specific casing styles including snake_case, CONSTANT_CASE, camelCase, and PascalCase, ensuring consistent naming conventions throughout your project.

Provide Code Actions

Semantic Syntax Highlighting

We highlight the code semantically. For example, "Rule" might be colored differently depending on whether "Rule" is an Definition or a Identifier. We does not specify colors directly, instead it assigns a tag (like variable) and a set of modifiers (like definition) to each token. It's up to the client to map those to specific colors.

Semantic Syntax Highlighting