mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-02-25 20:51:38 +00:00
lexer now turns '(' into an operator if noops=false
This commit is contained in:
parent
1a2c3c505c
commit
bc94d3f5b8
2 changed files with 11 additions and 1 deletions
11
lexer.c
11
lexer.c
|
@ -701,9 +701,18 @@ int lex_do(lex_file *lex)
|
||||||
/* single-character tokens */
|
/* single-character tokens */
|
||||||
switch (ch)
|
switch (ch)
|
||||||
{
|
{
|
||||||
case ';':
|
|
||||||
case '(':
|
case '(':
|
||||||
|
if (!lex_tokench(lex, ch) ||
|
||||||
|
!lex_endtoken(lex))
|
||||||
|
{
|
||||||
|
return (lex->tok->ttype = TOKEN_FATAL);
|
||||||
|
}
|
||||||
|
if (lex->flags.noops)
|
||||||
|
return (lex->tok->ttype = ch);
|
||||||
|
else
|
||||||
|
return (lex->tok->ttype = TOKEN_OPERATOR);
|
||||||
case ')':
|
case ')':
|
||||||
|
case ';':
|
||||||
case '{':
|
case '{':
|
||||||
case '}':
|
case '}':
|
||||||
case '[':
|
case '[':
|
||||||
|
|
1
lexer.h
1
lexer.h
|
@ -142,6 +142,7 @@ static const oper_info operators[] = {
|
||||||
{ "--", 1, opid3('S','-','-'), ASSOC_LEFT, 16, OP_SUFFIX},
|
{ "--", 1, opid3('S','-','-'), ASSOC_LEFT, 16, OP_SUFFIX},
|
||||||
|
|
||||||
{ ".", 2, opid1('.'), ASSOC_LEFT, 15, 0 },
|
{ ".", 2, opid1('.'), ASSOC_LEFT, 15, 0 },
|
||||||
|
{ "(", 0, opid1('('), ASSOC_LEFT, 15, OP_SUFFIX },
|
||||||
|
|
||||||
{ "!", 1, opid2('!', 'P'), ASSOC_RIGHT, 14, OP_PREFIX },
|
{ "!", 1, opid2('!', 'P'), ASSOC_RIGHT, 14, OP_PREFIX },
|
||||||
{ "~", 1, opid2('~', 'P'), ASSOC_RIGHT, 14, OP_PREFIX },
|
{ "~", 1, opid2('~', 'P'), ASSOC_RIGHT, 14, OP_PREFIX },
|
||||||
|
|
Loading…
Reference in a new issue