Skip to content

Instantly share code, notes, and snippets.

@m4rw3r
m4rw3r / nom_many1_fix_incomplete.diff
Created November 27, 2015 16:42
Nom: Fix for many1 not propagating incomplete state
diff --git a/src/macros.rs b/src/macros.rs
index 7ea9fbd..607ab25 100644
--- a/src/macros.rs
+++ b/src/macros.rs
@@ -1712,14 +1712,27 @@ macro_rules! many1(
{
let mut res = Vec::new();
let mut input = $i;
- while let $crate::IResult::Done(i,o) = $submac!(input, $($args)*) {
- if i.len() == input.len() {
extern crate combine;
use combine::*;
use combine::primitives::Error;
use combine::combinator::take_while1;
use std::fs::File;
use std::env;
#[macro_use]
extern crate nom;
use nom::IResult;
use std::env;
use std::fs::File;
#[derive(Debug)]
struct Request<'a> {
/// Macro emulating `do`-notation for the parser monad, automatically threading the linear type.
///
/// ```ignore
/// parse!{input;
/// parser("parameter");
/// let value = other_parser();
///
/// ret do_something(value);
/// }
/// // equivalent to:
#!/usr/bin/env php
<?php
$files = glob('Templates/*.tmpl');
$templates = array();
foreach($files as $file) {
$data = file_get_contents($file);
<?php
/**
* @ORM\Entity
*/
class User
{
/**
* @ORM\String
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
#include <assert.h>
#include <sys/mman.h>
typedef uint8_t Register;
#define Register_lowBits(r) (r & 0x7)
@m4rw3r
m4rw3r / gist:3070816
Created July 8, 2012 12:53
Test interpreter with function-pointers
#include <inttypes.h>
#include <stdio.h>
#define Util_StaticAssert_CONCAT_(a, b) a##b
#define Util_StaticAssert_CONCAT(a, b) Util_StaticAssert_CONCAT_(a, b)
#define Util_StaticAssert(e, msg) \
enum { Util_StaticAssert_CONCAT(assert_line_, __LINE__) = 1/(!!(e)) }
/* Function to calcuate the n first fibonacci numbers */
Frame *fib_frame = malloc(sizeof(Frame));
Frame_init(fib_frame);
uint32_t prevfr = Frame_allocVariable(fib_frame);
/* No continuations called here, so we can get away with not allocating space for return values */
uint32_t varsum = Frame_allocVariable(fib_frame);
uint32_t varn = Frame_allocVariable(fib_frame);
uint32_t vara = Frame_allocVariable(fib_frame);
uint32_t varb = Frame_allocVariable(fib_frame);
@m4rw3r
m4rw3r / gist:2775309
Created May 23, 2012 13:45
InjectStack middleware for ChunkedEncoding
<?php
/*
* Created by Martin Wernståhl on 2011-04-25.
* Copyright (c) 2011 Martin Wernståhl.
* All rights reserved.
*/
namespace Inject\Stack\Middleware;
use \Inject\Stack\MiddlewareInterface;