Project

General

Profile

Bug #2065

ambiguity in date/decimal literals that is not handled properly by the ProgressLexer

Added by Greg Shah about 11 years ago. Updated over 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Start date:
Due date:
% Done:

0%

Estimated time:
12.00 h
billable:
No
vendor_id:
GCD
case_num:

date_literals_vs_dec_literals.p Magnifier (12.9 KB) Greg Shah, 03/06/2013 01:25 PM

ges_upd20130308a.zip (360 KB) Greg Shah, 03/08/2013 10:48 AM

date_literals_vs_dec_literals.p Magnifier (13.1 KB) Greg Shah, 03/08/2013 10:48 AM

ges_upd20130308b.zip (360 KB) Greg Shah, 03/08/2013 10:56 AM

ges_upd20130308c.zip (360 KB) Greg Shah, 03/08/2013 12:12 PM

ges_upd20130308d.zip (361 KB) Greg Shah, 03/08/2013 02:05 PM

ges_upd20130308e.zip (361 KB) Greg Shah, 03/08/2013 03:28 PM

ges_upd20130308f.zip (267 KB) Greg Shah, 03/08/2013 05:05 PM

ca_upd20130313g.zip - initializer testcase (700 Bytes) Constantin Asofiei, 03/13/2013 02:33 PM

ca_upd20130313f.zip (268 KB) Constantin Asofiei, 03/14/2013 09:56 AM


Related issues

Related to Base Language - Feature #2063: Support negative numbers defined with the "-" on the right side Closed 02/27/2013

History

#1 Updated by Greg Shah about 11 years ago

For details, please see notes 6 and 7 of #2063.

#2 Updated by Greg Shah about 11 years ago

The following testcase shows the limits of this ambiguity.

From the header:

/* date literals can use a . (and -) as a separator; this can occur in ways that */
/* overlap with decimal usage (the same literal input can be both a date and a */
/* decimal; this testcase explores the limits of this behavior */

/* Months: */
/* can't just specify the month */
/* have to be between 1 and 12 inclusive */
/* can be zero padded, there seems to be no practical limit so this is probably dropped */
/* for literals, is always in the first (leftmost) position, no matter what the SESSION:DATE-FORMAT */

/* Days: */
/* have to be between 1 and the highest day of the corresponding month inclusive */
/* can be zero padded, there seems to be no practical limit so this is probably dropped */
/* for literals, is always in the second (middle if there is a year) position, no matter what the SESSION:DATE-FORMAT */

/* Year: */
/* this is optional */
/* for literals, is always in the third (last) position, no matter what the SESSION:DATE-FORMAT */
/* if present, then the date cannot be confused with a decimal literal, so we aren't testing those cases here */

/* most importantly: these "special" date forms can only be used inside a variable */
/* definition initializer!  when encountered in regular code, they are exclusively */
/* treated as decimal literals */

#3 Updated by Greg Shah about 11 years ago

Updated version of the testcase plus the prepared fixes which are going into conversion testing now.

The core solution is about disabling date literal processing in these cases of a DIGITS.DIGITS- and always making it a decimal literal. Then in the var def initializer processing, we detect when this is a date var and we rewrite the decimal literals to be date literals.

Please note that this also includes many other fixes for date, num and dec literal processing. Included are improvements to removing zero padding like the 4GL does and better handling of 64-bit literals.

#4 Updated by Greg Shah about 11 years ago

Fixed a stupid indexing error. Going back into conversion testing.

#5 Updated by Greg Shah about 11 years ago

Another silly mistake, I didn't properly exclude num literals from the trailing zero removal. This updated version is back in conversion testing. I don't expect further problems.

#6 Updated by Greg Shah about 11 years ago

How many times am I going to be wrong today? Majic compiled fine with the c update but there are still many unwanted removals of zero padding. This version resolves those cases. It has gone back into conversion testing.

#7 Updated by Greg Shah about 11 years ago

Final version going through conversion testing now. There was an issue with removal of zeros from the year portion of a date (it affected 1 place in Majic).

#8 Updated by Constantin Asofiei about 11 years ago

Another issue related to dates:

def var d as date init "".

converts to:
  date d = ""; /* compiler error !! */

#9 Updated by Greg Shah about 11 years ago

Passed conversion testing and checked in as revision 10269.

I'll handle the date from an empty string next.

#10 Updated by Greg Shah about 11 years ago

Fix for empty string used as a date var initializer. It is being conversion tested now.

#11 Updated by Greg Shah about 11 years ago

Passed conversion testing and checked in as bzr revision 10272.

#12 Updated by Greg Shah about 11 years ago

  • Status changed from WIP to Closed

#13 Updated by Constantin Asofiei about 11 years ago

The only remaining problem was with char field initializers, which were not handled (it was parsers fault). The notes 113, 114, 116,199 in #2068:
- CA:

One more issue related to initializers. Following is valid in 4GL:

def temp-table tt1 field f1 as char init 0.

- GES:

The places where we "coerce" incompatible types that are used in initializers are in:
1. progress.g in the initializer_constant rule
2. Variable.booleanManhandle()

- CA:

Actually, there is another place where this is done, for character variables: in fixups/variable_initializers. I've tested the date/int/dec/log/char cases (in both fields and vars) and the only problem was to char fields. The solution is to fix the progress.g's initializer_constant rule, to enclose the literal in quotes, if this is a char and the literal is not string or unknown_val. With this, we can remove the fixups in variable_initializers.

I'm putting this through conversion regression testing.

#14 Updated by Constantin Asofiei about 11 years ago

The update has passed conversion regression testing.

#15 Updated by Greg Shah about 11 years ago

I think the wrong update is posted here.

#16 Updated by Constantin Asofiei about 11 years ago

Correct, good letter, wrong date. Attached is the good one.

#17 Updated by Constantin Asofiei about 11 years ago

  • File deleted (ca_upd20130312f.zip)

#18 Updated by Greg Shah about 11 years ago

The update looks good. You can check it in and distribute it.

#19 Updated by Constantin Asofiei about 11 years ago

Committed to bzr revision 10285.

#20 Updated by Greg Shah over 7 years ago

  • Target version changed from Milestone 4 to Conversion Support for Server Features

Also available in: Atom PDF