Create a PEG function to consume a literal.
190036
def literal(x):
    
    xlen = len(x)
    msg = 'Expected: "{}"'.format(x)
    def match_literal(s, grm=None, pos=0):
        if s[:xlen] == x:
            return PegreResult(s[xlen:], x, (pos, pos+xlen))
        raise PegreError(msg, pos)
    return match_literal
709318
def state_not_literal(self, value):
        """"""
        value = negate = chr(value)
        while value == negate:
            value = choice(self.literals)
        yield value
611540
def macro(parser, token):
    '''
    
    '''
    name = token.strip()
    parser.build_method(name, endnodes=['endmacro'])
    return ast.Yield(value=ast.Str(s=''))
1210790
def char_in(string, func_name): 
  ''''''
  function = register_function(func_name, 
                      lambda char: char in string)
  return char_on_predicate(function)
380310
def consume(fmt, data, names):
    """"""
    size = struct.calcsize(fmt)
    return named(struct.unpack(fmt, data[:size]), names), data[size:]
135081
def lazy_result(f):
    """"""
    @wraps(f)
    def decorated(ctx, param, value):
        return LocalProxy(lambda: f(ctx, param, value))
    return decorated
719097
def assign_literal(element, value):
        
        """
        # Searches for a conversion method specific to the type of value.
        helper = helpers.CAST_DICT.get(type(value), str)

        # Removes all children and attributes.
        element.clear()
        element.text = helper(value)
1048096
def MakeANSIVersion(fn):
    
    @functools.wraps(fn)
    def wrapper(*argv, **argd):
        t_ansi    = GuessStringType.t_ansi
        t_unicode = GuessStringType.t_unicode
        v_types   = [ type(item) for item in argv ]
        v_types.extend( [ type(value) for (key, value) in compat.iteritems(argd) ] )
        if t_ansi in v_types:
            argv = list(argv)
            for index in compat.xrange(len(argv)):
                if v_types[index] == t_ansi:
                    argv[index] = t_unicode(argv[index])
            for key, value in argd.items():
                if type(value) == t_ansi:
                    argd[key] = t_unicode(value)
        return fn(*argv, **argd)
    return wrapper
819356
function elt(eltType, numargs) {
	return function () {
		var args = Array.prototype.slice.call(arguments);
		var len = args.length;
		if (len !== numargs)
			throw eltType + ' expects ' + numargs	+ ' arguments, but given ' + len;
		return {'t':eltType,'c':(len === 1 ? args[0] : args)};
	};
}
527692
def p_object_literal(self, p):
        
        if len(p) == 3:
            p[0] = self.asttypes.Object()
        else:
            p[0] = self.asttypes.Object(properties=p[2])
        p[0].setpos(p)
1268848
def _compile_literal(self, data):
        """"""
        if data is None:
            return 'nil'
        elif data is True:
            return 'yes'
        elif data is False:
            return 'no'
        else:
            return repr(data)
636863
def _make_function(instr, queue, stack, body, context):
    
    assert stack, "Empty stack before MAKE_FUNCTION."
    prev = stack[-1]
    expect(prev, instrs.LOAD_CONST, "before MAKE_FUNCTION")

    stack.append(instr)

    if is_lambda_name(prev.arg):
        return

    return context.update(
        make_function_context=MakeFunctionContext(
            closure=isinstance(instr, instrs.MAKE_CLOSURE),
        )
    )
359333
def normalize(expr):
    """"""
    args = [normalize(arg) for arg in expr.args]

    return type(expr)(expr.func, *args, start=expr.start, end=expr.end)
86249
def literal_to_ObjectLiteral(self, literal: ShExDocParser.LiteralContext) -> ShExJ.ObjectLiteral:
        
        rval = ShExJ.ObjectLiteral()
        if literal.rdfLiteral():
            rdflit = literal.rdfLiteral()
            txt = rdflit.string().getText()
            quote_char = ''
            if len(txt) > 5 and (txt.startswith("'''") and txt.endswith("'''") or
                                 txt.startswith('"""') and txt.endswith('"""')):
                txt = txt[3:-3]
            else:
                quote_char = txt[0]
                txt = txt[1:-1]

            txt = self.fix_text_escapes(txt, quote_char)
            rval.value = jsg.String(txt)
            if rdflit.LANGTAG():
                rval.language = ShExJ.LANGTAG(rdflit.LANGTAG().getText()[1:].lower())
            if rdflit.datatype():
                rval.type = self.iri_to_str(rdflit.datatype().iri())
        elif literal.numericLiteral():
            numlit = literal.numericLiteral()
            if numlit.INTEGER():
                rval.value = jsg.String(numlit.INTEGER().getText())
                rval.type = RDF_INTEGER_TYPE
            elif numlit.DECIMAL():
                rval.value = jsg.String(numlit.DECIMAL().getText())
                rval.type = RDF_DECIMAL_TYPE
            elif numlit.DOUBLE():
                rval.value = jsg.String(numlit.DOUBLE().getText())
                rval.type = RDF_DOUBLE_TYPE
        elif literal.booleanLiteral():
            rval.value = jsg.String(literal.booleanLiteral().getText().lower())
            rval.type = RDF_BOOL_TYPE
        return rval
888270
function consumeKeywordOrFunction(stream) {
	const kw = consumeKeyword(stream);
	if (kw) {
		const args = consumeArgumentList(stream);
		return args ? new FunctionCall(kw.toString(), args) : kw;
	}
}
843636
def p_object_literal(self, p):
        
        if len(p) == 3:
            p[0] = ast.Object()
        else:
            p[0] = ast.Object(properties=p[2])
353488
def fromTerm(cls, term):
        """"""

        if isinstance(term, Term):
            term = term.handle
        elif not isinstance(term, (c_void_p, int)):
            raise ArgumentTypeError((str(Term), str(c_void_p)), str(type(term)))

        a = atom_t()
        if PL_get_atom(term, byref(a)):
            return cls(a.value)