intellij-sjson/gen/ru/crabs/sdk/language/parser/SJsonParser.java

186 lines
5.7 KiB
Java

// This is a generated file. Not intended for manual editing.
package ru.crabs.sdk.language.parser;
import com.intellij.lang.PsiBuilder;
import com.intellij.lang.PsiBuilder.Marker;
import static ru.crabs.sdk.language.psi.SJsonTypes.*;
import static com.intellij.lang.parser.GeneratedParserUtilBase.*;
import com.intellij.psi.tree.IElementType;
import com.intellij.lang.ASTNode;
import com.intellij.psi.tree.TokenSet;
import com.intellij.lang.PsiParser;
import com.intellij.lang.LightPsiParser;
@SuppressWarnings({"SimplifiableIfStatement", "UnusedAssignment"})
public class SJsonParser implements PsiParser, LightPsiParser {
public ASTNode parse(IElementType t, PsiBuilder b) {
parseLight(t, b);
return b.getTreeBuilt();
}
public void parseLight(IElementType t, PsiBuilder b) {
boolean r;
b = adapt_builder_(t, b, this, null);
Marker m = enter_section_(b, 0, _COLLAPSE_, null);
r = parse_root_(t, b);
exit_section_(b, 0, m, t, r, true, TRUE_CONDITION);
}
protected boolean parse_root_(IElementType t, PsiBuilder b) {
return parse_root_(t, b, 0);
}
static boolean parse_root_(IElementType t, PsiBuilder b, int l) {
return root(b, l + 1);
}
/* ********************************************************** */
// "[" (item ",")* item "]"
public static boolean array(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "array")) return false;
boolean r;
Marker m = enter_section_(b, l, _NONE_, ARRAY, "<array>");
r = consumeToken(b, "[");
r = r && array_1(b, l + 1);
r = r && item(b, l + 1);
r = r && consumeToken(b, "]");
exit_section_(b, l, m, r, false, null);
return r;
}
// (item ",")*
private static boolean array_1(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "array_1")) return false;
while (true) {
int c = current_position_(b);
if (!array_1_0(b, l + 1)) break;
if (!empty_element_parsed_guard_(b, "array_1", c)) break;
}
return true;
}
// item ","
private static boolean array_1_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "array_1_0")) return false;
boolean r;
Marker m = enter_section_(b);
r = item(b, l + 1);
r = r && consumeToken(b, ",");
exit_section_(b, m, null, r);
return r;
}
/* ********************************************************** */
// object | array | var | string | number
public static boolean item(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "item")) return false;
boolean r;
Marker m = enter_section_(b, l, _NONE_, ITEM, "<item>");
r = object(b, l + 1);
if (!r) r = array(b, l + 1);
if (!r) r = var(b, l + 1);
if (!r) r = consumeToken(b, STRING);
if (!r) r = consumeToken(b, NUMBER);
exit_section_(b, l, m, r, false, null);
return r;
}
/* ********************************************************** */
// var ":" item
public static boolean mixin(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "mixin")) return false;
boolean r;
Marker m = enter_section_(b, l, _NONE_, MIXIN, "<mixin>");
r = var(b, l + 1);
r = r && consumeToken(b, ":");
r = r && item(b, l + 1);
exit_section_(b, l, m, r, false, null);
return r;
}
/* ********************************************************** */
// "{" (prop ",")* prop "}"
public static boolean object(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "object")) return false;
boolean r;
Marker m = enter_section_(b, l, _NONE_, OBJECT, "<object>");
r = consumeToken(b, "{");
r = r && object_1(b, l + 1);
r = r && prop(b, l + 1);
r = r && consumeToken(b, "}");
exit_section_(b, l, m, r, false, null);
return r;
}
// (prop ",")*
private static boolean object_1(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "object_1")) return false;
while (true) {
int c = current_position_(b);
if (!object_1_0(b, l + 1)) break;
if (!empty_element_parsed_guard_(b, "object_1", c)) break;
}
return true;
}
// prop ","
private static boolean object_1_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "object_1_0")) return false;
boolean r;
Marker m = enter_section_(b);
r = prop(b, l + 1);
r = r && consumeToken(b, ",");
exit_section_(b, m, null, r);
return r;
}
/* ********************************************************** */
// string ":" item
public static boolean pair(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "pair")) return false;
if (!nextTokenIs(b, STRING)) return false;
boolean r;
Marker m = enter_section_(b);
r = consumeToken(b, STRING);
r = r && consumeToken(b, ":");
r = r && item(b, l + 1);
exit_section_(b, m, PAIR, r);
return r;
}
/* ********************************************************** */
// pair | mixin
public static boolean prop(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "prop")) return false;
boolean r;
Marker m = enter_section_(b, l, _NONE_, PROP, "<prop>");
r = pair(b, l + 1);
if (!r) r = mixin(b, l + 1);
exit_section_(b, l, m, r, false, null);
return r;
}
/* ********************************************************** */
// object | COMMENT
static boolean root(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "root")) return false;
boolean r;
r = object(b, l + 1);
if (!r) r = consumeToken(b, COMMENT);
return r;
}
/* ********************************************************** */
// "regexp:\"$[^\"]*\""
public static boolean var(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "var")) return false;
boolean r;
Marker m = enter_section_(b, l, _NONE_, VAR, "<var>");
r = consumeToken(b, "regexp:\"$[^\"]*\"");
exit_section_(b, l, m, r, false, null);
return r;
}
}