mirror of
https://github.com/janet-lang/janet
synced 2024-12-26 00:10:27 +00:00
Update man page and add early exit to number scanning for parser.
This commit is contained in:
parent
d0fc29338c
commit
82cddef5bb
6
janet.1
6
janet.1
@ -37,7 +37,11 @@ Shows the version text and exits immediately.
|
|||||||
|
|
||||||
.TP
|
.TP
|
||||||
.BR \-s
|
.BR \-s
|
||||||
Read raw input from stdin, such as from a pipe without printing a prompt.
|
Read raw input from stdin and forgo prompt history and other readline-like features.
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.BR \-q
|
||||||
|
Quiet output. Don't prinpt a repl prompt or expression results to stdout.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.BR \-r
|
.BR \-r
|
||||||
|
@ -293,9 +293,11 @@ static int tokenchar(JanetParser *p, JanetParseState *state, uint8_t c) {
|
|||||||
}
|
}
|
||||||
/* Token finished */
|
/* Token finished */
|
||||||
blen = (int32_t) p->bufcount;
|
blen = (int32_t) p->bufcount;
|
||||||
|
int start_dig = p->buf[0] >= '0' && p->buf[0] <= '9';
|
||||||
|
int start_num = start_dig || p->buf[0] == '-' || p->buf[0] == '+';
|
||||||
if (p->buf[0] == ':') {
|
if (p->buf[0] == ':') {
|
||||||
ret = janet_keywordv(p->buf + 1, blen - 1);
|
ret = janet_keywordv(p->buf + 1, blen - 1);
|
||||||
} else if (!janet_scan_number(p->buf, blen, &numval)) {
|
} else if (start_num && !janet_scan_number(p->buf, blen, &numval)) {
|
||||||
ret = janet_wrap_number(numval);
|
ret = janet_wrap_number(numval);
|
||||||
} else if (!check_str_const("nil", p->buf, blen)) {
|
} else if (!check_str_const("nil", p->buf, blen)) {
|
||||||
ret = janet_wrap_nil();
|
ret = janet_wrap_nil();
|
||||||
@ -304,7 +306,7 @@ static int tokenchar(JanetParser *p, JanetParseState *state, uint8_t c) {
|
|||||||
} else if (!check_str_const("true", p->buf, blen)) {
|
} else if (!check_str_const("true", p->buf, blen)) {
|
||||||
ret = janet_wrap_true();
|
ret = janet_wrap_true();
|
||||||
} else if (p->buf) {
|
} else if (p->buf) {
|
||||||
if (p->buf[0] >= '0' && p->buf[0] <= '9') {
|
if (start_dig) {
|
||||||
p->error = "symbol literal cannot start with a digit";
|
p->error = "symbol literal cannot start with a digit";
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1024,7 +1024,7 @@ static const JanetReg cfuns[] = {
|
|||||||
"(peg/match peg text [,start=0])\n\n"
|
"(peg/match peg text [,start=0])\n\n"
|
||||||
"Match a Parsing Expression Grammar to a byte string and return an array of captured values. "
|
"Match a Parsing Expression Grammar to a byte string and return an array of captured values. "
|
||||||
"Returns nil if text does not match the language defined by peg. The syntax of PEGs are very "
|
"Returns nil if text does not match the language defined by peg. The syntax of PEGs are very "
|
||||||
"similar to those defined by LPeg, and have similar capabilities. Still WIP."
|
"similar to those defined by LPeg, and have similar capabilities."
|
||||||
},
|
},
|
||||||
{NULL, NULL, NULL}
|
{NULL, NULL, NULL}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user