@ SuppressWarnings ( "checkstyle:nestedifdepth" ) private static void exploreGrammar ( Grammar grammar , Set < String > expressionKeywords , Set < String > modifiers , Set < String > primitiveTypes , Set < String > punctuation , Set < String > literals , Set < String > excludedKeywords , Set < String > ignored ) { for ( final AbstractRule rule : grammar . getRules ( ) ) { final boolean isModifierRule = MODIFIER_RULE_PATTERN . matcher ( rule . getName ( ) ) . matches ( ) ; final TreeIterator < EObject > iterator = rule . eAllContents ( ) ; while ( iterator . hasNext ( ) ) { final EObject object = iterator . next ( ) ; if ( object instanceof Keyword ) { final Keyword xkeyword = ( Keyword ) object ; final String value = xkeyword . getValue ( ) ; if ( ! Strings . isEmpty ( value ) ) { if ( KEYWORD_PATTERN . matcher ( value ) . matches ( ) ) { if ( ! literals . contains ( value ) && ! primitiveTypes . contains ( value ) ) { if ( excludedKeywords . contains ( value ) ) { ignored . add ( value ) ; } else { if ( isModifierRule ) { modifiers . add ( value ) ; } else { expressionKeywords . add ( value ) ; } } } } else if ( PUNCTUATION_PATTERN . matcher ( value ) . matches ( ) ) { punctuation . add ( value ) ; } } } } } }
Explore the grammar for extracting the key elements .