is allowed.
#if HAVE_FLEXLEXER_YY_CURRENT_BUFFER
yy_current_buffer = 0;
#endif
- allow_includes_ = true;
}
/** Set the new input file to NAME, remember old file. */
void
Includable_lexer::new_input (string name, Sources *sources)
{
- if (!allow_includes_)
- {
- LexerError (_ ("include files are not allowed in safe mode").c_str ());
- return;
- }
-
Source_file *file = sources->get_file (&name);
if (!file)
{
vector<int> char_count_stack_;
public:
- bool allow_includes_;
Includable_lexer ();
~Includable_lexer ();
vector<string> file_name_strings_;
Source_file *get_source_file () const;
- void new_input (string s, Sources *);
+ virtual void new_input (string s, Sources *);
+
void new_input (string name, string data, Sources *);
-
+
char const *here_str0 () const;
};
void *lexval;
Input *lexloc;
bool is_main_input_;
- bool be_safe_;
Sources *sources_;
Lily_lexer (Sources *, Lily_parser *);
Lily_lexer (Lily_lexer const &, Lily_parser *);
int yylex ();
-
+
void add_lexed_char (int);
void prepare_for_next_token ();
void start_main_input ();
+ virtual void new_input (string s, Sources *);
+ virtual void new_input (string s, string d, Sources *);
+
SCM keyword_list () const;
SCM lookup_identifier (string s);
SCM lookup_identifier_symbol (SCM s);
Input hi = here_input();
hi.step_forward ();
SCM sval = ly_parse_scm (hi.start (), &n, hi,
- be_safe_ && is_main_input_);
+ be_safe_global && is_main_input_);
if (sval == SCM_UNDEFINED)
{
SCM_ASSERT_TYPE(lex, lexer, SCM_ARG1, __FUNCTION__, "lily lexer");
return lex->keyword_list ();
}
-
-
-LY_DEFINE(ly_lexer_set_safe, "ly:lexer-set-safe!",
- 1, 0, 0, (SCM lexer),
- "Switch on safe mode for the rest of the file.")
-{
- Lily_lexer * lex = Lily_lexer::unsmob (lexer);
- SCM_ASSERT_TYPE(lex, lexer, SCM_ARG1, __FUNCTION__, "lily lexer");
-
- lex->be_safe_ = true;
- lex->allow_includes_ = false;
-
- return SCM_UNSPECIFIED;
-}
new_input (main_input_name_, sources_);
- /* Do not allow \include in --safe-mode */
- allow_includes_ = allow_includes_ && !be_safe_global;
-
scm_module_define (scm_car (scopes_),
ly_symbol2scm ("input-file-name"),
scm_makfrom0str (main_input_name_.c_str ()));
}
+void
+Lily_lexer::new_input (string str, string d, Sources *ss)
+{
+ Includable_lexer::new_input (str, d, ss);
+}
+
+void
+Lily_lexer::new_input (string str, Sources *ss)
+{
+ if (is_main_input_ && be_safe_global)
+ {
+ LexerError (_ ("include files are not allowed in safe mode").c_str ());
+ return;
+ }
+
+ Includable_lexer::new_input (str, ss);
+}
+
void
Lily_lexer::set_identifier (SCM name, SCM s)
{
SCM
Lily_parser::make_scope () const
{
- return ly_make_anonymous_module (lexer_->be_safe_);
+ return ly_make_anonymous_module (be_safe_global);
}