Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
L ldpl
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 8
    • Issues 8
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Lartu
  • ldpl
  • Merge requests
  • !124

Merged
Created Jun 21, 2019 by Damián Garro@dgarroContributor

PARAMETERS, LOCAL DATA & CREATE STATEMENT

  • Overview 13
  • Commits 18
  • Changes 2

This resolves #113 (closed). Currently only LOCAL DATA section is implemented for now, I'll implement PARAMETERS later, you can review and test the code in the meantime.

Example:

DATA:
  x is number
PROCEDURE:
  sub-procedure foo
    LOCAL DATA:
      i is number
    PROCEDURE:
      incr i
      display "FOO " i crlf
  end sub-procedure
  sub-procedure bar
    LOCAL DATA:
      i is text
    PROCEDURE:
       join i and "-" in i
      display "BAR " i crlf
  end sub-procedure
  for x from 0 to 10 step 1 do
    call foo
    call bar
  repeat

Output:

FOO 1
BAR -
FOO 2
BAR --
FOO 3
BAR ---
FOO 4
BAR ----
FOO 5
BAR -----
FOO 6
BAR ------
FOO 7
BAR -------
FOO 8
BAR --------
FOO 9
BAR ---------
FOO 10
BAR ----------

All the variable declaration statements where merged to only one if to reduce duplicated code.

We store in which subprocedure a variable was declared and when we expect some variable we search it in the current subprocedure and main variables. The function variable_type handles this.

To keep the variable values persistent, we fix the C++ identifier based on the subprocedure (for example, LVAR_SUBPR_FOO_VAR_I) and declare it as a global variable.

The PROCEDURE: label is optional if the subprocedure only has procedure statements. This was implemented with the in_procedure_section function.

Assignee
Assign to
Reviewer
Request review from
None
Milestone
None
Assign milestone
Time tracking
Source branch: github/fork/dgarroDC/local-data