2019-02-05 02:44:07 +02:00
|
|
|
[Inter::Comment::] The Comment Construct.
|
|
|
|
|
2019-07-09 08:45:46 +03:00
|
|
|
Defining the comment construct.
|
2019-02-05 02:44:07 +02:00
|
|
|
|
|
|
|
@
|
|
|
|
|
|
|
|
@e COMMENT_IST
|
|
|
|
|
2022-02-10 01:48:51 +02:00
|
|
|
@d TEXT_COMMENT_IFLD 2
|
|
|
|
@d EXTENT_COMMENT_IFR 3
|
2019-02-05 02:44:07 +02:00
|
|
|
|
|
|
|
=
|
|
|
|
void Inter::Comment::define(void) {
|
2022-02-08 01:30:40 +02:00
|
|
|
inter_construct *IC = InterConstruct::create_construct(COMMENT_IST, I"comment");
|
2022-02-10 01:48:51 +02:00
|
|
|
InterConstruct::specify_syntax(IC, I"#ANY");
|
2019-07-09 08:45:46 +03:00
|
|
|
METHOD_ADD(IC, CONSTRUCT_READ_MTID, Inter::Comment::read);
|
2022-02-10 01:48:51 +02:00
|
|
|
METHOD_ADD(IC, CONSTRUCT_WRITE_MTID, Inter::Comment::write);
|
2019-09-07 03:28:18 +03:00
|
|
|
METHOD_ADD(IC, CONSTRUCT_TRANSPOSE_MTID, Inter::Comment::transpose);
|
2022-02-08 01:30:40 +02:00
|
|
|
InterConstruct::allow_in_depth_range(IC, 0, INFINITELY_DEEP);
|
|
|
|
InterConstruct::permit(IC, OUTSIDE_OF_PACKAGES_ICUP);
|
|
|
|
InterConstruct::permit(IC, INSIDE_PLAIN_PACKAGE_ICUP);
|
|
|
|
InterConstruct::permit(IC, INSIDE_CODE_PACKAGE_ICUP);
|
2019-02-05 02:44:07 +02:00
|
|
|
}
|
|
|
|
|
2019-07-14 12:44:07 +03:00
|
|
|
void Inter::Comment::read(inter_construct *IC, inter_bookmark *IBM, inter_line_parse *ilp, inter_error_location *eloc, inter_error_message **E) {
|
2022-02-09 12:33:49 +02:00
|
|
|
*E = InterConstruct::check_level_in_package(IBM, COMMENT_IST, ilp->indent_level, eloc);
|
2019-07-09 08:45:46 +03:00
|
|
|
if (*E) return;
|
2022-02-05 14:27:28 +02:00
|
|
|
if (SymbolAnnotation::nonempty(&(ilp->set))) { *E = Inter::Errors::plain(I"__annotations are not allowed", eloc); return; }
|
2022-02-10 01:48:51 +02:00
|
|
|
inter_ti ID = InterWarehouse::create_text(InterBookmark::warehouse(IBM), InterBookmark::package(IBM));
|
|
|
|
WRITE_TO(InterWarehouse::get_text(InterBookmark::warehouse(IBM), ID), "%S", ilp->mr.exp[0]);
|
|
|
|
*E = Inter::Comment::new(IBM, (inter_ti) ilp->indent_level, eloc, ID);
|
2019-02-05 02:44:07 +02:00
|
|
|
}
|
|
|
|
|
2020-07-01 02:58:55 +03:00
|
|
|
inter_error_message *Inter::Comment::new(inter_bookmark *IBM, inter_ti level, inter_error_location *eloc, inter_ti comment_ID) {
|
2022-02-10 01:48:51 +02:00
|
|
|
inter_tree_node *P = Inode::new_with_1_data_field(IBM, COMMENT_IST, comment_ID, eloc, level);
|
2022-02-07 00:33:07 +02:00
|
|
|
inter_error_message *E = InterConstruct::verify_construct(InterBookmark::package(IBM), P); if (E) return E;
|
2022-01-27 01:59:02 +02:00
|
|
|
NodePlacement::move_to_moving_bookmark(P, IBM);
|
2019-02-05 02:44:07 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
2019-09-07 03:28:18 +03:00
|
|
|
|
2022-02-10 01:48:51 +02:00
|
|
|
void Inter::Comment::write(inter_construct *IC, OUTPUT_STREAM, inter_tree_node *P, inter_error_message **E) {
|
|
|
|
text_stream *S = Inode::ID_to_text(P, P->W.instruction[TEXT_COMMENT_IFLD]);
|
|
|
|
if (Str::len(S) > 0) WRITE("#%S", S);
|
|
|
|
}
|
|
|
|
|
2020-07-01 02:58:55 +03:00
|
|
|
void Inter::Comment::transpose(inter_construct *IC, inter_tree_node *P, inter_ti *grid, inter_ti grid_extent, inter_error_message **E) {
|
2022-02-10 01:48:51 +02:00
|
|
|
P->W.instruction[TEXT_COMMENT_IFLD] = grid[P->W.instruction[TEXT_COMMENT_IFLD]];
|
2019-09-07 03:28:18 +03:00
|
|
|
}
|