Jeffrey Arnold avatar Jeffrey Arnold committed ba9777f

update StanLexer for changes in Stan 1.0.2

Comments (0)

Files changed (2)


     filenames = ['*.stan']
     _RESERVED = ('for', 'in', 'while', 'repeat', 'until', 'if',
-                'then', 'else', 'true', 'false', 'T')
+                 'then', 'else', 'true', 'false', 'T', 
+                 'lower', 'upper', 'print')
     _TYPES = ('int', 'real', 'vector', 'simplex', 'ordered', 'row_vector',
-              'matrix', 'corr_matrix', 'cov_matrix')
+              'matrix', 'corr_matrix', 'cov_matrix', 'positive_ordered')
     # STAN 1.0 Manual, Chapter 20
     _CONSTANTS = ['pi', 'e', 'sqrt2', 'log2', 'log10', 'nan', 'infinity',
                   'epsilon', 'negative_epsilon']
     _FUNCTIONS = ['abs', 'int_step', 'min', 'max',
-                  'if_else', 'step',
-                  'fabs', 'fdim',
-                  'fmin', 'fmax',
-                  'fmod',
+                  'if_else', 'step', 'fabs', 'fdim', 'fmin', 'fmax', 'fmod',
                   'floor', 'ceil', 'round', 'trunc',
                   'sqrt', 'cbrt', 'square', 'exp', 'exp2', 'expm1',
                   'log', 'log2', 'log10', 'pow', 'logit', 'inv_logit',
             (r'(//|#).*$', Comment.Single),
         'root': [
+            # Stan is more restrictive on strings than this regex
+            (r'"[^"]*"', String),
             # Comments
             # block start
             return 1.0
             return 0.0


      matrix[3,3] qux;
      simplex[3] quux;
      ordered[3] corge;
+     positive_ordered[3] wibble;
      corr_matrix[3] grault;
      cov_matrix[3] garply;
    // normal_log as a function
    lp__ <- lp__ + normal_log(plugh, 0, 1);
+   // print statement and string literal
+   print("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_~@#$%^&*`'-+={}[].,;: ");
+   print("Hello, world!");
+   print("");
 generated quantities {
    real bar1;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.