Get GrammaticalRelation between gov and dep, and null if gov is not the
governor of dep
548241
public static GrammaticalRelation getGrammaticalRelation(TreeGraphNode gov, TreeGraphNode dep) {
    GrammaticalRelation reln = GrammaticalRelation.DEPENDENT;
    TreeGraphNode govH = gov.highestNodeWithSameHead();
    TreeGraphNode depH = dep.highestNodeWithSameHead();
    /*System.out.println("gov node " + gov);
    System.out.println("govH " + govH);
    System.out.println("dep node " + dep);
    System.out.println("depH " + depH);*/

    // Set sortedSet = new TreeSet(new NameComparator());
    // sortedSet.addAll(govH.arcLabelsToNode(depH));
    // Set<Class<? extends GrammaticalRelationAnnotation>> arcLabels = sortedSet;
    Set<Class<? extends GrammaticalRelationAnnotation>> arcLabels = new TreeSet<Class<? extends GrammaticalRelationAnnotation>>(new NameComparator<Class<? extends GrammaticalRelationAnnotation>>());
    arcLabels.addAll(govH.arcLabelsToNode(depH));

    //System.out.println("arcLabels: " + arcLabels);

    for (Class<? extends GrammaticalRelationAnnotation> arcLabel : arcLabels) {
      if (arcLabel != null) {
        GrammaticalRelation reln2;
        try {
          reln2 = GrammaticalRelation.getRelation(arcLabel);
        } catch (Exception e) {
          continue;
        }
        //GrammaticalRelation reln2 = r;
        if (reln.isAncestor(reln2)) {
          reln = reln2;
        } else if (PRINT_DEBUGGING && ! reln2.isAncestor(reln)) {
          System.err.println("@@@\t" + reln + "\t" + reln2 + "\t" +
                             govH.label().get(CoreAnnotations.ValueAnnotation.class) + "\t" + depH.label().get(CoreAnnotations.ValueAnnotation.class));
        }
      }
    }
    if (PRINT_DEBUGGING && reln.equals(GrammaticalRelation.DEPENDENT)) {
      String topCat = govH.label().get(CoreAnnotations.ValueAnnotation.class);
      String topTag = govH.label().get(HeadTagAnnotation.class).value();
      String topWord = govH.label().get(HeadWordAnnotation.class).value();
      String botCat = depH.label().get(CoreAnnotations.ValueAnnotation.class);
      String botTag = depH.label().get(HeadTagAnnotation.class).value();
      String botWord = depH.label().get(HeadWordAnnotation.class).value();
      System.err.println("### dep\t" + topCat + "\t" + topTag + "\t" + topWord +
                         "\t" + botCat + "\t" + botTag + "\t" + botWord + "\t");
    }
    return reln;
  }
1064766
public final EObject ruleAlternatives() throws RecognitionException {
        EObject current = null;

        Token otherlv_2=null;
        EObject this_ConditionalBranch_0 = null;

        EObject lv_elements_3_0 = null;



        	enterRule();

        try {
            // InternalXtext.g:987:2: ( (this_ConditionalBranch_0= ruleConditionalBranch ( () (otherlv_2= '|' ( (lv_elements_3_0= ruleConditionalBranch ) ) )+ )? ) )
            // InternalXtext.g:988:2: (this_ConditionalBranch_0= ruleConditionalBranch ( () (otherlv_2= '|' ( (lv_elements_3_0= ruleConditionalBranch ) ) )+ )? )
            {
            // InternalXtext.g:988:2: (this_ConditionalBranch_0= ruleConditionalBranch ( () (otherlv_2= '|' ( (lv_elements_3_0= ruleConditionalBranch ) ) )+ )? )
            // InternalXtext.g:989:3: this_ConditionalBranch_0= ruleConditionalBranch ( () (otherlv_2= '|' ( (lv_elements_3_0= ruleConditionalBranch ) ) )+ )?
            {

            			newCompositeNode(grammarAccess.getAlternativesAccess().getConditionalBranchParserRuleCall_0());
            		
            pushFollow(FollowSets000.FOLLOW_25);
            this_ConditionalBranch_0=ruleConditionalBranch();

            state._fsp--;


            			current = this_ConditionalBranch_0;
            			afterParserOrEnumRuleCall();
            		
            // InternalXtext.g:997:3: ( () (otherlv_2= '|' ( (lv_elements_3_0= ruleConditionalBranch ) ) )+ )?
            int alt26=2;
            int LA26_0 = input.LA(1);

            if ( (LA26_0==30) ) {
                alt26=1;
            }
            switch (alt26) {
                case 1 :
                    // InternalXtext.g:998:4: () (otherlv_2= '|' ( (lv_elements_3_0= ruleConditionalBranch ) ) )+
                    {
                    // InternalXtext.g:998:4: ()
                    // InternalXtext.g:999:5: 
                    {

                    					current = forceCreateModelElementAndAdd(
                    						grammarAccess.getAlternativesAccess().getAlternativesElementsAction_1_0(),
                    						current);
                    				

                    }

                    // InternalXtext.g:1005:4: (otherlv_2= '|' ( (lv_elements_3_0= ruleConditionalBranch ) ) )+
                    int cnt25=0;
                    loop25:
                    do {
                        int alt25=2;
                        int LA25_0 = input.LA(1);

                        if ( (LA25_0==30) ) {
                            alt25=1;
                        }


                        switch (alt25) {
                    	case 1 :
                    	    // InternalXtext.g:1006:5: otherlv_2= '|' ( (lv_elements_3_0= ruleConditionalBranch ) )
                    	    {
                    	    otherlv_2=(Token)match(input,30,FollowSets000.FOLLOW_19); 

                    	    					newLeafNode(otherlv_2, grammarAccess.getAlternativesAccess().getVerticalLineKeyword_1_1_0());
                    	    				
                    	    // InternalXtext.g:1010:5: ( (lv_elements_3_0= ruleConditionalBranch ) )
                    	    // InternalXtext.g:1011:6: (lv_elements_3_0= ruleConditionalBranch )
                    	    {
                    	    // InternalXtext.g:1011:6: (lv_elements_3_0= ruleConditionalBranch )
                    	    // InternalXtext.g:1012:7: lv_elements_3_0= ruleConditionalBranch
                    	    {

                    	    							newCompositeNode(grammarAccess.getAlternativesAccess().getElementsConditionalBranchParserRuleCall_1_1_1_0());
                    	    						
                    	    pushFollow(FollowSets000.FOLLOW_25);
                    	    lv_elements_3_0=ruleConditionalBranch();

                    	    state._fsp--;


                    	    							if (current==null) {
                    	    								current = createModelElementForParent(grammarAccess.getAlternativesRule());
                    	    							}
                    	    							add(
                    	    								current,
                    	    								"elements",
                    	    								lv_elements_3_0,
                    	    								"org.eclipse.xtext.Xtext.ConditionalBranch");
                    	    							afterParserOrEnumRuleCall();
                    	    						

                    	    }


                    	    }


                    	    }
                    	    break;

                    	default :
                    	    if ( cnt25 >= 1 ) break loop25;
                                EarlyExitException eee =
                                    new EarlyExitException(25, input);
                                throw eee;
                        }
                        cnt25++;
                    } while (true);


                    }
                    break;

            }


            }


            }


            	leaveRule();

        }

            catch (RecognitionException re) {
                recover(input,re);
                appendSkippedTokens();
            }
        finally {
        }
        return current;
    }
1281883
function(re) {
  var match = re.exec(this.subject.slice(this.pos));
  if (match) {
    this.pos += match.index + match[0].length;
    return match[0];
  } else {
    return null;
  }
}
1164207
def parse(cls, parser, text, pos):
        """"""
        match = cls.regex.match(text)
        if match:
            # Check if match is is not in the grammar of the specific keyword class.
            if match.group(0).lower() not in cls.grammar:
                result = text, SyntaxError(repr(match.group(0)) + " is not a member of " + repr(cls.grammar))
            else:
                result = text[len(match.group(0)):], cls(match.group(0))
        else:
            result = text, SyntaxError("expecting " + repr(cls.__name__))
        return result
771394
def get_cont_state(self, string, backward=False):
        
        if string is None:
            return ()
        for _ in self.parser(self.scanner(string, True), True):
            if backward and len(self.parser.state[0]):
                break
        state = tuple(self.parser.state)
        self.scanner.reset()
        self.parser.reset()
        return state
701173
public final EObject ruleXNullLiteral() throws RecognitionException {
        EObject current = null;

        Token otherlv_1=null;


        	enterRule();

        try {
            // InternalPureXbase.g:5338:2: ( ( () otherlv_1= 'null' ) )
            // InternalPureXbase.g:5339:2: ( () otherlv_1= 'null' )
            {
            // InternalPureXbase.g:5339:2: ( () otherlv_1= 'null' )
            // InternalPureXbase.g:5340:3: () otherlv_1= 'null'
            {
            // InternalPureXbase.g:5340:3: ()
            // InternalPureXbase.g:5341:4: 
            {
            if ( state.backtracking==0 ) {

              				current = forceCreateModelElement(
              					grammarAccess.getXNullLiteralAccess().getXNullLiteralAction_0(),
              					current);
              			
            }

            }

            otherlv_1=(Token)match(input,76,FOLLOW_2); if (state.failed) return current;
            if ( state.backtracking==0 ) {

              			newLeafNode(otherlv_1, grammarAccess.getXNullLiteralAccess().getNullKeyword_1());
              		
            }

            }


            }

            if ( state.backtracking==0 ) {

              	leaveRule();

            }
        }

            catch (RecognitionException re) {
                recover(input,re);
                appendSkippedTokens();
            }
        finally {
        }
        return current;
    }
179539
def none_coalesce_handle(tokens):
    """"""
    if len(tokens) == 1:
        return tokens[0]
    elif tokens[0].isalnum():
        return "({b} if {a} is None else {a})".format(
            a=tokens[0],
            b=none_coalesce_handle(tokens[1:]),
        )
    else:
        return "(lambda {x}: {b} if {x} is None else {x})({a})".format(
            x=none_coalesce_var,
            a=tokens[0],
            b=none_coalesce_handle(tokens[1:]),
        )
1317262
function validateSentence(parsed) {
  const sentences = parsed.sentences();
  return [
    !isSingleSentence(sentences) ? 'Must be one and only one sentence.' : null,
    !isNotTooShort(parsed) ? 'Must be at least two words long.' : null,
    !isNotPunctuated(sentences) ? 'Must not have any end punctuation.' : null,
  ].filter(Boolean);
}
1342545
function pegParser(options, extension, cb) {
  if (typeof cb === 'undefined') {
    cb = extension;
    extension = null;
  }

  var grammarFiles = [];
  if (typeof options === 'string') {
    options = {grammar: options};
  }
  var grammar = options.grammar;
  if (typeof grammar === 'object') {
    if (grammar[extension]) {
      grammar = grammar[extension];
    }
  }
  if (typeof grammar !== 'string') {
    if (extension === 'js') {
      grammar = 'javascript';
    } else if (extension === 'md') {
      grammar = 'markdown';
    }
  }
  if (grammar) {
    grammarFiles.push(grammar);
    grammarFiles.push(path.join(__dirname, '../grammar', grammar + '.pegjs'));
  } else {
    grammarFiles.push(path.join(__dirname, '../grammar/javascript.pegjs'));
  }

  function findGrammarFile(wrapper, cb) {
    var grammarFile = wrapper.file;
    var cachedParser = quickpeg.parserFromMemory(grammarFile);
    if (cachedParser) {
      wrapper.parser = cachedParser;
      return cb(true);
    }

    var fsExists = fs.exists || path.exists;
    fsExists(grammarFile, function (exists) {
      if (!exists) {
        return cb(false);
      }

      quickpeg(grammarFile, function (err, cachedParser) {
        if (err) {
          wrapper.err = err;
          return;
        }
        wrapper.parser = cachedParser;
        return cb(true);
      });
    });
  }
  var grammarFileWrappers = grammarFiles.map(function (file) {
    return {
      parser: null,
      file: file,
      err: null
    };
  });
  async.detectSeries(grammarFileWrappers, findGrammarFile, function (wrapper) {
    if (wrapper.err || wrapper.parser) {
      return cb(wrapper.err, wrapper.parser, wrapper.file);
    }
    cb(new Error('grammar file not found'));
  });
}
128853
function getUsStatesList(s) {
        switch(s) {

        case 'usStatesTerrByAbbrLow':
            if (!usStatesTerrByAbbrLow) {
                getUsStatesList('usStatesTerrLow');
                usStatesTerrByAbbrLow = J.reverseObj(usStatesTerr, toLK);
            }
            return usStatesTerrByAbbrLow;
        case 'usStatesTerrByAbbr':
            if (!usStatesTerrByAbbr) {
                getUsStatesList('usStatesTerr');
                usStatesTerrByAbbr = J.reverseObj(usStatesTerr);
            }
            return usStatesTerrByAbbr;

        case 'usTerrByAbbrLow':
            if (!usTerrByAbbrLow) usTerrByAbbrLow = J.reverseObj(usTerr, toLK);
            return usTerrByAbbrLow;
        case 'usTerrByAbbr':
            if (!usTerrByAbbr) usTerrByAbbr = J.reverseObj(usTerr);
            return usTerrByAbbr;

        case 'usStatesByAbbrLow':
            if (!usStatesByAbbrLow) {
                usStatesByAbbrLow = J.reverseObj(usStates, toLK);
            }
            return usStatesByAbbrLow;
        case 'usStatesByAbbr':
            if (!usStatesByAbbr) usStatesByAbbr = J.reverseObj(usStates);
            return usStatesByAbbr;

        case 'usStatesTerrLow':
            if (!usStatesTerrLow) {
                if (!usStatesLow) usStatesLow = objToLK(usStates);
                if (!usTerrLow) usTerrLow = objToLK(usTerr);
                usStatesTerrLow = J.merge(usStatesLow, usTerrLow);
            }
            return usStatesTerrLow;
        case 'usStatesTerr':
            if (!usStatesTerr) usStatesTerr = J.merge(usStates, usTerr);
            return usStatesTerr;

        case 'usStatesLow':
            if (!usStatesLow) usStatesLow = objToLow(usStates, toLK);
            return usStatesLow;
        case 'usStates':
            return usStates;

        case 'usTerrLow':
            if (!usTerrLow) usTerrLow = objToLow(usTerr, toLK);
            return usTerrLow;
        case 'usTerr':
            return usTerr;

        default:
            throw new Error('getUsStatesList: unknown request: ' + s);
        }
    }
825623
def _extract_obo_relation(cls, rawterm):
        
        relations = {}
        if 'subClassOf' in rawterm:
            relations[Relationship('is_a')] = l = []
            l.extend(map(cls._get_id_from_url, rawterm.pop('subClassOf')))
        return relations
764174
function inlineRegex(regex) {
  return function match(source, state) {
    if (state.inline) {
      return regex.exec(source);
    } else {
      return null;
    }
  };
}
65132
private Grammar getEqualGrammar(Grammar gr) {

		for (Grammar gx : this.grammars) {
			if (gr == gx) {
				// System.out.println("Exactly the same grammar found: " + gx);
				return gx;
			}

			if (isSameGrammarType(gr, gx)) {
				// type of grammar the same

				if (gr.getNumberOfEvents() == gx.getNumberOfEvents()) {
					List<Grammar> handled = new ArrayList<Grammar>();
					if (isEqualGrammar(gr, gx, handled)) {
						// the same grammar found
						// System.out.println("Same grammar found for: " + gx +
						// " == " + gr);
						return gx;
					}
				}
			}

		}

		return null;
	}
507148
def _parse_or_match(self, text, pos, method_name):
        
        if not self.grammar:
            raise RuntimeError(
                "The {cls}.{method}() shortcut won't work because {cls} was "
                "never associated with a specific " "grammar. Fill out its "
                "`grammar` attribute, and try again.".format(
                    cls=self.__class__.__name__,
                    method=method_name))
        return self.visit(getattr(self.grammar, method_name)(text, pos=pos))
362375
def _match_state(self, state):
        """"""
        return (self.names == '*'
                or state in self.names
                or state.name in self.names)
90447
function(state) {
      if (isDefined(state.parent) && state.parent) return findState(state.parent);
      // regex matches any valid composite state name
      // would match "contact.list" but not "contacts"
      var compositeName = /^(.+)\.[^.]+$/.exec(state.name);
      return compositeName ? findState(compositeName[1]) : root;
    }
1040400
function getFieldState($ele) {
	var val = $ele.val()

	// If dependency is a radio group, then filter by `:checked`
	if ($ele.attr('type') === 'radio') {
		val = $ele.filter(':checked').val()
	}

	return {
		value: val,
		checked: $ele.is(':checked'),
		disabled: $ele.is(':disabled'),
		selected: $ele.is(':selected')
	}
}