Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Fixing an infinite type, updating code to match new Early parser, rem…
…embering to add protocol parser.
- Loading branch information
Showing
4 changed files
with
72 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Parsing pipes protocols from token trees. | ||
|
||
import parse::parser; | ||
import ast::ident; | ||
import parse::token; | ||
|
||
import pipec::*; | ||
|
||
impl proto_parser for parser { | ||
fn parse_proto(id: ident) -> protocol { | ||
let proto = protocol(id); | ||
|
||
self.expect(token::LBRACE); | ||
|
||
while self.token != token::RBRACE { | ||
self.parse_state(proto); | ||
} | ||
|
||
ret proto; | ||
} | ||
|
||
fn parse_state(proto: protocol) { | ||
let id = self.parse_ident(); | ||
self.expect(token::COLON); | ||
let dir = alt copy self.token { | ||
token::IDENT(n, _) { | ||
self.get_str(n) | ||
} | ||
_ { fail } | ||
}; | ||
self.bump(); | ||
let dir = alt dir { | ||
@"send" { send } | ||
@"recv" { recv } | ||
_ { fail } | ||
}; | ||
|
||
let state = proto.add_state(id, dir); | ||
// TODO: add typarams too. | ||
|
||
self.expect(token::LBRACE); | ||
|
||
while self.token != token::RBRACE { | ||
let mname = self.parse_ident(); | ||
|
||
// TODO: parse data | ||
|
||
self.expect(token::RARROW); | ||
|
||
let next = self.parse_ident(); | ||
// TODO: parse next types | ||
|
||
state.add_message(mname, ~[], next, ~[]); | ||
|
||
alt copy self.token { | ||
token::COMMA { self.bump() } | ||
token::RBRACE { } | ||
_ { fail } | ||
} | ||
} | ||
self.bump(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters