diff options
author | dos-reis <gdr@axiomatics.org> | 2008-05-22 01:08:03 +0000 |
---|---|---|
committer | dos-reis <gdr@axiomatics.org> | 2008-05-22 01:08:03 +0000 |
commit | db5b6bc58c7d8307b8874b37793074f789eb626a (patch) | |
tree | 83b3c602045e209e20f8ddf464d4b5973a3618a2 /src | |
parent | ab4a8ba818d6fa8d237a55639c7361b376162f81 (diff) | |
download | open-axiom-db5b6bc58c7d8307b8874b37793074f789eb626a.tar.gz |
* hyper/lex.c: Don't include hyper.h, hterror.h and
sockio.h. Include node.h.
* hyper/hyper.h: Don't include X11 headers. Include node.h.
Mode node data structures to node.h.
* hyper/cond.c: Don't include hterror.h. Include lex.h
* hyper/Makefile.in (HEADERS): Include node.h. Remove hterror.h.
(hypertex_SOURCES): Remove hterror.c
(htadd_SOURCES): Likewise.
* hyper/node.h: New.
* hyper/hterror.h: Remove.
* hyper/hterror.c (token_name): Move to hyper/lex.c.
(print_token): Likewise.
(print_next_ten_tokens): Likewise.
(print_page_and_filename): Likewise.
(jump): Likewise.
(ebuffer): Likewise.
(htperror): Move to parse-types.c
Remove file.
Diffstat (limited to 'src')
-rw-r--r-- | src/ChangeLog | 19 | ||||
-rw-r--r-- | src/hyper/Makefile.in | 8 | ||||
-rw-r--r-- | src/hyper/cond.c | 2 | ||||
-rw-r--r-- | src/hyper/htadd.c | 1 | ||||
-rw-r--r-- | src/hyper/hterror.c | 232 | ||||
-rw-r--r-- | src/hyper/hterror.h | 50 | ||||
-rw-r--r-- | src/hyper/hyper.h | 347 | ||||
-rw-r--r-- | src/hyper/lex.c | 258 | ||||
-rw-r--r-- | src/hyper/lex.h | 11 | ||||
-rw-r--r-- | src/hyper/mem.c | 4 | ||||
-rw-r--r-- | src/hyper/node.h | 460 | ||||
-rw-r--r-- | src/hyper/parse-types.c | 39 | ||||
-rw-r--r-- | src/hyper/parse.h | 1 | ||||
-rw-r--r-- | src/hyper/token.h | 110 |
14 files changed, 802 insertions, 740 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 181b1f70..81f8396a 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,24 @@ 2008-05-21 Gabriel Dos Reis <gdr@cs.tamu.edu> + * hyper/lex.c: Don't include hyper.h, hterror.h and + sockio.h. Include node.h. + * hyper/hyper.h: Don't include X11 headers. Include node.h. + Mode node data structures to node.h. + * hyper/cond.c: Don't include hterror.h. Include lex.h + * hyper/Makefile.in (HEADERS): Include node.h. Remove hterror.h. + (hypertex_SOURCES): Remove hterror.c + (htadd_SOURCES): Likewise. + * hyper/node.h: New. + * hyper/hterror.h: Remove. + * hyper/hterror.c (token_name): Move to hyper/lex.c. + (print_token): Likewise. + (print_next_ten_tokens): Likewise. + (print_page_and_filename): Likewise. + (jump): Likewise. + (ebuffer): Likewise. + (htperror): Move to parse-types.c + Remove file. + * include/cfuns.h (oa_get_tmpdir): Declare. (oa_access_file_for_read): Likewise. * lib/cfuns-c.c (oa_getcwd): Define. diff --git a/src/hyper/Makefile.in b/src/hyper/Makefile.in index 83ca718f..84838d31 100644 --- a/src/hyper/Makefile.in +++ b/src/hyper/Makefile.in @@ -53,8 +53,8 @@ SCRIPTS=${OUTLIB}/htsearch ${OUTLIB}/presea BINFILES= $(addprefix $(OUTLIB)/,$(bin_PROGRAMS)) -HEADERS = display.h event.h extent.h \ - group.h hterror.h hyper.h initx.h keyin.h lex.h \ +HEADERS = display.h event.h extent.h node.h \ + group.h hyper.h initx.h keyin.h lex.h \ parse.h parse-paste.h parse-types.h scrollbar.h \ titlebar.h token.h $(axiom_c_macros_h) @@ -62,7 +62,7 @@ HEADERS = display.h event.h extent.h \ build_libdir = $(top_builddir)/src/lib hypertex_SOURCES = addfile.c cond.c dialog.c display.c event.c extent1.c \ - extent2.c form-ext.c group.c hterror.c \ + extent2.c form-ext.c group.c \ htinp.c hyper.c initx.c input.c item.c keyin.c lex.c \ macro.c mem.c parse.c parse-aux.c parse-input.c \ parse-paste.c parse-types.c ReadBitmap.c scrollbar.c \ @@ -74,7 +74,7 @@ hypertex_objects = $(hypertex_SOURCES:.c=.lo) hypertex_LDADD = $(libspad_la) -L$(build_libdir) -lopen-axiom-core hypertex_DEPENDENCIES = -htadd_SOURCES = addfile.c htadd.c hterror.c lex.c +htadd_SOURCES = addfile.c htadd.c lex.c htadd_objects = $(htadd_SOURCES:.c=.lo) htadd_LDADD = $(libspad_la) -L$(build_libdir) -lopen-axiom-core htadd_DEPENDENCIES = diff --git a/src/hyper/cond.c b/src/hyper/cond.c index 82d79c4d..ef7c42e0 100644 --- a/src/hyper/cond.c +++ b/src/hyper/cond.c @@ -46,8 +46,8 @@ #include "debug.h" #include "sockio.h" -#include "hterror.h" #include "halloc.h" +#include "lex.h" #include "hyper.h" #include "all_hyper_proto.H1" diff --git a/src/hyper/htadd.c b/src/hyper/htadd.c index 18345d8f..14ffe618 100644 --- a/src/hyper/htadd.c +++ b/src/hyper/htadd.c @@ -46,7 +46,6 @@ #include <setjmp.h> #include "hash.h" -#include "hterror.h" #include "lex.h" #include "addfile.h" diff --git a/src/hyper/hterror.c b/src/hyper/hterror.c deleted file mode 100644 index 0b197cc0..00000000 --- a/src/hyper/hterror.c +++ /dev/null @@ -1,232 +0,0 @@ -/* - Copyright (C) 1991-2002, The Numerical Algorithms Group Ltd. - All rights reserved. - Copyright (C) 2007-2008, Gabriel Dos Reis. - All right reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical Algorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER - OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#define _HTERROR_C -#define HTERROR - -#include "openaxiom-c-macros.h" - -#include "debug.h" - -#include "sockio.h" -#include "lex.h" -#include "parse.h" -#include "hyper.h" - -#include "all_hyper_proto.H1" - -char ebuffer[128]; -jmp_buf jmpbuf; - -char *errmess[] = { - "place holder", - "parsing condition node", - "unrecognized keyword" -}; - -/* - * This file is the error handling routine in AXIOM. The main routine is - * called htperror(): arguments: msg - like perror it accepts an error - * message to be printed errno - the errno which occurred. This is so an - * appropriate error message can be printed. - * - * The prints out the page name, and then the filename in which the error - * occurred. If possible it also tries to print out the next ten tokens. - */ - -void -jump(void) -{ - if (gWindow == NULL) - exit(-1); - longjmp(jmpbuf, 1); - fprintf(stderr, "(HyperDoc) Long Jump failed, Exiting\n"); - exit(-1); -} - -void -print_page_and_filename(void) -{ - char obuff[128]; - - if (gPageBeingParsed->type == Normal) { - - /* - * Now try to inform the user as close to possible where the error - * occurred - */ - sprintf(obuff, "(HyperDoc) While parsing %s on line %d\n\tin the file %s\n", - gPageBeingParsed->name, line_number, - gPageBeingParsed->filename); - } - else if (gPageBeingParsed->type == SpadGen) { - sprintf(obuff, "While parsing %s from the Spad socket\n", - gPageBeingParsed->name); - } - else if (gPageBeingParsed->type == Unixfd) { - sprintf(obuff, "While parsing %s from a Unixpipe\n", - gPageBeingParsed->name); - } - else { - /* Unknown page type */ - sprintf(obuff, "While parsing %s\n", gPageBeingParsed->name); - } - fprintf(stderr, "%s", obuff); -} - - -void -print_next_ten_tokens(void) -{ - int i; - int v; - - fprintf(stderr, "Trying to print the next ten tokens\n"); - for (i = 0; i < 10; i++) { - v = get_token(); - if (v == EOF) - break; - print_token(); - } - fprintf(stderr, "\n"); -} - -/* print out a token value */ -void -print_token(void) -{ - if (token.type == Word) - printf("%s ", token.id); - else { - token_name(token.type); - printf("\\%s ", ebuffer); - } - fflush(stdout); -} - - -void -token_name(int type) -{ - if (type <= NumberUserTokens) - strcpy(ebuffer, token_table[type]); - else { - switch (type) { - case Lbrace: - strcpy(ebuffer, "{"); - break; - case Rbrace: - strcpy(ebuffer, "}"); - break; - case Macro: - strcpy(ebuffer, token.id); - break; - case Group: - strcpy(ebuffer, "{"); - break; - case Pound: - strcpy(ebuffer, "#"); - break; - case Lsquarebrace: - strcpy(ebuffer, "["); - break; - case Rsquarebrace: - strcpy(ebuffer, "]"); - break; - case Punctuation: - strcpy(ebuffer, token.id); - break; - case Dash: - strcpy(ebuffer, token.id); - break; - case Verbatim: - strcpy(ebuffer, "\\begin{verbatim}"); - break; - case Scroll: - strcpy(ebuffer, "\\begin{scroll}"); - break; - case Dollar: - strcpy(ebuffer, "$"); - break; - case Percent: - strcpy(ebuffer, "%"); - break; - case Carrot: - strcpy(ebuffer, "^"); - break; - case Underscore: - strcpy(ebuffer, "_"); - break; - case Tilde: - strcpy(ebuffer, "~"); - break; - case Cond: - sprintf(ebuffer, "\\%s", token.id); - break; - case Icorrection: - strcpy(ebuffer, "\\/"); - break; - case Paste: - strcpy(ebuffer, "\\begin{paste}"); - break; - case Patch: - strcpy(ebuffer, "\\begin{patch}"); - break; - default: - sprintf(ebuffer, " %d ", type); - } - /*return 1;*/ - } -} -void -htperror(char *msg, int erno) -{ - char obuff[256]; - - /* The first thing I do is create the error message */ - - if (erno <= Numerrors) { - sprintf(obuff, "%s:%s\n", msg, errmess[errno]); - } - else { - sprintf(obuff, "%s:\n", msg); - fprintf(stderr, "Unknown error type %d\n", erno); - } - fprintf(stderr, "%s", obuff); - - print_page_and_filename(); - - print_next_ten_tokens(); -} diff --git a/src/hyper/hterror.h b/src/hyper/hterror.h deleted file mode 100644 index 6e2b0ae4..00000000 --- a/src/hyper/hterror.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - Copyright (C) 1991-2002, The Numerical Algorithms Group Ltd. - All rights reserved. - Copyright (C) 2007-2008, Gabriel Dos Reis. - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - - Neither the name of The Numerical Algorithms Group Ltd. nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER - OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef OPENAXIOM_HTERROR -#define OPENAXIOM_HTERROR - -#define HTCONDNODE 1 /* unrecognized condition node */ -#define KEYTYPE 2 /* unrecognized keyword found in lex.c */ -#define Numerrors 2 - -extern void print_page_and_filename(void); -extern void jump(void); -extern void print_token(void); -extern void token_name(int); -extern void print_next_ten_tokens(void); -extern void htperror(char* , int); - -#endif /* OPENAXIOM_HTERROR */ diff --git a/src/hyper/hyper.h b/src/hyper/hyper.h index cbb2b506..cd716b44 100644 --- a/src/hyper/hyper.h +++ b/src/hyper/hyper.h @@ -42,13 +42,11 @@ #include <unistd.h> #include <limits.h> -#include <X11/Xlib.h> -#include <X11/Xutil.h> -#include <X11/Xos.h> #include "com.h" #include "token.h" #include "hash.h" +#include "node.h" #define boolean unsigned short int @@ -59,24 +57,6 @@ #define FALSE ((boolean) 0x0) #endif -/* Struct forward declarations */ - -struct text_node; -struct input_box; -struct input_window; -struct paste_node; -struct radio_boxes; -struct group_item; - -#define Scrollupbutton 1 -#define Scrolldownbutton 2 -#define Noopbutton 6 - -#define Scrolling 1 -#define Header 2 -#define Footer 3 -#define Title 4 - #ifndef HTADD extern int MenuServerOpened; @@ -112,297 +92,6 @@ extern XFontStruct *gActiveFont, #endif - -/** I am implementing a state node stack, this is the structure I store **/ - -typedef struct state_node { - int last_ch, last_token, input_type; - long fpos, keyword_fpos; - long page_start_fpos; - Token token; - char *input_string; - FILE *cfile; - int keyword; - struct state_node *next; -} StateNode; - -#ifndef HTADD -/** pointer to the top of the state node graph **/ -extern StateNode *top_state_node; -#endif - - -/* structure for a hyper text link */ -typedef struct hyper_link { - int type; /* Memolink, Spadlink, Downlink etc. */ - Window win; /* X11 window containing active area */ - union { - struct text_node *node; /* ID of link to which link refers */ - struct input_box *box; - struct input_window *string; - struct paste_node *paste; /* the paste node area */ - } reference; - int x,y; /* relative position inside page */ -} HyperLink; - - -typedef struct if_node { - struct text_node *cond; /* the condition nodes*/ - struct text_node *thennode; - struct text_node *elsenode; -} IfNode; - -typedef struct item_stack { - int indent; - int item_indent; - int in_item; - struct item_stack *next; -} ItemStack; - -typedef struct paste_node { - char *name; - int where; /* where should I be parsing from? */ - short int hasbutton; - short int haspaste; - struct group_item *group; - ItemStack *item_stack; - struct text_node *arg_node; - struct text_node *end_node; - struct text_node *begin_node; - struct input_window *paste_item; -} PasteNode; - -/* Structure for formatted hypertext */ - -typedef struct text_node { - short type; /* type of node (text, link, etc.) */ - int x,y, width, height; /* relative location on screen */ - int space; /* was there space in front of me ? */ - union { - char *text; /* piece of text to display */ - struct text_node *node; /* argument text */ - struct if_node *ifnode; - } data; - HyperLink *link; /* link for active text */ - union { - Pixmap pm; /* pixmap for bit images */ - XImage *xi; /* pixmap image */ - } image; - struct text_node *next; /* next node in formatted text */ -} TextNode; - -/** Structure used to store pixmaps and bitmaps **/ - -typedef struct image_struct { - int width,height; /** It's width and height **/ - union { - Pixmap pm; - XImage *xi; - } image; - char *filename; /** The filename used to reference it **/ -} ImageStruct; - -/* Structure for locating HyperDoc pages in a source file */ - -typedef struct { - char *name; /* file name */ - long pos; /* position in file */ - int ln; /* the line number */ -} FilePosition; - -/*** The structure needed for storing a macro **/ - -typedef struct macro_store { - short int loaded; - FilePosition fpos; - char *name; - char *macro_string; - short number_parameters; -} MacroStore; - - -/** Structure needed for storing a patch **/ -typedef struct patch_store { - short int loaded; - FilePosition fpos; - char *name; - char *string; -} PatchStore; - -/* Here are the structures needed for doing input to HyperDoc windows. */ - -typedef struct line_struct { - char *buffer; - int changed; /* Has the line changed */ - int line_number; - int buff_pntr; - int len; - struct line_struct *prev, *next; -} LineStruct; - -typedef struct input_window { - char *name; /* symbol name **/ - int size; /* the length of the window **/ - int cursor_x; /* x-coordinate for the cursor **/ - int entered; /* tells me whether I have typed here - before */ - int num_lines; /* number of lines needed to store - buffer */ - LineStruct *lines; - LineStruct *curr_line; /* the current line on which the cursor */ - Window win; - struct input_window *next; -} InputItem; - - -/* structure for storing input boxes **/ -typedef struct input_box { - char *name; - ImageStruct *selected, *unselected; - short int picked; - struct input_box *next; - struct radio_boxes *rbs; - Window win; -} InputBox; - -typedef struct radio_boxes { - char *name; - InputBox *boxes; - ImageStruct *selected, *unselected; - int width, height; - struct radio_boxes *next; -} RadioBoxes; - -/* Structure for spadcommand dependencies hash table entries */ -typedef struct spadcom_depend { - char *label; /* dependency label */ - TextNode *spadcom; /* spadcommand defining the label */ - short executed; /* true iff spadcommand has benn executed */ -} SpadcomDepend; - -typedef struct button_list { - int x0,y0,x1,y1; - HyperLink *link; - Window win; - struct button_list *next; -} ButtonList; - -/* Stucture for unformatted hyper text page */ - -typedef struct hyperdoc_page { - short type; /* Normal, Quitbutton, Upbutton etc. */ - char *name; /* ID of page */ - char *filename; /* The name of the file in which the page - occurs, Null if not */ - int scroll_off; /* The offset in the scrolling region */ - int bot_scroll_margin; /* bottom of the scrolling region */ - int top_scroll_margin; /* top of the scrolling region */ - TextNode *title; /* the title of the page */ - TextNode *header; /* formatted version of page */ - TextNode *scrolling; /* Top of scrolling region */ - TextNode *footer; /* top of non-scrolling region at bottom */ - openaxiom_sio *sock; /* socket connection for spad buffer */ - HashTable *fLinkHashTable; /* active link hash table */ - ButtonList *s_button_list; /* active buttons on page */ - ButtonList *button_list; /* active buttons on page */ - HashTable *depend_hash; /* Hash tables of spadcommand dependencies */ - InputItem *input_list; /* List of input structures */ - InputItem *current_item; /* a pntr to the currently active item */ - HashTable *box_hash; /* place where all the boxes are stored */ - RadioBoxes *radio_boxes; /* a linked list of radio boxes */ - short page_flags; /* A list of flags for the page */ - char *helppage; /* the name of the helppage */ -} HyperDocPage; - -/* Structure for an unloaded page */ - -typedef struct unloaded_page { - short type; /* indicator of unloaded page */ - char *name; /* name of page */ - FilePosition fpos; /* where to find the page */ -} UnloadedPage; - -/* Structure for a HyperDoc Window */ - -typedef struct { - Window fMainWindow; /* The main text field window. */ - Window fScrollWindow; /* The scrolling area of the window */ - Window fDisplayedWindow; /* The current window of the above two, */ - /* being filled by display */ - - Window fScrollUpWindow; /* Window for scrolling up a line */ - Window fScrollDownWindow; /* Window for scrolling down a line */ - - Window scrollbar; /* the window for scrolling */ - Window scroller; /* the scroller window */ - - Window fTitleBarButton1; /* 1st titlebar bitmap button */ - Window fTitleBarButton2; /* 2nd titlebar bitmap button */ - Window fTitleBarButton3; /* 3rd titlebar bitmap button */ - Window fTitleBarButton4; /* 4th titlebar bitmap button */ - - int fScrollerTopPos; /* where the top of the scroller is */ - int fScrollerHeight; /* the height of the scroller */ - int fScrollBarHeight; /* the height for the scrollbar */ - - int scrollwidth; /* the width of the scrolling area */ - int scrollheight; /* the height of the scrolling area */ - int scrollupy; /* Current y position of the scroll up */ - /* button */ - int scrolldowny; /* Current y position of the scroll */ - /* downbutton */ - int scrollbary; /* Current y position of teh scrollbar */ - int scrollx; /* X coordinates for all of the above */ - int border_width; /* Width of the border */ - HyperDocPage *page; /* currently displayed page */ - int width, height; /* in pixels */ - int columns; /* Width in characters, only setable */ - /* for form pages */ - HyperDocPage **fMemoStack; /* stack of memo links */ - HyperDocPage **fDownLinkStack;/* stack of down links */ - - int *fDownLinkStackTop; /* stack of down links */ - int fMemoStackIndex; /* memo stack pointer */ - int fDownLinkStackIndex; /* downlink stack pointer */ - - HashTable *fWindowHashTable; /* hash table of active subwindows */ - HashTable *fPageHashTable; /* hash table of HyperDoc pages */ - HashTable *fPasteHashTable; /* hash table for paste in areas */ - HashTable *fMacroHashTable; /* hash table of HyperDoc macros */ - HashTable *fCondHashTable; /* hash table for values */ - HashTable *fPatchHashTable; /* hash table for patch locations */ - - int fAxiomFrame; /* Axiom frame number initializing window */ - GC fStandardGC; /* Graphics context for window */ - GC fInputGC; /* Graphics context for the input windows */ - GC fCursorGC; /* Graphics context for the cursors */ - GC fControlGC; /* Graphics context for the buttons */ - Cursor fDisplayedCursor; /* The currently displayed cursor */ -} HDWindow; - -/* Structure for identifying appropriate link hash tables */ - -typedef struct { - int code; /* code of active area */ - HyperDocPage *page; /* page for which hash table applies */ -} LinkHashID; - -/*** Flags for the page ***/ - -#define NOLINES 0000001 /* Ibid, for the bottom of the page ***/ - - -/* external variables and functions. See the source file for a description - of their purposes */ - -extern HashTable gSessionHashTable; /* hash table of HD windows */ - -extern HDWindow *gParentWindow; /* the parent window. The one that - * appears when you first start HD */ - -extern HyperLink *quitLink; /** a special link to the protected quit page **/ - - #ifndef HTADD /* From hyper.c */ extern int gXScreenNumber; @@ -415,9 +104,9 @@ extern openaxiom_sio *session_server; extern openaxiom_sio *spad_socket; extern HashTable gFileHashTable; extern HashTable gImageHashTable; /* A global hash table for images */ -extern Cursor gNormalCursor; /* The normal mouse cursor */ -extern Cursor gActiveCursor; /* The cursor in active regions */ -extern Cursor gBusyCursor; /* The clock cursor for when I am busy */ +extern openaxiom_cursor gNormalCursor; /* The normal mouse cursor. */ +extern openaxiom_cursor gActiveCursor; /* The cursor in active regions. */ +extern openaxiom_cursor gBusyCursor; /* The clock cursor for when I am busy */ extern int gIsAxiomServer; /* true iff HyperDoc is acting as an Axiom server */ extern int gArgc; /* original argc from main */ extern char **gArgv; /* original argv from main */ @@ -428,10 +117,10 @@ extern int last_token, input_type, last_ch; extern char *input_string; extern FILE *cfile; /* from input.c */ -extern XImage *picked; +extern openaxiom_image *picked; extern int picked_height; extern int picked_width; -extern XImage *unpicked; +extern openaxiom_image *unpicked; extern int unpicked_height; extern int unpicked_width; /* from display.c */ @@ -533,30 +222,18 @@ extern int connect_spad(void); #define EmphasizeFontDefault "-adobe-courier-medium-o-normal--18-*-*-*-m-*-iso8859-1" #define BoldFontDefault "-adobe-courier-bold-r-normal--18-*-*-*-m-*-iso8859-1" +/* external variables and functions. See the source file for a description + of their purposes */ +extern HashTable gSessionHashTable; /* hash table of HD windows */ -typedef struct group_item { - int cur_color; - XFontStruct *cur_font; - int center; - struct group_item *next; -} GroupItem; +extern HDWindow *gParentWindow; /* the parent window. The one that + * appears when you first start HD */ +extern HyperLink *quitLink; /** a special link to the protected quit page **/ extern GroupItem *gTopOfGroupStack; extern HyperDocPage *gPageBeingParsed; - -typedef struct cond_node { - char *label; - char *cond; -} CondNode; - -typedef struct parameter_list_type { - char **list; /** The parameters in string form **/ - short number; /** How many parameters are there **/ - struct parameter_list_type *next; -} *ParameterList; - #endif diff --git a/src/hyper/lex.c b/src/hyper/lex.c index ad6f6672..16ec3230 100644 --- a/src/hyper/lex.c +++ b/src/hyper/lex.c @@ -66,29 +66,30 @@ int useAscii; #define PARSER 1 -#include "hyper.h" -#include "hterror.h" #include "halloc.h" -#include "sockio.h" #include "lex.h" - +#include "node.h" #include <ctype.h> #include <setjmp.h> +#include <stdlib.h> static int get_char1(void ); static void spad_error_handler(void ); static int keyword_type(void ); extern int gTtFontIs850; +extern HDWindow *gWindow; + StateNode *top_state_node; HyperDocPage *gPageBeingParsed; /* page currently being parsed */ -extern jmp_buf jmpbuf; -extern char ebuffer[]; +jmp_buf jmpbuf; +char ebuffer[128]; short int gInSpadsrc = 0; short int gInVerbatim; +openaxiom_sio* spad_socket; /* Parser variables */ long fpos; /* Position of pointer in file in characters */ @@ -112,6 +113,108 @@ char sock_buf[1024]; /* buffer for socket input */ static HashTable tokenHashTable; /* hash table of parser tokens */ +char* token_table[] = { + "", /* Dummy token name */ + "word", + "page", + "lispcommandquit", + "bf", + "link", + "downlink", + "beginscroll", + "spadcommand", + "nolines", + "env", + "par", + "centerline", + "begin", + "beginitems", + "item", + "table", + "fbox", + "tab", + "space", + "indent", + "horizontalline", + "newline", + "enditems", + "returnbutton", + "memolink", + "upbutton", + "endscroll", + "thispage", + "returnto", + "free", + "bound", + "lisplink", + "unixlink", + "mbox", + "inputstring", + "stringvalue", + "spadlink", + "inputbitmap", + "inputpixmap", + "unixcommand", + "em", + "lispcommand", + "lispmemolink", + "lispdownlink", + "spadcall", + "spadcallquit", + "spaddownlink", + "spadmemolink", + "qspadcall", + "qspadcallquit", + "inputbox", + "radioboxes", + "boxvalue", + "vspace", + "hspace", + "newcommand", + "windowid", + "beep", + "quitbutton", + "begintitems", + "titem", + "end", + "it", + "sl", + "tt", + "rm", + "ifcond", + "else", + "fi", + "newcond", + "setcond" , + "button", + "windowlink", + "haslisp", + "hasup", + "hasreturn", + "hasreturnto", + "lastwindow", + "endtitems", + "lispwindowlink", + "beginpile", + "endpile", + "nextline", + "pastebutton", + "color", + "helppage", + "patch", + "radiobox", + "ifrecond", + "math", + "mitem", + "pagename", + "examplenumber", + "replacepage", + "inputimage", + "spadgraph", + "indentrel", + "controlbitmap" + }; + void dumpToken(char *caller, Token t) { fprintf(stderr,"%s:dumpToken type=%s id=%s\n", @@ -534,6 +637,15 @@ typedef struct be_struct { BeStruct *top_be_stack; +void +jump(void) +{ + if (gWindow == NULL) + exit(-1); + longjmp(jmpbuf, 1); + fprintf(stderr, "(HyperDoc) Long Jump failed, Exiting\n"); + exit(-1); +} void push_be_stack(int type, const char* id) @@ -748,6 +860,140 @@ end_type(void) } +void +token_name(int type) +{ + if (type <= NumberUserTokens) + strcpy(ebuffer, token_table[type]); + else { + switch (type) { + case Lbrace: + strcpy(ebuffer, "{"); + break; + case Rbrace: + strcpy(ebuffer, "}"); + break; + case Macro: + strcpy(ebuffer, token.id); + break; + case Group: + strcpy(ebuffer, "{"); + break; + case Pound: + strcpy(ebuffer, "#"); + break; + case Lsquarebrace: + strcpy(ebuffer, "["); + break; + case Rsquarebrace: + strcpy(ebuffer, "]"); + break; + case Punctuation: + strcpy(ebuffer, token.id); + break; + case Dash: + strcpy(ebuffer, token.id); + break; + case Verbatim: + strcpy(ebuffer, "\\begin{verbatim}"); + break; + case Scroll: + strcpy(ebuffer, "\\begin{scroll}"); + break; + case Dollar: + strcpy(ebuffer, "$"); + break; + case Percent: + strcpy(ebuffer, "%"); + break; + case Carrot: + strcpy(ebuffer, "^"); + break; + case Underscore: + strcpy(ebuffer, "_"); + break; + case Tilde: + strcpy(ebuffer, "~"); + break; + case Cond: + sprintf(ebuffer, "\\%s", token.id); + break; + case Icorrection: + strcpy(ebuffer, "\\/"); + break; + case Paste: + strcpy(ebuffer, "\\begin{paste}"); + break; + case Patch: + strcpy(ebuffer, "\\begin{patch}"); + break; + default: + sprintf(ebuffer, " %d ", type); + } + /*return 1;*/ + } +} + + +/* print out a token value */ +void +print_token(void) +{ + if (token.type == Word) + printf("%s ", token.id); + else { + token_name(token.type); + printf("\\%s ", ebuffer); + } + fflush(stdout); +} + +void +print_next_ten_tokens(void) +{ + int i; + int v; + + fprintf(stderr, "Trying to print the next ten tokens\n"); + for (i = 0; i < 10; i++) { + v = get_token(); + if (v == EOF) + break; + print_token(); + } + fprintf(stderr, "\n"); +} + +void +print_page_and_filename(void) +{ + char obuff[128]; + + if (gPageBeingParsed->type == Normal) { + + /* + * Now try to inform the user as close to possible where the error + * occurred + */ + sprintf(obuff, "(HyperDoc) While parsing %s on line %d\n\tin the file %s\n", + gPageBeingParsed->name, line_number, + gPageBeingParsed->filename); + } + else if (gPageBeingParsed->type == SpadGen) { + sprintf(obuff, "While parsing %s from the Spad socket\n", + gPageBeingParsed->name); + } + else if (gPageBeingParsed->type == Unixfd) { + sprintf(obuff, "While parsing %s from a Unixpipe\n", + gPageBeingParsed->name); + } + else { + /* Unknown page type */ + sprintf(obuff, "While parsing %s\n", gPageBeingParsed->name); + } + fprintf(stderr, "%s", obuff); +} + static int keyword_type(void) diff --git a/src/hyper/lex.h b/src/hyper/lex.h index 44d688b5..244bc9bc 100644 --- a/src/hyper/lex.h +++ b/src/hyper/lex.h @@ -38,6 +38,10 @@ #include "token.h" +#define HTCONDNODE 1 /* unrecognized condition node */ +#define KEYTYPE 2 /* unrecognized keyword found in lex.c */ +#define Numerrors 2 + extern void get_expected_token(int); extern void parser_init(void); extern void init_scanner(void); @@ -55,7 +59,14 @@ extern int begin_type(void); extern int end_type(void); extern void reset_connection(void); +extern void print_page_and_filename(void); +extern void jump(void); +extern void print_token(void); +extern void token_name(int); +extern void print_next_ten_tokens(void); + extern short int gInSpadsrc; extern short int gInVerbatim; + #endif diff --git a/src/hyper/mem.c b/src/hyper/mem.c index feed98df..554b7ff2 100644 --- a/src/hyper/mem.c +++ b/src/hyper/mem.c @@ -340,7 +340,7 @@ alloc_ifnode(void) { IfNode *tempif; - tempif = (IfNode *) halloc(sizeof(struct if_node), "IfNode"); + tempif = (IfNode *) halloc(sizeof(IfNode), "IfNode"); tempif->thennode = tempif->elsenode = tempif->cond = NULL; return tempif; } @@ -350,7 +350,7 @@ alloc_condnode(void) { CondNode *temp; - temp = (CondNode *) halloc(sizeof(struct cond_node), "Cond Node"); + temp = (CondNode *) halloc(sizeof(CondNode), "Cond Node"); temp->cond = temp->label = NULL; return temp; } diff --git a/src/hyper/node.h b/src/hyper/node.h new file mode 100644 index 00000000..7cd6b31e --- /dev/null +++ b/src/hyper/node.h @@ -0,0 +1,460 @@ +/* + Copyright (C) 1991-2002, The Numerical Algorithms Group Ltd. + All rights reserved. + Copyright (C) 2007-2008, Gabriel Dos Reis. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of The Numerical Algorithms Group Ltd. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef OPENAXIOM_NODE +#define OPENAXIOM_NODE + +#include "openaxiom-c-macros.h" +#include "hash.h" + +#ifndef X_DISPLAY_MISSING +# include <X11/Xlib.h> +# include <X11/Xutil.h> +# include <X11/Xos.h> +typedef Window openaxiom_window; +typedef Pixmap openaxiom_pixmap; +typedef XImage openaxiom_image; +typedef GC openaxiom_graphic_context; +typedef Cursor openaxiom_cursor; +#else /* X_DISPLAY_MISSING */ +typedef HANDLE openaxiom_window; +typedef HANDLE openaxiom_pixmap; +typedef HANDLE openaxiom_image; +typedef HANDLE openaxiom_graphic_context; +typedef HANDLE openaxiom_cursor; +#endif /* X_DISPLAY_MISSING */ + +/* Struct forward declarations */ + +struct TextNode; +struct InputBox; +struct InputItem; +struct paste_node; +struct RadioBoxes; +struct GroupItem; + +#define Scrollupbutton 1 +#define Scrolldownbutton 2 +#define Noopbutton 6 + +#define Scrolling 1 +#define Header 2 +#define Footer 3 +#define Title 4 + + + +/** I am implementing a state node stack, this is the structure I store **/ + +typedef struct StateNode { + int last_ch, last_token, input_type; + long fpos, keyword_fpos; + long page_start_fpos; + Token token; + char *input_string; + FILE *cfile; + int keyword; + struct StateNode *next; +} StateNode; + +/** pointer to the top of the state node graph **/ +extern StateNode *top_state_node; + + +/* structure for a hyper text link */ +typedef struct HyperLink { + int type; /* Memolink, Spadlink, Downlink etc. */ + openaxiom_window win; /* X11 window containing active area */ + union { + struct TextNode *node; /* ID of link to which link refers */ + struct InputBox *box; + struct InputItem *string; + struct PasteNode *paste; /* the paste node area */ + } reference; + int x,y; /* relative position inside page */ +} HyperLink; + + +typedef struct IfNode { + struct TextNode *cond; /* the condition nodes*/ + struct TextNode *thennode; + struct TextNode *elsenode; +} IfNode; + +typedef struct ItemStack { + int indent; + int item_indent; + int in_item; + struct ItemStack *next; +} ItemStack; + +typedef struct PasteNode { + char *name; + int where; /* where should I be parsing from? */ + short int hasbutton; + short int haspaste; + struct GroupItem *group; + ItemStack *item_stack; + struct TextNode *arg_node; + struct TextNode *end_node; + struct TextNode *begin_node; + struct InputItem *paste_item; +} PasteNode; + +/* Structure for formatted hypertext */ + +typedef struct TextNode { + short type; /* type of node (text, link, etc.) */ + int x,y, width, height; /* relative location on screen */ + int space; /* was there space in front of me ? */ + union { + char *text; /* piece of text to display */ + struct TextNode *node; /* argument text */ + struct IfNode *ifnode; + } data; + HyperLink *link; /* link for active text */ + union { + openaxiom_pixmap pm; /* pixmap for bit images */ + openaxiom_image *xi; /* pixmap image */ + } image; + struct TextNode *next; /* next node in formatted text */ +} TextNode; + +/** Structure used to store pixmaps and bitmaps **/ + +typedef struct ImageStruct { + int width,height; /** It's width and height **/ + union { + openaxiom_pixmap pm; + openaxiom_image *xi; + } image; + char *filename; /** The filename used to reference it **/ +} ImageStruct; + +/* Structure for locating HyperDoc pages in a source file */ + +typedef struct FilePosition { + char *name; /* file name */ + long pos; /* position in file */ + int ln; /* the line number */ +} FilePosition; + +/*** The structure needed for storing a macro **/ + +typedef struct MacroStore { + short int loaded; + FilePosition fpos; + char *name; + char *macro_string; + short number_parameters; +} MacroStore; + + + +/** Structure needed for storing a patch **/ +typedef struct PatchStore { + short int loaded; + FilePosition fpos; + char *name; + char *string; +} PatchStore; + +/* Here are the structures needed for doing input to HyperDoc windows. */ + +typedef struct LineStruct { + char *buffer; + int changed; /* Has the line changed */ + int line_number; + int buff_pntr; + int len; + struct LineStruct *prev, *next; +} LineStruct; + +typedef struct InputItem { + char *name; /* symbol name **/ + int size; /* the length of the window **/ + int cursor_x; /* x-coordinate for the cursor **/ + int entered; /* tells me whether I have typed here + before */ + int num_lines; /* number of lines needed to store + buffer */ + LineStruct *lines; + LineStruct *curr_line; /* the current line on which the cursor */ + openaxiom_window win; + struct InputItem *next; +} InputItem; + + +/* structure for storing input boxes **/ +typedef struct InputBox { + char *name; + ImageStruct *selected, *unselected; + short int picked; + struct InputBox *next; + struct RadioBoxes *rbs; + openaxiom_window win; +} InputBox; + +typedef struct RadioBoxes { + char *name; + InputBox *boxes; + ImageStruct *selected, *unselected; + int width, height; + struct RadioBoxes *next; +} RadioBoxes; + +/* Structure for spadcommand dependencies hash table entries */ +typedef struct spadcom_depend { + char *label; /* dependency label */ + TextNode *spadcom; /* spadcommand defining the label */ + short executed; /* true iff spadcommand has benn executed */ +} SpadcomDepend; + +typedef struct ButtonList { + int x0,y0,x1,y1; + HyperLink *link; + openaxiom_window win; + struct ButtonList *next; +} ButtonList; + +/* Stucture for unformatted hyper text page */ + +typedef struct HyperDocPage { + short type; /* Normal, Quitbutton, Upbutton etc. */ + char *name; /* ID of page */ + char *filename; /* The name of the file in which the page + occurs, Null if not */ + int scroll_off; /* The offset in the scrolling region */ + int bot_scroll_margin; /* bottom of the scrolling region */ + int top_scroll_margin; /* top of the scrolling region */ + TextNode *title; /* the title of the page */ + TextNode *header; /* formatted version of page */ + TextNode *scrolling; /* Top of scrolling region */ + TextNode *footer; /* top of non-scrolling region at bottom */ + openaxiom_sio *sock; /* socket connection for spad buffer */ + HashTable *fLinkHashTable; /* active link hash table */ + ButtonList *s_button_list; /* active buttons on page */ + ButtonList *button_list; /* active buttons on page */ + HashTable *depend_hash; /* Hash tables of spadcommand dependencies */ + InputItem *input_list; /* List of input structures */ + InputItem *current_item; /* a pntr to the currently active item */ + HashTable *box_hash; /* place where all the boxes are stored */ + RadioBoxes *radio_boxes; /* a linked list of radio boxes */ + short page_flags; /* A list of flags for the page */ + char *helppage; /* the name of the helppage */ +} HyperDocPage; + +/* Structure for an unloaded page */ + +typedef struct UnloadedPage { + short type; /* indicator of unloaded page */ + char *name; /* name of page */ + FilePosition fpos; /* where to find the page */ +} UnloadedPage; + +/* Structure for a HyperDoc Window */ + +typedef struct HDWindow { + openaxiom_window fMainWindow; /* The main text field window. */ + openaxiom_window fScrollWindow; /* The scrolling area of the window. */ + openaxiom_window fDisplayedWindow; /* The current window of the above two,*/ + /* being filled by display */ + + openaxiom_window fScrollUpWindow; /* Window for scrolling up a line. */ + openaxiom_window fScrollDownWindow; /* Window for scrolling down a line. */ + + openaxiom_window scrollbar; /* the window for scrolling. */ + openaxiom_window scroller; /* the scroller window. */ + + openaxiom_window fTitleBarButton1; /* 1st titlebar bitmap button. */ + openaxiom_window fTitleBarButton2; /* 2nd titlebar bitmap button. */ + openaxiom_window fTitleBarButton3; /* 3rd titlebar bitmap button. */ + openaxiom_window fTitleBarButton4; /* 4th titlebar bitmap button. */ + + int fScrollerTopPos; /* where the top of the scroller is */ + int fScrollerHeight; /* the height of the scroller */ + int fScrollBarHeight; /* the height for the scrollbar */ + + int scrollwidth; /* the width of the scrolling area */ + int scrollheight; /* the height of the scrolling area */ + int scrollupy; /* Current y position of the scroll up */ + /* button */ + int scrolldowny; /* Current y position of the scroll */ + /* downbutton */ + int scrollbary; /* Current y position of teh scrollbar */ + int scrollx; /* X coordinates for all of the above */ + int border_width; /* Width of the border */ + HyperDocPage *page; /* currently displayed page */ + int width, height; /* in pixels */ + int columns; /* Width in characters, only setable */ + /* for form pages */ + HyperDocPage **fMemoStack; /* stack of memo links */ + HyperDocPage **fDownLinkStack;/* stack of down links */ + + int *fDownLinkStackTop; /* stack of down links */ + int fMemoStackIndex; /* memo stack pointer */ + int fDownLinkStackIndex; /* downlink stack pointer */ + + HashTable *fWindowHashTable; /* hash table of active subwindows */ + HashTable *fPageHashTable; /* hash table of HyperDoc pages */ + HashTable *fPasteHashTable; /* hash table for paste in areas */ + HashTable *fMacroHashTable; /* hash table of HyperDoc macros */ + HashTable *fCondHashTable; /* hash table for values */ + HashTable *fPatchHashTable; /* hash table for patch locations */ + + int fAxiomFrame; /* Axiom frame number initializing window */ + openaxiom_graphic_context fStandardGC; /* Graphics context for window */ + openaxiom_graphic_context fInputGC; /* Graphics context for the input windows */ + openaxiom_graphic_context fCursorGC; /* Graphics context for the cursors */ + openaxiom_graphic_context fControlGC; /* Graphics context for the buttons */ + openaxiom_cursor fDisplayedCursor; /* The currently displayed cursor */ +} HDWindow; + +/* Structure for identifying appropriate link hash tables */ + +typedef struct LinkHashID { + int code; /* code of active area */ + HyperDocPage *page; /* page for which hash table applies */ +} LinkHashID; + + + +typedef struct GroupItem { + int cur_color; + XFontStruct *cur_font; + int center; + struct GroupItem *next; +} GroupItem; + + +typedef struct CondNode { + char *label; + char *cond; +} CondNode; + +typedef struct parameter_list_type { + char **list; /** The parameters in string form **/ + short number; /** How many parameters are there **/ + struct parameter_list_type *next; +} *ParameterList; + + +/*** Flags for the page ***/ + +#define NOLINES 0000001 /* Ibid, for the bottom of the page ***/ + +/* Here are some of the functions and constants declared and needed in + htadd.c ******/ + +#define NoChar -9999 +#define db_file_name "ht.db" + + +/* Types of HyperDoc pages */ + +#define UlUnknownPage 9993 /*I hate this hack, but I have to know whether*/ +#define UnknownPage 9994 /*this page has been loaded or not. */ +#define ErrorPage 9995 +#define Unixfd 9996 +#define SpadGen 9997 +#define Normal 9998 +#define UnloadedPageType 9999 + +/* Commands from Axiom */ + +#define EndOfPage 99 +#define SendLine 98 +#define StartPage 97 /* A normal HyperDoc page */ +#define LinkToPage 96 +#define PopUpPage 95 /* A pop-up page */ +#define PopUpNamedPage 94 +#define KillPage 93 +#define ReplacePage 92 +#define ReplaceNamedPage 91 +#define SpadError 90 + +/* Constants declaring size of page stacks */ + +#define MaxMemoDepth 25 /* max nesting level for memolinks */ +#define MaxDownlinkDepth 50 /* max downlink nesting depth */ + +/* Constants defining the size of various hash tables */ + +#define PageHashSize 1000 +#define FileHashSize 30 +#define SessionHashSize 10 +#define MacroHashSize 100 +#define ImageHashSize 100 +#define CondHashSize 100 +#define BoxHashSize 20 +#define PasteHashSize 100 +#define PatchHashSize 100 + +/* A couple of macros for memo and down links */ + +#define need_up_button \ + (gWindow->fMemoStackIndex ? gWindow->fDownLinkStackIndex >= \ + gWindow->fDownLinkStackTop[gWindow->fMemoStackIndex-1] \ + : gWindow->fDownLinkStackIndex) + +#define need_return_button (gWindow->fMemoStackIndex) + +#define need_help_button (gWindow->page->helppage != NULL) + +#define max(x,y) ((x) > (y) ? (x) : (y)) + + +#define pick_box(box) fill_box(box->win, box->selected) +#define unpick_box(box) fill_box(box->win, box->unselected) + +#define TopLevelHelpPage "ugHyperPage" +#define NoMoreHelpPage "NoMoreHelpPage" +#define KeyDefsHelpPage "ugHyperKeysPage" +#define InputAreaHelpPage "ugHyperInputPage" + +/* definitions for connecting to the Axiom server */ + +#define Connected 0 +#define NotConnected 1 +#define SpadBusy 2 + +/* some GUI-dependent stuff */ + +#define BeepAtTheUser() /* (XBell(gXDisplay, 5)) */ +#define LoudBeepAtTheUser() /* (XBell(gXDisplay, 50)) */ + + + +#endif /* OPENAXIOM_NODE */ diff --git a/src/hyper/parse-types.c b/src/hyper/parse-types.c index b1ed2c0c..503aff3b 100644 --- a/src/hyper/parse-types.c +++ b/src/hyper/parse-types.c @@ -51,7 +51,6 @@ #include "hyper.h" #include "lex.h" #include "extent.h" -#include "hterror.h" #include "all_hyper_proto.H1" @@ -60,6 +59,44 @@ boolean gInIf = FALSE; boolean gInItems = FALSE; boolean gInOptional = FALSE; + +static char *errmess[] = { + "place holder", + "parsing condition node", + "unrecognized keyword" +}; + + +/* + * htperror(): arguments: msg - like perror it accepts an error + * message to be printed errno - the errno which occurred. This is so an + * appropriate error message can be printed. + * + * The prints out the page name, and then the filename in which the error + * occurred. If possible it also tries to print out the next ten tokens. + */ + +static void +htperror(char *msg, int erno) +{ + char obuff[256]; + + /* The first thing I do is create the error message */ + + if (erno <= Numerrors) { + sprintf(obuff, "%s:%s\n", msg, errmess[errno]); + } + else { + sprintf(obuff, "%s:\n", msg); + fprintf(stderr, "Unknown error type %d\n", erno); + } + fprintf(stderr, "%s", obuff); + + print_page_and_filename(); + + print_next_ten_tokens(); +} + void parse_ifcond(void) { diff --git a/src/hyper/parse.h b/src/hyper/parse.h index 698b0db0..3de6024a 100644 --- a/src/hyper/parse.h +++ b/src/hyper/parse.h @@ -37,7 +37,6 @@ #define _PARSE_H_ 1 #include "openaxiom-c-macros.h" -#include "hterror.h" #ifdef SUNplatform #include <sys/types.h> diff --git a/src/hyper/token.h b/src/hyper/token.h index a4dadac8..24a3c3f3 100644 --- a/src/hyper/token.h +++ b/src/hyper/token.h @@ -49,9 +49,9 @@ /* HyperDoc parser tokens */ -typedef struct toke { - int type; /* token type. One of those listed below */ - char *id; /* string value if type == Identifier */ +typedef struct Token { + int type; /* token type. One of those listed below */ + char *id; /* string value if type == Identifier */ } Token; /* @@ -162,110 +162,6 @@ typedef struct toke { extern char *token_table[]; -#ifdef PARSER -char *token_table[] = { - "", /* Dummy token name */ - "word", - "page", - "lispcommandquit", - "bf", - "link", - "downlink", - "beginscroll", - "spadcommand", - "nolines", - "env", - "par", - "centerline", - "begin", - "beginitems", - "item", - "table", - "fbox", - "tab", - "space", - "indent", - "horizontalline", - "newline", - "enditems", - "returnbutton", - "memolink", - "upbutton", - "endscroll", - "thispage", - "returnto", - "free", - "bound", - "lisplink", - "unixlink", - "mbox", - "inputstring", - "stringvalue", - "spadlink", - "inputbitmap", - "inputpixmap", - "unixcommand", - "em", - "lispcommand", - "lispmemolink", - "lispdownlink", - "spadcall", - "spadcallquit", - "spaddownlink", - "spadmemolink", - "qspadcall", - "qspadcallquit", - "inputbox", - "radioboxes", - "boxvalue", - "vspace", - "hspace", - "newcommand", - "windowid", - "beep", - "quitbutton", - "begintitems", - "titem", - "end", - "it", - "sl", - "tt", - "rm", - "ifcond", - "else", - "fi", - "newcond", - "setcond" , - "button", - "windowlink", - "haslisp", - "hasup", - "hasreturn", - "hasreturnto", - "lastwindow", - "endtitems", - "lispwindowlink", - "beginpile", - "endpile", - "nextline", - "pastebutton", - "color", - "helppage", - "patch", - "radiobox", - "ifrecond", - "math", - "mitem", - "pagename", - "examplenumber", - "replacepage", - "inputimage", - "spadgraph", - "indentrel", - "controlbitmap" - }; -#endif - /* places from which input may be read */ #define FromFile 1 |