org.sonar.sslr.grammar.GrammarRuleKey Java Examples
The following examples show how to use
org.sonar.sslr.grammar.GrammarRuleKey.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Assertions.java From sonar-esql-plugin with Apache License 2.0 | 5 votes |
public static ParserAssert assertThat(LexerlessGrammarBuilder b, GrammarRuleKey rule) { return new ParserAssert(new ActionParser<Tree>( Charsets.UTF_8, b, EsqlGrammar.class, new TreeFactory(), new EsqlNodeBuilder(), rule)); }
Example #2
Source File: CssParser.java From sonar-css-plugin with GNU Lesser General Public License v3.0 | 5 votes |
private static ActionParser<Tree> createParser(Charset charset, GrammarRuleKey rootRule) { return new CssParser( charset, LexicalGrammar.createCssGrammar(), CssGrammar.class, new TreeFactory(), new CssNodeBuilder(), rootRule); }
Example #3
Source File: BinaryExpressionTest.java From sonar-esql-plugin with Apache License 2.0 | 5 votes |
private void test_binary_expression(String str, GrammarRuleKey rule, Kind kind, String operator) throws Exception { BinaryExpressionTree tree = parse(str, rule, kind); assertThat(tree.is(kind)).isTrue(); assertThat(tree.leftOperand()).isNotNull(); assertThat(tree.operator().text()).isEqualTo(operator); assertThat(tree.rightOperand()).isNotNull(); tree = (BinaryExpressionTree) tree.leftOperand(); assertThat(tree.is(kind)).isTrue(); assertThat(tree.leftOperand()).isNotNull(); assertThat(tree.operator().text()).isEqualTo(operator); assertThat(tree.rightOperand()).isNotNull(); }
Example #4
Source File: EmbeddedCssParser.java From sonar-css-plugin with GNU Lesser General Public License v3.0 | 5 votes |
private static ActionParser<Tree> createParser(Charset charset, GrammarRuleKey rootRule) { return new EmbeddedCssParser( charset, LexicalGrammar.createEmbeddedCssGrammar(), EmbeddedCssGrammar.class, new TreeFactory(), new EmbeddedCssNodeBuilder(), rootRule); }
Example #5
Source File: EsqlNodeBuilder.java From sonar-esql-plugin with Apache License 2.0 | 5 votes |
@Override public Object createNonTerminal(GrammarRuleKey ruleKey, Rule rule, List<Object> children, int startIndex, int endIndex) { for (Object child : children) { if (child instanceof InternalSyntaxToken) { return child; } } return new InternalSyntaxSpacing(); }
Example #6
Source File: LessParser.java From sonar-css-plugin with GNU Lesser General Public License v3.0 | 5 votes |
private static ActionParser<Tree> createParser(Charset charset, GrammarRuleKey rootRule) { return new LessParser( charset, LexicalGrammar.createLessGrammar(), LessGrammar.class, new TreeFactory(), new LessNodeBuilder(), rootRule); }
Example #7
Source File: AbstractNodeBuilder.java From sonar-css-plugin with GNU Lesser General Public License v3.0 | 5 votes |
@Override public Object createNonTerminal(GrammarRuleKey ruleKey, Rule rule, List<Object> children, int startIndex, int endIndex) { for (Object child : children) { if (child instanceof InternalSyntaxToken) { return child; } } return new InternalSyntaxSpacing(startIndex, endIndex); }
Example #8
Source File: EsqlParser.java From sonar-esql-plugin with Apache License 2.0 | 5 votes |
public EsqlParser(GrammarRuleKey rootRule) { super( Charset.defaultCharset(), EsqlLegacyGrammar.createGrammarBuilder(), EsqlGrammar.class, new TreeFactory(), new EsqlNodeBuilder(), rootRule); }
Example #9
Source File: GherkinNodeBuilder.java From sonar-gherkin-plugin with GNU Lesser General Public License v3.0 | 5 votes |
@Override public Object createNonTerminal(GrammarRuleKey ruleKey, Rule rule, List<Object> children, int startIndex, int endIndex) { for (Object child : children) { if (child instanceof InternalSyntaxToken) { return child; } } return new InternalSyntaxSpacing(startIndex, endIndex); }
Example #10
Source File: ScssParser.java From sonar-css-plugin with GNU Lesser General Public License v3.0 | 5 votes |
private static ActionParser<Tree> createParser(Charset charset, GrammarRuleKey rootRule) { return new ScssParser( charset, LexicalGrammar.createScssGrammar(), ScssGrammar.class, new TreeFactory(), new ScssNodeBuilder(), rootRule); }
Example #11
Source File: GherkinParserBuilder.java From sonar-gherkin-plugin with GNU Lesser General Public License v3.0 | 5 votes |
private static GherkinParser createParser(Charset charset, GrammarRuleKey rootRule, String language) { return new GherkinParser( charset, GherkinLexicalGrammar.createGrammar(language), GherkinGrammar.class, new TreeFactory(), new GherkinNodeBuilder(), rootRule); }
Example #12
Source File: ApexRuleTest.java From enforce-sonarqube-plugin with MIT License | 4 votes |
protected void setRootRule(GrammarRuleKey ruleKey) { parser.setRootRule(parser.getGrammar().rule(ruleKey)); }
Example #13
Source File: Assertions.java From sonar-esql-plugin with Apache License 2.0 | 4 votes |
public static ParserAssert assertThat(GrammarRuleKey rule) { return assertThat(EsqlLegacyGrammar.createGrammarBuilder(), rule); }
Example #14
Source File: EsqlTreeModelTest.java From sonar-esql-plugin with Apache License 2.0 | 4 votes |
private ActionParser<Tree> getParser(GrammarRuleKey rule){ return new ActionParser<>(Charsets.UTF_8, EsqlLegacyGrammar.createGrammarBuilder(), EsqlGrammar.class, new TreeFactory(), new EsqlNodeBuilder(), rule); }
Example #15
Source File: EsqlParserBuilder.java From sonar-esql-plugin with Apache License 2.0 | 4 votes |
public static ActionParser<Tree> createParser(GrammarRuleKey rootRule){ return new EsqlParser(rootRule); }
Example #16
Source File: GherkinParserBuilder.java From sonar-gherkin-plugin with GNU Lesser General Public License v3.0 | 4 votes |
public static GherkinParser createTestParser(Charset charset, GrammarRuleKey rootRule) { return createParser(charset, rootRule, GherkinDialectProvider.DEFAULT_LANGUAGE); }
Example #17
Source File: GherkinParserBuilder.java From sonar-gherkin-plugin with GNU Lesser General Public License v3.0 | 4 votes |
public static GherkinParser createTestParser(Charset charset, GrammarRuleKey rootRule, String language) { return createParser(charset, rootRule, language); }
Example #18
Source File: GherkinParser.java From sonar-gherkin-plugin with GNU Lesser General Public License v3.0 | 4 votes |
public GherkinParser(Charset charset, LexerlessGrammarBuilder grammarBuilder, Class<GherkinGrammar> grammarClass, TreeFactory treeFactory, GherkinNodeBuilder nodeBuilder, GrammarRuleKey rootRule) { super(charset, grammarBuilder, grammarClass, treeFactory, nodeBuilder, rootRule); }
Example #19
Source File: AbstractParser.java From sonar-css-plugin with GNU Lesser General Public License v3.0 | 4 votes |
public AbstractParser(Charset charset, LexerlessGrammarBuilder grammarBuilder, Class<? extends CssGrammar> grammarClass, TreeFactory treeFactory, AbstractNodeBuilder nodeBuilder, GrammarRuleKey rootRule) { super(charset, grammarBuilder, grammarClass, treeFactory, nodeBuilder, rootRule); }
Example #20
Source File: ScssParser.java From sonar-css-plugin with GNU Lesser General Public License v3.0 | 4 votes |
@VisibleForTesting public static ActionParser<Tree> createTestParser(Charset charset, GrammarRuleKey rootRule) { return createParser(charset, rootRule); }
Example #21
Source File: ScssParser.java From sonar-css-plugin with GNU Lesser General Public License v3.0 | 4 votes |
private ScssParser(Charset charset, LexerlessGrammarBuilder grammarBuilder, Class<ScssGrammar> scssGrammarClass, TreeFactory treeFactory, ScssNodeBuilder scssNodeBuilder, GrammarRuleKey rootRule) { super(charset, grammarBuilder, scssGrammarClass, treeFactory, scssNodeBuilder, rootRule); }
Example #22
Source File: LessParser.java From sonar-css-plugin with GNU Lesser General Public License v3.0 | 4 votes |
@VisibleForTesting public static ActionParser<Tree> createTestParser(Charset charset, GrammarRuleKey rootRule) { return createParser(charset, rootRule); }
Example #23
Source File: LessParser.java From sonar-css-plugin with GNU Lesser General Public License v3.0 | 4 votes |
private LessParser(Charset charset, LexerlessGrammarBuilder grammarBuilder, Class<LessGrammar> lessGrammarClass, TreeFactory treeFactory, LessNodeBuilder lessNodeBuilder, GrammarRuleKey rootRule) { super(charset, grammarBuilder, lessGrammarClass, treeFactory, lessNodeBuilder, rootRule); }
Example #24
Source File: EmbeddedCssParser.java From sonar-css-plugin with GNU Lesser General Public License v3.0 | 4 votes |
@VisibleForTesting public static ActionParser<Tree> createTestParser(Charset charset, GrammarRuleKey rootRule) { return createParser(charset, rootRule); }
Example #25
Source File: EmbeddedCssParser.java From sonar-css-plugin with GNU Lesser General Public License v3.0 | 4 votes |
private EmbeddedCssParser(Charset charset, LexerlessGrammarBuilder grammarBuilder, Class<EmbeddedCssGrammar> embeddedCssGrammarClass, TreeFactory treeFactory, EmbeddedCssNodeBuilder embeddedCssNodeBuilder, GrammarRuleKey rootRule) { super(charset, grammarBuilder, embeddedCssGrammarClass, treeFactory, embeddedCssNodeBuilder, rootRule); }
Example #26
Source File: CssParser.java From sonar-css-plugin with GNU Lesser General Public License v3.0 | 4 votes |
@VisibleForTesting public static ActionParser<Tree> createTestParser(Charset charset, GrammarRuleKey rootRule) { return createParser(charset, rootRule); }
Example #27
Source File: CssParser.java From sonar-css-plugin with GNU Lesser General Public License v3.0 | 4 votes |
private CssParser(Charset charset, LexerlessGrammarBuilder grammarBuilder, Class<CssGrammar> cssGrammarClass, TreeFactory treeFactory, CssNodeBuilder cssNodeBuilder, GrammarRuleKey rootRule) { super(charset, grammarBuilder, cssGrammarClass, treeFactory, cssNodeBuilder, rootRule); }
Example #28
Source File: EsqlTreeModelTest.java From sonar-esql-plugin with Apache License 2.0 | 3 votes |
/** * Parse the given string and return the first descendant of the given kind. * * @param s * the string to parse * @param rule * the rule used to parse the string * @param descendantToReturn * the node kind to seek in the generated tree * @return the node found for the given kind, null if not found. */ @SuppressWarnings("unchecked") protected T parse(String s, GrammarRuleKey rule, Kind descendantToReturn) throws Exception { Tree node = getParser(rule).parse(s); checkFullFidelity(node, s); return (T) getFirstDescendant((EsqlTree) node, descendantToReturn); }