├── testData
├── parse
│ ├── Paren.pest
│ ├── Char.pest
│ ├── Issue25.pest
│ ├── SimpleRule.pest
│ ├── NestedComment.pest
│ ├── Builtins.pest
│ ├── Issue41.pest
│ ├── NestedComment.txt
│ ├── Issue25.txt
│ ├── Char.txt
│ ├── Issue41.txt
│ ├── SimpleRule.txt
│ ├── Paren.txt
│ └── Builtins.txt
└── rust
│ ├── External.rs
│ ├── Inline.rs
│ ├── External.txt
│ └── Inline.txt
├── .vscode
└── settings.json
├── settings.gradle.kts
├── rust
├── .gitignore
├── .cargo
│ └── config.toml
├── src
│ ├── str4j.rs
│ ├── misc.rs
│ └── lib.rs
├── Cargo.toml
└── README.md
├── res
├── rs
│ └── pest
│ │ ├── error
│ │ ├── token.bin
│ │ └── report-bundle.properties
│ │ └── pest-bundle.properties
├── inspectionDescriptions
│ └── PestDuplicateRule.html
├── fileTemplates
│ └── Pest File.pest.ft
├── META-INF
│ ├── plugin-rust.xml
│ ├── description.html
│ ├── pluginIcon_dark.svg
│ ├── pluginIcon.svg
│ ├── change-notes.html
│ └── plugin.xml
├── liveTemplates
│ └── Pest.xml
├── colorSchemes
│ ├── Pest_dark.xml
│ └── Pest.xml
└── icons
│ ├── pest_dark.svg
│ ├── pest.svg
│ ├── pest_file_dark.svg
│ └── pest_file.svg
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── src
├── icons
│ └── PestIcons.java
└── rs
│ └── pest
│ ├── action
│ ├── ui
│ │ ├── RuleSelector.java
│ │ ├── PestIdeBridgeInfo.java
│ │ ├── PestIntroduceRulePopup.java
│ │ ├── RuleSelector.form
│ │ ├── ui-impl.kt
│ │ ├── PestIntroduceRulePopup.form
│ │ └── PestIdeBridgeInfo.form
│ ├── create-file.kt
│ ├── tools.kt
│ ├── inline.kt
│ └── introduce.kt
│ ├── PestLanguage.java
│ ├── livePreview
│ ├── LivePreviewLanguage.java
│ ├── html.kt
│ ├── live-preview.kt
│ ├── ffi.kt
│ └── live-highlight.kt
│ ├── psi
│ ├── manipulators.kt
│ ├── utils.kt
│ ├── types.kt
│ ├── impl
│ │ ├── psi-impl.kt
│ │ └── psi-mixins.kt
│ └── PestStringEscaper.java
│ ├── editing
│ ├── pest-live-templates.kt
│ ├── pest-completion.kt
│ ├── pest-gutter.kt
│ ├── pest-structure.kt
│ ├── pest-annotator.kt
│ ├── pest-inspection.kt
│ └── pest-editing.kt
│ ├── format
│ ├── block.kt
│ └── model.kt
│ ├── pest-parser-def.kt
│ ├── rust
│ └── rust-inject.kt
│ ├── pest-infos.kt
│ └── pest-constants.kt
├── .editorconfig
├── test
└── rs
│ └── pest
│ ├── generation.kt
│ ├── parsing-test.kt
│ ├── psi
│ └── PestStringEscaperTest.java
│ └── rust-interaction-test.kt
├── .github
├── dependabot.yml
└── workflows
│ ├── release.yml
│ └── build.yml
├── appveyor.yml
├── gradlew.bat
├── README.md
├── .gitignore
├── gradlew
└── grammar
├── pest.bnf
└── pest.flex
/testData/parse/Paren.pest:
--------------------------------------------------------------------------------
1 | a = { a ~ (rule ~ b) ~ c }
2 |
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "editor.insertSpaces": false
3 | }
--------------------------------------------------------------------------------
/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | rootProject.name = "intellij-pest"
2 |
3 |
--------------------------------------------------------------------------------
/testData/parse/Char.pest:
--------------------------------------------------------------------------------
1 | test = { '\u{00}'..'\u{123456}' }
2 |
--------------------------------------------------------------------------------
/rust/.gitignore:
--------------------------------------------------------------------------------
1 | target
2 | Cargo.lock
3 | .idea
4 | .vscode
5 | .vs
6 |
--------------------------------------------------------------------------------
/testData/parse/Issue25.pest:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | */
4 |
5 | rule = { " " }
6 |
--------------------------------------------------------------------------------
/testData/parse/SimpleRule.pest:
--------------------------------------------------------------------------------
1 | rule = { rule | "" ~ 'a'..'z' | "bla" }
2 |
--------------------------------------------------------------------------------
/testData/parse/NestedComment.pest:
--------------------------------------------------------------------------------
1 | /*Joesph Joestar/*/**/*/ Oh My God*/
2 | rule={""}
3 |
--------------------------------------------------------------------------------
/testData/rust/External.rs:
--------------------------------------------------------------------------------
1 | #[derive(Parser)]
2 | #[grammar = "path/to/my_grammar.pest"]
3 | struct MyParser;
4 |
--------------------------------------------------------------------------------
/res/rs/pest/error/token.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pest-parser/intellij-pest/HEAD/res/rs/pest/error/token.bin
--------------------------------------------------------------------------------
/testData/rust/Inline.rs:
--------------------------------------------------------------------------------
1 | #[derive(Parser)]
2 | #[grammar_inline = "\
3 | my_rule = { \"\" }
4 | "]
5 | struct MyParser;
6 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pest-parser/intellij-pest/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/res/inspectionDescriptions/PestDuplicateRule.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Checks that every grammar rule has unique name.
4 |
5 |
6 |
--------------------------------------------------------------------------------
/res/fileTemplates/Pest File.pest.ft:
--------------------------------------------------------------------------------
1 | //
2 | // Created by intellij-pest on ${YEAR}-${MONTH}-${DAY}
3 | // ${NAME}
4 | // Author: ${USER}
5 | //
6 |
7 | ${NAME_SNAKE} = { "Hello World!" }
8 |
--------------------------------------------------------------------------------
/res/META-INF/plugin-rust.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/testData/parse/Builtins.pest:
--------------------------------------------------------------------------------
1 | //
2 | // Created by intellij-pest on 2019-03-22
3 | // Builtins
4 | // Author: ice1000
5 | //
6 |
7 | builtins = { "Hello World!" }
8 | COMMENT = { ID_CONTINUE }
9 | WHITESPACE = { WHITE_SPACE }
10 |
--------------------------------------------------------------------------------
/rust/.cargo/config.toml:
--------------------------------------------------------------------------------
1 | [build]
2 | target = "wasm32-unknown-unknown"
3 | # https://github.com/koute/substrate/blob/2aebf63b859f5f7a01f9b631828d90b5b54b608b/utils/wasm-builder/src/wasm_project.rs#L635C4-L635C7
4 | rustflags = "-C target-feature=-sign-ext"
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-rc-2-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/testData/parse/Issue41.pest:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Concat : '~~';
4 | Destruct : '~=';
5 |
6 | /* |&! */
7 |
8 | DoubleBang : '!!';
9 | BitNot : '!' | '\uFF01'; //U+FF01 !
10 |
11 | /* $ @ */
12 | Curry : '@@@';
13 | Apply : '@@';
14 | LetAssign : '@=';
15 |
16 | */
17 |
18 | rule = { "114514" }
19 |
--------------------------------------------------------------------------------
/src/icons/PestIcons.java:
--------------------------------------------------------------------------------
1 | package icons;
2 |
3 | import com.intellij.openapi.util.IconLoader;
4 | import org.jetbrains.annotations.NotNull;
5 |
6 | import javax.swing.*;
7 |
8 | public interface PestIcons {
9 | @NotNull Icon PEST_FILE = IconLoader.getIcon("/icons/pest_file.png");
10 | @NotNull Icon PEST = IconLoader.getIcon("/icons/pest.png");
11 | }
12 |
--------------------------------------------------------------------------------
/src/rs/pest/action/ui/RuleSelector.java:
--------------------------------------------------------------------------------
1 | package rs.pest.action.ui;
2 |
3 | import org.jetbrains.annotations.NotNull;
4 |
5 | import javax.swing.*;
6 |
7 | @SuppressWarnings("NullableProblems")
8 | public class RuleSelector {
9 | public @NotNull JPanel mainPanel;
10 | public @NotNull JComboBox ruleCombo;
11 | public @NotNull JButton okButton;
12 | }
13 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | [*]
2 | charset = utf-8
3 | end_of_line = lf
4 | insert_final_newline = false
5 | indent_style = tab
6 | tab_width = 2
7 |
8 | [gradle.properties]
9 | indent_size = 0
10 |
11 | [*.rst]
12 | indent_size = 3
13 | indent_style = space
14 |
15 | [*.yml]
16 | indent_style = space
17 | indent_size = 2
18 |
19 | [*.rs]
20 | indent_style = space
21 | indent_size = 4
22 |
--------------------------------------------------------------------------------
/src/rs/pest/PestLanguage.java:
--------------------------------------------------------------------------------
1 | package rs.pest;
2 |
3 | import com.intellij.lang.Language;
4 | import org.jetbrains.annotations.NotNull;
5 |
6 | import static rs.pest.Pest_constantsKt.PEST_LANGUAGE_NAME;
7 |
8 | /**
9 | * @author ice1000
10 | */
11 | public class PestLanguage extends Language {
12 | public static final @NotNull
13 | PestLanguage INSTANCE = new PestLanguage();
14 |
15 | private PestLanguage() {
16 | super(PEST_LANGUAGE_NAME, "text/" + PEST_LANGUAGE_NAME);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/test/rs/pest/generation.kt:
--------------------------------------------------------------------------------
1 | package rs.pest
2 |
3 | import org.junit.Test
4 |
5 | class CodeGeneration {
6 | @Test
7 | fun generateLexer() {
8 | BUILTIN_RULES.forEach {
9 | println("$it { return ${it}_TOKEN; }")
10 | }
11 | }
12 |
13 | @Test
14 | fun generateParser() {
15 | BUILTIN_RULES.forEach {
16 | println(" | ${it}_TOKEN")
17 | }
18 | }
19 |
20 | @Test
21 | fun generateHighlighter() {
22 | BUILTIN_RULES.forEach {
23 | println("PestTypes.${it}_TOKEN,")
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/testData/parse/NestedComment.txt:
--------------------------------------------------------------------------------
1 | FILE
2 | PsiComment(block comment)('/*Joesph Joestar/*/**/*/ Oh My God*/')
3 | PsiWhiteSpace('\n')
4 | PestGrammarRuleImpl(GRAMMAR_RULE)
5 | PestValidRuleNameImpl(VALID_RULE_NAME)
6 | PsiElement(IDENTIFIER_TOKEN)('rule')
7 | PsiElement(ASSIGNMENT_OPERATOR)('=')
8 | PestGrammarBodyImpl(GRAMMAR_BODY)
9 | PsiElement(OPENING_BRACE)('{')
10 | PestStringImpl(STRING)
11 | PsiElement(STRING_TOKEN)('""')
12 | PsiElement(CLOSING_BRACE)('}')
--------------------------------------------------------------------------------
/src/rs/pest/livePreview/LivePreviewLanguage.java:
--------------------------------------------------------------------------------
1 | package rs.pest.livePreview;
2 |
3 | import com.intellij.lang.Language;
4 | import org.jetbrains.annotations.NotNull;
5 |
6 | import static rs.pest.Pest_constantsKt.LP_LANGUAGE_NAME;
7 |
8 | /**
9 | * @author ice1000
10 | */
11 | public class LivePreviewLanguage extends Language {
12 | public static @NotNull
13 | LivePreviewLanguage INSTANCE = new LivePreviewLanguage();
14 |
15 | private LivePreviewLanguage() {
16 | super(LP_LANGUAGE_NAME, "text/" + LP_LANGUAGE_NAME);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/rust/src/str4j.rs:
--------------------------------------------------------------------------------
1 | use std::alloc::{self, Layout};
2 | use std::mem;
3 |
4 | #[unsafe(no_mangle)]
5 | pub extern "C" fn alloc(size: usize) -> *mut u8 {
6 | unsafe {
7 | let layout = Layout::from_size_align(size, mem::align_of::()).unwrap();
8 | alloc::alloc(layout)
9 | }
10 | }
11 |
12 | #[unsafe(no_mangle)]
13 | pub extern "C" fn dealloc(ptr: *mut u8, size: usize) {
14 | unsafe {
15 | let layout = Layout::from_size_align(size, mem::align_of::()).unwrap();
16 | alloc::dealloc(ptr, layout);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/testData/parse/Issue25.txt:
--------------------------------------------------------------------------------
1 | FILE
2 | PsiComment(block comment)('/*\n*\n*/')
3 | PsiWhiteSpace('\n\n')
4 | PestGrammarRuleImpl(GRAMMAR_RULE)
5 | PestValidRuleNameImpl(VALID_RULE_NAME)
6 | PsiElement(IDENTIFIER_TOKEN)('rule')
7 | PsiWhiteSpace(' ')
8 | PsiElement(ASSIGNMENT_OPERATOR)('=')
9 | PsiWhiteSpace(' ')
10 | PestGrammarBodyImpl(GRAMMAR_BODY)
11 | PsiElement(OPENING_BRACE)('{')
12 | PsiWhiteSpace(' ')
13 | PestStringImpl(STRING)
14 | PsiElement(STRING_TOKEN)('" "')
15 | PsiWhiteSpace(' ')
16 | PsiElement(CLOSING_BRACE)('}')
--------------------------------------------------------------------------------
/src/rs/pest/action/ui/PestIdeBridgeInfo.java:
--------------------------------------------------------------------------------
1 | package rs.pest.action.ui;
2 |
3 | import com.intellij.ui.components.labels.LinkLabel;
4 | import org.jetbrains.annotations.NotNull;
5 |
6 | import javax.swing.*;
7 |
8 | @SuppressWarnings("NullableProblems")
9 | public abstract class PestIdeBridgeInfo {
10 | protected @NotNull JPanel mainPanel;
11 | protected @NotNull LinkLabel