Lines Matching refs:scs

51   } *scs;
353 fprintf(stderr, "file %s line %d: ", TT.scs->filename, TT.scs->line_num);
728 TT.scs->filename = TT.scs->prog_args->arg;
729 TT.scs->prog_args = TT.scs->prog_args->next;
730 TT.scs->fp = stdin;
731 if (strcmp(TT.scs->filename, "-")) TT.scs->fp = fopen(TT.scs->filename, "r");
732 if (!TT.scs->fp) error_exit("Can't open %s", TT.scs->filename);
733 TT.scs->line_num = 0;
739 // On first entry, TT.scs->p points to progstring if any, or null string.
741 int c = *(TT.scs->p)++;
745 if (TT.scs->progstring) { // Fake newline at end of progstring.
746 if (TT.scs->progstring == nl) return EOF;
747 TT.scs->p = TT.scs->progstring = nl;
751 if (TT.scs->line == nl) return EOF;
752 if (!TT.scs->fp) {
758 int lastchar = (TT.scs->p)[-2];
759 TT.scs->line_len = getline(&TT.scs->line, &TT.scs->line_size, TT.scs->fp);
760 if (TT.scs->line_len > 0) {
761 TT.scs->line_num++;
762 TT.scs->p = TT.scs->line;
767 fclose(TT.scs->fp);
768 TT.scs->fp = 0;
769 TT.scs->p = " " + 2;
770 if (!TT.scs->prog_args) {
771 xfree(TT.scs->line);
774 TT.scs->line = TT.scs->p = nl;
781 if (TT.scs->toklen == TT.scs->maxtok - 1) {
782 TT.scs->maxtok *= 2;
783 TT.scs->tokstr = xrealloc(TT.scs->tokstr, TT.scs->maxtok);
785 TT.scs->tokstr[TT.scs->toklen++] = c;
786 TT.scs->tokstr[TT.scs->toklen] = 0;
793 TT.scs->ch = get_char();
794 } while (TT.scs->ch == '\r');
799 append_this_char(TT.scs->ch);
809 if (TT.scs->toklen >= 10) return 0;
810 strcat(s, TT.scs->tokstr);
822 strcat(s, TT.scs->tokstr);
841 // Assumes TT.scs->ch is digit or dot on entry.
842 // TT.scs->p points to the following character.
850 TT.scs->numval = strtod(TT.scs->p - 1, &leftover);
851 len = leftover - TT.scs->p + 1;
854 TT.scs->toktype = ERROR;
855 TT.scs->tok = tkerr;
856 TT.scs->error = 1;
857 FFATAL("Unexpected token '%s'\n", TT.scs->tokstr);
867 while (TT.scs->ch != endchar) {
868 if (TT.scs->ch == '\n') {
873 } else if (TT.scs->ch == '\\') {
877 if (TT.scs->ch == '\n') { // backslash newline is continuation
880 } else if ((p = strchr(escapes, TT.scs->ch))) {
888 } else if (TT.scs->ch == 'x') {
890 if (isxdigit(TT.scs->ch)) {
891 int c = hexval(TT.scs->ch);
893 if (isxdigit(TT.scs->ch)) {
894 c = c * 16 + hexval(TT.scs->ch);
899 } else if (TT.scs->ch == 'u') {
901 if (isxdigit(TT.scs->ch)) {
905 codep[j++] = TT.scs->ch;
907 } while (j < 8 && isxdigit(TT.scs->ch));
912 } else if (isdigit(TT.scs->ch)) {
913 if (TT.scs->ch < '8') {
916 if (isdigit(TT.scs->ch) && TT.scs->ch < '8') {
917 c = c * 8 + TT.scs->ch - '0';
930 if (!strchr(".[]()*+?{}|^$-", TT.scs->ch)) {
931 XERR("warning: '\\%c' -- unknown regex escape\n", TT.scs->ch);
935 XERR("warning: '\\%c' treated as plain '%c'\n", TT.scs->ch, TT.scs->ch);
938 } else if (TT.scs->ch == EOF) {
951 TT.scs->tokbuiltin = 0;
952 TT.scs->toklen = 0;
953 TT.scs->tokstr[0] = 0;
954 while (TT.scs->ch == ' ' || TT.scs->ch == '\t')
956 if (TT.scs->ch == '\\') {
958 if (TT.scs->ch == '\n') {
962 TT.scs->toktype = ERROR; // \ not last char in line.
963 TT.scs->tok = tkerr;
964 TT.scs->error = 3;
971 if (TT.scs->ch == '#') {
973 while (TT.scs->ch != '\n')
977 if (TT.scs->ch == '\n') {
978 TT.scs->toktype = NEWLINE;
979 TT.scs->tok = tknl;
981 } else if (isalpha(TT.scs->ch) || TT.scs->ch == '_') {
983 while (isalnum(TT.scs->ch) || TT.scs->ch == '_') {
987 TT.scs->toktype = KEYWORD;
988 TT.scs->tok = n;
990 TT.scs->toktype = BUILTIN;
991 TT.scs->tok = tkbuiltin;
992 TT.scs->tokbuiltin = n;
993 } else if ((TT.scs->ch == '(')) {
994 TT.scs->toktype = USERFUNC;
995 TT.scs->tok = tkfunc;
997 TT.scs->toktype = VAR;
998 TT.scs->tok = tkvar;
1000 while (TT.scs->ch == ' ' || TT.scs->ch == '\t')
1004 } else if (TT.scs->ch == '"') {
1005 TT.scs->toktype = STRING;
1006 TT.scs->tok = tkstring;
1008 } else if (isdigit(TT.scs->ch) || TT.scs->ch == '.') {
1009 TT.scs->toktype = NUMBER;
1010 TT.scs->tok = tknumber;
1012 } else if (TT.scs->ch == '/' && ! div_op_allowed_here) {
1013 TT.scs->toktype = REGEX;
1014 TT.scs->tok = tkregex;
1016 } else if (TT.scs->ch == EOF) {
1017 TT.scs->toktype = EOF;
1018 TT.scs->tok = tkeof;
1019 } else if (TT.scs->ch == '\0') {
1021 TT.scs->toktype = ERROR;
1022 TT.scs->tok = tkerr;
1023 TT.scs->error = 5;
1027 TT.scs->toktype = TT.scs->ch;
1030 if (TT.scs->toktype == '*' && TT.scs->ch == '*') {
1032 if (TT.scs->ch == '=') {
1034 TT.scs->tok = tkpowasgn;
1035 } else TT.scs->tok = tkpow;
1036 TT.scs->toktype = TT.scs->tok + 200;
1040 if (TT.scs->ch != ' ' && TT.scs->ch != '\n') {
1041 append_this_char(TT.scs->ch);
1043 TT.scs->tok = find_token();
1044 TT.scs->toktype = TT.scs->tok + 200;
1048 TT.scs->toklen--; // Not 2-character token; back off.
1049 TT.scs->tokstr[TT.scs->toklen] = 0;
1051 TT.scs->tok = find_token();
1052 if (TT.scs->tok) return;
1053 TT.scs->toktype = ERROR;
1054 TT.scs->tok = tkerr;
1055 TT.scs->error = 4;
1056 FFATAL("Unexpected token '%s'\n", TT.scs->tokstr);
1064 do ascan_opt_div(div_op_allowed_here); while (TT.scs->tok == tkerr);
1081 TT.prevtok = TT.scs->tok;
1084 TT.tokstr = TT.scs->tokstr;
1104 #define CURTOK() (TT.scs->tok)
1105 #define ISTOK(toknum) (TT.scs->tok == (toknum))
1482 if (ISTOK(tkvar) && (TT.scs->ch == ',' || TT.scs->ch == ')')) {
1501 if (ISTOK(tkvar) && (TT.scs->ch == ',' || TT.scs->ch == ')')) {
1536 functk = TT.scs->tokbuiltin;
1561 if (ISTOK(tkvar) && (TT.scs->ch == ',' || TT.scs->ch == ')')) {
1721 gen2cd(tknumber, make_literal_num_val(TT.scs->numval));
1888 // On entry: TT.scs has first symbol of expression, e.g. var, number, string,
4497 TT.scs->p = progstring ? progstring : " " + 2;
4498 TT.scs->progstring = progstring;
4499 TT.scs->prog_args = prog_args;
4500 TT.scs->filename = "(cmdline)";
4501 TT.scs->maxtok = 256;
4502 TT.scs->tokstr = xzalloc(TT.scs->maxtok);
4510 TT.scs = &ss;