/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ /** The actual routine to return one Symbol. This is normally called from * next_token(), but for debugging purposes can be called indirectly from * debug_next_token(). */ protected static Symbol real_next_token() { int sym_num; for (;;) { /* look for white space */ if (next_char == ' ' || next_char == '\t' || next_char == '\n' || next_char == '\f' || next_char == '\r') { /* advance past it and try the next character */ advance(); continue; } /* look for a single character symbol */ sym_num = find_single_char(next_char); if (sym_num != -1) { /* found one -- advance past it and return a Symbol for it */ advance(); return(new Symbol(sym_num)); } /* look for : or ::= */ if (next_char == ':') { /* if we don't have a second ':' return COLON */ if (next_char2 != ':') { advance(); return(new Symbol(sym.COLON)); } /* move forward and look for the '=' */ advance(); if (next_char2 == '=') { advance(); advance(); return(new Symbol(sym.COLON_COLON_EQUALS)); } else { /* return just the colon (already consumed) */ return(new Symbol(sym.COLON)); } } /* find a "%prec" string and return it. otherwise, a '%' was found, * which has no right being in the specification otherwise */ if (next_char == '%') { advance(); if ((next_char == 'p') && (next_char2 == 'r') && (next_char3 == 'e') && (next_char4 == 'c')) { advance(); advance(); advance(); advance(); return(new Symbol(sym.PERCENT_PREC)); } else { emit_error("Found extraneous percent sign"); } } /* look for a comment */ if (next_char == '/' && (next_char2 == '*' || next_char2 == '/')) { /* swallow then continue the scan */ swallow_comment(); continue; } /* look for start of code string */ if (next_char == '{' && next_char2 == ':') { return(do_code_string()); } /* look for an id or keyword */ if (id_start_char(next_char)) { return(do_id()); } if (next_char == '#' && current_position == 1 && (next_char2 == 'u') && (next_char3 == 's') && (next_char4 == 'e')) { //https://github.com/TypeCobolTeam/TypeCobol/issues/1000 //#use directive must appears as the first character in the line. //Read the whole line after the #use directive and trim it as being the file path to be included. string useLine = System.Console.In.ReadLine(); current_line += 1; lexer.InitLookaheads(); return(LexerContext.HandleUseDirective(useLine?.Trim())); } /* look for EOF */ if (next_char == EOF_CHAR) { return(new Symbol(sym.EOF)); } /* if we get here, we have an unrecognized character */ emit_warn("Unrecognized character '" + next_char + "'(" + next_char + ") -- ignored"); /* advance past it */ advance(); } }