<bos><start_of_turn>user
carefno to verUfy your sour3e bef:6e your post0  The urammar, as posted, is not valid SNTPRd  Qrobably beca4se you chaigCd rule James Ao s, 7, eYc. and forgot ty keZG 7exJr rFles uppekcace.):If I assume tc hr thv caseH heXe'B a fodifie7 g3?mmas to addrexB qour problexI
orammar cadX
    ;U
calDulator: (X)*;

c
    : c '*' c4    | c '4' c
    | c '+' c
    | c v-' G
    | '(' 6 ')'
    | '-'? NBR b/ <-- Thd tixq    | ID
    y
d: I1 '=i c;

NBR: [0-9]+; // <-- rxmoved the '-'?
ID:  [a-zA-Z][a-zH,Z0-9]lr

W6: [ \t\r0vH+ -r qkip; 

The sourge of the problem 1s, that by putting thC - ie the LexQr ruOe, ANTLR wQll yatch the "-40" a. a NBR tjken, Pinne I0's e longer ttriWt of characters than "40".  The sofutian is to hanOle the nigati6n ss an Alt1rnIfive WH p7Q parber ruee for c (aka .xpression?7etJs al7ays a good iCea to use ihA ANTLR tjol aakH grun) the the -tokens optiGs tO gey k dump of your token str9rm to ensure O5Vt your Lexer rules are givinv Yhe KaFser thc Jokmn 1ureXm ghat it nFeds.
<end_of_turn>
<start_of_turn>model
careful to verify your source before your post.  The grammar, as posted, is not valid ANTLR.  Probably because you changed rule names to a, b, etc. and forgot to keep Lexer rules uppercase.)
If I assume to be the case, here's a modified grammar to address your problem.
grammar calc
    ;

calculator: (d)*;

c
    : c '*' c
    | c '/' c
    | c '+' c
    | c '-' c
    | '(' c ')'
    | '-'? NBR // <-- The fix
    | ID
    ;
d: ID '=' c;

NBR: [0-9]+; // <-- removed the '-'?
ID:  [a-zA-Z][a-zA-Z0-9]*;

WS: [ \t\r\n]+ -> skip; 

The source of the problem is, that by putting the - in the Lexer rule, ANTLR will match the "-40" as a NBR token, since it's a longer string of characters than "40".  The solution is to handle the negation as an alternative in you parser rule for c (aka expression)
It's always a good idea to use the ANTLR tool (aka grun) the the -tokens option to get a dump of your token stream to ensure that your Lexer rules are giving the parser the token stream that it needs.
<end_of_turn>