Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
    • Help
    • Support
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
dynare
dynare
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
    • Cycle Analytics
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Charts
  • Issues 115
    • Issues 115
    • List
    • Boards
    • Labels
    • Milestones
  • Merge Requests 6
    • Merge Requests 6
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Charts
  • Packages
    • Packages
    • Container Registry
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Dynare
  • dynaredynare
  • Issues
  • #1578

Closed
Open
Opened Jan 12, 2018 by Johannes Pfeifer @JohannesPfeifer
  • Report abuse
  • New issue
Report abuse New issue

macro-processor: allow for nested variables

  1. Related to https://forum.dynare.org/t/total-number-of-periods-given-by-variable/11200/3

We should allow

@#define J=10
@#define K=1:@{J}

but currently the lexer gives an error when encountering the @{J} in the second line.

  1. Related to this, according to the manual, we have at the command line -DMACRO_VARIABLE=MACRO_EXPRESSION But we do not really macro expressions as dynare macro.mod -D=[1,2] fails.

  2. I tried to get around this by using

n_countries=2;
fid=fopen('n_countries_def.txt','w+');
fprintf(fid,'@#for co in 1:%u\n',n_countries)
fclose(fid)

to write a text file creating the first statement and then using

@#include "n_countries_def.txt"
var C_@{co};
@#endfor

But this is also not allowed:

ERROR in macro-processor: n_countries_def.txt:1.15: @#for loop not matched by an @#endfor or file does not end with a new line (unexpected end of file)

because apparently the macro processor checks for completeness of the macro in each included file instead of the whole created file.

Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
2
Labels
bug macroprocessor
Assign labels
  • View project labels
Reference: Dynare/dynare#1578