Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » RPGLE - String Literal Parsing(Rules to parse strings in the RPGLE langle)
RPGLE - String Literal Parsing [message #1791986] Mon, 09 July 2018 11:01 Go to next message
Christoff Erasmus is currently offline Christoff ErasmusFriend
Messages: 32
Registered: December 2016
Member
I would like to be able to correctly parse strings as defined for the RPGLE language.

Attached are some example strings that I would like to be able to parse.

Request:
Please help me, work out the logic to correctly parse the example strings attached.

This issues I am encountering relates to the following:

Issue 1 - Escape Characters:

  • Strings Literals are contained in single quotes, 'I am a Simple String'
  • Strings with nested quotes are escaped with another single quote. 'I have a nested '' in me'
  • No other escape characters allowed


Issue 2 - String Literal Continuation:

    For character, date, time, and timestamp literals :
  • A hyphen (-) indicates continuation is in the first available position in the continued field (=> Aka Blanks Honored)
  • A plus (+) indicates continuation with the first non-blank character in or past the first position in the continued field (=> Aka Blanks NOT Honored)


References
IBM Knowledge Center - Continuation Rules for RPGLE
Re: RPGLE - String Literal Parsing [message #1791988 is a reply to message #1791986] Mon, 09 July 2018 11:20 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

for (1) since you share nothing with us i am not sure what you expect what did you try? e.g. the most naive thing
terminal STRING:
	"'" (!"'"|"''")* "'"
;

is (2) not a value converter thingy (so should not be treated in the parser itself


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: RPGLE - String Literal Parsing [message #1792002 is a reply to message #1791988] Mon, 09 July 2018 15:53 Go to previous message
Christoff Erasmus is currently offline Christoff ErasmusFriend
Messages: 32
Registered: December 2016
Member
Thanks for the help.

For my future self:
https://www.eclipse.org/forums/index.php?t=msg&th=1078680&goto=1736332&#msg_1736332
https://www.eclipse.org/forums/index.php?t=msg&th=170689&goto=542524&#msg_542524
http://pettergraff.blogspot.com/2009/11/xtext-valueconverter.html
Previous Topic:Formatting Scientific Notation
Next Topic:Handling terminals without assigned feature, for code generation
Goto Forum:
  


Current Time: Fri Apr 26 09:59:23 GMT 2024

Powered by FUDForum. Page generated in 0.03294 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top