From anthony_clayden at clear.net.nz Sat Oct 6 05:34:39 2018 From: anthony_clayden at clear.net.nz (Anthony Clayden) Date: Sat, 06 Oct 2018 18:34:39 +1300 Subject: strange code in lexer Message-ID: <5bb8496f.1b1.23c9.11953@clear.net.nz> Reading input.c (as you do - I was modifying to allow TRex label names to start upper-case), there's some strange code in lexing qualified names -- routine yylex(): if (isIn(c0,LARGE)) { /* Look for qualified name */ Text it = readIdent(); /* No keyword begins with LARGE ...*/ if (c0=='.' && isIn(c1,(SMALL|LARGE|SYMBOL))) { Text it2 = NIL; loop: skip(); /* Skip qualifying dot */ if (isIn(c0,SYMBOL)) { /* Qualified operator */ it2 = readOperator(); if (opType==CONOP) { top() = yylval = mkQConOp(it,it2); return QCONOP; } else { top() = yylval = mkQVarOp(it,it2); return QVAROP; } } else { /* Qualified identifier */ it2 = readIdent(); if (identType==CONID) { top() = yylval = mkQCon(it,it2); if (c0=='.' && isIn(c0,(SMALL|LARGE|SYMBOL))) { it = mkNestedQual(yylval); goto loop; } return QCONID; } else { top() = yylval = mkQVar(it,it2); return QVARID; After the first readIdent( ), look for trailing '.' then letter or symbol. ie c0 == '.' && isIn(c1, ...) If a letter; readIdent( ) then look again for trailing '.' then letter or symbol. But that code has c0 == '.' && isIn(c0, ...) That must always return False, surely(?) Testing c0 twice. The second c0 should be c1(?) I've tried breaking it by using a module name 4-dots-deep. But that seemed to work. (Perhaps the yacc detects something and glues it back together? I'm finding that impenetrable.) It if it ain't broke, I'm very loathe to fix it. BTW gotta love that goto to a label called `loop` ;-) AntC