00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include <stdio.h>
00034 #include <stdlib.h>
00035 #if defined(__linux__) && ! defined(__USE_BSD)
00036 #define __USE_BSD
00037 #endif
00038 #include <string.h>
00039 #include <errno.h>
00040
00041 #include "emit.h"
00042 #include "macros.h"
00043 #include "scanner.h"
00044 #include "ticvocab.h"
00045 #include "dictionary.h"
00046 #include "vocabfuncts.h"
00047 #include "devnode.h"
00048 #include "clflags.h"
00049 #include "parselocals.h"
00050 #include "errhandler.h"
00051 #include "tokzesc.h"
00052 #include "conditl.h"
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180 static tic_hdr_t *global_voc_dict_ptr = NULL;
00181 static tic_hdr_t *fc_tokens_list_ender = NULL;
00182 static tic_hdr_t *fc_tokens_list_start = NULL;
00183 static tic_hdr_t *shared_fwords_ender = NULL;
00184 static tic_hdr_t *global_voc_reset_ptr = NULL;
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205 tic_hdr_t *lookup_core_word( char *tname)
00206 {
00207 tic_hdr_t *found ;
00208
00209 found = lookup_tic_entry( tname, global_voc_dict_ptr);
00210 return ( found ) ;
00211 }
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231 bool exists_in_core( char *name)
00232 {
00233 return exists_in_tic_vocab( name, global_voc_dict_ptr );
00234 }
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258 bool handle_core_word( char *tname )
00259 {
00260 bool retval;
00261
00262 retval = handle_tic_vocab( tname, global_voc_dict_ptr );
00263
00264 return ( retval ) ;
00265 }
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297 bool create_core_alias( char *new_name, char *old_name)
00298 {
00299 bool retval = create_tic_alias( new_name, old_name, &global_voc_dict_ptr);
00300 return ( retval );
00301 }
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327 static void emit_fc_token( tic_param_t pfield)
00328 {
00329 u16 fc_tok = (u16)pfield.deflt_elem;
00330 emit_fcode( fc_tok);
00331 }
00332
00333 #define FC_TOKEN_FUNC emit_fc_token
00334
00335 #define BUILTIN_FCODE( tok, nam) \
00336 VALPARAM_TIC(nam, FC_TOKEN_FUNC, tok , UNSPECIFIED )
00337
00338
00339 #define BI_FCODE_VALUE( tok, nam) \
00340 VALPARAM_TIC(nam, FC_TOKEN_FUNC, tok , VALUE )
00341
00342 #define BI_FCODE_VRBLE( tok, nam) \
00343 VALPARAM_TIC(nam, FC_TOKEN_FUNC, tok , VARIABLE )
00344
00345 #define BI_FCODE_DEFER( tok, nam) \
00346 VALPARAM_TIC(nam, FC_TOKEN_FUNC, tok , DEFER )
00347
00348 #define BI_FCODE_CONST( tok, nam) \
00349 VALPARAM_TIC(nam, FC_TOKEN_FUNC, tok , CONST )
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362 static void obsolete_warning( void)
00363 {
00364 if ( obso_fcode_warning )
00365 {
00366 tokenization_error( WARNING, "%s is an Obsolete FCode.\n",
00367 strupr(statbuf) );
00368 }
00369 }
00370
00371 static void obsolete_fc_token( tic_param_t pfield)
00372 {
00373 obsolete_warning();
00374 emit_fc_token( pfield);
00375 }
00376
00377 #define OBSO_FC_FUNC obsolete_fc_token
00378
00379 #define OBSOLETE_FCODE( tok, nam) \
00380 VALPARAM_TIC(nam, OBSO_FC_FUNC, tok , UNSPECIFIED )
00381
00382 #define OBSOLETE_VALUE( tok, nam) \
00383 VALPARAM_TIC(nam, OBSO_FC_FUNC, tok , VALUE )
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402 void handle_internal( tic_param_t pfield);
00403
00404 void skip_string( tic_param_t pfield);
00405
00406 #define FWORD_EXEC_FUNC handle_internal
00407
00408 #define BUILTIN_FWORD( fwt, nam) \
00409 FWORD_TKN_TIC(nam, FWORD_EXEC_FUNC, fwt, BI_FWRD_DEFN )
00410
00411 #define SHARED_FWORD( fwt, nam) \
00412 FWORD_TKN_TIC(nam, FWORD_EXEC_FUNC, fwt, COMMON_FWORD )
00413
00414
00415 #define SHR_FWD_SKOW( fwt, nam) \
00416 DUALFUNC_FWT_TIC(nam, FWORD_EXEC_FUNC, fwt, skip_a_word, COMMON_FWORD )
00417
00418
00419 #define SH_FW_SK_WIL( fwt, nam) \
00420 DUALFUNC_FWT_TIC(nam, FWORD_EXEC_FUNC, fwt, \
00421 skip_a_word_in_line, COMMON_FWORD )
00422
00423
00424 #define SH_FW_SK2WIL( fwt, nam) \
00425 DUALFUNC_FWT_TIC(nam, FWORD_EXEC_FUNC, fwt, \
00426 skip_two_words_in_line, COMMON_FWORD )
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441 #define SHARED_IG_HDLR(nam, afunc, pval, ifunc) \
00442 DUFNC_FWT_PARM(nam, afunc, pval, ifunc, COMMON_FWORD )
00443
00444
00445 #define SHR_SAMIG_FWRD( fwt, nam) \
00446 DUFNC_FWT_PARM(nam, FWORD_EXEC_FUNC, fwt, FWORD_EXEC_FUNC, COMMON_FWORD )
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458 #define BI_IG_FW_HDLR( fwt, nam) \
00459 DUALFUNC_FWT_TIC(nam, FWORD_EXEC_FUNC, fwt, FWORD_EXEC_FUNC, BI_FWRD_DEFN )
00460
00461
00462 #define BI_FWD_SKP_OW( fwt, nam) \
00463 DUALFUNC_FWT_TIC(nam, FWORD_EXEC_FUNC, fwt, skip_a_word, BI_FWRD_DEFN )
00464
00465
00466 #define BI_FWD_STRING( fwt, nam) \
00467 DUALFUNC_FWT_TIC(nam, FWORD_EXEC_FUNC, fwt, skip_string, BI_FWRD_DEFN )
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514 static tic_hdr_t **save_device_definitions;
00515
00516 bool scope_is_global = FALSE;
00517
00518
00519 void enter_global_scope( void )
00520 {
00521 if ( scope_is_global )
00522 {
00523 tokenization_error( WARNING,
00524 "%s -- Global Scope already in effect; ignoring.\n",
00525 strupr(statbuf) );
00526 }else{
00527 tokenization_error( INFO,
00528 "Initiating Global Scope definitions.\n" );
00529 scope_is_global = TRUE;
00530 save_device_definitions = current_definitions;
00531 current_definitions = &global_voc_dict_ptr;
00532 }
00533 }
00534
00535 void resume_device_scope( void )
00536 {
00537 if ( scope_is_global )
00538 {
00539 tokenization_error( INFO,
00540 "Terminating Global Scope definitions; "
00541 "resuming Device-node definitions.\n" );
00542 current_definitions = save_device_definitions;
00543 scope_is_global = FALSE;
00544 }else{
00545 tokenization_error( WARNING,
00546 "%s -- Device-node Scope already in effect; ignoring.\n",
00547 strupr(statbuf) );
00548 }
00549
00550 }
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585 tic_hdr_t *lookup_current( char *tname)
00586 {
00587
00588 tic_hdr_t *retval;
00589 retval = lookup_tic_entry( tname, *current_definitions);
00590 if ( (retval == NULL) && INVERSE(scope_is_global) )
00591 {
00592 retval = lookup_core_word( tname);
00593 }
00594 return ( retval );
00595 }
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614 bool exists_in_current( char *tname)
00615 {
00616 tic_hdr_t *found = lookup_word( tname, NULL, NULL);
00617 bool retval = BOOLVAL ( found != NULL);
00618 return( retval);
00619 }
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643 bool handle_current( char *tname )
00644 {
00645 bool retval = handle_tic_vocab( tname, *current_definitions );
00646
00647 if ( INVERSE(retval) && INVERSE(scope_is_global) )
00648 {
00649 retval = handle_core_word( tname );
00650 }
00651 return ( retval );
00652
00653 }
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677 tic_hdr_t *lookup_in_dev_node( char *tname)
00678 {
00679 tic_hdr_t *retval = NULL;
00680
00681 if ( INVERSE(scope_is_global) )
00682 {
00683 retval = lookup_tic_entry( tname, *current_definitions);
00684 }
00685 return ( retval );
00686 }
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705 static tic_hdr_t *save_current = NULL;
00706
00707
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757 void add_to_current( char *name,
00758 TIC_P_DEFLT_TYPE fc_token,
00759 fwtoken definer,
00760 bool define_token)
00761 {
00762 save_current = *current_definitions;
00763 if ( define_token )
00764 {
00765 char *nu_name = strdup( name);
00766 add_tic_entry( nu_name, FC_TOKEN_FUNC, fc_token,
00767 definer, 0 , NULL, current_definitions );
00768 }
00769 }
00770
00771
00772 void hide_last_colon ( void )
00773 {
00774 tic_hdr_t *temp_vocab;
00775
00776
00777
00778
00779
00780
00781
00782 temp_vocab = save_current ;
00783 save_current = *current_definitions;
00784 *current_definitions = temp_vocab;
00785
00786 }
00787
00788 void reveal_last_colon ( void )
00789 {
00790
00791
00792
00793 *current_definitions = save_current ;
00794 }
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847
00848
00849
00850
00851
00852
00853
00854
00855
00856
00857
00858
00859
00860
00861
00862
00863
00864
00865
00866 bool create_current_alias( char *new_name, char *old_name )
00867 {
00868 bool retval = FALSE;
00869
00870 if ( create_tic_alias( new_name, old_name, current_definitions) )
00871 {
00872 return ( TRUE );
00873 }
00874
00875 if ( INVERSE(scope_is_global) )
00876 {
00877 tic_hdr_t *found = lookup_core_word( old_name );
00878 if ( found != NULL )
00879 {
00880 add_tic_entry( new_name, found->funct,
00881 found->pfield.deflt_elem,
00882 found->fword_defr,
00883 0, found->ign_func,
00884 current_definitions );
00885 retval = TRUE;
00886 {
00887 tokenization_error( INFO,
00888 "%s is a Global definition, but its alias, %s, "
00889 "will only be defined %s",
00890 strupr( old_name), new_name,
00891 in_what_node( current_device_node) );
00892 show_node_start();
00893 }
00894 }
00895 }
00896
00897 return ( retval );
00898 }
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908
00909
00910
00911
00912
00913
00914
00915
00916
00917 static tic_hdr_t tokens_table[] =
00918 {
00919 BUILTIN_FCODE( 0x000, "end0" ) ,
00920 BUILTIN_FCODE( 0x010, "b(lit)" ) ,
00921 BUILTIN_FCODE( 0x011, "b(')" ) ,
00922 BUILTIN_FCODE( 0x012, "b(\")" ) ,
00923 BUILTIN_FCODE( 0x013, "bbranch" ) ,
00924 BUILTIN_FCODE( 0x014, "b?branch" ) ,
00925 BUILTIN_FCODE( 0x015, "b(loop)" ) ,
00926 BUILTIN_FCODE( 0x016, "b(+loop)" ) ,
00927 BUILTIN_FCODE( 0x017, "b(do)" ) ,
00928 BUILTIN_FCODE( 0x018, "b(?do)" ) ,
00929 BUILTIN_FCODE( 0x019, "i" ) ,
00930 BUILTIN_FCODE( 0x01a, "j" ) ,
00931 BUILTIN_FCODE( 0x01b, "b(leave)" ) ,
00932 BUILTIN_FCODE( 0x01c, "b(of)" ) ,
00933 BUILTIN_FCODE( 0x01d, "execute" ) ,
00934 BUILTIN_FCODE( 0x01e, "+" ) ,
00935 BUILTIN_FCODE( 0x01f, "-" ) ,
00936 BUILTIN_FCODE( 0x020, "*" ) ,
00937 BUILTIN_FCODE( 0x021, "/" ) ,
00938 BUILTIN_FCODE( 0x022, "mod" ) ,
00939 BUILTIN_FCODE( 0x023, "and" ) ,
00940 BUILTIN_FCODE( 0x024, "or" ) ,
00941 BUILTIN_FCODE( 0x025, "xor" ) ,
00942 BUILTIN_FCODE( 0x026, "invert" ) ,
00943 BUILTIN_FCODE( 0x026, "not" ) ,
00944 BUILTIN_FCODE( 0x027, "lshift" ) ,
00945 BUILTIN_FCODE( 0x027, "<<" ) ,
00946 BUILTIN_FCODE( 0x028, "rshift" ) ,
00947 BUILTIN_FCODE( 0x028, ">>" ) ,
00948 BUILTIN_FCODE( 0x029, ">>a" ) ,
00949 BUILTIN_FCODE( 0x02a, "/mod" ) ,
00950 BUILTIN_FCODE( 0x02b, "u/mod" ) ,
00951 BUILTIN_FCODE( 0x02c, "negate" ) ,
00952 BUILTIN_FCODE( 0x02d, "abs" ) ,
00953 BUILTIN_FCODE( 0x02e, "min" ) ,
00954 BUILTIN_FCODE( 0x02f, "max" ) ,
00955 BUILTIN_FCODE( 0x030, ">r" ) ,
00956 BUILTIN_FCODE( 0x031, "r>" ) ,
00957 BUILTIN_FCODE( 0x032, "r@" ) ,
00958 BUILTIN_FCODE( 0x033, "exit" ) ,
00959 BUILTIN_FCODE( 0x034, "0=" ) ,
00960 BUILTIN_FCODE( 0x035, "0<>" ) ,
00961 BUILTIN_FCODE( 0x036, "0<" ) ,
00962 BUILTIN_FCODE( 0x037, "0<=" ) ,
00963 BUILTIN_FCODE( 0x038, "0>" ) ,
00964 BUILTIN_FCODE( 0x039, "0>=" ) ,
00965 BUILTIN_FCODE( 0x03a, "<" ) ,
00966 BUILTIN_FCODE( 0x03b, ">" ) ,
00967 BUILTIN_FCODE( 0x03c, "=" ) ,
00968 BUILTIN_FCODE( 0x03d, "<>" ) ,
00969 BUILTIN_FCODE( 0x03e, "u>" ) ,
00970 BUILTIN_FCODE( 0x03f, "u<=" ) ,
00971 BUILTIN_FCODE( 0x040, "u<" ) ,
00972 BUILTIN_FCODE( 0x041, "u>=" ) ,
00973 BUILTIN_FCODE( 0x042, ">=" ) ,
00974 BUILTIN_FCODE( 0x043, "<=" ) ,
00975 BUILTIN_FCODE( 0x044, "between" ) ,
00976 BUILTIN_FCODE( 0x045, "within" ) ,
00977 BUILTIN_FCODE( 0x046, "drop" ) ,
00978 BUILTIN_FCODE( 0x047, "dup" ) ,
00979 BUILTIN_FCODE( 0x048, "over" ) ,
00980 BUILTIN_FCODE( 0x049, "swap" ) ,
00981 BUILTIN_FCODE( 0x04A, "rot" ) ,
00982 BUILTIN_FCODE( 0x04b, "-rot" ) ,
00983 BUILTIN_FCODE( 0x04c, "tuck" ) ,
00984 BUILTIN_FCODE( 0x04d, "nip" ) ,
00985 BUILTIN_FCODE( 0x04e, "pick" ) ,
00986 BUILTIN_FCODE( 0x04f, "roll" ) ,
00987 BUILTIN_FCODE( 0x050, "?dup" ) ,
00988 BUILTIN_FCODE( 0x051, "depth" ) ,
00989 BUILTIN_FCODE( 0x052, "2drop" ) ,
00990 BUILTIN_FCODE( 0x053, "2dup" ) ,
00991 BUILTIN_FCODE( 0x054, "2over" ) ,
00992 BUILTIN_FCODE( 0x055, "2swap" ) ,
00993 BUILTIN_FCODE( 0x056, "2rot" ) ,
00994 BUILTIN_FCODE( 0x057, "2/" ) ,
00995 BUILTIN_FCODE( 0x058, "u2/" ) ,
00996 BUILTIN_FCODE( 0x059, "2*" ) ,
00997 BUILTIN_FCODE( 0x05a, "/c" ) ,
00998 BUILTIN_FCODE( 0x05b, "/w" ) ,
00999 BUILTIN_FCODE( 0x05c, "/l" ) ,
01000 BUILTIN_FCODE( 0x05d, "/n" ) ,
01001 BUILTIN_FCODE( 0x05e, "ca+" ) ,
01002 BUILTIN_FCODE( 0x05f, "wa+" ) ,
01003 BUILTIN_FCODE( 0x060, "la+" ) ,
01004 BUILTIN_FCODE( 0x061, "na+" ) ,
01005 BUILTIN_FCODE( 0x062, "char+" ) ,
01006 BUILTIN_FCODE( 0x062, "ca1+" ) ,
01007 BUILTIN_FCODE( 0x063, "wa1+" ) ,
01008 BUILTIN_FCODE( 0x064, "la1+" ) ,
01009 BUILTIN_FCODE( 0x065, "cell+" ) ,
01010 BUILTIN_FCODE( 0x065, "na1+" ) ,
01011 BUILTIN_FCODE( 0x066, "chars" ) ,
01012 BUILTIN_FCODE( 0x066, "/c*" ) ,
01013 BUILTIN_FCODE( 0x067, "/w*" ) ,
01014 BUILTIN_FCODE( 0x068, "/l*" ) ,
01015 BUILTIN_FCODE( 0x069, "cells" ) ,
01016 BUILTIN_FCODE( 0x069, "/n*" ) ,
01017 BUILTIN_FCODE( 0x06a, "on" ) ,
01018 BUILTIN_FCODE( 0x06b, "off" ) ,
01019 BUILTIN_FCODE( 0x06c, "+!" ) ,
01020 BUILTIN_FCODE( 0x06d, "@" ) ,
01021 BUILTIN_FCODE( 0x06e, "l@" ) ,
01022 BUILTIN_FCODE( 0x06f, "w@" ) ,
01023 BUILTIN_FCODE( 0x070, "<w@" ) ,
01024 BUILTIN_FCODE( 0x071, "c@" ) ,
01025 BUILTIN_FCODE( 0x072, "!" ) ,
01026 BUILTIN_FCODE( 0x073, "l!" ) ,
01027 BUILTIN_FCODE( 0x074, "w!" ) ,
01028 BUILTIN_FCODE( 0x075, "c!" ) ,
01029 BUILTIN_FCODE( 0x076, "2@" ) ,
01030 BUILTIN_FCODE( 0x077, "2!" ) ,
01031 BUILTIN_FCODE( 0x078, "move" ) ,
01032 BUILTIN_FCODE( 0x079, "fill" ) ,
01033 BUILTIN_FCODE( 0x07a, "comp" ) ,
01034 BUILTIN_FCODE( 0x07b, "noop" ) ,
01035 BUILTIN_FCODE( 0x07c, "lwsplit" ) ,
01036 BUILTIN_FCODE( 0x07d, "wljoin" ) ,
01037 BUILTIN_FCODE( 0x07e, "lbsplit" ) ,
01038 BUILTIN_FCODE( 0x07f, "bljoin" ) ,
01039 BUILTIN_FCODE( 0x080, "wbflip" ) ,
01040 BUILTIN_FCODE( 0x080, "flip" ) ,
01041 BUILTIN_FCODE( 0x081, "upc" ) ,
01042 BUILTIN_FCODE( 0x082, "lcc" ) ,
01043 BUILTIN_FCODE( 0x083, "pack" ) ,
01044 BUILTIN_FCODE( 0x084, "count" ) ,
01045 BUILTIN_FCODE( 0x085, "body>" ) ,
01046 BUILTIN_FCODE( 0x086, ">body" ) ,
01047 BUILTIN_FCODE( 0x087, "fcode-revision" ) ,
01048 BUILTIN_FCODE( 0x087, "version" ) ,
01049 BI_FCODE_VRBLE( 0x088, "span" ) ,
01050 BUILTIN_FCODE( 0x089, "unloop" ) ,
01051 BUILTIN_FCODE( 0x08a, "expect" ) ,
01052 BUILTIN_FCODE( 0x08b, "alloc-mem" ) ,
01053 BUILTIN_FCODE( 0x08c, "free-mem" ) ,
01054 BUILTIN_FCODE( 0x08d, "key?" ) ,
01055 BUILTIN_FCODE( 0x08e, "key" ) ,
01056 BUILTIN_FCODE( 0x08f, "emit" ) ,
01057 BUILTIN_FCODE( 0x090, "type" ) ,
01058 BUILTIN_FCODE( 0x091, "(cr" ) ,
01059 BUILTIN_FCODE( 0x092, "cr" ) ,
01060 BI_FCODE_VRBLE( 0x093, "#out" ) ,
01061 BI_FCODE_VRBLE( 0x094, "#line" ) ,
01062 BUILTIN_FCODE( 0x095, "hold" ) ,
01063 BUILTIN_FCODE( 0x096, "<#" ) ,
01064 BUILTIN_FCODE( 0x097, "u#>" ) ,
01065 BUILTIN_FCODE( 0x098, "sign" ) ,
01066 BUILTIN_FCODE( 0x099, "u#" ) ,
01067 BUILTIN_FCODE( 0x09a, "u#s" ) ,
01068 BUILTIN_FCODE( 0x09b, "u." ) ,
01069 BUILTIN_FCODE( 0x09c, "u.r" ) ,
01070 BUILTIN_FCODE( 0x09d, "." ) ,
01071 BUILTIN_FCODE( 0x09e, ".r" ) ,
01072 BUILTIN_FCODE( 0x09f, ".s" ) ,
01073 BI_FCODE_VRBLE( 0x0a0, "base" ) ,
01074 OBSOLETE_FCODE( 0x0a1, "convert" ) ,
01075 BUILTIN_FCODE( 0x0a2, "$number" ) ,
01076 BUILTIN_FCODE( 0x0a3, "digit" ) ,
01077 BI_FCODE_CONST( 0x0a4, "-1" ) ,
01078 BI_FCODE_CONST( 0x0a4, "true" ) ,
01079 BI_FCODE_CONST( 0x0a5, "0" ) ,
01080 BI_FCODE_CONST( 0x0a5, "false" ) ,
01081 BI_FCODE_CONST( 0x0a5, "struct" ) ,
01082 BI_FCODE_CONST( 0x0a6, "1" ) ,
01083 BI_FCODE_CONST( 0x0a7, "2" ) ,
01084 BI_FCODE_CONST( 0x0a8, "3" ) ,
01085 BI_FCODE_CONST( 0x0a9, "bl" ) ,
01086 BI_FCODE_CONST( 0x0aa, "bs" ) ,
01087 BI_FCODE_CONST( 0x0ab, "bell" ) ,
01088 BUILTIN_FCODE( 0x0ac, "bounds" ) ,
01089 BUILTIN_FCODE( 0x0ad, "here" ) ,
01090 BUILTIN_FCODE( 0x0ae, "aligned" ) ,
01091 BUILTIN_FCODE( 0x0af, "wbsplit" ) ,
01092 BUILTIN_FCODE( 0x0b0, "bwjoin" ) ,
01093 BUILTIN_FCODE( 0x0b1, "b(<mark)" ) ,
01094 BUILTIN_FCODE( 0x0b2, "b(>resolve)" ) ,
01095 OBSOLETE_FCODE( 0x0b3, "set-token-table" ) ,
01096 OBSOLETE_FCODE( 0x0b4, "set-table" ) ,
01097 BUILTIN_FCODE( 0x0b5, "new-token" ) ,
01098 BUILTIN_FCODE( 0x0b6, "named-token" ) ,
01099 BUILTIN_FCODE( 0x0b7, "b(:)" ) ,
01100 BUILTIN_FCODE( 0x0b8, "b(value)" ) ,
01101 BUILTIN_FCODE( 0x0b9, "b(variable)" ) ,
01102 BUILTIN_FCODE( 0x0ba, "b(constant)" ) ,
01103 BUILTIN_FCODE( 0x0bb, "b(create)" ) ,
01104 BUILTIN_FCODE( 0x0bc, "b(defer)" ) ,
01105 BUILTIN_FCODE( 0x0bd, "b(buffer:)" ) ,
01106 BUILTIN_FCODE( 0x0be, "b(field)" ) ,
01107 OBSOLETE_FCODE( 0x0bf, "b(code)" ) ,
01108 BUILTIN_FCODE( 0x0c0, "instance" ) ,
01109 BUILTIN_FCODE( 0x0c2, "b(;)" ) ,
01110 BUILTIN_FCODE( 0x0c3, "b(to)" ) ,
01111 BUILTIN_FCODE( 0x0c4, "b(case)" ) ,
01112 BUILTIN_FCODE( 0x0c5, "b(endcase)" ) ,
01113 BUILTIN_FCODE( 0x0c6, "b(endof)" ) ,
01114 BUILTIN_FCODE( 0x0c7, "#" ) ,
01115 BUILTIN_FCODE( 0x0c8, "#s" ) ,
01116 BUILTIN_FCODE( 0x0c9, "#>" ) ,
01117 BUILTIN_FCODE( 0x0ca, "external-token" ) ,
01118 BUILTIN_FCODE( 0x0cb, "$find" ) ,
01119 BUILTIN_FCODE( 0x0cc, "offset16" ) ,
01120 BUILTIN_FCODE( 0x0cd, "evaluate" ) ,
01121 BUILTIN_FCODE( 0x0cd, "eval" ) ,
01122 BUILTIN_FCODE( 0x0d0, "c," ) ,
01123 BUILTIN_FCODE( 0x0d1, "w," ) ,
01124 BUILTIN_FCODE( 0x0d2, "l," ) ,
01125 BUILTIN_FCODE( 0x0d3, "," ) ,
01126 BUILTIN_FCODE( 0x0d4, "um*" ) ,
01127 BUILTIN_FCODE( 0x0d4, "u*x" ) ,
01128 BUILTIN_FCODE( 0x0d5, "um/mod" ) ,
01129 BUILTIN_FCODE( 0x0d5, "xu/mod" ) ,
01130 BUILTIN_FCODE( 0x0d8, "d+" ) ,
01131 BUILTIN_FCODE( 0x0d8, "x+" ) ,
01132 BUILTIN_FCODE( 0x0d9, "d-" ) ,
01133 BUILTIN_FCODE( 0x0d9, "x-" ) ,
01134 BUILTIN_FCODE( 0x0da, "get-token" ) ,
01135 BUILTIN_FCODE( 0x0db, "set-token" ) ,
01136 BI_FCODE_VRBLE( 0x0dc, "state" ) ,
01137 BUILTIN_FCODE( 0x0dd, "compile" ) ,
01138 BUILTIN_FCODE( 0x0de, "behavior" ) ,
01139 BUILTIN_FCODE( 0x0f0, "start0" ) ,
01140 BUILTIN_FCODE( 0x0f1, "start1" ) ,
01141 BUILTIN_FCODE( 0x0f2, "start2" ) ,
01142 BUILTIN_FCODE( 0x0f3, "start4" ) ,
01143 BUILTIN_FCODE( 0x0fc, "ferror" ) ,
01144 BUILTIN_FCODE( 0x0fd, "version1" ) ,
01145 OBSOLETE_FCODE( 0x0fe, "4-byte-id" ) ,
01146 BUILTIN_FCODE( 0x0ff, "end1" ) ,
01147 OBSOLETE_FCODE( 0x101, "dma-alloc" ) ,
01148 BUILTIN_FCODE( 0x102, "my-address" ) ,
01149 BUILTIN_FCODE( 0x103, "my-space" ) ,
01150 OBSOLETE_FCODE( 0x104, "memmap" ) ,
01151 BUILTIN_FCODE( 0x105, "free-virtual" ) ,
01152 OBSOLETE_FCODE( 0x106, ">physical" ) ,
01153 OBSOLETE_FCODE( 0x10f, "my-params" ) ,
01154 BUILTIN_FCODE( 0x110, "property" ) ,
01155 BUILTIN_FCODE( 0x110, "attribute" ) ,
01156 BUILTIN_FCODE( 0x111, "encode-int" ) ,
01157 BUILTIN_FCODE( 0x111, "xdrint" ) ,
01158 BUILTIN_FCODE( 0x112, "encode+" ) ,
01159 BUILTIN_FCODE( 0x112, "xdr+" ) ,
01160 BUILTIN_FCODE( 0x113, "encode-phys" ) ,
01161 BUILTIN_FCODE( 0x113, "xdrphys" ) ,
01162 BUILTIN_FCODE( 0x114, "encode-string" ) ,
01163 BUILTIN_FCODE( 0x114, "xdrstring" ) ,
01164 BUILTIN_FCODE( 0x115, "encode-bytes" ) ,
01165 BUILTIN_FCODE( 0x115, "xdrbytes" ) ,
01166 BUILTIN_FCODE( 0x116, "reg" ) ,
01167 OBSOLETE_FCODE( 0x117, "intr" ) ,
01168 OBSOLETE_FCODE( 0x118, "driver" ) ,
01169 BUILTIN_FCODE( 0x119, "model" ) ,
01170 BUILTIN_FCODE( 0x11a, "device-type" ) ,
01171 BUILTIN_FCODE( 0x11b, "parse-2int" ) ,
01172 BUILTIN_FCODE( 0x11b, "decode-2int" ) ,
01173 BUILTIN_FCODE( 0x11c, "is-install" ) ,
01174 BUILTIN_FCODE( 0x11d, "is-remove" ) ,
01175 BUILTIN_FCODE( 0x11e, "is-selftest" ) ,
01176 BUILTIN_FCODE( 0x11f, "new-device" ) ,
01177 BUILTIN_FCODE( 0x120, "diagnostic-mode?" ) ,
01178 BUILTIN_FCODE( 0x121, "display-status" ) ,
01179 BUILTIN_FCODE( 0x122, "memory-test-issue" ) ,
01180 OBSOLETE_FCODE( 0x123, "group-code" ) ,
01181 BI_FCODE_VRBLE( 0x124, "mask" ) ,
01182 BUILTIN_FCODE( 0x125, "get-msecs" ) ,
01183 BUILTIN_FCODE( 0x126, "ms" ) ,
01184 BUILTIN_FCODE( 0x127, "finish-device" ) ,
01185 BUILTIN_FCODE( 0x128, "decode-phys" ) ,
01186 BUILTIN_FCODE( 0x12b, "interpose" ) ,
01187 BUILTIN_FCODE( 0x130, "map-low" ) ,
01188 BUILTIN_FCODE( 0x130, "map-sbus" ) ,
01189 BUILTIN_FCODE( 0x131, "sbus-intr>cpu" ) ,
01190 BI_FCODE_VALUE( 0x150, "#lines" ) ,
01191 BI_FCODE_VALUE( 0x151, "#columns" ) ,
01192 BI_FCODE_VALUE( 0x152, "line#" ) ,
01193 BI_FCODE_VALUE( 0x153, "column#" ) ,
01194 BI_FCODE_VALUE( 0x154, "inverse?" ) ,
01195 BI_FCODE_VALUE( 0x155, "inverse-screen?" ) ,
01196 OBSOLETE_VALUE( 0x156, "frame-buffer-busy?" ) ,
01197 BI_FCODE_DEFER( 0x157, "draw-character" ) ,
01198 BI_FCODE_DEFER( 0x158, "reset-screen" ) ,
01199 BI_FCODE_DEFER( 0x159, "toggle-cursor" ) ,
01200 BI_FCODE_DEFER( 0x15a, "erase-screen" ) ,
01201 BI_FCODE_DEFER( 0x15b, "blink-screen" ) ,
01202 BI_FCODE_DEFER( 0x15c, "invert-screen" ) ,
01203 BI_FCODE_DEFER( 0x15d, "insert-characters" ) ,
01204 BI_FCODE_DEFER( 0x15e, "delete-characters" ) ,
01205 BI_FCODE_DEFER( 0x15f, "insert-lines" ) ,
01206 BI_FCODE_DEFER( 0x160, "delete-lines" ) ,
01207 BI_FCODE_DEFER( 0x161, "draw-logo" ) ,
01208 BI_FCODE_VALUE( 0x162, "frame-buffer-adr" ) ,
01209 BI_FCODE_VALUE( 0x163, "screen-height" ) ,
01210 BI_FCODE_VALUE( 0x164, "screen-width" ) ,
01211 BI_FCODE_VALUE( 0x165, "window-top" ) ,
01212 BI_FCODE_VALUE( 0x166, "window-left" ) ,
01213 BUILTIN_FCODE( 0x16a, "default-font" ) ,
01214 BUILTIN_FCODE( 0x16b, "set-font" ) ,
01215 BI_FCODE_VALUE( 0x16c, "char-height" ) ,
01216 BI_FCODE_VALUE( 0x16d, "char-width" ) ,
01217 BUILTIN_FCODE( 0x16e, ">font" ) ,
01218 BI_FCODE_VALUE( 0x16f, "fontbytes" ) ,
01219 OBSOLETE_FCODE( 0x170, "fb1-draw-character" ) ,
01220 OBSOLETE_FCODE( 0x171, "fb1-reset-screen" ) ,
01221 OBSOLETE_FCODE( 0x172, "fb1-toggle-cursor" ) ,
01222 OBSOLETE_FCODE( 0x173, "fb1-erase-screen" ) ,
01223 OBSOLETE_FCODE( 0x174, "fb1-blink-screen" ) ,
01224 OBSOLETE_FCODE( 0x175, "fb1-invert-screen" ) ,
01225 OBSOLETE_FCODE( 0x176, "fb1-insert-characters" ) ,
01226 OBSOLETE_FCODE( 0x177, "fb1-delete-characters" ) ,
01227 OBSOLETE_FCODE( 0x178, "fb1-insert-lines" ) ,
01228 OBSOLETE_FCODE( 0x179, "fb1-delete-lines" ) ,
01229 OBSOLETE_FCODE( 0x17a, "fb1-draw-logo" ) ,
01230 OBSOLETE_FCODE( 0x17b, "fb1-install" ) ,
01231 OBSOLETE_FCODE( 0x17c, "fb1-slide-up" ) ,
01232 BUILTIN_FCODE( 0x180, "fb8-draw-character" ) ,
01233 BUILTIN_FCODE( 0x181, "fb8-reset-screen" ) ,
01234 BUILTIN_FCODE( 0x182, "fb8-toggle-cursor" ) ,
01235 BUILTIN_FCODE( 0x183, "fb8-erase-screen" ) ,
01236 BUILTIN_FCODE( 0x184, "fb8-blink-screen" ) ,
01237 BUILTIN_FCODE( 0x185, "fb8-invert-screen" ) ,
01238 BUILTIN_FCODE( 0x186, "fb8-insert-characters" ) ,
01239 BUILTIN_FCODE( 0x187, "fb8-delete-characters" ) ,
01240 BUILTIN_FCODE( 0x188, "fb8-insert-lines" ) ,
01241 BUILTIN_FCODE( 0x189, "fb8-delete-lines" ) ,
01242 BUILTIN_FCODE( 0x18a, "fb8-draw-logo" ) ,
01243 BUILTIN_FCODE( 0x18b, "fb8-install" ) ,
01244 OBSOLETE_FCODE( 0x1a0, "return-buffer" ) ,
01245 OBSOLETE_FCODE( 0x1a1, "xmit-packet" ) ,
01246 OBSOLETE_FCODE( 0x1a2, "poll-packet" ) ,
01247 BUILTIN_FCODE( 0x1a4, "mac-address" ) ,
01248 BUILTIN_FCODE( 0x201, "device-name" ) ,
01249 BUILTIN_FCODE( 0x201, "name" ) ,
01250 BUILTIN_FCODE( 0x202, "my-args" ) ,
01251 BI_FCODE_VALUE( 0x203, "my-self" ) ,
01252 BUILTIN_FCODE( 0x204, "find-package" ) ,
01253 BUILTIN_FCODE( 0x205, "open-package" ) ,
01254 BUILTIN_FCODE( 0x206, "close-package" ) ,
01255 BUILTIN_FCODE( 0x207, "find-method" ) ,
01256 BUILTIN_FCODE( 0x208, "call-package" ) ,
01257 BUILTIN_FCODE( 0x209, "$call-parent" ) ,
01258 BUILTIN_FCODE( 0x20a, "my-parent" ) ,
01259 BUILTIN_FCODE( 0x20b, "ihandle>phandle" ) ,
01260 BUILTIN_FCODE( 0x20d, "my-unit" ) ,
01261 BUILTIN_FCODE( 0x20e, "$call-method" ) ,
01262 BUILTIN_FCODE( 0x20f, "$open-package" ) ,
01263 OBSOLETE_FCODE( 0x210, "processor-type" ) ,
01264 OBSOLETE_FCODE( 0x211, "firmware-version" ) ,
01265 OBSOLETE_FCODE( 0x212, "fcode-version" ) ,
01266 BUILTIN_FCODE( 0x213, "alarm" ) ,
01267 BUILTIN_FCODE( 0x214, "(is-user-word)" ) ,
01268 BUILTIN_FCODE( 0x215, "suspend-fcode" ) ,
01269 BUILTIN_FCODE( 0x216, "abort" ) ,
01270 BUILTIN_FCODE( 0x217, "catch" ) ,
01271 BUILTIN_FCODE( 0x218, "throw" ) ,
01272 BUILTIN_FCODE( 0x219, "user-abort" ) ,
01273 BUILTIN_FCODE( 0x21a, "get-my-property" ) ,
01274 BUILTIN_FCODE( 0x21a, "get-my-attribute" ) ,
01275 BUILTIN_FCODE( 0x21b, "decode-int" ) ,
01276 BUILTIN_FCODE( 0x21b, "xdrtoint" ) ,
01277 BUILTIN_FCODE( 0x21c, "decode-string" ) ,
01278 BUILTIN_FCODE( 0x21c, "xdrtostring" ),
01279 BUILTIN_FCODE( 0x21d, "get-inherited-property" ) ,
01280 BUILTIN_FCODE( 0x21d, "get-inherited-attribute" ) ,
01281 BUILTIN_FCODE( 0x21e, "delete-property" ) ,
01282 BUILTIN_FCODE( 0x21e, "delete-attribute" ) ,
01283 BUILTIN_FCODE( 0x21f, "get-package-property" ) ,
01284 BUILTIN_FCODE( 0x21f, "get-package-attribute" ) ,
01285 BUILTIN_FCODE( 0x220, "cpeek" ) ,
01286 BUILTIN_FCODE( 0x221, "wpeek" ) ,
01287 BUILTIN_FCODE( 0x222, "lpeek" ) ,
01288 BUILTIN_FCODE( 0x223, "cpoke" ) ,
01289 BUILTIN_FCODE( 0x224, "wpoke" ) ,
01290 BUILTIN_FCODE( 0x225, "lpoke" ) ,
01291 BUILTIN_FCODE( 0x226, "lwflip" ) ,
01292 BUILTIN_FCODE( 0x227, "lbflip" ) ,
01293 BUILTIN_FCODE( 0x228, "lbflips" ) ,
01294 OBSOLETE_FCODE( 0x229, "adr-mask" ) ,
01295 BUILTIN_FCODE( 0x230, "rb@" ) ,
01296 BUILTIN_FCODE( 0x231, "rb!" ) ,
01297 BUILTIN_FCODE( 0x232, "rw@" ) ,
01298 BUILTIN_FCODE( 0x233, "rw!" ) ,
01299 BUILTIN_FCODE( 0x234, "rl@" ) ,
01300 BUILTIN_FCODE( 0x235, "rl!" ) ,
01301 BUILTIN_FCODE( 0x236, "wbflips" ) ,
01302 BUILTIN_FCODE( 0x236, "wflips" ) ,
01303 BUILTIN_FCODE( 0x237, "lwflips" ) ,
01304 BUILTIN_FCODE( 0x237, "lflips" ) ,
01305 OBSOLETE_FCODE( 0x238, "probe" ) ,
01306 OBSOLETE_FCODE( 0x239, "probe-virtual" ) ,
01307 BUILTIN_FCODE( 0x23b, "child" ) ,
01308 BUILTIN_FCODE( 0x23c, "peer" ) ,
01309 BUILTIN_FCODE( 0x23d, "next-property" ) ,
01310 BUILTIN_FCODE( 0x23e, "byte-load" ) ,
01311 BUILTIN_FCODE( 0x23f, "set-args" ) ,
01312 BUILTIN_FCODE( 0x240, "left-parse-string" ) ,
01313
01314
01315 BUILTIN_FCODE( 0x22e, "rx@" ) ,
01316 BUILTIN_FCODE( 0x22f, "rx!" ) ,
01317 BUILTIN_FCODE( 0x241, "bxjoin" ) ,
01318 BUILTIN_FCODE( 0x242, "<l@" ) ,
01319 BUILTIN_FCODE( 0x243, "lxjoin" ) ,
01320 BUILTIN_FCODE( 0x244, "wxjoin" ) ,
01321 BUILTIN_FCODE( 0x245, "x," ) ,
01322 BUILTIN_FCODE( 0x246, "x@" ) ,
01323 BUILTIN_FCODE( 0x247, "x!" ) ,
01324 BUILTIN_FCODE( 0x248, "/x" ) ,
01325 BUILTIN_FCODE( 0x249, "/x*" ) ,
01326 BUILTIN_FCODE( 0x24a, "xa+" ) ,
01327 BUILTIN_FCODE( 0x24b, "xa1+" ) ,
01328 BUILTIN_FCODE( 0x24c, "xbflip" ) ,
01329 BUILTIN_FCODE( 0x24d, "xbflips" ) ,
01330 BUILTIN_FCODE( 0x24e, "xbsplit" ) ,
01331 BUILTIN_FCODE( 0x24f, "xlflip" ) ,
01332 BUILTIN_FCODE( 0x250, "xlflips" ) ,
01333 BUILTIN_FCODE( 0x251, "xlsplit" ) ,
01334 BUILTIN_FCODE( 0x252, "xwflip" ) ,
01335 BUILTIN_FCODE( 0x253, "xwflips" ) ,
01336 BUILTIN_FCODE( 0x254, "xwsplit" )
01337 };
01338
01339 static const int number_of_builtin_tokens =
01340 sizeof(tokens_table)/sizeof(tic_hdr_t);
01341
01342
01343
01344
01345
01346
01347
01348
01349
01350
01351
01352
01353
01354
01355
01356
01357
01358
01359
01360
01361
01362
01363
01364
01365
01366
01367
01368
01369
01370
01371
01372
01373
01374
01375
01376
01377
01378
01379
01380 void emit_token( const char *fc_name)
01381 {
01382
01383 if ( handle_tic_vocab( (char *)fc_name, fc_tokens_list_start) )
01384 {
01385 return;
01386 }
01387
01388 tokenization_error( FATAL, "Did not recognize FCode name %s", fc_name);
01389 }
01390
01391
01392
01393
01394
01395
01396
01397
01398
01399
01400
01401
01402
01403
01404
01405
01406
01407
01408
01409
01410 tic_hdr_t *lookup_token( char *tname)
01411 {
01412 tic_hdr_t *found ;
01413
01414 found = lookup_tic_entry( tname, fc_tokens_list_start);
01415 return ( found ) ;
01416 }
01417
01418
01419
01420
01421
01422
01423
01424
01425
01426
01427
01428
01429
01430
01431
01432
01433
01434
01435
01436
01437
01438
01439
01440
01441
01442
01443
01444
01445
01446
01447
01448
01449
01450
01451
01452
01453
01454
01455 bool entry_is_token( tic_hdr_t *test_entry )
01456 {
01457 bool retval = FALSE;
01458 if ( test_entry != NULL )
01459 {
01460 if ( ( test_entry->funct == FC_TOKEN_FUNC ) ||
01461 ( test_entry->funct == OBSO_FC_FUNC ) )
01462 {
01463 retval = TRUE;
01464 }
01465 }
01466 return ( retval );
01467 }
01468
01469
01470
01471
01472
01473
01474
01475
01476
01477
01478
01479
01480
01481
01482
01483
01484
01485
01486
01487
01488
01489
01490
01491
01492
01493 void token_entry_warning( tic_hdr_t *t_entry)
01494 {
01495 if ( t_entry->funct == OBSO_FC_FUNC )
01496 {
01497 obsolete_warning();
01498 }
01499 }
01500
01501
01502
01503
01504
01505
01506
01507
01508 static tic_fwt_hdr_t fwords_list[] = {
01509
01510 BI_FWD_SKP_OW(COLON, ":") ,
01511 BUILTIN_FWORD(SEMICOLON, ";") ,
01512 BI_FWD_SKP_OW(TICK, "'") ,
01513 BUILTIN_FWORD(AGAIN, "again") ,
01514 BI_FWD_SKP_OW(BRACK_TICK, "[']") ,
01515 BI_FWD_SKP_OW(ASCII, "ascii") ,
01516 BUILTIN_FWORD(BEGIN, "begin") ,
01517 BI_FWD_SKP_OW(BUFFER, "buffer:") ,
01518 BUILTIN_FWORD(CASE, "case") ,
01519 BI_FWD_SKP_OW(CONST, "constant") ,
01520 BI_FWD_SKP_OW(CONTROL, "control") ,
01521 BI_FWD_SKP_OW(CREATE, "create") ,
01522
01523 BI_FWD_SKP_OW(DEFER, "defer") ,
01524 BUILTIN_FWORD(CDO, "?do") ,
01525 BUILTIN_FWORD(DO, "do") ,
01526 BUILTIN_FWORD(ELSE, "else") ,
01527 BUILTIN_FWORD(ENDCASE, "endcase") ,
01528 BUILTIN_FWORD(ENDOF, "endof") ,
01529 BUILTIN_FWORD(EXTERNAL, "external") ,
01530 BI_FWD_SKP_OW(FIELD, "field") ,
01531 BUILTIN_FWORD(FINISH_DEVICE, "finish-device" ) ,
01532 BUILTIN_FWORD(HEADERLESS, "headerless") ,
01533 BUILTIN_FWORD(HEADERS, "headers") ,
01534
01535 BUILTIN_FWORD(INSTANCE , "instance") ,
01536
01537 BUILTIN_FWORD(IF, "if") ,
01538 BUILTIN_FWORD(UNLOOP, "unloop") ,
01539 BUILTIN_FWORD(LEAVE, "leave") ,
01540 BUILTIN_FWORD(PLUS_LOOP, "+loop") ,
01541 BUILTIN_FWORD(LOOP, "loop") ,
01542
01543 BUILTIN_FWORD(OF, "of") ,
01544 BUILTIN_FWORD(REPEAT, "repeat") ,
01545 BUILTIN_FWORD(THEN, "then") ,
01546 BI_FWD_SKP_OW(TO, "to") ,
01547 BI_FWD_SKP_OW(IS, "is") ,
01548 BUILTIN_FWORD(UNTIL, "until") ,
01549 BI_FWD_SKP_OW(VALUE, "value") ,
01550 BI_FWD_SKP_OW(VARIABLE, "variable") ,
01551 BUILTIN_FWORD(WHILE, "while") ,
01552 BUILTIN_FWORD(OFFSET16, "offset16") ,
01553
01554 BI_FWD_STRING(STRING, "\"") ,
01555 BI_FWD_STRING(PSTRING, ".\"") ,
01556 BI_FWD_STRING(PBSTRING, ".(") ,
01557 BI_FWD_STRING(SSTRING, "s\"") ,
01558 BUILTIN_FWORD(IFILE_NAME, "[input-file-name]"),
01559 BUILTIN_FWORD(ILINE_NUM, "[line-number]"),
01560 BUILTIN_FWORD(RECURSE, "recurse") ,
01561 BUILTIN_FWORD(RECURSIVE, "recursive") ,
01562 BUILTIN_FWORD(RET_STK_FETCH, "r@") ,
01563 BUILTIN_FWORD(RET_STK_FROM, "r>") ,
01564 BUILTIN_FWORD(RET_STK_TO, ">r") ,
01565 BUILTIN_FWORD(THEN, "endif" ) ,
01566 BUILTIN_FWORD(NEW_DEVICE, "new-device" ) ,
01567 BUILTIN_FWORD(LOOP_I, "i") ,
01568 BUILTIN_FWORD(LOOP_J, "j") ,
01569
01570
01571 BUILTIN_FWORD(VERSION1, "version1") ,
01572 BUILTIN_FWORD(START0, "start0") ,
01573 BUILTIN_FWORD(START1, "start1") ,
01574 BUILTIN_FWORD(START2, "start2") ,
01575 BUILTIN_FWORD(START4, "start4") ,
01576 BUILTIN_FWORD(END0, "end0") ,
01577 BUILTIN_FWORD(END1, "end1") ,
01578 BUILTIN_FWORD(FCODE_V1, "fcode-version1") ,
01579 BUILTIN_FWORD(FCODE_V2, "fcode-version2") ,
01580 BUILTIN_FWORD(FCODE_V3, "fcode-version3") ,
01581 BUILTIN_FWORD(FCODE_END, "fcode-end") ,
01582
01583
01584 BI_FWD_STRING(CURLY_BRACE, "{") ,
01585 BI_FWD_STRING(DASH_ARROW, "->") ,
01586 BUILTIN_FWORD(EXIT, "exit") ,
01587
01588
01589 BUILTIN_FWORD(CHAR, "char") ,
01590 BUILTIN_FWORD(CCHAR, "[char]") ,
01591 BI_FWD_STRING(ABORTTXT, "abort\"") ,
01592
01593 BUILTIN_FWORD(ENCODEFILE, "encode-file") ,
01594
01595 BI_IG_FW_HDLR(ESCAPETOK, "tokenizer[") ,
01596 BI_IG_FW_HDLR(ESCAPETOK, "f[") ,
01597 };
01598
01599 static const int number_of_builtin_fwords =
01600 sizeof(fwords_list)/sizeof(tic_hdr_t);
01601
01602
01603
01604
01605
01606
01607
01608
01609
01610 static tic_fwt_hdr_t shared_words_list[] = {
01611 SHARED_FWORD(FLOAD, "fload") ,
01612
01613 SHR_SAMIG_FWRD(ALLOW_MULTI_LINE, "multi-line") ,
01614
01615 SHR_FWD_SKOW( F_BRACK_TICK, "f[']") ,
01616
01617 SH_FW_SK2WIL(ALIAS, "alias") ,
01618 SHARED_FWORD(DECIMAL, "decimal") ,
01619 SHARED_FWORD(HEX, "hex") ,
01620 SHARED_FWORD(OCTAL, "octal") ,
01621 SH_FW_SK_WIL(HEXVAL, "h#") ,
01622 SH_FW_SK_WIL(DECVAL, "d#") ,
01623 SH_FW_SK_WIL(OCTVAL, "o#") ,
01624
01625 SH_FW_SK_WIL(ASC_NUM, "a#") ,
01626 SH_FW_SK_WIL(ASC_LEFT_NUM, "al#") ,
01627
01628
01629 SHARED_FWORD(FLITERAL, "fliteral") ,
01630
01631
01632 SH_FW_SK_WIL(DEFINED, "[defined]") ,
01633 SH_FW_SK_WIL(DEFINED, "#defined") ,
01634 SH_FW_SK_WIL(DEFINED, "[#defined]") ,
01635
01636
01637
01638 SHARED_FWORD(FCODE_DATE, "[fcode-date]") ,
01639 SHARED_FWORD(FCODE_TIME, "[fcode-time]") ,
01640
01641
01642 SHARED_FWORD(FUNC_NAME, "[function-name]"),
01643
01644
01645
01646
01647
01648
01649
01650
01651 SHARED_FWORD(CONDL_ELSE, "#else") ,
01652 SHARED_FWORD(CONDL_ELSE, "[else]") ,
01653 SHARED_FWORD(CONDL_ELSE, "[#else]") ,
01654
01655
01656 SHARED_FWORD(CONDL_ENDER, "#then") ,
01657 SHARED_FWORD(CONDL_ENDER, "[then]") ,
01658 SHARED_FWORD(CONDL_ENDER, "[#then]") ,
01659
01660 SHARED_FWORD(CONDL_ENDER, "#endif") ,
01661 SHARED_FWORD(CONDL_ENDER, "[endif]") ,
01662 SHARED_FWORD(CONDL_ENDER, "[#endif]") ,
01663
01664
01665 SHARED_FWORD(OVERLOAD, "overload" ) ,
01666
01667 SHARED_FWORD(GLOB_SCOPE , "global-definitions" ) ,
01668 SHARED_FWORD(DEV_SCOPE , "device-definitions" ) ,
01669
01670
01671 SH_FW_SK_WIL(CL_FLAG, "[FLAG]") ,
01672 SH_FW_SK_WIL(CL_FLAG, "#FLAG") ,
01673 SH_FW_SK_WIL(CL_FLAG, "[#FLAG]") ,
01674
01675
01676 SHARED_FWORD(SHOW_CL_FLAGS, "[FLAGS]") ,
01677 SHARED_FWORD(SHOW_CL_FLAGS, "#FLAGS") ,
01678 SHARED_FWORD(SHOW_CL_FLAGS, "[#FLAGS]") ,
01679 SHARED_FWORD(SHOW_CL_FLAGS, "SHOW-FLAGS") ,
01680
01681
01682 SHARED_FWORD(PUSH_FCODE, "FCODE-PUSH") ,
01683 SHARED_FWORD(POP_FCODE, "FCODE-POP") ,
01684
01685
01686
01687
01688 SHARED_FWORD(RESET_FCODE, "FCODE-RESET") ,
01689
01690
01691
01692
01693
01694 SHARED_FWORD(PCIHDR, "pci-header") ,
01695 SHARED_FWORD(PCIEND, "pci-end") ,
01696 SHARED_FWORD(PCIEND, "pci-header-end") ,
01697 SHARED_FWORD(PCIREV, "pci-revision") ,
01698 SHARED_FWORD(PCIREV, "pci-code-revision") ,
01699 SHARED_FWORD(PCIREV, "set-rev-level") ,
01700 SHARED_FWORD(NOTLAST, "not-last-image") ,
01701 SHARED_FWORD(NOTLAST, "not-last-img") ,
01702 SHARED_FWORD(ISLAST, "last-image") ,
01703 SHARED_FWORD(ISLAST, "last-img") ,
01704 SHARED_FWORD(SETLAST, "set-last-image") ,
01705 SHARED_FWORD(SETLAST, "set-last-img") ,
01706
01707 SH_FW_SK_WIL(SAVEIMG, "save-image") ,
01708 SH_FW_SK_WIL(SAVEIMG, "save-img") ,
01709
01710 SHARED_FWORD(RESETSYMBS, "reset-symbols") ,
01711
01712
01713 SHARED_IG_HDLR("[MACRO]", add_user_macro, 0 , skip_user_macro) ,
01714
01715
01716 SHARED_IG_HDLR("\\", process_remark, '\n', process_remark) ,
01717 SHARED_IG_HDLR("(", process_remark, ')', process_remark) ,
01718
01719
01720 SHARED_IG_HDLR("[MESSAGE]", user_message, '\n', skip_user_message) ,
01721 SHARED_IG_HDLR("#MESSAGE", user_message, '\n', skip_user_message) ,
01722 SHARED_IG_HDLR("[#MESSAGE]", user_message, '\n', skip_user_message) ,
01723 SHARED_IG_HDLR("#MESSAGE\"", user_message, '"' , skip_user_message) ,
01724 };
01725
01726 static const int number_of_shared_words =
01727 sizeof(shared_words_list)/sizeof(tic_hdr_t);
01728
01729
01730
01731
01732
01733
01734
01735
01736
01737
01738
01739
01740
01741
01742
01743
01744
01745
01746
01747
01748
01749
01750
01751
01752
01753
01754
01755
01756
01757
01758
01759
01760
01761 tic_hdr_t *lookup_shared_word( char *tname)
01762 {
01763 tic_hdr_t *found ;
01764 tic_hdr_t *retval = NULL ;
01765
01766 found = lookup_current( tname );
01767 if ( found != NULL )
01768 {
01769 if ( found->fword_defr == COMMON_FWORD )
01770 {
01771 retval = found ;
01772 }
01773 }
01774
01775 return ( retval );
01776
01777 }
01778
01779
01780
01781
01782
01783
01784
01785
01786
01787
01788
01789
01790
01791
01792
01793
01794
01795
01796
01797
01798 bool handle_shared_word( char *tname )
01799 {
01800 tic_hdr_t *found ;
01801 bool retval = FALSE;
01802
01803 found = lookup_shared_word( tname );
01804 if ( found != NULL )
01805 {
01806 found->funct(found->pfield);
01807 retval = TRUE;
01808 }
01809
01810 return ( retval ) ;
01811 }
01812
01813
01814
01815
01816
01817
01818
01819
01820
01821
01822
01823
01824
01825
01826
01827
01828
01829
01830
01831
01832
01833
01834
01835
01836
01837
01838
01839
01840
01841
01842
01843
01844
01845
01846 tic_hdr_t *lookup_shared_f_exec_word( char *tname)
01847 {
01848 tic_hdr_t *found ;
01849 tic_hdr_t *retval = NULL ;
01850
01851 found = lookup_shared_word( tname );
01852 if ( found != NULL )
01853 {
01854 if ( found->funct == FWORD_EXEC_FUNC )
01855 {
01856 retval = found ;
01857 }
01858 }
01859
01860 return ( retval );
01861
01862 }
01863
01864
01865
01866
01867
01868
01869
01870
01871
01872
01873
01874
01875
01876
01877
01878
01879
01880
01881
01882
01883
01884
01885
01886
01887
01888
01889
01890
01891
01892
01893
01894
01895
01896
01897
01898
01899
01900
01901
01902
01903
01904
01905
01906
01907
01908
01909
01910
01911 void init_dictionary( void )
01912 {
01913
01914 global_voc_dict_ptr = NULL;
01915
01916
01917 fc_tokens_list_ender = global_voc_dict_ptr;
01918 init_tic_vocab( tokens_table,
01919 number_of_builtin_tokens,
01920 &global_voc_dict_ptr ) ;
01921 fc_tokens_list_start = global_voc_dict_ptr;
01922
01923
01924 init_tic_vocab( (tic_hdr_t *)fwords_list,
01925 number_of_builtin_fwords,
01926 &global_voc_dict_ptr ) ;
01927
01928
01929 shared_fwords_ender = global_voc_dict_ptr;
01930 init_tic_vocab( (tic_hdr_t *)shared_words_list,
01931 number_of_shared_words,
01932 &global_voc_dict_ptr ) ;
01933
01934
01935 init_conditionals_vocab( &global_voc_dict_ptr ) ;
01936
01937
01938 init_macros( &global_voc_dict_ptr ) ;
01939
01940
01941 global_voc_reset_ptr = global_voc_dict_ptr;
01942
01943
01944 init_tokz_esc_vocab();
01945
01946
01947
01948 }
01949
01950
01951
01952
01953
01954
01955
01956
01957
01958
01959
01960
01961
01962
01963
01964
01965
01966
01967
01968
01969
01970
01971
01972
01973
01974
01975
01976
01977
01978
01979
01980
01981
01982
01983
01984
01985
01986
01987
01988
01989
01990
01991
01992
01993
01994 void reset_normal_vocabs( void )
01995 {
01996 reset_tic_vocab( &global_voc_dict_ptr, global_voc_reset_ptr );
01997
01998
01999
02000
02001
02002 do
02003 {
02004 if ( current_device_node->parent_node != NULL )
02005 {
02006 tokenization_error( TKERROR,
02007 "Missing FINISH-DEVICE for new device");
02008 started_at( current_device_node->ifile_name,
02009 current_device_node->line_no );
02010 }
02011 delete_device_vocab();
02012 } while ( current_device_node->parent_node != NULL );
02013
02014 }
02015
02016
02017
02018
02019
02020
02021
02022
02023
02024
02025
02026
02027
02028
02029
02030
02031
02032
02033
02034
02035
02036
02037
02038
02039
02040
02041 void reset_vocabs( void )
02042 {
02043 reset_normal_vocabs();
02044 reset_tokz_esc();
02045 }