src/main/java/br/com/starcode/parccser/Parser.java
protected Selector selector() throws ParserException {
        int initialPosition = pos;
        StringBuilder sb = new StringBuilder();
        List<SimpleSelectorSequence> simpleSelectors = new ArrayList<SimpleSelectorSequence>();
        List<Combinator> combinators = new ArrayList<Combinator>();
        int lastChar = pos;
        while (!end()) {
        	//finds combinator, but not in the first iteration
        	Combinator combinator = null;
        	if (!simpleSelectors.isEmpty()) {
        		//stores if it has spaces until the next token
                boolean hasWhitespace = false;
                if (!end() && Character.isWhitespace(current)) {
                    hasWhitespace = true;
                    ignoreWhitespaces();
                }
                if (!end()) {
                    //implements "combinator" rule
                    if (current == '+') combinator = Combinator.ADJASCENT_SIBLING;
                    else if (current == '>') combinator = Combinator.CHILD;
                    else if (current == '~') combinator = Combinator.GENERAL_SIBLING;
                    //if hasn't any but spaces
                    else if (hasWhitespace) combinator = Combinator.DESCENDANT;
                    //is it the end?
                    if (combinator == null || current == ',') {
                        break;
                    }
                    //don't advance because spaces were just advanced
                    if (combinator != Combinator.DESCENDANT) {
                    	sb.append(current);
                        next();
                    } else {
                    	sb.append(' ');
                    }
                    ignoreWhitespaces();
                    if (end()) {
                        throw new ParserException("Unexpected end of selector at position " + pos);
                    }
                } else {
                    break;
                }
                combinators.add(combinator);
        	}
        	//get next sequence
            SimpleSelectorSequence simpleSelectorSequence = simpleSelectorSequence();
            sb.append(simpleSelectorSequence);
            //sends combinator here (the first case it's null)
            simpleSelectors.add(simpleSelectorSequence);
            parserListener.selectorSequence(simpleSelectorSequence, combinator);
            lastChar = pos;
        }
        return new Selector(simpleSelectors, combinators, new Context(content, sb.toString(), initialPosition, lastChar));
    }
protected Selector selector() throws ParserException {
        int initialPosition = pos;
        StringBuilder sb = new StringBuilder();
        List<SimpleSelectorSequence> simpleSelectors = new ArrayList<SimpleSelectorSequence>();
        List<Combinator> combinators = new ArrayList<Combinator>();
        int lastChar = pos;
        while (!end()) {
        	//finds combinator, but not in the first iteration
        	Combinator combinator = null;
        	if (!simpleSelectors.isEmpty()) {
        		//stores if it has spaces until the next token
                boolean hasWhitespace = false;
                if (!end() && Character.isWhitespace(current)) {
                    hasWhitespace = true;
                    ignoreWhitespaces();
                }
                if (!end()) {
                    //implements "combinator" rule
                    if (current == '+') combinator = Combinator.ADJASCENT_SIBLING;
                    else if (current == '>') combinator = Combinator.CHILD;
                    else if (current == '~') combinator = Combinator.GENERAL_SIBLING;
                    //if hasn't any but spaces
                    else if (hasWhitespace) combinator = Combinator.DESCENDANT;
                    //is it the end?
                    if (combinator == null || current == ',') {
                        break;
                    }
                    //don't advance because spaces were just advanced
                    if (combinator != Combinator.DESCENDANT) {
                    	sb.append(current);
                        next();
                    } else {
                    	sb.append(' ');
                    }
                    ignoreWhitespaces();
                    if (end()) {
                        throw new ParserException("Unexpected end of selector at position " + pos);
                    }
                } else {
                    break;
                }
                combinators.add(combinator);
        	}
        	//get next sequence
            SimpleSelectorSequence simpleSelectorSequence = simpleSelectorSequence();
            sb.append(simpleSelectorSequence);
            //sends combinator here (the first case it's null)
            simpleSelectors.add(simpleSelectorSequence);
            parserListener.selectorSequence(simpleSelectorSequence, combinator);
            lastChar = pos;
        }
        return new Selector(simpleSelectors, combinators, new Context(content, sb.toString(), initialPosition, lastChar));
    }
selector
: simple_selector_sequence [ combinator simple_selector_sequence ]*
;

combinator
: PLUS S* | GREATER S* | TILDE S* | S+