From da2cbdd4623e5ea51a2a99de4f2935b37195136e Mon Sep 17 00:00:00 2001 From: David Kastrup Date: Mon, 12 Jun 2017 13:21:55 +0200 Subject: [PATCH] Issue 5145/1: Lexer: factor out push_markup_predicates --- lily/include/lily-lexer.hh | 1 + lily/lexer.ll | 31 +++++++++++++++++++------------ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/lily/include/lily-lexer.hh b/lily/include/lily-lexer.hh index eb26403b00..ff2e8668c3 100644 --- a/lily/include/lily-lexer.hh +++ b/lily/include/lily-lexer.hh @@ -46,6 +46,7 @@ private: int scan_shorthand (const string&); int scan_scm_id (SCM); int identifier_type (SCM); + void push_markup_predicates (SCM sig); char escaped_char (char) const; const char *YYText_utf8 (); diff --git a/lily/lexer.ll b/lily/lexer.ll index 93184ebe08..19f84616f3 100644 --- a/lily/lexer.ll +++ b/lily/lexer.ll @@ -684,18 +684,8 @@ BOM_UTF8 \357\273\277 // value (for token type MARKUP_FUNCTION or // MARKUP_LIST_FUNCTION). - push_extra_token (here_input (), EXPECT_NO_MORE_ARGS); - s = scm_cdr(s); - for (; scm_is_pair(s); s = scm_cdr(s)) { - SCM predicate = scm_car(s); - - if (scm_is_eq (predicate, SCM (Lily::markup_list_p))) - push_extra_token (here_input (), EXPECT_MARKUP_LIST); - else if (scm_is_eq (predicate, SCM (Lily::markup_p))) - push_extra_token (here_input (), EXPECT_MARKUP); - else - push_extra_token (here_input (), EXPECT_SCM, predicate); - } + push_markup_predicates (scm_cdr (s)); + return token_type; } [^$#{}\"\\ \t\n\r\f]+ { @@ -892,6 +882,23 @@ Lily_lexer::pop_state () } +void +Lily_lexer::push_markup_predicates (SCM sig) +{ + push_extra_token (here_input (), EXPECT_NO_MORE_ARGS); + for (SCM s = sig; scm_is_pair(s); s = scm_cdr(s)) { + SCM predicate = scm_car(s); + + if (scm_is_eq (predicate, SCM (Lily::markup_list_p))) + push_extra_token (here_input (), EXPECT_MARKUP_LIST); + else if (scm_is_eq (predicate, SCM (Lily::markup_p))) + push_extra_token (here_input (), EXPECT_MARKUP); + else + push_extra_token (here_input (), EXPECT_SCM, predicate); + } +} + + int Lily_lexer::identifier_type (SCM sid) { -- 2.39.2