nashorn/src/jdk/nashorn/internal/parser/JSONParser.java
changeset 17981 9b8e085aa1fe
parent 17523 cb4a7c901e0d
child 18317 2f5434c9c9fd
equal deleted inserted replaced
17979:adae4d39ee07 17981:9b8e085aa1fe
   280         final long objectToken = token;
   280         final long objectToken = token;
   281         // LBRACE tested in caller.
   281         // LBRACE tested in caller.
   282         next();
   282         next();
   283 
   283 
   284         // Prepare to accumulate elements.
   284         // Prepare to accumulate elements.
   285         final List<Node> elements = new ArrayList<>();
   285         final List<PropertyNode> elements = new ArrayList<>();
   286 
   286 
   287         // Create a block for the object literal.
   287         // Create a block for the object literal.
   288 loop:
   288 loop:
   289         while (true) {
   289         while (true) {
   290             switch (type) {
   290             switch (type) {
   296                 next();
   296                 next();
   297                 break;
   297                 break;
   298 
   298 
   299             default:
   299             default:
   300                 // Get and add the next property.
   300                 // Get and add the next property.
   301                 final Node property = propertyAssignment();
   301                 final PropertyNode property = propertyAssignment();
   302                 elements.add(property);
   302                 elements.add(property);
   303 
   303 
   304                 // Comma between property assigments is mandatory in JSON.
   304                 // Comma between property assigments is mandatory in JSON.
   305                 if (type != RBRACE && type != COMMARIGHT) {
   305                 if (type != RBRACE && type != COMMARIGHT) {
   306                     throw error(AbstractParser.message("expected", ", or }", type.getNameOrType()));
   306                     throw error(AbstractParser.message("expected", ", or }", type.getNameOrType()));
   315 
   315 
   316     /**
   316     /**
   317      * Parse a property assignment from the token stream
   317      * Parse a property assignment from the token stream
   318      * @return the property assignment as a Node
   318      * @return the property assignment as a Node
   319      */
   319      */
   320     private Node propertyAssignment() {
   320     private PropertyNode propertyAssignment() {
   321         // Capture firstToken.
   321         // Capture firstToken.
   322         final long propertyToken = token;
   322         final long propertyToken = token;
   323         LiteralNode<?> name = null;
   323         LiteralNode<?> name = null;
   324 
   324 
   325         if (type == STRING) {
   325         if (type == STRING) {