Skip to content

Commit

Permalink
[feature] Parser: alphanum, bool and ident funs added
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricss committed Apr 30, 2012
1 parent 92fedf7 commit a1e61f3
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ New supported platform:

New features:

* Parser.alphanum, Parser.ident and Parser.bool added

* Scheduler
- new set_max_compute_successive function
- new set_nb_step_apply function
Expand Down
38 changes: 37 additions & 1 deletion stdlib/core/parser/parser.opa
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,48 @@ Parser =
*
* @param an input string
*
* @return [some(f)] with [f : float] begin the float point number
* @return [some(f)] with [f : float] being the float point number
* represented by the input or [none] if the source does not contain
* a valid representation of a float point number.
*/
float = try_parse(Rule.float, _)

/**
* A parsing function for alphanumerical strings, i.e a non empty
* a sequence of letters (a-z and A-Z) and digits (0-9):
*
* @param an input string
*
* @return [some(f)] with [f : string]
* or [none] if the source is not contain
* a valid representation of an alphanum sequence
*/
alphanum = try_parse(Rule.alphanum_string, _)

/**
* A parsing function for idents, ie a non empty
* sequence of letters (a-z and A-Z), digits (0-9) and underscores.
*
* @param an input string
*
* @return [some(f)] with [f : string]
* or [none] if the source is not contain
* a valid representation of an ident
*/
ident = try_parse(Rule.ident, _)

/**
* A parsing function for boolean string
* ("false", "False", "true" or "True")
*
* @param an input string
*
* @return [some(f)] with [f : bool]
* or [none] if the source is not contain
* a valid representation of boolean
*/
bool = try_parse(Rule.bool, _)

/**
* {2 Parsing related functions}
*/
Expand Down

0 comments on commit a1e61f3

Please sign in to comment.