Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[70_9] Parser: improve number_parser and keyword_parser for S7 Scheme #1871

Merged
merged 3 commits into from
May 15, 2024

Conversation

da-liii
Copy link
Contributor

@da-liii da-liii commented May 15, 2024

What

  • number_parser: support # prefix
  • keyword_parser: support customizing extra chars
  • improve s7-lang.scm

Why

In S7 Scheme

#b001
#xab1
#o777
#t 
#f

string->number
string?
set!

How to test your changes?

Launch Mogan Research and check TeXmacs/tests/tm/70_9.tm

@da-liii da-liii requested review from jingkaimori and Oyyko May 15, 2024 14:53
@da-liii da-liii changed the title [70_9] Parser: support number starting with # like #t, #b101, #o777, … [70_9] Parser: improve number_parser and keyword_parser for S7 Scheme May 15, 2024
@da-liii
Copy link
Contributor Author

da-liii commented May 15, 2024

image

read_keyword (string s, int& i, string& result, array<char> extras) {
int opos= i;
int s_N = N (s);
if (i < s_N && is_alpha (s[i])) i++;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a keyword must start with alpha

!(s[pos] == '.' && pos + 1 < N (s) && is_digit (s[pos + 1])))
return;

// Start with 0b, 0o, 0x
if (can_parse_prefix_0b (s, pos)) {
if (prefix_hash () && pos + 1 < N (s) && s[pos] == '#' &&
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for #t and #f

else {
for (int j= 0; j < group_of_keywords_N; j++) {
string word= get_label (group_of_keywords[j]);
p_keyword_parser.put (utf8_to_cork (word), group);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when matching the keyword, string->number is actually string-<gtr>number

@da-liii da-liii merged commit 511f393 into branch-1.2 May 15, 2024
8 checks passed
@da-liii da-liii deleted the da/70_9/number_hash branch May 15, 2024 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant