diff --git a/ZenScriptIntelliJPlugin.jar b/ZenScriptIntelliJPlugin.jar new file mode 100644 index 0000000..cb78f89 Binary files /dev/null and b/ZenScriptIntelliJPlugin.jar differ diff --git a/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/parsing/ZsParser.java b/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/parsing/ZsParser.java index 22ca6ef..6601832 100644 --- a/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/parsing/ZsParser.java +++ b/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/parsing/ZsParser.java @@ -4,7 +4,7 @@ import com.intellij.lang.PsiBuilder; import com.intellij.lang.PsiBuilder.Marker; import static de.bloodworkxgaming.zenscript.plugin.zsLanguage.psi.ZsTypes.*; -import static com.intellij.lang.parser.GeneratedParserUtilBase.*; +import static de.bloodworkxgaming.zenscript.plugin.zsLanguage.parsing.ZsParserUtil.*; import com.intellij.psi.tree.IElementType; import com.intellij.lang.ASTNode; import com.intellij.psi.tree.TokenSet; @@ -47,6 +47,9 @@ else if (t == CONDITION) { else if (t == EQUATION) { r = equation(b, 0); } + else if (t == FIELD_REFERENCE) { + r = field_reference(b, 0); + } else if (t == FOR_LOOP) { r = for_loop(b, 0); } @@ -71,6 +74,9 @@ else if (t == IMPORT_STATEMENT) { else if (t == LAMBDA_FUNCTION_DECLARATION) { r = lambda_function_declaration(b, 0); } + else if (t == MODULO_TYPE) { + r = moduloType(b, 0); + } else if (t == NUMBER) { r = number(b, 0); } @@ -80,6 +86,12 @@ else if (t == PARAMETER_LIST) { else if (t == PARAMETER_VARIABLE) { r = parameter_variable(b, 0); } + else if (t == PREPROCESSOR) { + r = preprocessor(b, 0); + } + else if (t == PREPROCESSOR_LIST) { + r = preprocessor_list(b, 0); + } else if (t == RETURN_STATEMENT) { r = return_statement(b, 0); } @@ -209,13 +221,13 @@ private static boolean arrayRead_2_0(PsiBuilder b, int l) { } /* ********************************************************** */ - // (VAR | VAL)? variable EQUAL validVariable + // (VAR | VAL)? field_reference EQUAL validVariable public static boolean assignStatement(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "assignStatement")) return false; boolean r; Marker m = enter_section_(b, l, _NONE_, ASSIGN_STATEMENT, ""); r = assignStatement_0(b, l + 1); - r = r && variable(b, l + 1); + r = r && field_reference(b, l + 1); r = r && consumeToken(b, EQUAL); r = r && validVariable(b, l + 1); exit_section_(b, l, m, r, false, null); @@ -241,13 +253,12 @@ private static boolean assignStatement_0_0(PsiBuilder b, int l) { } /* ********************************************************** */ - // PLUS | MINUS | ASTERISK | DIV + // PLUS MINUS | ASTERISK | DIV static boolean binary_math_signs(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "binary_math_signs")) return false; boolean r; Marker m = enter_section_(b); - r = consumeToken(b, PLUS); - if (!r) r = consumeToken(b, MINUS); + r = parseTokens(b, 0, PLUS, MINUS); if (!r) r = consumeToken(b, ASTERISK); if (!r) r = consumeToken(b, DIV); exit_section_(b, m, null, r); @@ -354,21 +365,43 @@ private static boolean class_name_1_0(PsiBuilder b, int l) { } /* ********************************************************** */ - // validVariable (EQEQ | NOT_EQUAL | GREATER_EQUAL | LESS_EQUAL | L_ANGLE_BRACKET | R_ANGLE_BRACKET) validVariable + // validVariable ((EQEQ | NOT_EQUAL | GREATER_EQUAL | LESS_EQUAL | L_ANGLE_BRACKET | R_ANGLE_BRACKET) validVariable)* public static boolean condition(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "condition")) return false; boolean r; Marker m = enter_section_(b, l, _NONE_, CONDITION, ""); r = validVariable(b, l + 1); r = r && condition_1(b, l + 1); - r = r && validVariable(b, l + 1); exit_section_(b, l, m, r, false, null); return r; } - // EQEQ | NOT_EQUAL | GREATER_EQUAL | LESS_EQUAL | L_ANGLE_BRACKET | R_ANGLE_BRACKET + // ((EQEQ | NOT_EQUAL | GREATER_EQUAL | LESS_EQUAL | L_ANGLE_BRACKET | R_ANGLE_BRACKET) validVariable)* private static boolean condition_1(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "condition_1")) return false; + int c = current_position_(b); + while (true) { + if (!condition_1_0(b, l + 1)) break; + if (!empty_element_parsed_guard_(b, "condition_1", c)) break; + c = current_position_(b); + } + return true; + } + + // (EQEQ | NOT_EQUAL | GREATER_EQUAL | LESS_EQUAL | L_ANGLE_BRACKET | R_ANGLE_BRACKET) validVariable + private static boolean condition_1_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "condition_1_0")) return false; + boolean r; + Marker m = enter_section_(b); + r = condition_1_0_0(b, l + 1); + r = r && validVariable(b, l + 1); + exit_section_(b, m, null, r); + return r; + } + + // EQEQ | NOT_EQUAL | GREATER_EQUAL | LESS_EQUAL | L_ANGLE_BRACKET | R_ANGLE_BRACKET + private static boolean condition_1_0_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "condition_1_0_0")) return false; boolean r; Marker m = enter_section_(b); r = consumeToken(b, EQEQ); @@ -436,6 +469,40 @@ private static boolean equation_2_0_1(PsiBuilder b, int l) { return true; } + /* ********************************************************** */ + // validCallable (DOT IDENTIFIER)* + public static boolean field_reference(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "field_reference")) return false; + boolean r; + Marker m = enter_section_(b, l, _NONE_, FIELD_REFERENCE, ""); + r = validCallable(b, l + 1); + r = r && field_reference_1(b, l + 1); + exit_section_(b, l, m, r, false, null); + return r; + } + + // (DOT IDENTIFIER)* + private static boolean field_reference_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "field_reference_1")) return false; + int c = current_position_(b); + while (true) { + if (!field_reference_1_0(b, l + 1)) break; + if (!empty_element_parsed_guard_(b, "field_reference_1", c)) break; + c = current_position_(b); + } + return true; + } + + // DOT IDENTIFIER + private static boolean field_reference_1_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "field_reference_1_0")) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeTokens(b, 0, DOT, IDENTIFIER); + exit_section_(b, m, null, r); + return r; + } + /* ********************************************************** */ // FOR (((variable COMMA)? variable in variable) | (variable IN DIGITS ((DOT DOT) | TO) DIGITS)) statement_body public static boolean for_loop(PsiBuilder b, int l) { @@ -527,89 +594,115 @@ private static boolean for_loop_1_1_3_0(PsiBuilder b, int l) { } /* ********************************************************** */ - // validCallable (DOT IDENTIFIER)* (L_ROUND_BRACKET R_ROUND_BRACKET | (L_ROUND_BRACKET (validVariable (COMMA validVariable)*) R_ROUND_BRACKET)) + // validCallable ((DOT IDENTIFIER)* (L_ROUND_BRACKET R_ROUND_BRACKET | (L_ROUND_BRACKET (validVariable (COMMA validVariable)*) R_ROUND_BRACKET)))+ public static boolean functionCall(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "functionCall")) return false; boolean r; Marker m = enter_section_(b, l, _NONE_, FUNCTION_CALL, ""); r = validCallable(b, l + 1); r = r && functionCall_1(b, l + 1); - r = r && functionCall_2(b, l + 1); exit_section_(b, l, m, r, false, null); return r; } - // (DOT IDENTIFIER)* + // ((DOT IDENTIFIER)* (L_ROUND_BRACKET R_ROUND_BRACKET | (L_ROUND_BRACKET (validVariable (COMMA validVariable)*) R_ROUND_BRACKET)))+ private static boolean functionCall_1(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "functionCall_1")) return false; + boolean r; + Marker m = enter_section_(b); + r = functionCall_1_0(b, l + 1); int c = current_position_(b); - while (true) { + while (r) { if (!functionCall_1_0(b, l + 1)) break; if (!empty_element_parsed_guard_(b, "functionCall_1", c)) break; c = current_position_(b); } - return true; + exit_section_(b, m, null, r); + return r; } - // DOT IDENTIFIER + // (DOT IDENTIFIER)* (L_ROUND_BRACKET R_ROUND_BRACKET | (L_ROUND_BRACKET (validVariable (COMMA validVariable)*) R_ROUND_BRACKET)) private static boolean functionCall_1_0(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "functionCall_1_0")) return false; boolean r; Marker m = enter_section_(b); + r = functionCall_1_0_0(b, l + 1); + r = r && functionCall_1_0_1(b, l + 1); + exit_section_(b, m, null, r); + return r; + } + + // (DOT IDENTIFIER)* + private static boolean functionCall_1_0_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "functionCall_1_0_0")) return false; + int c = current_position_(b); + while (true) { + if (!functionCall_1_0_0_0(b, l + 1)) break; + if (!empty_element_parsed_guard_(b, "functionCall_1_0_0", c)) break; + c = current_position_(b); + } + return true; + } + + // DOT IDENTIFIER + private static boolean functionCall_1_0_0_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "functionCall_1_0_0_0")) return false; + boolean r; + Marker m = enter_section_(b); r = consumeTokens(b, 0, DOT, IDENTIFIER); exit_section_(b, m, null, r); return r; } // L_ROUND_BRACKET R_ROUND_BRACKET | (L_ROUND_BRACKET (validVariable (COMMA validVariable)*) R_ROUND_BRACKET) - private static boolean functionCall_2(PsiBuilder b, int l) { - if (!recursion_guard_(b, l, "functionCall_2")) return false; + private static boolean functionCall_1_0_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "functionCall_1_0_1")) return false; boolean r; Marker m = enter_section_(b); r = parseTokens(b, 0, L_ROUND_BRACKET, R_ROUND_BRACKET); - if (!r) r = functionCall_2_1(b, l + 1); + if (!r) r = functionCall_1_0_1_1(b, l + 1); exit_section_(b, m, null, r); return r; } // L_ROUND_BRACKET (validVariable (COMMA validVariable)*) R_ROUND_BRACKET - private static boolean functionCall_2_1(PsiBuilder b, int l) { - if (!recursion_guard_(b, l, "functionCall_2_1")) return false; + private static boolean functionCall_1_0_1_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "functionCall_1_0_1_1")) return false; boolean r; Marker m = enter_section_(b); r = consumeToken(b, L_ROUND_BRACKET); - r = r && functionCall_2_1_1(b, l + 1); + r = r && functionCall_1_0_1_1_1(b, l + 1); r = r && consumeToken(b, R_ROUND_BRACKET); exit_section_(b, m, null, r); return r; } // validVariable (COMMA validVariable)* - private static boolean functionCall_2_1_1(PsiBuilder b, int l) { - if (!recursion_guard_(b, l, "functionCall_2_1_1")) return false; + private static boolean functionCall_1_0_1_1_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "functionCall_1_0_1_1_1")) return false; boolean r; Marker m = enter_section_(b); r = validVariable(b, l + 1); - r = r && functionCall_2_1_1_1(b, l + 1); + r = r && functionCall_1_0_1_1_1_1(b, l + 1); exit_section_(b, m, null, r); return r; } // (COMMA validVariable)* - private static boolean functionCall_2_1_1_1(PsiBuilder b, int l) { - if (!recursion_guard_(b, l, "functionCall_2_1_1_1")) return false; + private static boolean functionCall_1_0_1_1_1_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "functionCall_1_0_1_1_1_1")) return false; int c = current_position_(b); while (true) { - if (!functionCall_2_1_1_1_0(b, l + 1)) break; - if (!empty_element_parsed_guard_(b, "functionCall_2_1_1_1", c)) break; + if (!functionCall_1_0_1_1_1_1_0(b, l + 1)) break; + if (!empty_element_parsed_guard_(b, "functionCall_1_0_1_1_1_1", c)) break; c = current_position_(b); } return true; } // COMMA validVariable - private static boolean functionCall_2_1_1_1_0(PsiBuilder b, int l) { - if (!recursion_guard_(b, l, "functionCall_2_1_1_1_0")) return false; + private static boolean functionCall_1_0_1_1_1_1_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "functionCall_1_0_1_1_1_1_0")) return false; boolean r; Marker m = enter_section_(b); r = consumeToken(b, COMMA); @@ -906,14 +999,25 @@ private static boolean lambda_function_declaration_2_0(PsiBuilder b, int l) { } /* ********************************************************** */ - // L_ROUND_BRACKET | R_ROUND_BRACKET - static boolean math_brackets(PsiBuilder b, int l) { - if (!recursion_guard_(b, l, "math_brackets")) return false; - if (!nextTokenIs(b, "", L_ROUND_BRACKET, R_ROUND_BRACKET)) return false; + // (bracketHandler | variable)PERC DIGITS + public static boolean moduloType(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "moduloType")) return false; + if (!nextTokenIs(b, "", IDENTIFIER, L_ANGLE_BRACKET)) return false; + boolean r; + Marker m = enter_section_(b, l, _NONE_, MODULO_TYPE, ""); + r = moduloType_0(b, l + 1); + r = r && consumeTokens(b, 0, PERC, DIGITS); + exit_section_(b, l, m, r, false, null); + return r; + } + + // bracketHandler | variable + private static boolean moduloType_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "moduloType_0")) return false; boolean r; Marker m = enter_section_(b); - r = consumeToken(b, L_ROUND_BRACKET); - if (!r) r = consumeToken(b, R_ROUND_BRACKET); + r = bracketHandler(b, l + 1); + if (!r) r = variable(b, l + 1); exit_section_(b, m, null, r); return r; } @@ -998,6 +1102,46 @@ private static boolean parameter_variable_1_0(PsiBuilder b, int l) { return r; } + /* ********************************************************** */ + // HASH IDENTIFIER* + public static boolean preprocessor(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "preprocessor")) return false; + if (!nextTokenIs(b, HASH)) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeToken(b, HASH); + r = r && preprocessor_1(b, l + 1); + exit_section_(b, m, PREPROCESSOR, r); + return r; + } + + // IDENTIFIER* + private static boolean preprocessor_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "preprocessor_1")) return false; + int c = current_position_(b); + while (true) { + if (!consumeToken(b, IDENTIFIER)) break; + if (!empty_element_parsed_guard_(b, "preprocessor_1", c)) break; + c = current_position_(b); + } + return true; + } + + /* ********************************************************** */ + // preprocessor* + public static boolean preprocessor_list(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "preprocessor_list")) return false; + Marker m = enter_section_(b, l, _NONE_, PREPROCESSOR_LIST, ""); + int c = current_position_(b); + while (true) { + if (!preprocessor(b, l + 1)) break; + if (!empty_element_parsed_guard_(b, "preprocessor_list", c)) break; + c = current_position_(b); + } + exit_section_(b, l, m, true, false, null); + return true; + } + /* ********************************************************** */ // RETURN validVariable SEMICOLON public static boolean return_statement(PsiBuilder b, int l) { @@ -1054,31 +1198,48 @@ private static boolean statement_2(PsiBuilder b, int l) { } /* ********************************************************** */ - // L_CURLY_BRACKET statement* R_CURLY_BRACKET + // L_CURLY_BRACKET statement* R_CURLY_BRACKET | function_body public static boolean statement_body(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "statement_body")) return false; if (!nextTokenIs(b, L_CURLY_BRACKET)) return false; boolean r; Marker m = enter_section_(b); + r = statement_body_0(b, l + 1); + if (!r) r = function_body(b, l + 1); + exit_section_(b, m, STATEMENT_BODY, r); + return r; + } + + // L_CURLY_BRACKET statement* R_CURLY_BRACKET + private static boolean statement_body_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "statement_body_0")) return false; + boolean r; + Marker m = enter_section_(b); r = consumeToken(b, L_CURLY_BRACKET); - r = r && statement_body_1(b, l + 1); + r = r && statement_body_0_1(b, l + 1); r = r && consumeToken(b, R_CURLY_BRACKET); - exit_section_(b, m, STATEMENT_BODY, r); + exit_section_(b, m, null, r); return r; } // statement* - private static boolean statement_body_1(PsiBuilder b, int l) { - if (!recursion_guard_(b, l, "statement_body_1")) return false; + private static boolean statement_body_0_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "statement_body_0_1")) return false; int c = current_position_(b); while (true) { if (!statement(b, l + 1)) break; - if (!empty_element_parsed_guard_(b, "statement_body_1", c)) break; + if (!empty_element_parsed_guard_(b, "statement_body_0_1", c)) break; c = current_position_(b); } return true; } + /* ********************************************************** */ + // SEMICOLON + static boolean statement_recover(PsiBuilder b, int l) { + return consumeToken(b, SEMICOLON); + } + /* ********************************************************** */ // EXCL static boolean unary_math_signs(PsiBuilder b, int l) { @@ -1086,7 +1247,11 @@ static boolean unary_math_signs(PsiBuilder b, int l) { } /* ********************************************************** */ - // bracketHandler | variable | DOUBLE_QUOTED_STRING | SINGLE_QUOTED_STRING | arrayRead + // bracketHandler + // | variable + // | DOUBLE_QUOTED_STRING + // | SINGLE_QUOTED_STRING + // | arrayRead public static boolean validCallable(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "validCallable")) return false; boolean r; @@ -1106,6 +1271,7 @@ public static boolean validCallable(PsiBuilder b, int l) { // | equation // | bracketHandler // | functionCall + // | field_reference // | variable // | number // | NULL @@ -1113,6 +1279,9 @@ public static boolean validCallable(PsiBuilder b, int l) { // | SINGLE_QUOTED_STRING // | arrayDeclaration // | arrayRead + // | moduloType + // | TRUE + // | FALSE public static boolean validVariable(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "validVariable")) return false; boolean r; @@ -1122,6 +1291,7 @@ public static boolean validVariable(PsiBuilder b, int l) { if (!r) r = equation(b, l + 1); if (!r) r = bracketHandler(b, l + 1); if (!r) r = functionCall(b, l + 1); + if (!r) r = field_reference(b, l + 1); if (!r) r = variable(b, l + 1); if (!r) r = number(b, l + 1); if (!r) r = consumeToken(b, NULL); @@ -1129,6 +1299,9 @@ public static boolean validVariable(PsiBuilder b, int l) { if (!r) r = consumeToken(b, SINGLE_QUOTED_STRING); if (!r) r = arrayDeclaration(b, l + 1); if (!r) r = arrayRead(b, l + 1); + if (!r) r = moduloType(b, l + 1); + if (!r) r = consumeToken(b, TRUE); + if (!r) r = consumeToken(b, FALSE); exit_section_(b, l, m, r, false, null); return r; } @@ -1165,32 +1338,40 @@ public static boolean variable(PsiBuilder b, int l) { } /* ********************************************************** */ - // import_list (statement | function_declaration )* + // preprocessor_list? import_list (statement | function_declaration )* static boolean zsFile(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "zsFile")) return false; boolean r; Marker m = enter_section_(b); - r = import_list(b, l + 1); - r = r && zsFile_1(b, l + 1); + r = zsFile_0(b, l + 1); + r = r && import_list(b, l + 1); + r = r && zsFile_2(b, l + 1); exit_section_(b, m, null, r); return r; } + // preprocessor_list? + private static boolean zsFile_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "zsFile_0")) return false; + preprocessor_list(b, l + 1); + return true; + } + // (statement | function_declaration )* - private static boolean zsFile_1(PsiBuilder b, int l) { - if (!recursion_guard_(b, l, "zsFile_1")) return false; + private static boolean zsFile_2(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "zsFile_2")) return false; int c = current_position_(b); while (true) { - if (!zsFile_1_0(b, l + 1)) break; - if (!empty_element_parsed_guard_(b, "zsFile_1", c)) break; + if (!zsFile_2_0(b, l + 1)) break; + if (!empty_element_parsed_guard_(b, "zsFile_2", c)) break; c = current_position_(b); } return true; } // statement | function_declaration - private static boolean zsFile_1_0(PsiBuilder b, int l) { - if (!recursion_guard_(b, l, "zsFile_1_0")) return false; + private static boolean zsFile_2_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "zsFile_2_0")) return false; boolean r; Marker m = enter_section_(b); r = statement(b, l + 1); diff --git a/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/ZsAssignStatement.java b/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/ZsAssignStatement.java index eb4ee0b..712554d 100644 --- a/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/ZsAssignStatement.java +++ b/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/ZsAssignStatement.java @@ -8,9 +8,9 @@ public interface ZsAssignStatement extends PsiElement { @NotNull - ZsValidVariable getValidVariable(); + ZsFieldReference getFieldReference(); @NotNull - ZsVariable getVariable(); + ZsValidVariable getValidVariable(); } diff --git a/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/ZsFieldReference.java b/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/ZsFieldReference.java new file mode 100644 index 0000000..53612e6 --- /dev/null +++ b/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/ZsFieldReference.java @@ -0,0 +1,13 @@ +// This is a generated file. Not intended for manual editing. +package de.bloodworkxgaming.zenscript.plugin.zsLanguage.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface ZsFieldReference extends PsiElement { + + @NotNull + ZsValidCallable getValidCallable(); + +} diff --git a/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/ZsModuloType.java b/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/ZsModuloType.java new file mode 100644 index 0000000..44201c7 --- /dev/null +++ b/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/ZsModuloType.java @@ -0,0 +1,19 @@ +// This is a generated file. Not intended for manual editing. +package de.bloodworkxgaming.zenscript.plugin.zsLanguage.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface ZsModuloType extends PsiElement { + + @Nullable + ZsBracketHandler getBracketHandler(); + + @Nullable + ZsVariable getVariable(); + + @NotNull + PsiElement getDigits(); + +} diff --git a/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/ZsPreprocessor.java b/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/ZsPreprocessor.java new file mode 100644 index 0000000..224d7a2 --- /dev/null +++ b/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/ZsPreprocessor.java @@ -0,0 +1,10 @@ +// This is a generated file. Not intended for manual editing. +package de.bloodworkxgaming.zenscript.plugin.zsLanguage.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface ZsPreprocessor extends PsiElement { + +} diff --git a/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/ZsPreprocessorList.java b/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/ZsPreprocessorList.java new file mode 100644 index 0000000..d5880be --- /dev/null +++ b/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/ZsPreprocessorList.java @@ -0,0 +1,13 @@ +// This is a generated file. Not intended for manual editing. +package de.bloodworkxgaming.zenscript.plugin.zsLanguage.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface ZsPreprocessorList extends PsiElement { + + @NotNull + List getPreprocessorList(); + +} diff --git a/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/ZsStatementBody.java b/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/ZsStatementBody.java index 7216986..57bc316 100644 --- a/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/ZsStatementBody.java +++ b/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/ZsStatementBody.java @@ -7,6 +7,9 @@ public interface ZsStatementBody extends PsiElement { + @Nullable + ZsFunctionBody getFunctionBody(); + @NotNull List getStatementList(); diff --git a/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/ZsTypes.java b/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/ZsTypes.java index 6d00924..fde56eb 100644 --- a/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/ZsTypes.java +++ b/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/ZsTypes.java @@ -16,6 +16,7 @@ public interface ZsTypes { IElementType CLASS_NAME = new ZsElementType("CLASS_NAME"); IElementType CONDITION = new ZsElementType("CONDITION"); IElementType EQUATION = new ZsElementType("EQUATION"); + IElementType FIELD_REFERENCE = new ZsElementType("FIELD_REFERENCE"); IElementType FOR_LOOP = new ZsElementType("FOR_LOOP"); IElementType FUNCTION_BODY = new ZsElementType("FUNCTION_BODY"); IElementType FUNCTION_CALL = new ZsElementType("FUNCTION_CALL"); @@ -24,9 +25,12 @@ public interface ZsTypes { IElementType IMPORT_LIST = new ZsElementType("IMPORT_LIST"); IElementType IMPORT_STATEMENT = new ZsElementType("IMPORT_STATEMENT"); IElementType LAMBDA_FUNCTION_DECLARATION = new ZsElementType("LAMBDA_FUNCTION_DECLARATION"); + IElementType MODULO_TYPE = new ZsElementType("MODULO_TYPE"); IElementType NUMBER = new ZsElementType("NUMBER"); IElementType PARAMETER_LIST = new ZsElementType("PARAMETER_LIST"); IElementType PARAMETER_VARIABLE = new ZsElementType("PARAMETER_VARIABLE"); + IElementType PREPROCESSOR = new ZsElementType("PREPROCESSOR"); + IElementType PREPROCESSOR_LIST = new ZsElementType("PREPROCESSOR_LIST"); IElementType RETURN_STATEMENT = new ZsElementType("RETURN_STATEMENT"); IElementType STATEMENT = new ZsElementType("STATEMENT"); IElementType STATEMENT_BODY = new ZsElementType("STATEMENT_BODY"); @@ -125,6 +129,9 @@ else if (type == CONDITION) { else if (type == EQUATION) { return new ZsEquationImpl(node); } + else if (type == FIELD_REFERENCE) { + return new ZsFieldReferenceImpl(node); + } else if (type == FOR_LOOP) { return new ZsForLoopImpl(node); } @@ -149,6 +156,9 @@ else if (type == IMPORT_STATEMENT) { else if (type == LAMBDA_FUNCTION_DECLARATION) { return new ZsLambdaFunctionDeclarationImpl(node); } + else if (type == MODULO_TYPE) { + return new ZsModuloTypeImpl(node); + } else if (type == NUMBER) { return new ZsNumberImpl(node); } @@ -158,6 +168,12 @@ else if (type == PARAMETER_LIST) { else if (type == PARAMETER_VARIABLE) { return new ZsParameterVariableImpl(node); } + else if (type == PREPROCESSOR) { + return new ZsPreprocessorImpl(node); + } + else if (type == PREPROCESSOR_LIST) { + return new ZsPreprocessorListImpl(node); + } else if (type == RETURN_STATEMENT) { return new ZsReturnStatementImpl(node); } diff --git a/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/ZsValidVariable.java b/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/ZsValidVariable.java index c9b2192..f103015 100644 --- a/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/ZsValidVariable.java +++ b/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/ZsValidVariable.java @@ -22,12 +22,18 @@ public interface ZsValidVariable extends PsiElement { @Nullable ZsEquation getEquation(); + @Nullable + ZsFieldReference getFieldReference(); + @Nullable ZsFunctionCall getFunctionCall(); @Nullable ZsLambdaFunctionDeclaration getLambdaFunctionDeclaration(); + @Nullable + ZsModuloType getModuloType(); + @Nullable ZsNumber getNumber(); diff --git a/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/ZsVisitor.java b/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/ZsVisitor.java index 2ef3a00..82d88ac 100644 --- a/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/ZsVisitor.java +++ b/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/ZsVisitor.java @@ -39,6 +39,10 @@ public void visitEquation(@NotNull ZsEquation o) { visitPsiElement(o); } + public void visitFieldReference(@NotNull ZsFieldReference o) { + visitPsiElement(o); + } + public void visitForLoop(@NotNull ZsForLoop o) { visitPsiElement(o); } @@ -71,6 +75,10 @@ public void visitLambdaFunctionDeclaration(@NotNull ZsLambdaFunctionDeclaration visitPsiElement(o); } + public void visitModuloType(@NotNull ZsModuloType o) { + visitPsiElement(o); + } + public void visitNumber(@NotNull ZsNumber o) { visitPsiElement(o); } @@ -83,6 +91,14 @@ public void visitParameterVariable(@NotNull ZsParameterVariable o) { visitPsiElement(o); } + public void visitPreprocessor(@NotNull ZsPreprocessor o) { + visitPsiElement(o); + } + + public void visitPreprocessorList(@NotNull ZsPreprocessorList o) { + visitPsiElement(o); + } + public void visitReturnStatement(@NotNull ZsReturnStatement o) { visitPsiElement(o); } diff --git a/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/impl/ZsAssignStatementImpl.java b/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/impl/ZsAssignStatementImpl.java index b8f2a7f..49bebfb 100644 --- a/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/impl/ZsAssignStatementImpl.java +++ b/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/impl/ZsAssignStatementImpl.java @@ -28,14 +28,14 @@ public void accept(@NotNull PsiElementVisitor visitor) { @Override @NotNull - public ZsValidVariable getValidVariable() { - return findNotNullChildByClass(ZsValidVariable.class); + public ZsFieldReference getFieldReference() { + return findNotNullChildByClass(ZsFieldReference.class); } @Override @NotNull - public ZsVariable getVariable() { - return findNotNullChildByClass(ZsVariable.class); + public ZsValidVariable getValidVariable() { + return findNotNullChildByClass(ZsValidVariable.class); } } diff --git a/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/impl/ZsFieldReferenceImpl.java b/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/impl/ZsFieldReferenceImpl.java new file mode 100644 index 0000000..1773f07 --- /dev/null +++ b/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/impl/ZsFieldReferenceImpl.java @@ -0,0 +1,35 @@ +// This is a generated file. Not intended for manual editing. +package de.bloodworkxgaming.zenscript.plugin.zsLanguage.psi.impl; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.lang.ASTNode; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiElementVisitor; +import com.intellij.psi.util.PsiTreeUtil; +import static de.bloodworkxgaming.zenscript.plugin.zsLanguage.psi.ZsTypes.*; +import com.intellij.extapi.psi.ASTWrapperPsiElement; +import de.bloodworkxgaming.zenscript.plugin.zsLanguage.psi.*; + +public class ZsFieldReferenceImpl extends ASTWrapperPsiElement implements ZsFieldReference { + + public ZsFieldReferenceImpl(ASTNode node) { + super(node); + } + + public void accept(@NotNull ZsVisitor visitor) { + visitor.visitFieldReference(this); + } + + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof ZsVisitor) accept((ZsVisitor)visitor); + else super.accept(visitor); + } + + @Override + @NotNull + public ZsValidCallable getValidCallable() { + return findNotNullChildByClass(ZsValidCallable.class); + } + +} diff --git a/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/impl/ZsModuloTypeImpl.java b/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/impl/ZsModuloTypeImpl.java new file mode 100644 index 0000000..0f9a9ca --- /dev/null +++ b/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/impl/ZsModuloTypeImpl.java @@ -0,0 +1,47 @@ +// This is a generated file. Not intended for manual editing. +package de.bloodworkxgaming.zenscript.plugin.zsLanguage.psi.impl; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.lang.ASTNode; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiElementVisitor; +import com.intellij.psi.util.PsiTreeUtil; +import static de.bloodworkxgaming.zenscript.plugin.zsLanguage.psi.ZsTypes.*; +import com.intellij.extapi.psi.ASTWrapperPsiElement; +import de.bloodworkxgaming.zenscript.plugin.zsLanguage.psi.*; + +public class ZsModuloTypeImpl extends ASTWrapperPsiElement implements ZsModuloType { + + public ZsModuloTypeImpl(ASTNode node) { + super(node); + } + + public void accept(@NotNull ZsVisitor visitor) { + visitor.visitModuloType(this); + } + + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof ZsVisitor) accept((ZsVisitor)visitor); + else super.accept(visitor); + } + + @Override + @Nullable + public ZsBracketHandler getBracketHandler() { + return findChildByClass(ZsBracketHandler.class); + } + + @Override + @Nullable + public ZsVariable getVariable() { + return findChildByClass(ZsVariable.class); + } + + @Override + @NotNull + public PsiElement getDigits() { + return findNotNullChildByType(DIGITS); + } + +} diff --git a/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/impl/ZsPreprocessorImpl.java b/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/impl/ZsPreprocessorImpl.java new file mode 100644 index 0000000..0f52d7c --- /dev/null +++ b/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/impl/ZsPreprocessorImpl.java @@ -0,0 +1,29 @@ +// This is a generated file. Not intended for manual editing. +package de.bloodworkxgaming.zenscript.plugin.zsLanguage.psi.impl; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.lang.ASTNode; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiElementVisitor; +import com.intellij.psi.util.PsiTreeUtil; +import static de.bloodworkxgaming.zenscript.plugin.zsLanguage.psi.ZsTypes.*; +import com.intellij.extapi.psi.ASTWrapperPsiElement; +import de.bloodworkxgaming.zenscript.plugin.zsLanguage.psi.*; + +public class ZsPreprocessorImpl extends ASTWrapperPsiElement implements ZsPreprocessor { + + public ZsPreprocessorImpl(ASTNode node) { + super(node); + } + + public void accept(@NotNull ZsVisitor visitor) { + visitor.visitPreprocessor(this); + } + + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof ZsVisitor) accept((ZsVisitor)visitor); + else super.accept(visitor); + } + +} diff --git a/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/impl/ZsPreprocessorListImpl.java b/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/impl/ZsPreprocessorListImpl.java new file mode 100644 index 0000000..4dc9259 --- /dev/null +++ b/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/impl/ZsPreprocessorListImpl.java @@ -0,0 +1,35 @@ +// This is a generated file. Not intended for manual editing. +package de.bloodworkxgaming.zenscript.plugin.zsLanguage.psi.impl; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.lang.ASTNode; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiElementVisitor; +import com.intellij.psi.util.PsiTreeUtil; +import static de.bloodworkxgaming.zenscript.plugin.zsLanguage.psi.ZsTypes.*; +import com.intellij.extapi.psi.ASTWrapperPsiElement; +import de.bloodworkxgaming.zenscript.plugin.zsLanguage.psi.*; + +public class ZsPreprocessorListImpl extends ASTWrapperPsiElement implements ZsPreprocessorList { + + public ZsPreprocessorListImpl(ASTNode node) { + super(node); + } + + public void accept(@NotNull ZsVisitor visitor) { + visitor.visitPreprocessorList(this); + } + + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof ZsVisitor) accept((ZsVisitor)visitor); + else super.accept(visitor); + } + + @Override + @NotNull + public List getPreprocessorList() { + return PsiTreeUtil.getChildrenOfTypeAsList(this, ZsPreprocessor.class); + } + +} diff --git a/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/impl/ZsStatementBodyImpl.java b/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/impl/ZsStatementBodyImpl.java index d093f66..c57553e 100644 --- a/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/impl/ZsStatementBodyImpl.java +++ b/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/impl/ZsStatementBodyImpl.java @@ -26,6 +26,12 @@ public void accept(@NotNull PsiElementVisitor visitor) { else super.accept(visitor); } + @Override + @Nullable + public ZsFunctionBody getFunctionBody() { + return findChildByClass(ZsFunctionBody.class); + } + @Override @NotNull public List getStatementList() { diff --git a/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/impl/ZsValidVariableImpl.java b/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/impl/ZsValidVariableImpl.java index 8dfb9d6..a9089b9 100644 --- a/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/impl/ZsValidVariableImpl.java +++ b/gen/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/impl/ZsValidVariableImpl.java @@ -56,6 +56,12 @@ public ZsEquation getEquation() { return findChildByClass(ZsEquation.class); } + @Override + @Nullable + public ZsFieldReference getFieldReference() { + return findChildByClass(ZsFieldReference.class); + } + @Override @Nullable public ZsFunctionCall getFunctionCall() { @@ -68,6 +74,12 @@ public ZsLambdaFunctionDeclaration getLambdaFunctionDeclaration() { return findChildByClass(ZsLambdaFunctionDeclaration.class); } + @Override + @Nullable + public ZsModuloType getModuloType() { + return findChildByClass(ZsModuloType.class); + } + @Override @Nullable public ZsNumber getNumber() { diff --git a/resources/META-INF/plugin.xml b/resources/META-INF/plugin.xml index 05b1fa9..170d780 100644 --- a/resources/META-INF/plugin.xml +++ b/resources/META-INF/plugin.xml @@ -37,6 +37,7 @@ + diff --git a/src/de/bloodworkxgaming/zenscript/plugin/zsLanguage/completion/ZsCompletionContributor.java b/src/de/bloodworkxgaming/zenscript/plugin/zsLanguage/completion/ZsCompletionContributor.java index 0a5bfa0..b7707d5 100644 --- a/src/de/bloodworkxgaming/zenscript/plugin/zsLanguage/completion/ZsCompletionContributor.java +++ b/src/de/bloodworkxgaming/zenscript/plugin/zsLanguage/completion/ZsCompletionContributor.java @@ -1,13 +1,24 @@ package de.bloodworkxgaming.zenscript.plugin.zsLanguage.completion; import com.intellij.codeInsight.completion.*; +import com.intellij.codeInsight.lookup.LookupElement; import com.intellij.codeInsight.lookup.LookupElementBuilder; import com.intellij.patterns.PlatformPatterns; +import com.intellij.psi.PsiNamedElement; import com.intellij.util.ProcessingContext; +import de.bloodworkxgaming.zenscript.plugin.zsLanguage.ZsIcon; import de.bloodworkxgaming.zenscript.plugin.zsLanguage.ZsLanguage; +import de.bloodworkxgaming.zenscript.plugin.zsLanguage.psi.ZsFile; import de.bloodworkxgaming.zenscript.plugin.zsLanguage.psi.ZsTypes; +import de.bloodworkxgaming.zenscript.plugin.zsLanguage.psi.ZsUtil; +import de.bloodworkxgaming.zenscript.plugin.zsLanguage.psi.ZsVariable; import org.jetbrains.annotations.NotNull; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + public class ZsCompletionContributor extends CompletionContributor { private String[] keywords = { "any", @@ -44,6 +55,22 @@ protected void addCompletions(@NotNull CompletionParameters parameters, Processi for (String keyword : keywords) { result.addElement(LookupElementBuilder.create(keyword)); } + + if (parameters.getOriginalFile() instanceof ZsFile){ + + List properties = ZsUtil.findVariables((ZsFile) parameters.getOriginalFile()); + Set alreadyAdded = new HashSet<>(); + + for (final ZsVariable property : properties) { + if (property.getName() != null && property.getName().length() > 0) { + if (!alreadyAdded.contains(property.getName())){ + alreadyAdded.add(property.getName()); + + result.addElement(LookupElementBuilder.create(property)); + } + } + } + } } }); } diff --git a/src/de/bloodworkxgaming/zenscript/plugin/zsLanguage/formatter/ZsAnnotator.java b/src/de/bloodworkxgaming/zenscript/plugin/zsLanguage/formatter/ZsAnnotator.java new file mode 100644 index 0000000..b456417 --- /dev/null +++ b/src/de/bloodworkxgaming/zenscript/plugin/zsLanguage/formatter/ZsAnnotator.java @@ -0,0 +1,17 @@ +package de.bloodworkxgaming.zenscript.plugin.zsLanguage.formatter; + +import com.intellij.lang.annotation.AnnotationHolder; +import com.intellij.lang.annotation.Annotator; +import com.intellij.openapi.project.DumbAware; +import com.intellij.psi.PsiElement; +import de.bloodworkxgaming.zenscript.plugin.zsLanguage.psi.ZsVariable; +import org.jetbrains.annotations.NotNull; + +public class ZsAnnotator implements Annotator, DumbAware{ + @Override + public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder holder) { + if (element instanceof ZsVariable){ + holder.createInfoAnnotation(element.getTextRange(), "ZenScript Variable: " + ((ZsVariable) element).getName()); + } + } +} diff --git a/src/de/bloodworkxgaming/zenscript/plugin/zsLanguage/formatter/ZsBraceMatcher.java b/src/de/bloodworkxgaming/zenscript/plugin/zsLanguage/formatter/ZsBraceMatcher.java index 8413e37..e78e623 100644 --- a/src/de/bloodworkxgaming/zenscript/plugin/zsLanguage/formatter/ZsBraceMatcher.java +++ b/src/de/bloodworkxgaming/zenscript/plugin/zsLanguage/formatter/ZsBraceMatcher.java @@ -13,10 +13,10 @@ public class ZsBraceMatcher implements PairedBraceMatcher { @Override public BracePair[] getPairs() { return new BracePair[]{ - new BracePair(ZsTypes.L_ROUND_BRACKET, ZsTypes.R_ROUND_BRACKET, true), - new BracePair(ZsTypes.L_ANGLE_BRACKET, ZsTypes.R_ANGLE_BRACKET, true), - new BracePair(ZsTypes.L_SQUARE_BRACKET, ZsTypes.R_SQUARE_BRACKET, true), - new BracePair(ZsTypes.L_CURLY_BRACKET, ZsTypes.R_CURLY_BRACKET, true), + new BracePair(ZsTypes.L_ROUND_BRACKET, ZsTypes.R_ROUND_BRACKET, false), + new BracePair(ZsTypes.L_ANGLE_BRACKET, ZsTypes.R_ANGLE_BRACKET, false), + new BracePair(ZsTypes.L_SQUARE_BRACKET, ZsTypes.R_SQUARE_BRACKET, false), + new BracePair(ZsTypes.L_CURLY_BRACKET, ZsTypes.R_CURLY_BRACKET, false), }; } diff --git a/src/de/bloodworkxgaming/zenscript/plugin/zsLanguage/formatter/ZsSyntaxHighlighter.java b/src/de/bloodworkxgaming/zenscript/plugin/zsLanguage/formatter/ZsSyntaxHighlighter.java index ae2a98b..96ae300 100644 --- a/src/de/bloodworkxgaming/zenscript/plugin/zsLanguage/formatter/ZsSyntaxHighlighter.java +++ b/src/de/bloodworkxgaming/zenscript/plugin/zsLanguage/formatter/ZsSyntaxHighlighter.java @@ -23,7 +23,7 @@ public class ZsSyntaxHighlighter extends SyntaxHighlighterBase { public static final TextAttributesKey SEPARATOR = createTextAttributesKey("ZS_SEPARATOR", DefaultLanguageHighlighterColors.OPERATION_SIGN); public static final TextAttributesKey KEYWORD = createTextAttributesKey("ZS_KEY", DefaultLanguageHighlighterColors.KEYWORD); - public static final TextAttributesKey VARIABLE = createTextAttributesKey("ZS_VARIABLE", DefaultLanguageHighlighterColors.KEYWORD); //TODO: set back to right name + public static final TextAttributesKey VARIABLE = createTextAttributesKey("ZS_VARIABLE", DefaultLanguageHighlighterColors.LOCAL_VARIABLE); //TODO: set back to right name public static final TextAttributesKey COMMENT = createTextAttributesKey("ZS_COMMENT", DefaultLanguageHighlighterColors.LINE_COMMENT); public static final TextAttributesKey BAD_CHARACTER = createTextAttributesKey("ZS_BAD_CHARACTER", HighlighterColors.BAD_CHARACTER); public static final TextAttributesKey STRING = createTextAttributesKey("ZS_STRING", DefaultLanguageHighlighterColors.STRING); @@ -51,21 +51,28 @@ public Lexer getHighlightingLexer() { public TextAttributesKey[] getTokenHighlights(IElementType tokenType) { if (tokenType.equals(ZsTypes.VARIABLE)) { return VARIABLE_KEYS; - } else if (isKeyword(tokenType)) { + } + if (isKeyword(tokenType)) { return KEYWORD_KEYS; - } else if (tokenType.equals(ZsTypes.DOUBLE_QUOTED_STRING) | tokenType.equals(ZsTypes.SINGLE_QUOTED_STRING)) { + } + if (tokenType.equals(ZsTypes.DOUBLE_QUOTED_STRING) | tokenType.equals(ZsTypes.SINGLE_QUOTED_STRING)) { return STRING_KEYS; - } else if (tokenType.equals(ZsTypes.LINE_COMMENT) || tokenType.equals(ZsTypes.BLOCK_COMMENT)) { + } + if (tokenType.equals(ZsTypes.LINE_COMMENT) || tokenType.equals(ZsTypes.BLOCK_COMMENT)) { return COMMENT_KEYS; - } else if (tokenType.equals(TokenType.BAD_CHARACTER)) { + } + if (tokenType.equals(TokenType.BAD_CHARACTER)) { return BAD_CHAR_KEYS; - } else if (isNumber(tokenType)){ + } + if (isNumber(tokenType)){ return NUMBER_KEYS; - } else if (tokenType.equals(ZsTypes.BRACKET_HANDLER)){ + } + if (tokenType.equals(ZsTypes.BRACKET_HANDLER)){ return BRACKET_HANDLER_KEYS; - } else if (tokenType.equals(ZsTypes.IDENTIFIER)){ - return VARIABLE_KEYS; } + /* if (tokenType.equals(ZsTypes.IDENTIFIER)){ + return VARIABLE_KEYS; + }*/ return EMPTY_KEYS; } diff --git a/src/de/bloodworkxgaming/zenscript/plugin/zsLanguage/formatter/ZsTypes_old.java b/src/de/bloodworkxgaming/zenscript/plugin/zsLanguage/formatter/ZsTypes_old.java deleted file mode 100644 index 5bcc282..0000000 --- a/src/de/bloodworkxgaming/zenscript/plugin/zsLanguage/formatter/ZsTypes_old.java +++ /dev/null @@ -1,61 +0,0 @@ -package de.bloodworkxgaming.zenscript.plugin.zsLanguage.formatter; - -import com.intellij.psi.tree.IElementType; -import com.intellij.psi.tree.TokenSet; -import de.bloodworkxgaming.zenscript.plugin.zsLanguage.ZsLanguage; - -public class ZsTypes_old { - /** - * Normal ElementTypes - */ - public static final IElementType IDENTIFIER = new IElementType("IDENTIFIER", ZsLanguage.INSTANCE); - public static final IElementType INTEGER_LITERAL = new IElementType("INTEGER_LITERAL", ZsLanguage.INSTANCE); - - public static final IElementType WHITESPACE = new IElementType("WHITESPACE", ZsLanguage.INSTANCE); - - /** - * Braces - */ - public static final IElementType L_ROUND_BRACKET = new IElementType("L_ROUND_BRACKET", ZsLanguage.INSTANCE); - public static final IElementType R_ROUND_BRACKET = new IElementType("R_ROUND_BRACKET", ZsLanguage.INSTANCE); - - public static final IElementType L_ANGLE_BRACKET = new IElementType("L_ANGLE_BRACKET", ZsLanguage.INSTANCE); - public static final IElementType R_ANGLE_BRACKET = new IElementType("R_ANGLE_BRACKET", ZsLanguage.INSTANCE); - - public static final IElementType L_SQUARE_BRACKET = new IElementType("L_SQUARE_BRACKET", ZsLanguage.INSTANCE); - public static final IElementType R_SQUARE_BRACKET = new IElementType("R_SQUARE_BRACKET", ZsLanguage.INSTANCE); - - public static final IElementType L_SWIRL_BRACKET = new IElementType("L_SWIRL_BRACKET", ZsLanguage.INSTANCE); - public static final IElementType R_SWIRL_BRACKET = new IElementType("R_SWIRL_BRACKET", ZsLanguage.INSTANCE); - - /** - * Operators - */ - public static final IElementType EQ = new IElementType("EQ", ZsLanguage.INSTANCE); - public static final IElementType EQEQ = new IElementType("EQEQ", ZsLanguage.INSTANCE); - public static final IElementType PLUS = new IElementType("PLUS", ZsLanguage.INSTANCE); - - /** - * Keywords - */ - public static final IElementType BOOLEAN = new IElementType("BOOLEAN", ZsLanguage.INSTANCE); - public static final IElementType BREAK = new IElementType("BREAK", ZsLanguage.INSTANCE); - - - /** - * Comment types - */ - public static final IElementType C_STYLE_COMMENT = new IElementType("C_STYLE_COMMENT", ZsLanguage.INSTANCE); - public static final IElementType END_OF_LINE_COMMENT = new IElementType("END_OF_LINE_COMMENT", ZsLanguage.INSTANCE); - public static final IElementType DOC_COMMENT = new IElementType("DOC_COMMENT", ZsLanguage.INSTANCE); - - - /** - * TokenSets - */ - public static final TokenSet WHITESPACE_SET = TokenSet.create(WHITESPACE); - public static final TokenSet JAVA_PLAIN_COMMENT_BIT_SET = TokenSet.create(END_OF_LINE_COMMENT, C_STYLE_COMMENT); - public static final TokenSet JAVA_COMMENT_BIT_SET = TokenSet.orSet(JAVA_PLAIN_COMMENT_BIT_SET, TokenSet.create(DOC_COMMENT)); - - -} diff --git a/src/de/bloodworkxgaming/zenscript/plugin/zsLanguage/parsing/ZsParserUtil.java b/src/de/bloodworkxgaming/zenscript/plugin/zsLanguage/parsing/ZsParserUtil.java new file mode 100644 index 0000000..4ebe8f3 --- /dev/null +++ b/src/de/bloodworkxgaming/zenscript/plugin/zsLanguage/parsing/ZsParserUtil.java @@ -0,0 +1,6 @@ +package de.bloodworkxgaming.zenscript.plugin.zsLanguage.parsing; + +import com.intellij.lang.parser.GeneratedParserUtilBase; + +public class ZsParserUtil extends GeneratedParserUtilBase { +} diff --git a/src/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/ZenScript.bnf b/src/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/ZenScript.bnf index def5845..d176e4e 100644 --- a/src/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/ZenScript.bnf +++ b/src/de/bloodworkxgaming/zenscript/plugin/zsLanguage/psi/ZenScript.bnf @@ -1,5 +1,6 @@ { parserClass="de.bloodworkxgaming.zenscript.plugin.zsLanguage.parsing.ZsParser" + parserUtilClass="de.bloodworkxgaming.zenscript.plugin.zsLanguage.parsing.ZsParserUtil" extends="com.intellij.extapi.psi.ASTWrapperPsiElement" @@ -97,10 +98,13 @@ ] } -zsFile ::= import_list (statement | function_declaration )* +zsFile ::= preprocessor_list? import_list (statement | function_declaration )* // private item_ ::= +preprocessor_list ::= preprocessor* +preprocessor ::= HASH IDENTIFIER* + import_list ::= import_statement* import_statement ::= IMPORT IDENTIFIER (DOT IDENTIFIER)* SEMICOLON @@ -109,7 +113,10 @@ statement ::= assignStatement SEMICOLON | EOL | functionCall SEMICOLON | for_loop - | if_statement + | if_statement /*{recoverWhile=statement_recover}*/ + +private statement_recover ::= SEMICOLON + bracketHandler ::= L_ANGLE_BRACKET (IDENTIFIER | COLON | DIGITS | ASTERISK)* R_ANGLE_BRACKET @@ -120,6 +127,7 @@ class_name ::= IDENTIFIER (L_SQUARE_BRACKET R_SQUARE_BRACKET)* number ::= DIGITS | FLOATING_POINT + validVariable ::= lambda_function_declaration | castExpression | equation @@ -133,6 +141,9 @@ validVariable ::= lambda_function_declaration | SINGLE_QUOTED_STRING | arrayDeclaration | arrayRead + | moduloType + | TRUE + | FALSE validCallable ::= bracketHandler | variable @@ -140,24 +151,27 @@ validCallable ::= bracketHandler | SINGLE_QUOTED_STRING | arrayRead -field_reference ::= validCallable (DOT IDENTIFIER)+ +field_reference ::= validCallable (DOT IDENTIFIER)* + +moduloType ::= (bracketHandler | variable)PERC DIGITS assignStatement ::= (VAR | VAL)? field_reference EQUAL validVariable /*{mixin= "de.bloodworkxgaming.zenscript.plugin.zsLanguage.psi.impl.ZsNamedElementImpl" implements= "de.bloodworkxgaming.zenscript.plugin.zsLanguage.psi.impl.ZsNamedElementImpl" methods=[getVariableName getNameIdentifier setVariableName]}*/ -functionCall ::= validCallable (DOT IDENTIFIER)* (L_ROUND_BRACKET R_ROUND_BRACKET | (L_ROUND_BRACKET (validVariable (COMMA validVariable)*) R_ROUND_BRACKET)) +functionCall ::= validCallable ((DOT IDENTIFIER)* (L_ROUND_BRACKET R_ROUND_BRACKET | (L_ROUND_BRACKET (validVariable (COMMA validVariable)*) R_ROUND_BRACKET)))+ arrayDeclaration ::= L_SQUARE_BRACKET validVariable (COMMA validVariable)* R_SQUARE_BRACKET arrayRead ::= IDENTIFIER (DOT IDENTIFIER)* (L_SQUARE_BRACKET DIGITS R_SQUARE_BRACKET)+ castExpression ::= (arrayDeclaration | IDENTIFIER | bracketHandler) AS class_name -statement_body ::= L_CURLY_BRACKET statement* R_CURLY_BRACKET +// CONTROL STATEMENTS +statement_body ::= (L_CURLY_BRACKET statement* R_CURLY_BRACKET | function_body) return_statement ::= RETURN validVariable SEMICOLON for_loop ::= FOR (((variable COMMA)? variable in variable) | (variable IN DIGITS ((DOT DOT) | TO) DIGITS)) statement_body -condition ::= validVariable (EQEQ | NOT_EQUAL | GREATER_EQUAL | LESS_EQUAL | L_ANGLE_BRACKET | R_ANGLE_BRACKET) validVariable +condition ::= validVariable ((EQEQ | NOT_EQUAL | GREATER_EQUAL | LESS_EQUAL | L_ANGLE_BRACKET | R_ANGLE_BRACKET) validVariable)* if_statement ::= IF L_ROUND_BRACKET condition ((OR | AND | XOR) condition)* R_ROUND_BRACKET statement_body (ELSE statement_body)?