In CORE mode I am trying to write something like this:
local oDt1 as DateTime
local oDt2 as DateTime
oDt1 := DateTime{...}
oDt2 := Dt1:Date
and I receive this:
error XS9002: Parser: unexpected input ':DATE'
Compilation failed (1 error)
How can I get a date value from oDt1 variable?
I use XIDE.
Regards
Jacek
DateTime Class
DateTime Class
Stefan,
exactly I have:
LOCAL oDt1 AS Nullable<DateTime>
LOCAL oDt2 AS Nullable<DateTime>
and
oDt2 := oDt1:Value:@@Date
works for me.
Thank you
Jacek
exactly I have:
LOCAL oDt1 AS Nullable<DateTime>
LOCAL oDt2 AS Nullable<DateTime>
and
oDt2 := oDt1:Value:@@Date
works for me.
Thank you
Jacek
DateTime Class
As Stefan said, DATE is a keyword.
Adding a @@ tells the compiler preprocessor (parser) not to touch the word that follows it.
https://www.xsharp.eu/help/x-keywords.html
Dev Team
I think the compile time error should be more explanatory.
Like:
error XS9002: Parser: a keyword is used ':DATE'. Use @@ before keyword. Compilation failed (1 error).
Or maybe X# intellisense can detect such situations and suggest a fix when writing such code.
Adding a @@ tells the compiler preprocessor (parser) not to touch the word that follows it.
https://www.xsharp.eu/help/x-keywords.html
Dev Team
I think the compile time error should be more explanatory.
Like:
error XS9002: Parser: a keyword is used ':DATE'. Use @@ before keyword. Compilation failed (1 error).
Or maybe X# intellisense can detect such situations and suggest a fix when writing such code.
DateTime Class
Hmm, interesting idea about intellisense doing this automatically...
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
DateTime Class
Hi Chris,
I think intellisense should notice that xx:Date is a property and not a keyword.
Also the parser should recognize xx:Date as a property and not the Type DATE.
Regards,
Stefan
I think intellisense should notice that xx:Date is a property and not a keyword.
Also the parser should recognize xx:Date as a property and not the Type DATE.
Regards,
Stefan
DateTime Class
Hi Stefan,
The problem is not that Date is a property and a type, but that DATE is also a keyword, similar to "CLASS", "FUNCTION" etc. And the parser works with rules, which specify in what places a keyword can exist, and there's no rule saying "DATE" can exist after a ":", hence the parser error.
One solution could be to remove DATE from the keywords list, and maybe handle it later resolving it to the Date type. Or make a rule that DATE should not be treated as a keyword after ":". But doing such stuff increases the complexity of the parser and compiler, and of course it is not enough to do it just for DATE, it has to be done for dozens more keywords as well...
But I agree about intellisense, it could indeed identify you are autocompleting an expression with a token that is also a keyword and in this case automatically add the "@@". Btw, the VOXporter already does that, for X#keywords that were not keywords in VO.
The problem is not that Date is a property and a type, but that DATE is also a keyword, similar to "CLASS", "FUNCTION" etc. And the parser works with rules, which specify in what places a keyword can exist, and there's no rule saying "DATE" can exist after a ":", hence the parser error.
One solution could be to remove DATE from the keywords list, and maybe handle it later resolving it to the Date type. Or make a rule that DATE should not be treated as a keyword after ":". But doing such stuff increases the complexity of the parser and compiler, and of course it is not enough to do it just for DATE, it has to be done for dozens more keywords as well...
But I agree about intellisense, it could indeed identify you are autocompleting an expression with a token that is also a keyword and in this case automatically add the "@@". Btw, the VOXporter already does that, for X#keywords that were not keywords in VO.
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu