Skip to content

Commit

Permalink
#88: TS: F.not() & P.debug()
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-zozol committed Nov 11, 2017
1 parent 1971272 commit c297a20
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
9 changes: 9 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ Changelog

# Functions

Every parser in CharBundle, FlowBundle and NumberBundle need to be called as a function

//Previously
const p = C.letter.then(N.integer).then(F.eos);

// Now:
const p = C.letter().then(N.integer()).then(F.eos());

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



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



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

function day() {
return C.stringIn(['MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY', 'SATURDAY', 'SUNDAY']);
}

function a(){
return C.char('a');
}

const string = 'Xabx';



function combinator() {
return F.not(day()).then(F.not(a())).then(F.not(day()));
}

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

assertFalse(parsing.isAccepted());
assertTrue(parsing.offset === 2);

1 change: 1 addition & 0 deletions integration-ts/examples/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import './beginner/hello-something'
import './beginner/number'
import './beginner/response'
import './flow/try-with-no-or'
import './flow/not'
import './lazy/transmission'


Expand Down

0 comments on commit c297a20

Please sign in to comment.