Skip to content

Commit

Permalink
#88: TS: F.startWith(), F.moveUntil(), F.dropTo()
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-zozol committed Nov 11, 2017
1 parent f50797c commit f335dca
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 186 deletions.
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ Every parser in CharBundle, FlowBundle and NumberBundle need to be called as a f

It's less funky, but it avoids construction of Parsers at import statement, before writing the first line code.

### FlowBundle

* `F.startWith(value)`


0.5 -> 0.6
Expand Down
2 changes: 1 addition & 1 deletion documentation/doing-and-todos.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

Documentation for F.startWith


-> release
Expand Down
3 changes: 0 additions & 3 deletions integration-ts/examples/flow/not.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@



import {Streams, F, C,Option, N, SingleParser} from '@robusta/trash'
import {assertFalse, assertTrue} from '../../assert';

Expand Down
21 changes: 21 additions & 0 deletions integration-ts/examples/flow/startWith-moveUntil-dropTo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {Streams, F, C,Option, N, SingleParser} from '@robusta/trash'
import {assertFalse, assertTrue} from '../../assert';

const string = 'The quick brown fox jumps over the lazy dog';



function combinator() {
return F.startWith('hello: ')
.then(F.moveUntil('brown'))
.then(C.string('brown'))
.then(F.dropTo(F.eos()));
}

let stream = Streams.ofString(string);
let parsing = combinator().parse(stream);

assertFalse(parsing.isAccepted());
assertTrue(parsing.offset === 2);
assertTrue(parsing.value.join('') === 'hello: The quick brown');

151 changes: 0 additions & 151 deletions integration-ts/index.d.ts

This file was deleted.

27 changes: 0 additions & 27 deletions integration-ts/working.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/lib/parsec/flow-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function sequence() {
return current;
}

function startsWith(value) {
function startWith(value) {
return nop().thenReturns(value);
}

Expand Down Expand Up @@ -149,7 +149,7 @@ export default {
eos,
satisfy,
sequence,
startsWith,
startWith,
moveUntil,
dropTo,
};
Expand Down
4 changes: 2 additions & 2 deletions src/test/parsec/flow-bundle-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ export default {
test.done();
},

'expect startsWith to start': function(test) {
'expect startWith to start': function(test) {
const string = ' world';
const object = 'hello';
// tests here
const parser = F.startsWith(object)
const parser = F.startWith(object)
.then(C.string(' world'))
.then(F.eos().drop());
testParser(parser, string);
Expand Down

0 comments on commit f335dca

Please sign in to comment.