$ANTLR start "EXTEND"
349955
public final void mEXTEND() throws RecognitionException {
        try {
            int _type = EXTEND;
            int _channel = DEFAULT_TOKEN_CHANNEL;
            // com/dyuproject/protostuff/parser/ProtoLexer.g:139:5: ( 'extend' )
            // com/dyuproject/protostuff/parser/ProtoLexer.g:139:9: 'extend'
            {
            match("extend"); 


            }

            state.type = _type;
            state.channel = _channel;
        }
        finally {
        }
    }
736117
public final void mBOOLEAN() throws RecognitionException {
        try {
            int _type = BOOLEAN;
            int _channel = DEFAULT_TOKEN_CHANNEL;
            // /home/victor/srec/core/src/main/antlr/srec.g:114:2: ( 'true' | 'false' )
            int alt1=2;
            int LA1_0 = input.LA(1);

            if ( (LA1_0=='t') ) {
                alt1=1;
            }
            else if ( (LA1_0=='f') ) {
                alt1=2;
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("", 1, 0, input);

                throw nvae;
            }
            switch (alt1) {
                case 1 :
                    // /home/victor/srec/core/src/main/antlr/srec.g:114:4: 'true'
                    {
                    match("true"); 


                    }
                    break;
                case 2 :
                    // /home/victor/srec/core/src/main/antlr/srec.g:114:13: 'false'
                    {
                    match("false"); 


                    }
                    break;

            }
            state.type = _type;
            state.channel = _channel;
        }
        finally {
        }
    }
145413
def parse_input_object_type_extension(lexer: Lexer) -> Node:
    """"""
    start = lexer.token
    expect_keyword(lexer, "extend")
    expect_keyword(lexer, "input")
    name = parse_name(lexer)
    directives = parse_directives(lexer, True)
    fields = parse_input_fields_definition(lexer)
    if not (directives or fields):
        raise unexpected(lexer)
    return Node(
        name=name, directives=directives, fields=fields, loc=loc(lexer, start)
    )
5637
private void parseExtension(Extension ext) throws IOException {
        try {
            Class<?> extClass = OIDMap.getClass(ext.getExtensionId());
            if (extClass == null) {   // Unsupported extension
                if (ext.isCritical()) {
                    unsupportedCritExt = true;
                }
                if (map.put(ext.getExtensionId().toString(), ext) == null) {
                    return;
                } else {
                    throw new IOException("Duplicate extensions not allowed");
                }
            }
            Constructor<?> cons = extClass.getConstructor(PARAMS);

            Object[] passed = new Object[] {Boolean.valueOf(ext.isCritical()),
                    ext.getExtensionValue()};
                    CertAttrSet<?> certExt = (CertAttrSet<?>)
                            cons.newInstance(passed);
                    if (map.put(certExt.getName(), (Extension)certExt) != null) {
                        throw new IOException("Duplicate extensions not allowed");
                    }
        } catch (InvocationTargetException invk) {
            Throwable e = invk.getTargetException();
            if (ext.isCritical() == false) {
                // ignore errors parsing non-critical extensions
                if (unparseableExtensions == null) {
                    unparseableExtensions = new TreeMap<String,Extension>();
                }
                unparseableExtensions.put(ext.getExtensionId().toString(),
                        new UnparseableExtension(ext, e));
                if (debug != null) {
                    debug.println("Error parsing extension: " + ext);
                    e.printStackTrace();
                    HexDumpEncoder h = new HexDumpEncoder();
                    System.err.println(h.encodeBuffer(ext.getExtensionValue()));
                }
                return;
            }
            if (e instanceof IOException) {
                throw (IOException)e;
            } else {
                throw new IOException(e);
            }
        } catch (IOException e) {
            throw e;
        } catch (Exception e) {
            throw new IOException(e);
        }
    }
520165
def perform_extended_selection(self, event=None):
        
        TextHelper(self.editor).select_extended_word(
            continuation_chars=self.continuation_characters)
        if event:
            event.accept()
597724
def extend(self, xs: Union['List[T]', typing.List[T]]) -> 'List[T]':  # type: ignore
        
        return type(self)(self.unbox() + List(xs).unbox())
1086632
public final ProtoParser.extend_block_return extend_block(Proto proto, Message parent) throws RecognitionException {
        ProtoParser.extend_block_return retval = new ProtoParser.extend_block_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token EXTEND157=null;
        Token FULL_ID158=null;
        Token ID159=null;
        Token LEFTCURLY160=null;
        Token RIGHTCURLY162=null;
        Token SEMICOLON163=null;
        ProtoParser.extend_body_return extend_body161 = null;


        Object EXTEND157_tree=null;
        Object FULL_ID158_tree=null;
        Object ID159_tree=null;
        Object LEFTCURLY160_tree=null;
        Object RIGHTCURLY162_tree=null;
        Object SEMICOLON163_tree=null;


            Extension extension = null;

        try {
            // com/dyuproject/protostuff/parser/ProtoParser.g:614:5: ( EXTEND ( FULL_ID | ID ) LEFTCURLY ( extend_body[proto, extension] )* RIGHTCURLY ( ( SEMICOLON )? ) )
            // com/dyuproject/protostuff/parser/ProtoParser.g:614:9: EXTEND ( FULL_ID | ID ) LEFTCURLY ( extend_body[proto, extension] )* RIGHTCURLY ( ( SEMICOLON )? )
            {
            root_0 = (Object)adaptor.nil();

            EXTEND157=(Token)match(input,EXTEND,FOLLOW_EXTEND_in_extend_block2513); if (state.failed) return retval;
            if ( state.backtracking==0 ) {
            EXTEND157_tree = (Object)adaptor.create(EXTEND157);
            adaptor.addChild(root_0, EXTEND157_tree);
            }
            // com/dyuproject/protostuff/parser/ProtoParser.g:614:16: ( FULL_ID | ID )
            int alt34=2;
            switch ( input.LA(1) ) {
            case FULL_ID:
                {
                alt34=1;
                }
                break;
            case ID:
                {
                alt34=2;
                }
                break;
            default:
                if (state.backtracking>0) {state.failed=true; return retval;}
                NoViableAltException nvae =
                    new NoViableAltException("", 34, 0, input);

                throw nvae;
            }

            switch (alt34) {
                case 1 :
                    // com/dyuproject/protostuff/parser/ProtoParser.g:615:9: FULL_ID
                    {
                    FULL_ID158=(Token)match(input,FULL_ID,FOLLOW_FULL_ID_in_extend_block2525); if (state.failed) return retval;
                    if ( state.backtracking==0 ) {
                    FULL_ID158_tree = (Object)adaptor.create(FULL_ID158);
                    adaptor.addChild(root_0, FULL_ID158_tree);
                    }
                    if ( state.backtracking==0 ) {

                                  String fullType = (FULL_ID158!=null?FULL_ID158.getText():null);
                                  int lastDot = fullType.lastIndexOf('.');
                                  String packageName = fullType.substring(0, lastDot); 
                                  String type = fullType.substring(lastDot+1);
                                  extension = new Extension(proto, parent, packageName, type);
                              
                    }

                    }
                    break;
                case 2 :
                    // com/dyuproject/protostuff/parser/ProtoParser.g:621:13: ID
                    {
                    ID159=(Token)match(input,ID,FOLLOW_ID_in_extend_block2531); if (state.failed) return retval;
                    if ( state.backtracking==0 ) {
                    ID159_tree = (Object)adaptor.create(ID159);
                    adaptor.addChild(root_0, ID159_tree);
                    }
                    if ( state.backtracking==0 ) {
                       extension = new Extension(proto, parent, null, (ID159!=null?ID159.getText():null)); 
                    }

                    }
                    break;

            }

            if ( state.backtracking==0 ) {

                          if(parent==null)
                              proto.addExtension(extension);
                          else
                              parent.addNestedExtension(extension);
                              
                          proto.addAnnotationsTo(extension);
                      
            }
            LEFTCURLY160=(Token)match(input,LEFTCURLY,FOLLOW_LEFTCURLY_in_extend_block2547); if (state.failed) return retval;
            if ( state.backtracking==0 ) {
            LEFTCURLY160_tree = (Object)adaptor.create(LEFTCURLY160);
            adaptor.addChild(root_0, LEFTCURLY160_tree);
            }
            // com/dyuproject/protostuff/parser/ProtoParser.g:629:19: ( extend_body[proto, extension] )*
            loop35:
            do {
                int alt35=2;
                switch ( input.LA(1) ) {
                case AT:
                case REQUIRED:
                case OPTIONAL:
                case REPEATED:
                    {
                    alt35=1;
                    }
                    break;

                }

                switch (alt35) {
            	case 1 :
            	    // com/dyuproject/protostuff/parser/ProtoParser.g:629:20: extend_body[proto, extension]
            	    {
            	    pushFollow(FOLLOW_extend_body_in_extend_block2550);
            	    extend_body161=extend_body(proto, extension);

            	    state._fsp--;
            	    if (state.failed) return retval;
            	    if ( state.backtracking==0 ) adaptor.addChild(root_0, extend_body161.getTree());

            	    }
            	    break;

            	default :
            	    break loop35;
                }
            } while (true);

            RIGHTCURLY162=(Token)match(input,RIGHTCURLY,FOLLOW_RIGHTCURLY_in_extend_block2555); if (state.failed) return retval;
            if ( state.backtracking==0 ) {
            RIGHTCURLY162_tree = (Object)adaptor.create(RIGHTCURLY162);
            adaptor.addChild(root_0, RIGHTCURLY162_tree);
            }
            if ( state.backtracking==0 ) {

                          if(!proto.annotations.isEmpty())
                              throw new IllegalStateException("Misplaced annotations: " + proto.annotations);
                              
                      
            }
            // com/dyuproject/protostuff/parser/ProtoParser.g:633:11: ( ( SEMICOLON )? )
            // com/dyuproject/protostuff/parser/ProtoParser.g:633:12: ( SEMICOLON )?
            {
            // com/dyuproject/protostuff/parser/ProtoParser.g:633:12: ( SEMICOLON )?
            int alt36=2;
            switch ( input.LA(1) ) {
                case SEMICOLON:
                    {
                    alt36=1;
                    }
                    break;
            }

            switch (alt36) {
                case 1 :
                    // com/dyuproject/protostuff/parser/ProtoParser.g:633:12: SEMICOLON
                    {
                    SEMICOLON163=(Token)match(input,SEMICOLON,FOLLOW_SEMICOLON_in_extend_block2560); if (state.failed) return retval;
                    if ( state.backtracking==0 ) {
                    SEMICOLON163_tree = (Object)adaptor.create(SEMICOLON163);
                    adaptor.addChild(root_0, SEMICOLON163_tree);
                    }

                    }
                    break;

            }


            }


            }

            retval.stop = input.LT(-1);

            if ( state.backtracking==0 ) {

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
72272
function findTypeForExtend(types, extend) {
  var orig = types.find(ea => ea.name === extend.name && ea.type !== "extend");
  if (!orig) throw new Error("Cannot find original for extension " + JSON.stringify(extend, null, 2));
  return orig;
}
709188
def extend(cls, name):
        
        if six.PY2 and isinstance(name, six.text_type):
            # In python2, class name must be a python2 str.
            name = name.encode('utf-8')
        return type(name, (cls,), {})
820125
def parse_extend(self, c, i):
        """"""

        # Start list parsing
        success = True
        index = i.index
        list_type = c
        try:
            c = next(i)
            if c != '(':
                raise StopIteration
            while c != ')':
                c = next(i)

                if self.extend and c in EXT_TYPES and self.parse_extend(c, i):
                    continue

                if c == '\\':
                    try:
                        self._references(i)
                    except StopIteration:
                        pass
                elif c == '[':
                    index = i.index
                    try:
                        self._sequence(i)
                    except StopIteration:
                        i.rewind(i.index - index)

        except StopIteration:
            success = False
            c = list_type
            i.rewind(i.index - index)

        return success
467929
function extendFormatExtensions (extensionName, extensionValue) {
        if (typeof extensionName !== 'string' || !(extensionValue instanceof RegExp)) {
            throw new Error('extensionName or extensionValue undefined or not correct type');
        }

        if (revalidator.validate.formats.hasOwnProperty(extensionName) ||
            revalidator.validate.formats.hasOwnProperty(extensionName)) {
            var msg = 'extensionName: ' + extensionName + ' already exists in formatExtensions.';
            throw  new Error(msg);
        }

        revalidator.validate.formatExtensions[extensionName] = extensionValue;
    }
198856
function expandShortNotation(node, lookup, options) {
	const classNames = node.classList.reduce((out, cl) => {
		let prefix, m;
		const originalClass = cl;

		// parse element definition (could be only one)
		if (m = cl.match(reElement)) {
			prefix = getBlockName(node, lookup, m[1]) + options.element + m[2];
			out.add(prefix);
			cl = cl.slice(m[0].length);
		}

		// parse modifiers definitions 
		if (m = cl.match(reModifier)) {
			if (!prefix) {
				prefix = getBlockName(node, lookup, m[1]);
				out.add(prefix);
			}

			out.add(`${prefix}${options.modifier}${m[2]}`);
			cl = cl.slice(m[0].length);
		}

		if (cl === originalClass) {
			// class name wasn’t modified: it’s not a BEM-specific class,
			// add it as-is into output
			out.add(originalClass);
		}

		return out;
	}, new Set());

	const arrClassNames = Array.from(classNames).filter(Boolean);
	if (arrClassNames.length) {
		node.setAttribute('class', arrClassNames.join(' '));
	}
}
440905
public void beginType(String type, String kind, int modifiers,
      String extendsType, String... implementsTypes) throws IOException {
    indent();
    modifiers(modifiers);
    out.write(kind);
    out.write(" ");
    type(type);
    if (extendsType != null) {
      out.write("\n");
      indent();
      out.write("    extends ");
      type(extendsType);
    }
    if (implementsTypes.length > 0) {
      out.write("\n");
      indent();
      out.write("    implements ");
      for (int i = 0; i < implementsTypes.length; i++) {
        if (i != 0) {
          out.write(", ");
        }
        type(implementsTypes[i]);
      }
    }
    out.write(" {\n");
    pushScope(Scope.TYPE_DECLARATION);
  }
82717
function(isRule) {
                var elements, e, index = i, option, extendList, extend;

                if (!(isRule ? $re(/^&:extend\(/) : $re(/^:extend\(/))) { return; }

                do {
                    option = null;
                    elements = null;
                    while (! (option = $re(/^(all)(?=\s*(\)|,))/))) {
                        e = this.element();
                        if (!e) { break; }
                        if (elements) { elements.push(e); } else { elements = [ e ]; }
                    }

                    option = option && option[1];

                    extend = new(tree.Extend)(new(tree.Selector)(elements), option, index);
                    if (extendList) { extendList.push(extend); } else { extendList = [ extend ]; }

                } while($char(","));

                expect(/^\)/);

                if (isRule) {
                    expect(/^;/);
                }

                return extendList;
            }
1106411
def forward_word_end_extend_selection(self, e): # 
        """
        self.l_buffer.forward_word_end_extend_selection(self.argument_reset)
        self.finalize()
872185
function extend() {
    let arg = arguments,
        target = arg[0] || {},
        deep = false,
        length = arg.length,
        i = 1,
        value, attr,
        copyIsArray;

    if (isBoolean(target)) {
        deep = target;
        target = arg[1] || {};
        i++;
    }

    for (; i < length; i++) {
        for (attr in arg[i]) {

            value = arg[i][attr];

            if (deep && (isPlainObject(value) || (copyIsArray = isArray(value)))) {

                let src = target[attr];

                if (copyIsArray) {
                    copyIsArray = false;
                    src = isArray(src) ? src : [];
                } else {
                    src = isPlainObject(src) ? src : {};
                }

                target[attr] = extend(deep, src, value);

            } else {
                target[attr] = value;
            }
        }
    }

    return target;
}
900772
private ExtendElement readExtend(String documentation) {
    String name = readName();
    String qualifiedName = name;
    if (!name.contains(".") && packageName != null) {
      qualifiedName = packageName + "." + name;
    }
    ExtendElement.Builder builder = ExtendElement.builder()
        .name(name)
        .qualifiedName(qualifiedName)
        .documentation(documentation);

    if (readChar() != '{') throw unexpected("expected '{'");
    while (true) {
      String nestedDocumentation = readDocumentation();
      if (peekChar() == '}') {
        pos++;
        break;
      }
      Object declared = readDeclaration(nestedDocumentation, Context.EXTEND);
      if (declared instanceof FieldElement) {
        builder.addField((FieldElement) declared);
      }
    }
    return builder.build();
  }