Skip to content

Commit

Permalink
Update and use globals_struct_use.
Browse files Browse the repository at this point in the history
  • Loading branch information
crlf0710 committed Oct 9, 2020
1 parent 41cde64 commit fb93ff8
Show file tree
Hide file tree
Showing 27 changed files with 930 additions and 808 deletions.
33 changes: 29 additions & 4 deletions src/lib.rs
Expand Up @@ -42,6 +42,7 @@ mod section_0032;
mod section_0033;
mod section_0034;
mod section_0035;
#[macro_use]
mod section_0036;
mod section_0037;
mod section_0038;
Expand Down Expand Up @@ -94,11 +95,35 @@ mod section_0290_to_0296;
mod section_0297;
mod section_0298;
mod section_0299;
mod section_0300_to_0320;
mod section_0321_to_0331;
mod section_0300;
mod section_0301;
#[macro_use]
mod section_0302;
mod section_0303_to_0306;
mod section_0307;
mod section_0308_to_0320;
mod section_0321_to_0323;
mod section_0324;
mod section_0325_to_0331;
mod section_0332_to_0340;
mod section_0341;
mod section_0342_to_0365;
reversing_order_items!(
{
mod section_0341;
mod section_0342;
}
{
#[macro_use]
mod section_0343;
}
{
mod section_0344_to_0356;
}
{
#[macro_use]
mod section_0357;
}
);
mod section_0358_to_0365;
mod section_0366_to_0379;
mod section_0380;
mod section_0381_to_0401;
Expand Down
10 changes: 1 addition & 9 deletions src/section_0004.rs
Expand Up @@ -35,6 +35,7 @@ pub(crate) mod TeXGlobals {
include!("src/section_0054.rs");
include!("src/section_0076.rs");
include!("src/section_0297.rs");
include!("src/section_0301.rs");
include!("src/section_1299.rs");
include!("src/section_1331.rs");
}
Expand All @@ -52,13 +53,4 @@ pub(crate) fn initialize(globals: &mut TeXGlobals) {
// @t\4@>@<Basic printing procedures@>@/
// @t\4@>@<Error handling procedures@>@/

use crate::pascal::integer;
use crate::section_0025::alpha_file;
use crate::section_0025::eight_bits;
use crate::section_0038::str_number;
use crate::section_0076::history_state::{self, fatal_error_stop};
use crate::section_0113::halfword;
use crate::section_0115::null;
use crate::section_0115::pointer;

use globals_struct::globals_struct;
5 changes: 4 additions & 1 deletion src/section_0032.rs
Expand Up @@ -17,4 +17,7 @@ pub(crate) static term_in: alpha_file = alpha_file::default();
/// the terminal as an output file
pub(crate) static term_out: alpha_file = alpha_file::default();

use globals_struct::globals_struct_field;
#[globals_struct_use(TeXGlobals)]
pub(crate) use crate::section_0025::alpha_file;

use globals_struct::{globals_struct_field, globals_struct_use};
11 changes: 8 additions & 3 deletions src/section_0036.rs
Expand Up @@ -23,6 +23,11 @@
//! before a non-blank line comes in. The prompt is `\.{**}' instead of the
//! later `\.*' because the meaning is slightly different: `\.{\\input}' need
//! not be typed immediately after~`\.{**}'.)
//!
//! @d loc==cur_input.loc_field {location of first unread character in |buffer|}
//!

// @d loc==cur_input.loc_field {location of first unread character in |buffer|}
/// location of first unread character in `buffer`
macro_rules! loc {
($globals:expr) => {
$globals.cur_input.loc_field
};
}
5 changes: 4 additions & 1 deletion src/section_0054.rs
Expand Up @@ -66,4 +66,7 @@ pub(crate) static log_file: alpha_file = alpha_file::default();
// @!first_count: integer; {another variable for pseudoprinting}
//

use globals_struct::globals_struct_field;
#[globals_struct_use(TeXGlobals)]
pub(crate) use crate::section_0025::alpha_file;

use globals_struct::{globals_struct_field, globals_struct_use};
11 changes: 7 additions & 4 deletions src/section_0076.rs
Expand Up @@ -20,7 +20,7 @@

#[doc(hidden)]
#[derive(Copy, Clone)]
pub(crate) enum history_state {
pub(crate) enum history_kind {
/// `history` value when nothing has been amiss yet
spotless = 0,
/// `history` value when `begin_diagnostic` has been called
Expand All @@ -32,7 +32,7 @@ pub(crate) enum history_state {
}

#[doc(inline)]
pub(crate) use history_state::*;
pub(crate) use history_kind::*;

// @<Glob...@>=
// @!deletions_allowed:boolean; {is it safe for |error| to call |get_token|?}
Expand All @@ -41,10 +41,13 @@ pub(crate) use history_state::*;
// @!history:spotless..fatal_error_stop; {has the source input been clean so far?}
#[globals_struct_field(TeXGlobals)]
/// has the source input been clean so far?
pub(crate) static history: history_state = fatal_error_stop;
pub(crate) static history: history_kind = fatal_error_stop;

// @!error_count:-1..100; {the number of scrolled errors since the
// last paragraph ended}
//

use globals_struct::globals_struct_field;
#[globals_struct_use(TeXGlobals)]
use crate::section_0076::history_kind::{self, fatal_error_stop};

use globals_struct::{globals_struct_field, globals_struct_use};
5 changes: 4 additions & 1 deletion src/section_0115.rs
Expand Up @@ -25,6 +25,9 @@ pub(crate) const null: pointer = min_halfword;
/// a pointer variable for occasional emergency use
pub(crate) static temp_ptr: pointer = null;

#[globals_struct_use(TeXGlobals)]
use crate::section_0115::pointer;

use crate::section_0110::min_halfword;
use crate::section_0113::halfword;
use globals_struct::globals_struct_field;
use globals_struct::{globals_struct_field, globals_struct_use};
11 changes: 10 additions & 1 deletion src/section_0297.rs
Expand Up @@ -63,4 +63,13 @@ pub(crate) static cur_cs: pointer = null;
/// packed representative of `cur_cmd` and `cur_chr`
pub(crate) static cur_tok: halfword = halfword::default();

use globals_struct::globals_struct_field;
#[globals_struct_use(TeXGlobals)]
use crate::section_0025::eight_bits;
#[globals_struct_use(TeXGlobals)]
use crate::section_0113::halfword;
#[globals_struct_use(TeXGlobals)]
use crate::section_0115::null;
#[globals_struct_use(TeXGlobals)]
use crate::section_0115::pointer;

use globals_struct::{globals_struct_field, globals_struct_use};
40 changes: 40 additions & 0 deletions src/section_0300.rs
@@ -0,0 +1,40 @@
//! @* \[22] Input stacks and states.
//! This implementation of
//! \TeX\ uses two different conventions for representing sequential stacks.
//! @^stack conventions@>@^conventions for representing stacks@>
//!
//! \yskip\hangg 1) If there is frequent access to the top entry, and if the
//! stack is essentially never empty, then the top entry is kept in a global
//! variable (even better would be a machine register), and the other entries
//! appear in the array $\\{stack}[0\to(\\{ptr}-1)]$. For example, the
//! semantic stack described above is handled this way, and so is the input
//! stack that we are about to study.
//!
//! \yskip\hangg 2) If there is infrequent top access, the entire stack contents
//! are in the array $\\{stack}[0\to(\\{ptr}-1)]$. For example, the |save_stack|
//! is treated this way, as we have seen.
//!
//! \yskip\noindent
//! The state of \TeX's input mechanism appears in the input stack, whose
//! entries are records with six fields, called |state|, |index|, |start|, |loc|,
//! |limit|, and |name|. This stack is maintained with
//! convention~(1), so it is declared in the following way:

// @<Types...@>=

// @!in_state_record = record
// @!state_field, @!index_field: quarterword;
// @!start_field,@!loc_field, @!limit_field, @!name_field: halfword;
// end;
#[derive(Default)]
pub(crate) struct in_state_record {
pub(crate) state_field: quarterword,
pub(crate) index_field: quarterword,
pub(crate) start_field: halfword,
pub(crate) loc_field: halfword,
pub(crate) limit_field: halfword,
pub(crate) name_field: halfword,
}

use crate::section_0113::halfword;
use crate::section_0113::quarterword;

0 comments on commit fb93ff8

Please sign in to comment.