From 9288d5142c5a282a1ad8342140ba779af5cf1932 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemia=20=28Scylla=29?= Date: Tue, 5 Feb 2019 22:03:19 +0100 Subject: [PATCH] Add model_local_variable declaration for declaring model local variables with tex names Manually cherry-picked from 628c4cf27bc4180a0e4bf284201b86abed167a81. --- py/pygment/dynare.py | 2 +- src/source/the-model-file.rst | 36 +++++++++++++++++++++++++++-------- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/py/pygment/dynare.py b/py/pygment/dynare.py index b2b31b8fd..08bd8513e 100644 --- a/py/pygment/dynare.py +++ b/py/pygment/dynare.py @@ -33,7 +33,7 @@ class DynareLexer(RegexLexer): filenames = ['*.mod'] commands = ( - "dynare","var","varexo","varexo_det","parameters","change_type", + "dynare","var","varexo","varexo_det","parameters","change_type","model_local_variable", "predetermined_variables","trend_var","log_trend_var","external_function", "write_latex_original_model","write_latex_dynamic_model", "write_latex_static_model","resid","initval_file","histval_file","dsample", diff --git a/src/source/the-model-file.rst b/src/source/the-model-file.rst index 466de31eb..b3c44bcb4 100644 --- a/src/source/the-model-file.rst +++ b/src/source/the-model-file.rst @@ -376,6 +376,8 @@ for declaring variables and parameters are described below. *Example* + :: + trend_var (growth_factor=gA) A; @@ -386,6 +388,21 @@ for declaring variables and parameters are described below. the log of a variable with a multiplicative trend). +.. command:: model_local_variable VARIABLE_NAME [LATEX_NAME]... ; + + This optional command declares a model local variable. See + :ref:`conv` for the syntax of VARIABLE_NAME. As you can create + model local variables on the fly in the model block (see + :ref:`model-decl`), the interest of this command is primarily to + assign a LATEX_NAME to the model local variable. + + *Example* + + :: + + model_local_variable GDP_US $GDPUS$; + + .. _expr: Expressions @@ -750,17 +767,20 @@ The model is declared inside a ``model`` block: MODEL_EXPRESSION; - |br| Inside the model block, Dynare allows the creation of *model-local - variables*, which constitute a simple way to share a common - expression between several equations. The syntax consists of a - pound sign (#) followed by the name of the new model local - variable (which must **not** be declared as in :ref:`var-decl`), - an equal sign, and the expression for which this new variable will + |br| Inside the model block, Dynare allows the creation of + *model-local variables*, which constitute a simple way to share a + common expression between several equations. The syntax consists + of a pound sign (#) followed by the name of the new model local + variable (which must **not** be declared as in :ref:`var-decl`, + but may have been declared by :comm:`model_local_variable`), an + equal sign, and the expression for which this new variable will stand. Later on, every time this variable appears in the model, Dynare will substitute it by the expression assigned to the variable. Note that the scope of this variable is restricted to - the model block; it cannot be used outside. A model local variable - declaration looks like: + the model block; it cannot be used outside. To assign a LaTeX name + to the model local variable, use the declaration syntax outlined + by :comm:`model_local_variable`. A model local variable declaration + looks like: #VARIABLE_NAME = MODEL_EXPRESSION;