// Path: src/main/java/com/nebhale/jsonpath/internal/parser/PathCharacter.java
// enum CharacterType {
//     ARRAY_CLOSE, //
//     ARRAY_OPEN, //
//     COMMA, //
//     COMPLEX_NAME_CHARACTER, //
//     DIGIT, //
//     DOT, //
//     DOUBLE_QUOTE, //
//     END, //
//     HYPHEN, //
//     INDEX_CHARACTER, //
//     LETTER, //
//     QUOTE, //
//     ROOT, //
//     SIMPLE_NAME_CHARACTER, //
//     SPACE, //
//     UNDERSCORE, //
//     WILDCARD;
// }
// 
// Path: src/main/java/com/nebhale/jsonpath/internal/util/Sets.java
// public final class Sets {
// 
//     private Sets() {
//     }
// 
//     /**
//      * Creates a {@link Set} from a collection of items
//      *
//      * @param items The items to create the set from
//      * @return The set created from the collection of items
//      */
//     public static <T> Set<T> asSet(T... items) {
//         Set<T> set = new HashSet<T>();
//         for (T item : items) {
//             set.add(item);
//         }
//         return set;
//     }
// }


import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import com.nebhale.jsonpath.internal.parser.PathCharacter.CharacterType;
import com.nebhale.jsonpath.internal.util.Sets;
/*
 * Copyright 2013 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.nebhale.jsonpath.internal.parser;



/**
 * A {@link PathScanner} that scans into the following types:
 * <p />
 *
 * <pre>
 * COMPLEX_NAME_CHARACTER: LETTER | DIGIT | COMMA | HYPHEN | SPACE | UNDERSCORE
 * SIMPLE_NAME_CHARACTER:  LETTER | DIGIT | UNDERSCORE
 * INDEX_CHARACTER:        DIGIT | COMMA | SPACE
 * LETTER:                 [A-Za-z]
 * DIGIT:                  [0-9]
 *
 * ARRAY_CLOSE:     ]
 * ARRAY_OPEN:      [
 * COMMA:           ,
 * DOT:             .
 * DOUBLE_QUOTE:    "
 * HYPHEN:          -
 * QUOTE:           '
 * ROOT:            $
 * SPACE:          ' '
 * UNDERSCORE:      _
 * WILDCARD:        *
 * </pre>
 *
 * <strong>Concurrent Semantics</strong><br />
 *
 * Not thread-safe
 */
final class StandardPathScanner implements PathScanner {

    private static final char ARRAY_CLOSE = ']';

    private static final char ARRAY_OPEN = '[';

    private static final char COMMA = ',';

    private static final char DOT = '.';

    private static final char DOUBLE_QUOTE = '"';

    private static final char HYPHEN = '-';

    private static final char QUOTE = '\'';

    private static final char ROOT = '$';

    private static final char SPACE = ' ';

    private static final char UNDERSCORE = '_';

    private static final char WILDCARD = '*';

    private final List<PathCharacter> pathCharacters = new ArrayList<PathCharacter>();

    private volatile int position = 0;

    StandardPathScanner(String expression) {
        int counter = 0;
        for (char c : expression.toCharArray()) {
// Path: src/main/java/com/nebhale/jsonpath/internal/parser/PathCharacter.java
// enum CharacterType {
//     ARRAY_CLOSE, //
//     ARRAY_OPEN, //
//     COMMA, //
//     COMPLEX_NAME_CHARACTER, //
//     DIGIT, //
//     DOT, //
//     DOUBLE_QUOTE, //
//     END, //
//     HYPHEN, //
//     INDEX_CHARACTER, //
//     LETTER, //
//     QUOTE, //
//     ROOT, //
//     SIMPLE_NAME_CHARACTER, //
//     SPACE, //
//     UNDERSCORE, //
//     WILDCARD;
// }
// 
// Path: src/main/java/com/nebhale/jsonpath/internal/util/Sets.java
// public final class Sets {
// 
//     private Sets() {
//     }
// 
//     /**
//      * Creates a {@link Set} from a collection of items
//      *
//      * @param items The items to create the set from
//      * @return The set created from the collection of items
//      */
//     public static <T> Set<T> asSet(T... items) {
//         Set<T> set = new HashSet<T>();
//         for (T item : items) {
//             set.add(item);
//         }
//         return set;
//     }
// }


// Path: src/main/java/com/nebhale/jsonpath/internal/parser/StandardPathScanner.java
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import com.nebhale.jsonpath.internal.parser.PathCharacter.CharacterType;
import com.nebhale.jsonpath.internal.util.Sets;

/*
 * Copyright 2013 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.nebhale.jsonpath.internal.parser;



/**
 * A {@link PathScanner} that scans into the following types:
 * <p />
 *
 * <pre>
 * COMPLEX_NAME_CHARACTER: LETTER | DIGIT | COMMA | HYPHEN | SPACE | UNDERSCORE
 * SIMPLE_NAME_CHARACTER:  LETTER | DIGIT | UNDERSCORE
 * INDEX_CHARACTER:        DIGIT | COMMA | SPACE
 * LETTER:                 [A-Za-z]
 * DIGIT:                  [0-9]
 *
 * ARRAY_CLOSE:     ]
 * ARRAY_OPEN:      [
 * COMMA:           ,
 * DOT:             .
 * DOUBLE_QUOTE:    "
 * HYPHEN:          -
 * QUOTE:           '
 * ROOT:            $
 * SPACE:          ' '
 * UNDERSCORE:      _
 * WILDCARD:        *
 * </pre>
 *
 * <strong>Concurrent Semantics</strong><br />
 *
 * Not thread-safe
 */
final class StandardPathScanner implements PathScanner {

    private static final char ARRAY_CLOSE = ']';

    private static final char ARRAY_OPEN = '[';

    private static final char COMMA = ',';

    private static final char DOT = '.';

    private static final char DOUBLE_QUOTE = '"';

    private static final char HYPHEN = '-';

    private static final char QUOTE = '\'';

    private static final char ROOT = '$';

    private static final char SPACE = ' ';

    private static final char UNDERSCORE = '_';

    private static final char WILDCARD = '*';

    private final List<PathCharacter> pathCharacters = new ArrayList<PathCharacter>();

    private volatile int position = 0;

    StandardPathScanner(String expression) {
        int counter = 0;
        for (char c : expression.toCharArray()) {
            Set<CharacterType> characterTypes = new HashSet<CharacterType>();