├── examples ├── graph.pdf ├── dyntext.pdf ├── README.md ├── comments.md ├── dyntext.dotex ├── dyntext.domd └── dyntext.md ├── img ├── dyntext_domd.png ├── stata-vscode.png ├── comments-example-output.png ├── comments-example-vscode.png └── comments-example-doeditor.png ├── grammars ├── stata-dyndoc-latex.json ├── stata-dyndoc-md.json ├── stata-dyndoc.json └── stata.json ├── .vscode └── launch.json ├── language_config.json ├── LICENSE ├── package.json ├── README.md └── CHANGELOG.md /examples/graph.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hugetim/language-stata-vscode/main/examples/graph.pdf -------------------------------------------------------------------------------- /examples/dyntext.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hugetim/language-stata-vscode/main/examples/dyntext.pdf -------------------------------------------------------------------------------- /img/dyntext_domd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hugetim/language-stata-vscode/main/img/dyntext_domd.png -------------------------------------------------------------------------------- /img/stata-vscode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hugetim/language-stata-vscode/main/img/stata-vscode.png -------------------------------------------------------------------------------- /img/comments-example-output.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hugetim/language-stata-vscode/main/img/comments-example-output.png -------------------------------------------------------------------------------- /img/comments-example-vscode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hugetim/language-stata-vscode/main/img/comments-example-vscode.png -------------------------------------------------------------------------------- /img/comments-example-doeditor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hugetim/language-stata-vscode/main/img/comments-example-doeditor.png -------------------------------------------------------------------------------- /grammars/stata-dyndoc-latex.json: -------------------------------------------------------------------------------- 1 | { 2 | "scopeName": "source.dyndoc.latex.stata", 3 | "name": "Stata Dyndoc (LaTeX)", 4 | "fileTypes": [ 5 | "dotex" 6 | ], 7 | "patterns": [ 8 | { 9 | "include": "source.dyndoc.stata" 10 | }, 11 | { 12 | "include": "text.tex.latex" 13 | } 14 | ] 15 | } -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | // A launch configuration that launches the extension inside a new window 2 | { 3 | "version": "0.1.0", 4 | "configurations": [ 5 | { 6 | "name": "Launch Extension", 7 | "type": "extensionHost", 8 | "request": "launch", 9 | "runtimeExecutable": "${execPath}", 10 | "args": ["--extensionDevelopmentPath=${workspaceRoot}" ] 11 | } 12 | ] 13 | } -------------------------------------------------------------------------------- /language_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "comments": { 3 | "lineComment": ["//", "*"], 4 | "blockComment": [ "/*", "*/" ] 5 | }, 6 | "brackets": [ 7 | ["{", "}"], 8 | ["[", "]"], 9 | ["(", ")"] 10 | ], 11 | "autoClosingPairs": [ 12 | ["{", "}"], 13 | ["[", "]"], 14 | ["(", ")"], 15 | ["\"", "\""], 16 | ["`", "'"] 17 | ], 18 | "surroundingPairs": [ 19 | ["{", "}"], 20 | ["[", "]"], 21 | ["(", ")"], 22 | ["\"", "\""], 23 | ["`", "'"] 24 | ] 25 | } -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | # Examples 2 | 3 | ## Comments 4 | 5 | See [comments.md](comments.md) for information on how Stata deals with comments. 6 | 7 | ## Dynamic Documents 8 | 9 | The file [`dyntext.pdf`](dyntext.pdf) in this folder was created with 10 | 11 | ```stata 12 | dyntext dyntext.domd, saving(dyntext.md) replace 13 | ``` 14 | 15 | from inside Stata 15, and then with 16 | 17 | ``` 18 | pandoc dyntext.md -o dyntext.pdf 19 | ``` 20 | 21 | on the command line using [Pandoc](https://pandoc.org/). 22 | 23 | The file [`dyntext.dotex`](dyntext.dotex) is a proof-of-concept and should compile with LaTeX but the output is not shown here. 24 | 25 | --- 26 | 27 | #### `dyntext.domd`: 28 | 29 | ![](../img/dyntext_domd.png) 30 | 31 | #### `dyntext.dotex`: 32 | 33 | ![](../img/dyntext_dotex.png) 34 | -------------------------------------------------------------------------------- /grammars/stata-dyndoc-md.json: -------------------------------------------------------------------------------- 1 | { 2 | "scopeName": "source.dyndoc.md.stata", 3 | "name": "Stata Dyndoc (Markdown)", 4 | "fileTypes": [ 5 | "domd" 6 | ], 7 | "patterns": [ 8 | { 9 | "begin": "^\\s*([`~]{3,})(stata)?$", 10 | "beginCaptures": { 11 | "1": { 12 | "name": "punctuation.md" 13 | } 14 | }, 15 | "end": "^\\s*(\\1)$", 16 | "endCaptures": { 17 | "1": { 18 | "name": "punctuation.md" 19 | } 20 | }, 21 | "name": "fenced.code.md", 22 | "patterns": [ 23 | { 24 | "include": "source.dyndoc.stata" 25 | } 26 | ] 27 | }, 28 | { 29 | "include": "source.dyndoc.stata" 30 | }, 31 | { 32 | "include": "text.html.markdown" 33 | } 34 | ] 35 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Kyle Barron 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /examples/comments.md: -------------------------------------------------------------------------------- 1 | # Accurate comment highlighting 2 | 3 | The intricates of Stata's comment syntax highlighting were brought to my attention by [this Statalist post](https://www.statalist.org/forums/forum/general-stata-discussion/general/1448244-understanding-stata-s-comment-hierarchy). 4 | 5 | This package now highlights comments more accurately than the Stata Do-file Editor. This way you'll know exactly which parts of your do-file will actually run. 6 | 7 | VS Code highlighter: 8 | ![](../img/comments-example-vscode.png) 9 | 10 | Dofile Editor: 11 | ![](../img/comments-example-doeditor.png) 12 | 13 | Stata output (with Stata SE 15.1) 14 | ![](../img/comments-example-output.png) 15 | 16 | Here's the example text. 17 | 18 | ```stata 19 | * /* This will be a multi-line comment 20 | disp "Not printed" 21 | */ 22 | 23 | * // /* Ignored due to inline comment 24 | disp "Printed 1" 25 | 26 | // /* Also ignored due to inline comment 27 | disp "Printed 2" 28 | 29 | *// /* This is not an inline comment, so this is multi-line again 30 | disp "Not printed" 31 | */ 32 | 33 | * /// 34 | disp "Not printed. Line continuation applies" 35 | 36 | * line continuation /// 37 | /// 38 | disp "Not printed. Line continuation applies" 39 | 40 | // /// Line continuation ignored due to inline comment 41 | disp "Printed 3" 42 | 43 | /* 44 | /* Nested */ 45 | disp "Not printed" 46 | */* disp "Not printed" 47 | ``` -------------------------------------------------------------------------------- /examples/dyntext.dotex: -------------------------------------------------------------------------------- 1 | <> 2 | 3 | \documentclass[12pt]{article} 4 | \usepackage{graphicsx} 5 | \begin{document} 6 | 7 | \section{Using Stata dynamic tags in a text file with the \texttt{dyntext} command} 8 | 9 | Let us consider an example where we study the \texttt{mpg} and \texttt{weight} variables in 10 | \texttt{auto.dta}. In our examples below, we will first write the commands so that 11 | they will be displayed in our output text file. Then, we will write the 12 | commands so that Stata will process the Stata dynamic tags, displaying the 13 | results of the Stata commands in the output text file. 14 | 15 | We first use the \texttt{sysuse} command to load the dataset and then describe 16 | the data using the \texttt{describe} command. 17 | 18 | <> 19 | <> 20 | sysuse auto, clear 21 | describe 22 | <> 23 | <> 24 | 25 | This produces the following Stata results: 26 | 27 | <> 28 | sysuse auto, clear 29 | describe 30 | <> 31 | 32 | Now, we want to check if \texttt{mpg} is always greater than 0 and less than 100. 33 | We use the \texttt{assert} command to perform the check. In this case, we do not 34 | want to include any output in the output text file, so we use the \texttt{quietly} 35 | attribute to modify the behavior of the \texttt{dd_do} Stata dynamic tag. 36 | 37 | <> 38 | <> 39 | assert mpg > 0 & mpg < 100 40 | <> 41 | <> 42 | 43 | <> 44 | assert mpg > 0 & mpg < 100 45 | <> 46 | 47 | If the data do not satisfy the conditions, \texttt{dyntext} will fail with an error 48 | message, which will occur if we run the same \texttt{assert} command in a do-file. 49 | 50 | Next, we want to summarize the \texttt{weight} variable: 51 | 52 | <> 53 | <> 54 | summarize weight 55 | <> 56 | <> 57 | 58 | This produces the following in the output text file: 59 | 60 | <> 61 | summarize weight 62 | <> 63 | 64 | We want to use the minimum and maximum values of \texttt{weight} in a sentence. 65 | Instead of copying and pasting the numbers from the \texttt{summarize} output, we can 66 | use the \texttt{dd_display} Stata dynamic tag with the \texttt{r(min)} and \texttt{r(max)} 67 | stored results 68 | 69 | <> 70 | The variable weight has minimum value <> and 71 | has maximum value <>. 72 | <> 73 | 74 | which produces the following in the output text file: 75 | 76 | > The variable weight has minimum value <> 77 | and has maximum value <>. 78 | 79 | The \texttt{dd_display} dynamic tag uses Stata's \texttt{display} command to evaluate 80 | expressions. It can be used as a calculator. For example, if we want to 81 | include the $range = max - min$ in a sentence, instead of calculating the 82 | number and then copying and pasting it, we can use 83 | 84 | <> 85 | The variable weight has range <>. 86 | <> 87 | 88 | which produces the following in the output text file: 89 | 90 | > The variable weight has range <>. 91 | 92 | \end{document} -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "stata-enhanced", 3 | "displayName": "Stata Enhanced", 4 | "description": "Enhanced Stata syntax highlighting in Visual Studio Code", 5 | "author": { 6 | "name": "Kyle Barron" 7 | }, 8 | "version": "1.6.1", 9 | "publisher": "kylebarron", 10 | "engines": { 11 | "vscode": "^1.0.0" 12 | }, 13 | "license": "MIT", 14 | "bugs": { 15 | "url": "https://github.com/kylebarron/language-stata/issues" 16 | }, 17 | "homepage": "https://github.com/kylebarron/language-stata/blob/vscode/README.md", 18 | "repository": { 19 | "type": "git", 20 | "url": "https://github.com/kylebarron/language-stata.git" 21 | }, 22 | "categories": [ 23 | "Programming Languages" 24 | ], 25 | "galleryBanner": { 26 | "color": "#1d5f6d", 27 | "theme": "dark" 28 | }, 29 | "contributes": { 30 | "languages": [ 31 | { 32 | "id": "stata", 33 | "aliases": [ 34 | "Stata Enhanced", 35 | "Stata", 36 | "stata" 37 | ], 38 | "extensions": [ 39 | ".do", 40 | ".ado", 41 | ".mata" 42 | ], 43 | "configuration": "./language_config.json" 44 | }, 45 | { 46 | "id": "stata-dyndoc-latex", 47 | "aliases": [ 48 | "Stata Dyndoc (LaTeX)" 49 | ], 50 | "extensions": [ 51 | ".dotex" 52 | ], 53 | "configuration": "./language_config.json" 54 | }, 55 | { 56 | "id": "stata-dyndoc-md", 57 | "aliases": [ 58 | "Stata Dyndoc (Markdown)" 59 | ], 60 | "extensions": [ 61 | ".domd" 62 | ], 63 | "configuration": "./language_config.json" 64 | }, 65 | { 66 | "id": "stata-dyndoc", 67 | "aliases": [ 68 | "Stata Dyndoc (Base)" 69 | ], 70 | "extensions": [ 71 | ], 72 | "configuration": "./language_config.json" 73 | } 74 | ], 75 | "grammars": [ 76 | { 77 | "language": "stata", 78 | "scopeName": "source.stata", 79 | "path": "./grammars/stata.json" 80 | }, 81 | { 82 | "language": "stata-dyndoc-latex", 83 | "scopeName": "source.dyndoc.latex.stata", 84 | "path": "./grammars/stata-dyndoc-latex.json" 85 | }, 86 | { 87 | "language": "stata-dyndoc-md", 88 | "scopeName": "source.dyndoc.md.stata", 89 | "path": "./grammars/stata-dyndoc-md.json" 90 | }, 91 | { 92 | "language": "stata-dyndoc", 93 | "scopeName": "source.dyndoc.stata", 94 | "path": "./grammars/stata-dyndoc.json" 95 | } 96 | ] 97 | } 98 | } -------------------------------------------------------------------------------- /examples/dyntext.domd: -------------------------------------------------------------------------------- 1 | <> 2 | 3 | # Using Stata dynamic tags in a text file with the dyndoc command 4 | 5 | Let us consider an example where we study the **mpg** and **weight** variables 6 | in **auto.dta**. In our examples below, we will first write the commands so 7 | that they will be displayed in our target HTML file. Then, we will write the 8 | commands so that Stata will process the Stata dynamic tags, displaying the 9 | results of the Stata commands in the target HTML file. 10 | 11 | 12 | We first use the **sysuse** command to load the dataset and then describe 13 | the data using the **describe** command. 14 | 15 | ``` 16 | <> 17 | <> 18 | sysuse auto, clear 19 | describe 20 | <> 21 | <> 22 | ``` 23 | 24 | This produces the following Stata results: 25 | 26 | ``` 27 | <> 28 | sysuse auto, clear 29 | describe 30 | <> 31 | ``` 32 | 33 | Now, we want to check if **mpg** is always greater than 0 and less than 100. 34 | We use the **assert** command to perform the check. In this case, we do not 35 | want to include any output in the target HTML file, so we use the **quietly** 36 | attribute to modify the behavior of the **dd_do** Stata dynamic tag. 37 | 38 | ``` 39 | <> 40 | <> 41 | assert mpg > 0 & mpg < 100 42 | <> 43 | <> 44 | 45 | <> 46 | assert mpg > 0 & mpg < 100 47 | <> 48 | 49 | ``` 50 | 51 | If the data do not satisfy the conditions, **dyndoc** will fail with an error 52 | message, which will occur if we run the same **assert** command in a do-file. 53 | 54 | 55 | Next, we want to summarize the **weight** variable: 56 | 57 | ``` 58 | <> 59 | <> 60 | summarize weight 61 | <> 62 | <> 63 | ``` 64 | 65 | This produces the following in the target HTML file: 66 | 67 | ``` 68 | <> 69 | summarize weight 70 | <> 71 | ``` 72 | 73 | We want to use the minimum and maximum values of **weight** in a sentence. 74 | Instead of copying and pasting the numbers from the **summarize** output, we can 75 | use the **dd_display** Stata dynamic tag with the **r(min)** and **r(max)** 76 | stored results: 77 | 78 | ``` 79 | <> 80 | The variable weight has minimum value <> and 81 | has maximum value <>. 82 | <> 83 | ``` 84 | 85 | This produces the following in the target HTML file: 86 | 87 | ``` 88 | 89 | > The variable weight has minimum value <> 90 | and has maximum value <>. 91 | 92 | ``` 93 | 94 | The **dd_display** dynamic tag uses Stata's **display** command to evaluate 95 | expressions. It can be used as a calculator. For example, if we want to 96 | include the $$range = max - min$$ in a sentence, instead of calculating the 97 | number and then copying and pasting it, we can use 98 | 99 | ``` 100 | <> 101 | The variable weight has range <>. 102 | <> 103 | ``` 104 | 105 | which produces the following in the target HTML file: 106 | 107 | ``` 108 | 109 | > The variable weight has range <>. 110 | 111 | ``` 112 | 113 | Now, we want to graph **mpg** and **weight** using a scatterplot. We use the 114 | **dd_do** tag with the **nooutput** attribute to generate the scatterplot 115 | first. The **nooutput** attribute leaves the command in the output only, 116 | 117 | ``` 118 | <> 119 | <> 120 | scatter mpg weight, mcolor(blue%50) 121 | <> 122 | <> 123 | ``` 124 | 125 | which generates a scatterplot of **mpg** and **weight** with 50% opacity 126 | color markers. 127 | 128 | ``` 129 | <> 130 | scatter mpg weight, mcolor(blue%50) 131 | <> 132 | ``` 133 | 134 | Now, we want to export the graph to a file and include an image link to the 135 | file. 136 | 137 | ``` 138 | <> 139 | <> 140 | <> 141 | ``` 142 | 143 | This produces a graph of 400 pixels high. 144 | 145 | <> -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Stata language support in Visual Studio Code 2 | 3 | #### Stata syntax highlighting in Visual Studio Code, built from the ground up. 4 | 5 | ![stata](./img/stata-vscode.png) 6 | Code snippet from [Gtools](https://github.com/mcaceresb/stata-gtools), a faster implementation of Stata's collapse and egen using C plugins. Shown with the [Material](https://marketplace.visualstudio.com/items?itemName=Equinusocio.vsc-material-theme) theme. 7 | 8 | 9 | ## Features 10 | 11 | This package highlights: 12 | - System commands, functions, and function arguments 13 | - Macros, both global and local 14 | - Accurately colors nested macros and escaped macros in strings when you want the inner macro to evaluate at runtime 15 | - Colors macro extended functions inside `` `: ... '`` as well as after `local lname:` 16 | - Comments, [more accurately than Stata's Do-file Editor](examples/comments.md). 17 | - Regular expressions 18 | - Colors both the limited syntax provided through the `regexr()` and `regexm()` functions, as well as the vastly expanded regex syntax provided in Stata 14 and 15 through the `ustrregexm()`, `ustrregexrf()`, and `ustrregexra()` functions. 19 | - Dynamic Markdown and LaTeX documents. [Instructions below.](#dynamic-documents) 20 | 21 | Other nice features: 22 | - Works with unicode identifiers. Use unicode anywhere it's legal Stata syntax. 23 | - Alerts you if your variable name is illegal, i.e. if your variable name is more than 32 chars, starts with a number, or is a reserved name. 24 | - Alerts you if you have any text other than } on a line ending a foreach/forvalues/if/else command 25 | - Local macro back tick autocompletion. When you write a `, Visual Studio Code automatically fills in a ' after your cursor 26 | - Makes it easy to spot incorrect nesting of compound quotes 27 | - Support for programming ligatures for all valid Stata syntax for fonts that support them, like the [Fira Code](https://github.com/tonsky/FiraCode) font. 28 | - Highlights SQL queries used in the odbc command. (The language-sql base package must be active.) 29 | 30 | #### Note 31 | Some themes may not color all parts of the syntax. 32 | 33 | ## Installation 34 | Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter. 35 | ``` 36 | ext install stata-enhanced 37 | ``` 38 | 39 | ## Dynamic Documents 40 | 41 | ![](img/dyntext_domd.png) 42 | 43 | Stata 15 brought new features for working with dynamic documents. The [`dyndoc`](https://www.stata.com/help.cgi?dyndoc) command lets you write in Markdown and converts your file and code to HTML for viewing in a web browser. 44 | 45 | It also added the [`dyntext`](https://www.stata.com/help.cgi?dyntext) command, which fills in Stata output for any text file, without touching the text itself. This lets you then use third-party document generators like [Pandoc](https://pandoc.org/) and [LaTeX](https://www.latex-project.org/) to generate documents. 46 | 47 | This package now provides syntax highlighting for Stata code written inside Stata's [dynamic tags](https://www.stata.com/help.cgi?dynamic+tags) for Markdown and LaTeX documents. 48 | 49 | By default, this package's Markdown and LaTeX syntax highlighting will be applied for files ending in `.domd` and `.dotex` respectively. **The [Markdown All in One](https://marketplace.visualstudio.com/items?itemName=yzhang.markdown-all-in-one) and [LaTeX Workshop](https://marketplace.visualstudio.com/items?itemName=James-Yu.latex-workshop) packages must be installed for the highlighting to work.** 50 | 51 | If you name your file with a different extension, you can manually set the highlighting by clicking on the "Plain Text" button on the bottom right of the screen (or by pressing CTRL+SHIFT+L) and then selecting `Stata Dyndoc (Markdown)` or `Stata Dyndoc (LaTeX)` from the drop-down menu. 52 | 53 | ### Examples 54 | 55 | An example of the PDF output of using `dyntext` and Pandoc is in the examples folder: [`dyntext.pdf`](examples/dyntext.pdf). 56 | 57 | That file was created by running 58 | 59 | ```stata 60 | dyntext dyntext.domd, saving(dyntext.md) replace 61 | ``` 62 | from inside Stata 15, and then with 63 | 64 | ``` 65 | pandoc dyntext.md -o dyntext.pdf 66 | ``` 67 | 68 | on the command line using [Pandoc](https://pandoc.org/). 69 | 70 | The file [`dyntext.dotex`](examples/dyntext.dotex) is a proof-of-concept and should compile with LaTeX but the output is not shown here. 71 | 72 | ## Acknowledgements 73 | 74 | This extension was forked from [the vscode branch of kylebarron/language-stata](https://github.com/kylebarron/language-stata/tree/vscode). 75 | -------------------------------------------------------------------------------- /examples/dyntext.md: -------------------------------------------------------------------------------- 1 | 2 | # Using Stata dynamic tags in a text file with the dyndoc command 3 | 4 | Let us consider an example where we study the **mpg** and **weight** variables 5 | in **auto.dta**. In our examples below, we will first write the commands so 6 | that they will be displayed in our target HTML file. Then, we will write the 7 | commands so that Stata will process the Stata dynamic tags, displaying the 8 | results of the Stata commands in the target HTML file. 9 | 10 | 11 | We first use the **sysuse** command to load the dataset and then describe 12 | the data using the **describe** command. 13 | 14 | ``` 15 | <> 16 | sysuse auto, clear 17 | describe 18 | <> 19 | ``` 20 | 21 | This produces the following Stata results: 22 | 23 | ``` 24 | . sysuse auto, clear 25 | (1978 Automobile Data) 26 | 27 | . describe 28 | 29 | Contains data from /home/kyle/local/stata/ado/base/a/auto.dta 30 | obs: 74 1978 Automobile Data 31 | vars: 12 13 Apr 2016 17:45 32 | size: 3,182 (_dta has notes) 33 | -------------------------------------------------------------------------------- 34 | storage display value 35 | variable name type format label variable label 36 | -------------------------------------------------------------------------------- 37 | make str18 %-18s Make and Model 38 | price int %8.0gc Price 39 | mpg int %8.0g Mileage (mpg) 40 | rep78 int %8.0g Repair Record 1978 41 | headroom float %6.1f Headroom (in.) 42 | trunk int %8.0g Trunk space (cu. ft.) 43 | weight int %8.0gc Weight (lbs.) 44 | length int %8.0g Length (in.) 45 | turn int %8.0g Turn Circle (ft.) 46 | displacement int %8.0g Displacement (cu. in.) 47 | gear_ratio float %6.2f Gear Ratio 48 | foreign byte %8.0g origin Car type 49 | -------------------------------------------------------------------------------- 50 | Sorted by: foreign 51 | 52 | ``` 53 | 54 | Now, we want to check if **mpg** is always greater than 0 and less than 100. 55 | We use the **assert** command to perform the check. In this case, we do not 56 | want to include any output in the target HTML file, so we use the **quietly** 57 | attribute to modify the behavior of the **dd_do** Stata dynamic tag. 58 | 59 | ``` 60 | <> 61 | assert mpg > 0 & mpg < 100 62 | <> 63 | 64 | 65 | ``` 66 | 67 | If the data do not satisfy the conditions, **dyndoc** will fail with an error 68 | message, which will occur if we run the same **assert** command in a do-file. 69 | 70 | 71 | Next, we want to summarize the **weight** variable: 72 | 73 | ``` 74 | <> 75 | summarize weight 76 | <> 77 | ``` 78 | 79 | This produces the following in the target HTML file: 80 | 81 | ``` 82 | . summarize weight 83 | 84 | Variable | Obs Mean Std. Dev. Min Max 85 | -------------+--------------------------------------------------------- 86 | weight | 74 3019.459 777.1936 1760 4840 87 | 88 | ``` 89 | 90 | We want to use the minimum and maximum values of **weight** in a sentence. 91 | Instead of copying and pasting the numbers from the **summarize** output, we can 92 | use the **dd_display** Stata dynamic tag with the **r(min)** and **r(max)** 93 | stored results: 94 | 95 | ``` 96 | The variable weight has minimum value <> and 97 | has maximum value <>. 98 | ``` 99 | 100 | This produces the following in the target HTML file: 101 | 102 | ``` 103 | 104 | > The variable weight has minimum value 1760.00 105 | and has maximum value 4840.00. 106 | 107 | ``` 108 | 109 | The **dd_display** dynamic tag uses Stata's **display** command to evaluate 110 | expressions. It can be used as a calculator. For example, if we want to 111 | include the $$range = max - min$$ in a sentence, instead of calculating the 112 | number and then copying and pasting it, we can use 113 | 114 | ``` 115 | The variable weight has range <>. 116 | ``` 117 | 118 | which produces the following in the target HTML file: 119 | 120 | ``` 121 | 122 | > The variable weight has range 3080.00. 123 | 124 | ``` 125 | 126 | Now, we want to graph **mpg** and **weight** using a scatterplot. We use the 127 | **dd_do** tag with the **nooutput** attribute to generate the scatterplot 128 | first. The **nooutput** attribute leaves the command in the output only, 129 | 130 | ``` 131 | <> 132 | scatter mpg weight, mcolor(blue%50) 133 | <> 134 | ``` 135 | 136 | which generates a scatterplot of **mpg** and **weight** with 50% opacity 137 | color markers. 138 | 139 | ``` 140 | . scatter mpg weight, mcolor(blue%50) 141 | 142 | ``` 143 | 144 | Now, we want to export the graph to a file and include an image link to the 145 | file. 146 | 147 | ``` 148 | <> 149 | ``` 150 | 151 | This produces a graph of 400 pixels high. 152 | 153 | ![scatter mpg price](graph.pdf) -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## [1.6.1] - 2018-06-12 4 | 5 | - Fix links in README 6 | 7 | ## [1.6.0] - 2018-06-12 8 | 9 | - Update for Unicode identifiers. You should be able to use unicode anywhere it's legal now and have it be correctly colored. #84 10 | - Fix bug with multiple expressions in parentheses. #46 11 | - Fix comments inside locals, and fix comments inside globals used with `${...}`. #90 12 | - Color macros better in list extended function. #75 13 | - Allow macros within subscripts. #74 and #57 14 | - Make comment highlighting stubbornly accurate. See [this Statalist post](https://www.statalist.org/forums/forum/general-stata-discussion/general/1448244-understanding-stata-s-comment-hierarchy) for more information about how Stata highlights in practice, and [go here for an example](examples/comments.md). 15 | - Add note to README that language-latex and language-markdown must be installed for dynamic documents syntax highlighting to work 16 | - Update to highlight dynamic documents in Markdown and LaTeX 17 | - Add highlighting for Python-like docstrings in block comments 18 | - Don't alert for error around braces (`{}`) inside function calls 19 | 20 | - Add support for factor variables. Fixes #70 21 | - Fix coloring for macro functions that take multiple new macros as arguments, i.e. `tempvar`, `tempfile`, and `tempname`. Fixes #71 22 | - Add regex functions to autocomplete. Fixes #69 23 | - Alert when variable labels are >80 characters. Fixes #72 24 | 25 | ## [1.2.8] - 2017-11-28 26 | - Fix syntax command. Fixes #61 27 | - Add some user-written commands. Fixes #64 28 | 29 | ## [1.2.7] - 2017-11-20 30 | - allow there to be no spaces before = in gen command. Fixes https://github.com/kylebarron/language-stata/issues/59. 31 | 32 | ## [1.2.6] - 2017-11-18 33 | - No changes 34 | 35 | ## [1.2.5] - 2017-11-18 36 | - allow /* to start a comment block anywhere, not just after whitespace. Fixes https://github.com/kylebarron/language-stata/issues/55 37 | 38 | ## [1.2.4] - 2017-11-18 39 | - Fix `gen` command 40 | - Fix global macro coloring when using `\` as a path delimiter in strings. (i.e. `"$datadir\file.dta"`). Fixes [#52](https://github.com/kylebarron/language-stata/issues/52). 41 | - Allow for markdown code block in strings to not apply "macro" tags in specific situations. Allows e.g. `di "```stata"` as long as there's no `'` character in the text. Fixes [#53](https://github.com/kylebarron/language-stata/issues/53). 42 | 43 | ## [1.2.3] - 2017-11-11 44 | - Fix bugs created in 1.2.1 45 | - Namely, fix the list of macro reserved names 46 | 47 | ## [1.2.2] - 2017-11-11 48 | - Fix bugs created in 1.2.1 49 | 50 | ## [1.2.1] - 2017-11-10 51 | - Fix macro extended function bugs 52 | - Add macro checking to `foreach` and `syntax` 53 | - Restore name checking to `gen` 54 | - Fix bug for brackets before comma in the `syntax` command 55 | - Add `\` as an operator for use with matrices 56 | - Allow functions to be embedded within subscripts 57 | 58 | ## [1.2.0] - 2017-11-03 59 | - Color SQL queries used in the `odbc` command. (The `language-sql` base package must be active.) 60 | - Regex bug fixes and enhancements: 61 | - Color parentheses forming capture groups 62 | - In regular `regexm()`, color as illegal any group starting with `*`, `?`, or `+`. 63 | - Color lookaheads and lookbehinds in `ustrregexm()` 64 | - Fix highlighting of enclosed functions in `regexm()` and `ustrregexm()` 65 | - Standardize highlighting for `regress` and other "model commands". (Had been colored as _functions_, should be colored as _commands_.) 66 | 67 | ## [1.1.2] - 2017-10-12 68 | - Color `==` as illegal in `replace var == 0` 69 | - Fix `log` coloring so that `filename.log` isn't colored 70 | - Bugfixes with `drop` and `keep` commands 71 | - Allow embedded macros in extended macro functions 72 | - Miscellaneous bugs fixed by adding `\\b` so that something like `if_yes` doesn't color `if` 73 | 74 | ## [1.1.1] - 2017-10-11 75 | - Fixed bug where, e.g. only `label vari` was colored of `label variable ...`. There were many instances of code that could have been affected that were fixed. 76 | 77 | ## [1.1.0] - 2017-10-11 78 | - Improved `syntax` command to correctly color across multiple lines. Solves https://github.com/kylebarron/language-stata/issues/19 79 | - Colors extended macro functions inside local macros as well as during macro instantiation. 80 | - Allow macros in `forvalues` loop statement, like ``forval i = `start_num' / `end_num' {`` 81 | - Allow for local and global macros within regular expression match strings 82 | - Color `_all` as a constant 83 | - Include Mata functions from old [atom-language-stata](https://github.com/benwhalley/atom-language-stata) package 84 | - `drop` and `keep` alert you if you type `drop varlist if` or `drop varlist in`. (It's only legal to use `if` or `in` without a _varlist_). 85 | 86 | ## [1.0.4] - 2017-10-02 87 | - Fix highlighting for global macro with braces inside loop 88 | - Now the `}` line can only be colored as error if there's text on that line and if there's at least one space before the `}`. 89 | - Remove some deprecated functions 90 | - Turn off docblockr tag if appears immediately after word character 91 | - Show error for `gen var == 5` 92 | 93 | ## [1.0.3] - 2017-10-02 94 | - Fix comment bug created in 1.0.2. 95 | - Disallow star-comments inside block-comments 96 | 97 | ## [1.0.2] - 2017-10-02 98 | - Fix bug to allow nested comment blocks 99 | - Fix docblockr tag coloring 100 | 101 | ## [1.0.1] - 2017-10-01 102 | - Fix `*regexr*()` functions to color regex before typing the second comma 103 | 104 | ## [1.0.0] - 2017-09-30 105 | ### Added 106 | - Unicode regex support. This includes support for the entire (or at least most) of the ICU regex engine. 107 | - Colors invalid escapes as illegal in the standard regex parser, like \w or \s. 108 | 109 | ### Fixed 110 | - color regex functions within other functions 111 | - Don't color as illegal the {} within the `spacebef` and `spaceaft` functions in the outreg package. 112 | 113 | ## [0.5.16] - 2017-09-22 114 | ### Added 115 | - Autocomplete support in general for all words 116 | - `gen` and `egen` now color a new tempvar as a macro. I.e.: 117 | ``` 118 | tempvar new_variable 119 | gen `new_variable' = ... 120 | ``` 121 | - Now colors `@ERROR` and `@error` in comments as illegal/invalid 122 | - Started CHANGELOG! Hopefully will go back and fill out previous revisions' edits. 123 | 124 | ### Fixed 125 | - Regex highlighting error that colored capturing groups wrong 126 | - -------------------------------------------------------------------------------- /grammars/stata-dyndoc.json: -------------------------------------------------------------------------------- 1 | { 2 | "scopeName": "source.dyndoc.stata", 3 | "name": "Stata Dyndoc", 4 | "patterns": [ 5 | { 6 | "begin": "(<<)(dd_do)(:)?([^>]+)?(>>)([^\r\n]*)?", 7 | "beginCaptures": { 8 | "1": { 9 | "name": "punctuation.definition.tag.begin.html" 10 | }, 11 | "2": { 12 | "name": "entity.name.tag.block.$2.html" 13 | }, 14 | "3": { 15 | "name": "punctuation.separator.key-value.dyndoc.stata" 16 | }, 17 | "4": { 18 | "patterns": [ 19 | { 20 | "match": "quietly|quietl|quiet|quie|qui", 21 | "name": "keyword.control.flow.dyndoc.stata" 22 | }, 23 | { 24 | "match": "nocommands|nocommand|nocomman|nocomma|nocomm|nocom", 25 | "name": "keyword.control.flow.dyndoc.stata" 26 | }, 27 | { 28 | "match": "nooutput|nooutpu|nooutp|noout", 29 | "name": "keyword.control.flow.dyndoc.stata" 30 | }, 31 | { 32 | "match": "noprompt|nopromp|noprom", 33 | "name": "keyword.control.flow.dyndoc.stata" 34 | } 35 | ] 36 | }, 37 | "5": { 38 | "name": "punctuation.definition.tag.end.html" 39 | }, 40 | "6": { 41 | "name": "invalid.illegal.name.dyndoc.stata" 42 | } 43 | }, 44 | "end": "(<>)([^\r\n]*)?", 45 | "endCaptures": { 46 | "1": { 47 | "name": "punctuation.definition.tag.begin.html" 48 | }, 49 | "2": { 50 | "name": "entity.name.tag.block.$2.html" 51 | }, 52 | "3": { 53 | "name": "punctuation.definition.tag.end.html" 54 | }, 55 | "4": { 56 | "name": "invalid.illegal.name.dyndoc.stata" 57 | } 58 | }, 59 | "name": "meta.tag.block.$2.html", 60 | "patterns": [ 61 | { 62 | "include": "source.stata" 63 | } 64 | ] 65 | }, 66 | { 67 | "begin": "(<<)(dd_display|dd_graph)(:)", 68 | "beginCaptures": { 69 | "1": { 70 | "name": "punctuation.definition.tag.begin.html" 71 | }, 72 | "2": { 73 | "name": "entity.name.tag.block.$2.html" 74 | }, 75 | "3": { 76 | "name": "punctuation.separator.key-value.dyndoc.stata" 77 | } 78 | }, 79 | "end": "(>>)", 80 | "endCaptures": { 81 | "1": { 82 | "name": "punctuation.definition.tag.end.html" 83 | } 84 | }, 85 | "name": "meta.tag.block.$2.html", 86 | "patterns": [ 87 | { 88 | "include": "source.stata" 89 | } 90 | ] 91 | }, 92 | { 93 | "begin": "(<<)(dd_include|dd_skip_if)(:)", 94 | "beginCaptures": { 95 | "1": { 96 | "name": "punctuation.definition.tag.begin.html" 97 | }, 98 | "2": { 99 | "name": "entity.name.tag.block.$2.html" 100 | }, 101 | "3": { 102 | "name": "punctuation.separator.key-value.dyndoc.stata" 103 | } 104 | }, 105 | "end": "(>>)([^\r\n]*)?", 106 | "endCaptures": { 107 | "1": { 108 | "name": "punctuation.definition.tag.end.html" 109 | }, 110 | "2": { 111 | "name": "invalid.illegal.name.dyndoc.stata" 112 | } 113 | }, 114 | "name": "meta.tag.block.$2.html" 115 | }, 116 | { 117 | "begin": "(<<)(dd_ignore)(>>)([^\r\n]*)?", 118 | "beginCaptures": { 119 | "1": { 120 | "name": "punctuation.definition.tag.begin.html" 121 | }, 122 | "2": { 123 | "name": "entity.name.tag.block.$2.html" 124 | }, 125 | "3": { 126 | "name": "punctuation.definition.tag.end.html" 127 | }, 128 | "4": { 129 | "name": "invalid.illegal.name.dyndoc.stata" 130 | } 131 | }, 132 | "end": "(<>)([^\r\n]*)?", 133 | "endCaptures": { 134 | "1": { 135 | "name": "punctuation.definition.tag.begin.html" 136 | }, 137 | "2": { 138 | "name": "entity.name.tag.block.$2.html" 139 | }, 140 | "3": { 141 | "name": "punctuation.definition.tag.end.html" 142 | }, 143 | "4": { 144 | "name": "invalid.illegal.name.dyndoc.stata" 145 | } 146 | }, 147 | "name": "meta.tag.block.$2.html", 148 | "patterns": [ 149 | { 150 | "include": "$self" 151 | } 152 | ] 153 | }, 154 | { 155 | "match": "(<<)(dd_skip_else|dd_skip_end)(>>)([^\r\n]*)?", 156 | "captures": { 157 | "1": { 158 | "name": "punctuation.definition.tag.begin.html" 159 | }, 160 | "2": { 161 | "name": "entity.name.tag.block.$2.html" 162 | }, 163 | "3": { 164 | "name": "punctuation.definition.tag.end.html" 165 | }, 166 | "4": { 167 | "name": "invalid.illegal.name.dyndoc.stata" 168 | } 169 | }, 170 | "name": "meta.tag.block.$2.html" 171 | }, 172 | { 173 | "match": "(<<)(dd_version)(:)\\s*([0-9]+)(>>)([^\r\n]*)?", 174 | "captures": { 175 | "1": { 176 | "name": "punctuation.definition.tag.begin.html" 177 | }, 178 | "2": { 179 | "name": "entity.name.tag.block.$2.html" 180 | }, 181 | "3": { 182 | "name": "punctuation.separator.key-value.dyndoc.stata" 183 | }, 184 | "4": { 185 | "name": "constant.numeric.integer.dyndoc.stata" 186 | }, 187 | "5": { 188 | "name": "punctuation.definition.tag.end.html" 189 | }, 190 | "6": { 191 | "name": "invalid.illegal.name.dyndoc.stata" 192 | } 193 | }, 194 | "name": "meta.tag.block.$2.html" 195 | }, 196 | { 197 | "begin": "<>", 198 | "captures": { 199 | "0": { 200 | "name": "punctuation.definition.comment.dyndoc.stata" 201 | } 202 | }, 203 | "end": "<>", 204 | "name": "comment.block.dyndoc.stata" 205 | } 206 | ] 207 | } -------------------------------------------------------------------------------- /grammars/stata.json: -------------------------------------------------------------------------------- 1 | { 2 | "scopeName": "source.stata", 3 | "name": "Stata", 4 | "fileTypes": [ 5 | "do", 6 | "ado", 7 | "mata" 8 | ], 9 | "foldingStartMarker": "\\{\\s*$", 10 | "foldingStopMarker": "^\\s*\\}", 11 | "patterns": [ 12 | { 13 | "include": "#ascii-regex-functions" 14 | }, 15 | { 16 | "include": "#unicode-regex-functions" 17 | }, 18 | { 19 | "include": "#constants" 20 | }, 21 | { 22 | "include": "#functions" 23 | }, 24 | { 25 | "include": "#comments" 26 | }, 27 | { 28 | "include": "#subscripts" 29 | }, 30 | { 31 | "include": "#operators" 32 | }, 33 | { 34 | "include": "#macro-local" 35 | }, 36 | { 37 | "include": "#macro-global" 38 | }, 39 | { 40 | "include": "#string-compound" 41 | }, 42 | { 43 | "include": "#string-regular" 44 | }, 45 | { 46 | "include": "#builtin_variables" 47 | }, 48 | { 49 | "include": "#macro-commands" 50 | }, 51 | { 52 | "comment": "keywords that delimit flow conditionals", 53 | "name": "keyword.control.conditional.stata", 54 | "match": "\\b(if|else if|else)\\b" 55 | }, 56 | { 57 | "captures": { 58 | "1": { 59 | "name": "storage.type.scalar.stata" 60 | } 61 | }, 62 | "match": "^\\s*(sca(lar|la|l)?(\\s+de(fine|fin|fi|f)?)?)\\s+(?!(drop|dir?|l(ist|is|i)?)\\s+)" 63 | }, 64 | { 65 | "begin": "\\b(mer(ge|g)?)\\s+(1|m|n)(:)(1|m|n)", 66 | "beginCaptures": { 67 | "1": { 68 | "name": "keyword.control.flow.stata" 69 | }, 70 | "3": { 71 | "patterns": [ 72 | { 73 | "include": "#constants" 74 | }, 75 | { 76 | "match": "m|n", 77 | "name": "" 78 | } 79 | ] 80 | }, 81 | "4": { 82 | "name": "punctuation.separator.key-value" 83 | }, 84 | "5": { 85 | "patterns": [ 86 | { 87 | "include": "#constants" 88 | }, 89 | { 90 | "match": "m|n", 91 | "name": "" 92 | } 93 | ] 94 | } 95 | }, 96 | "end": "using", 97 | "patterns": [ 98 | { 99 | "include": "#builtin_variables" 100 | }, 101 | { 102 | "include": "#macro-local" 103 | }, 104 | { 105 | "include": "#macro-global" 106 | }, 107 | { 108 | "include": "#comments" 109 | } 110 | ] 111 | }, 112 | { 113 | "match": "\\b(foreach)\\s+((?!in|of).+)\\s+(in|of var(list|lis|li|l)?|of new(list|lis|li|l)?|of num(list|lis|li|l)?)\\b", 114 | "captures": { 115 | "1": { 116 | "name": "keyword.control.flow.stata" 117 | }, 118 | "2": { 119 | "patterns": [ 120 | { 121 | "include": "#macro-local-identifiers" 122 | }, 123 | { 124 | "include": "#macro-local" 125 | }, 126 | { 127 | "include": "#macro-global" 128 | } 129 | ] 130 | }, 131 | "3": { 132 | "name": "keyword.control.flow.stata" 133 | } 134 | } 135 | }, 136 | { 137 | "begin": "\\b(foreach)\\s+((?!in|of).+)\\s+(of loc(al|a)?|of glo(bal|ba|b)?)\\b\\s*", 138 | "beginCaptures": { 139 | "1": { 140 | "name": "keyword.control.flow.stata" 141 | }, 142 | "2": { 143 | "patterns": [ 144 | { 145 | "include": "#macro-local-identifiers" 146 | }, 147 | { 148 | "include": "#macro-local" 149 | }, 150 | { 151 | "include": "#macro-global" 152 | } 153 | ] 154 | }, 155 | "3": { 156 | "name": "keyword.control.flow.stata" 157 | } 158 | }, 159 | "end": "(?=\\s*\\{)", 160 | "patterns": [ 161 | { 162 | "include": "#macro-local-identifiers" 163 | }, 164 | { 165 | "include": "#macro-local" 166 | }, 167 | { 168 | "include": "#macro-global" 169 | } 170 | ] 171 | }, 172 | { 173 | "begin": "\\b(forvalues|forvalue|forvalu|forval|forva|forv)\\s*", 174 | "end": "\\s*(=)\\s*([^\\{]+)\\s*|(?=\\n)", 175 | "beginCaptures": { 176 | "1": { 177 | "name": "keyword.control.flow.stata" 178 | } 179 | }, 180 | "endCaptures": { 181 | "1": { 182 | "name": "keyword.operator.assignment.stata" 183 | }, 184 | "2": { 185 | "patterns": [ 186 | { 187 | "include": "#constants" 188 | }, 189 | { 190 | "include": "#operators" 191 | }, 192 | { 193 | "include": "#macro-local" 194 | }, 195 | { 196 | "include": "#macro-global" 197 | } 198 | ] 199 | } 200 | }, 201 | "patterns": [ 202 | { 203 | "include": "#macro-local-identifiers" 204 | }, 205 | { 206 | "include": "#macro-local" 207 | }, 208 | { 209 | "include": "#macro-global" 210 | } 211 | ] 212 | }, 213 | { 214 | "comment": "keywords that delimit loops", 215 | "name": "keyword.control.flow.stata", 216 | "match": "\\b(while|continue)\\b" 217 | }, 218 | { 219 | "captures": { 220 | "1": { 221 | "name": "keyword.other.stata" 222 | } 223 | }, 224 | "comment": "keywords that haven't fit into other groups (yet).", 225 | "match": "\\b(as|ass|asse|asser|assert)\\b" 226 | }, 227 | { 228 | "match": "\\b(by(sort|sor|so|s)?|statsby|rolling|bootstrap|jackknife|permute|simulate|svy|mi est(imate|imat|ima|im|i)?|nestreg|stepwise|xi|fp|mfp|vers(ion|io|i)?)\\b", 229 | "name": "storage.type.function.stata", 230 | "comment": "prefixes that require a colon" 231 | }, 232 | { 233 | "comment": "prefixes that don't need a colon", 234 | "name": "keyword.control.flow.stata", 235 | "match": "\\b(qui(etly|etl|et|e)?|n(oisily|oisil|oisi|ois|oi|o)?|cap(ture|tur|tu|t)?)\\b:?" 236 | }, 237 | { 238 | "match": "\\s*(pr(ogram|ogra|ogr|og|o)?)\\s+((di(r)?|drop|l(ist|is|i)?)\\s+)([\\w&&[^0-9]]\\w{0,31})", 239 | "captures": { 240 | "1": { 241 | "name": "storage.type.function.stata" 242 | }, 243 | "3": { 244 | "name": "storage.type.function.stata" 245 | }, 246 | "7": { 247 | "name": "entity.name.function.stata" 248 | } 249 | } 250 | }, 251 | { 252 | "begin": "^\\s*(pr(ogram|ogra|ogr|og|o)?)\\s+(de(fine|fin|fi|f)?\\s+)?", 253 | "beginCaptures": { 254 | "1": { 255 | "name": "storage.type.function.stata" 256 | }, 257 | "3": { 258 | "name": "storage.type.function.stata" 259 | } 260 | }, 261 | "end": "(?=,|\\n|/)", 262 | "patterns": [ 263 | { 264 | "include": "#macro-local" 265 | }, 266 | { 267 | "include": "#macro-global" 268 | }, 269 | { 270 | "match": "[\\w&&[^0-9]]\\w{0,31}", 271 | "name": "entity.name.function.stata" 272 | }, 273 | { 274 | "match": "[^A-za-z_0-9,\\n/ ]+", 275 | "name": "invalid.illegal.name.stata" 276 | } 277 | ] 278 | }, 279 | { 280 | "match": "\\b(form(at|a)?)\\s*([\\w&&[^0-9]]\\w{0,31})*\\s*(%)(-)?(0)?([0-9]+)(.)([0-9]+)(e|f|g)(c)?", 281 | "captures": { 282 | "1": "keyword.functions.data.stata.test" 283 | } 284 | }, 285 | { 286 | "include": "#braces-with-error" 287 | }, 288 | { 289 | "begin": "(?=syntax)", 290 | "end": "\\n", 291 | "patterns": [ 292 | { 293 | "comment": "color before the comma", 294 | "begin": "syntax", 295 | "beginCaptures": { 296 | "0": { 297 | "name": "keyword.functions.program.stata" 298 | } 299 | }, 300 | "end": "(?=,|\\n)", 301 | "patterns": [ 302 | { 303 | "begin": "///", 304 | "end": "\\n", 305 | "name": "comment.block.stata" 306 | }, 307 | { 308 | "match": "\\[", 309 | "name": "punctuation.definition.parameters.begin.stata" 310 | }, 311 | { 312 | "match": "\\]", 313 | "name": "punctuation.definition.parameters.end.stata" 314 | }, 315 | { 316 | "match": "\\b(varlist|varname|newvarlist|newvarname|namelist|name|anything)\\b", 317 | "name": "entity.name.type.class.stata" 318 | }, 319 | { 320 | "match": "\\b((if|in|using|fweight|aweight|pweight|iweight))\\b(/)?", 321 | "captures": { 322 | "2": { 323 | "name": "entity.name.type.class.stata" 324 | }, 325 | "3": { 326 | "name": "keyword.operator.arithmetic.stata" 327 | } 328 | } 329 | }, 330 | { 331 | "match": "(/)?(exp)", 332 | "captures": { 333 | "1": { 334 | "name": "keyword.operator.arithmetic.stata" 335 | }, 336 | "2": { 337 | "name": "entity.name.type.class.stata" 338 | } 339 | } 340 | }, 341 | { 342 | "include": "#constants" 343 | }, 344 | { 345 | "include": "#operators" 346 | }, 347 | { 348 | "include": "#string-compound" 349 | }, 350 | { 351 | "include": "#string-regular" 352 | }, 353 | { 354 | "include": "#macro-local" 355 | }, 356 | { 357 | "include": "#macro-global" 358 | }, 359 | { 360 | "include": "#builtin_variables" 361 | } 362 | ] 363 | }, 364 | { 365 | "comment": "things to color after the comma", 366 | "begin": ",", 367 | "beginCaptures": { 368 | "0": { 369 | "name": "punctuation.definition.variable.begin.stata" 370 | } 371 | }, 372 | "end": "(?=\\n)", 373 | "patterns": [ 374 | { 375 | "begin": "///", 376 | "end": "\\n", 377 | "name": "comment.block.stata" 378 | }, 379 | { 380 | "comment": "color options with parentheses", 381 | "begin": "([^\\s\\[\\]]+)(\\()", 382 | "beginCaptures": { 383 | "1": { 384 | "patterns": [ 385 | { 386 | "include": "#macro-local-identifiers" 387 | }, 388 | { 389 | "include": "#macro-local" 390 | }, 391 | { 392 | "include": "#macro-global" 393 | } 394 | ], 395 | "comment": "these are the names that become macros" 396 | }, 397 | "2": { 398 | "name": "keyword.operator.parentheses.stata" 399 | } 400 | }, 401 | "end": "\\)", 402 | "endCaptures": { 403 | "0": { 404 | "name": "keyword.operator.parentheses.stata" 405 | } 406 | }, 407 | "patterns": [ 408 | { 409 | "comment": "the first word is often a type", 410 | "match": "\\b(integer|intege|integ|inte|int|real|string|strin|stri|str)\\b", 411 | "captures": { 412 | "0": { 413 | "name": "support.type.stata" 414 | } 415 | } 416 | }, 417 | { 418 | "include": "#constants" 419 | }, 420 | { 421 | "include": "#operators" 422 | }, 423 | { 424 | "include": "#string-compound" 425 | }, 426 | { 427 | "include": "#string-regular" 428 | }, 429 | { 430 | "include": "#macro-local" 431 | }, 432 | { 433 | "include": "#macro-global" 434 | }, 435 | { 436 | "include": "#builtin_variables" 437 | } 438 | ] 439 | }, 440 | { 441 | "include": "#macro-local-identifiers" 442 | }, 443 | { 444 | "include": "#constants" 445 | }, 446 | { 447 | "include": "#operators" 448 | }, 449 | { 450 | "include": "#string-compound" 451 | }, 452 | { 453 | "include": "#string-regular" 454 | }, 455 | { 456 | "include": "#macro-local" 457 | }, 458 | { 459 | "include": "#macro-global" 460 | }, 461 | { 462 | "include": "#builtin_variables" 463 | } 464 | ] 465 | } 466 | ] 467 | }, 468 | { 469 | "captures": { 470 | "1": { 471 | "name": "keyword.functions.data.stata" 472 | } 473 | }, 474 | "comment": "one-word commands", 475 | "match": "\\b(sa(v|ve)|saveold|destring|tostring|u(se|s)?|note(s)?|form(at|a)?)\\b" 476 | }, 477 | { 478 | "match": "\\b(exit|end)\\b", 479 | "name": "keyword.functions.data.stata", 480 | "comment": "programming commands" 481 | }, 482 | { 483 | "match": "\\b(replace)\\s+([^=]+)\\s*((==)|(=))", 484 | "captures": { 485 | "1": { 486 | "name": "keyword.functions.data.stata" 487 | }, 488 | "2": { 489 | "patterns": [ 490 | { 491 | "include": "#macro-local" 492 | } 493 | ] 494 | }, 495 | "4": { 496 | "name": "invalid.illegal.name.stata" 497 | }, 498 | "5": { 499 | "name": "keyword.operator.assignment.stata" 500 | } 501 | } 502 | }, 503 | { 504 | "match": "\\b(g(enerate|enerat|enera|ener|ene|en|e)?|egen)\\s+((byte|int|long|float|double|str[1-9]?[0-9]?[0-9]?[0-9]?|strL)\\s+)?([^=\\s]+)\\s*((==)|(=))", 505 | "captures": { 506 | "1": { 507 | "name": "keyword.functions.data.stata" 508 | }, 509 | "3": { 510 | "name": "support.type.stata" 511 | }, 512 | "5": { 513 | "patterns": [ 514 | { 515 | "include": "#reserved-names" 516 | }, 517 | { 518 | "include": "#macro-local" 519 | } 520 | ] 521 | }, 522 | "7": { 523 | "name": "invalid.illegal.name.stata" 524 | }, 525 | "8": { 526 | "name": "keyword.operator.assignment.stata" 527 | } 528 | } 529 | }, 530 | { 531 | "match": "\\b(set ty(pe|p)?)\\s+((byte|int|long|float|double|str[1-9]?[0-9]?[0-9]?[0-9]?|strL)?\\s+)\\b", 532 | "captures": { 533 | "1": { 534 | "name": "keyword.functions.data.stata" 535 | }, 536 | "3": { 537 | "name": "support.type.stata" 538 | } 539 | } 540 | }, 541 | { 542 | "match": "\\b(la(bel|be|b)?)\\s+(var(iable|iabl|iab|ia|i)?)\\s+([\\w&&[^0-9]]\\w{0,31})\\s+(`\")(.+)(\"')", 543 | "captures": { 544 | "1": { 545 | "name": "keyword.functions.data.stata" 546 | }, 547 | "3": { 548 | "name": "keyword.functions.data.stata" 549 | }, 550 | "6": { 551 | "name": "punctuation.definition.string.begin.stata" 552 | }, 553 | "7": { 554 | "patterns": [ 555 | { 556 | "include": "#string-compound" 557 | }, 558 | { 559 | "include": "#macro-local-escaped" 560 | }, 561 | { 562 | "include": "#macro-global-escaped" 563 | }, 564 | { 565 | "include": "#macro-local" 566 | }, 567 | { 568 | "include": "#macro-global" 569 | }, 570 | { 571 | "match": "[^`\\$]{81,}", 572 | "name": "invalid.illegal.name.stata" 573 | }, 574 | { 575 | "match": ".", 576 | "name": "string.quoted.double.compound.stata" 577 | } 578 | ] 579 | }, 580 | "8": { 581 | "name": "punctuation.definition.string.begin.stata" 582 | } 583 | } 584 | }, 585 | { 586 | "match": "\\b(la(bel|be|b)?)\\s+(var(iable|iabl|iab|ia|i)?)\\s+([\\w&&[^0-9]]\\w{0,31})\\s+(\")(.+)(\")", 587 | "captures": { 588 | "1": { 589 | "name": "keyword.functions.data.stata" 590 | }, 591 | "3": { 592 | "name": "keyword.functions.data.stata" 593 | }, 594 | "6": { 595 | "name": "punctuation.definition.string.begin.stata" 596 | }, 597 | "7": { 598 | "patterns": [ 599 | { 600 | "include": "#macro-local-escaped" 601 | }, 602 | { 603 | "include": "#macro-global-escaped" 604 | }, 605 | { 606 | "include": "#macro-local" 607 | }, 608 | { 609 | "include": "#macro-global" 610 | }, 611 | { 612 | "match": "[^`\\$]{81,}", 613 | "name": "invalid.illegal.name.stata" 614 | }, 615 | { 616 | "match": ".", 617 | "name": "string.quoted.double.stata" 618 | } 619 | ] 620 | }, 621 | "8": { 622 | "name": "punctuation.definition.string.begin.stata" 623 | } 624 | } 625 | }, 626 | { 627 | "match": "\\b(la(bel|be|b)?)\\s+(da(ta|t)?|var(iable|iabl|iab|ia|i)?|de(f|fi|fin|fine)?|val(ues|ue|u)?|di(r)?|l(ist|is|i)?|copy|drop|save|lang(uage|uag|ua|u)?)\\b", 628 | "captures": { 629 | "1": { 630 | "name": "keyword.functions.data.stata" 631 | }, 632 | "3": { 633 | "name": "keyword.functions.data.stata" 634 | } 635 | } 636 | }, 637 | { 638 | "begin": "\\b(drop|keep)\\b(?!\\s+(if|in)\\b)", 639 | "beginCaptures": { 640 | "1": { 641 | "name": "keyword.functions.data.stata" 642 | } 643 | }, 644 | "end": "\\n", 645 | "patterns": [ 646 | { 647 | "match": "\\b(if|in)\\b", 648 | "name": "invalid.illegal.name.stata" 649 | }, 650 | { 651 | "include": "#comments" 652 | }, 653 | { 654 | "include": "#macro-local" 655 | }, 656 | { 657 | "include": "#macro-global" 658 | }, 659 | { 660 | "include": "#operators" 661 | } 662 | ] 663 | }, 664 | { 665 | "match": "\\b(drop|keep)\\s+(if|in)\\b", 666 | "captures": { 667 | "1": { 668 | "name": "keyword.functions.data.stata" 669 | }, 670 | "2": { 671 | "name": "keyword.functions.data.stata" 672 | } 673 | } 674 | }, 675 | { 676 | "begin": "^\\s*mata:?\\s*$", 677 | "comment": "won't match single-line Mata statements", 678 | "end": "^\\s*end\\s*$\\n?", 679 | "name": "meta.embedded.block.mata", 680 | "patterns": [ 681 | { 682 | "match": "(?\\=|\\<\\=|\\<|\\>|\\!\\=|\\#|\\+|\\-|\\*|\\^|\\/", 708 | "name": "keyword.operator.mata" 709 | }, 710 | { 711 | "include": "$self" 712 | } 713 | ] 714 | }, 715 | { 716 | "begin": "\\b(odbc)\\b", 717 | "beginCaptures": { 718 | "0": { 719 | "name": "keyword.control.flow.stata" 720 | } 721 | }, 722 | "end": "\\n", 723 | "patterns": [ 724 | { 725 | "begin": "///", 726 | "end": "\\n", 727 | "name": "comment.block.stata" 728 | }, 729 | { 730 | "begin": "(exec?)(\\(\")", 731 | "beginCaptures": { 732 | "1": { 733 | "name": "support.function.builtin.stata" 734 | }, 735 | "2": { 736 | "name": "punctuation.definition.parameters.begin.stata" 737 | } 738 | }, 739 | "end": "\"\\)", 740 | "endCaptures": { 741 | "0": { 742 | "name": "punctuation.definition.parameters.end.stata" 743 | } 744 | }, 745 | "patterns": [ 746 | { 747 | "include": "source.sql" 748 | } 749 | ] 750 | }, 751 | { 752 | "include": "$self" 753 | } 754 | ] 755 | }, 756 | { 757 | "include": "#commands-other" 758 | } 759 | ], 760 | "repository": { 761 | "functions": { 762 | "patterns": [ 763 | { 764 | "begin": "\\b((abbrev|abs|acos|acosh|asin|asinh|atan|atan2|atanh|autocode|betaden|binomial|binomialp|binomialtail|binormalbofd|byteorder|c|cauchy|cauchyden|cauchytail|Cdhms|ceil|char|chi2|chi2den|chi2tail|Chms|cholesky|chop|clip|clock|Clock|cloglog|Cmdyhms|cofC|Cofc|cofd|Cofd|coleqnumb|collatorlocale|collatorversion|colnfreeparms|colnumb|colsof|comb|cond|corr|cos|cosh|daily|date|day|det|dgammapda|dgammapdada|dgammapdadx|dgammapdx|dgammapdxdx|dhms|diag|diag0cnt|digamma|dofb|dofc|dofC|dofh|dofm|dofq|dofw|dofy|dow|doy|dunnettprob|e|el|epsdouble|epsfloat|exp|exponential|exponentialden|exponentialtail|F|Fden|fileexists|fileread|filereaderror|filewrite|float|floor|fmtwidth|Ftail|gammaden|gammap|gammaptail|get|hadamard|halfyear|halfyearly|hh|hhC|hms|hofd|hours|hypergeometric|hypergeometricp|I|ibeta|ibetatail|igaussian|igaussianden|igaussiantail|indexnot|inlist|inrange|int|inv|invbinomial|invbinomialtail|invcauchy|invcauchytail|invchi2|invchi2tail|invcloglog|invdunnettprob|invexponential|invexponentialtail|invF|invFtail|invgammap|invgammaptail|invibeta|invibetatail|invigaussian|invigaussiantail|invlaplace|invlaplacetail|invlogistic|invlogistictail|invlogit|invnbinomial|invnbinomialtail|invnchi2|invnchi2tail|invnF|invnFtail|invnibeta|invnormal|invnt|invnttail|invpoisson|invpoissontail|invsym|invt|invttail|invtukeyprob|invweibull|invweibullph|invweibullphtail|invweibulltail|irecode|issymmetric|itrim|J|laplace|laplaceden|laplacetail|length|ln|lncauchyden|lnfactorial|lngamma|lnigammaden|lnigaussianden|lniwishartden|lnlaplaceden|lnmvnormalden|lnnormal|lnnormalden|lnwishartden|log|log10|logistic|logisticden|logistictail|logit|lower|ltrim|matmissing|matrix|matuniform|max|maxbyte|maxdouble|maxfloat|maxint|maxlong|mdy|mdyhms|mi|min|minbyte|mindouble|minfloat|minint|minlong|minutes|missing|mm|mmC|mod|mofd|month|monthly|mreldif|msofhours|msofminutes|msofseconds|nbetaden|nbinomial|nbinomialp|nbinomialtail|nchi2|nchi2den|nchi2tail|nF|nFden|nFtail|nibeta|normal|normalden|npnchi2|npnF|npnt|nt|ntden|nttail|nullmat|plural|poisson|poissonp|poissontail|proper|qofd|quarter|quarterly|r|rbeta|rbinomial|rcauchy|rchi2|real|recode|regexs|reldif|replay|return|reverse|rexponential|rgamma|rhypergeometric|rigaussian|rlaplace|rlogistic|rnbinomial|rnormal|round|roweqnumb|rownfreeparms|rownumb|rowsof|rpoisson|rt|rtrim|runiform|runiformint|rweibull|rweibullph|s|scalar|seconds|sign|sin|sinh|smallestdouble|soundex|sqrt|ss|ssC|string|stritrim|strlen|strlower|strltrim|strmatch|strofreal|strpos|strproper|strreverse|strrpos|strrtrim|strtoname|strtrim|strupper|subinstr|subinword|substr|sum|sweep|t|tan|tanh|tc|tC|td|tden|th|tin|tm|tobytes|tq|trace|trigamma|trim|trunc|ttail|tukeyprob|tw|twithin|uchar|udstrlen|udsubstr|uisdigit|uisletter|upper|ustrcompare|ustrcompareex|ustrfix|ustrfrom|ustrinvalidcnt|ustrleft|ustrlen|ustrlower|ustrltrim|ustrnormalize|ustrpos|ustrregexs|ustrreverse|ustrright|ustrrpos|ustrrtrim|ustrsortkey|ustrsortkeyex|ustrtitle|ustrto|ustrtohex|ustrtoname|ustrtrim|ustrunescape|ustrupper|ustrword|ustrwordcount|usubinstr|usubstr|vec|vecdiag|week|weekly|weibull|weibullden|weibullph|weibullphden|weibullphtail|weibulltail|wofd|word|wordbreaklocale|wordcount|year|yearly|yh|ym|yofd|yq|yw)|([\\w&&[^0-9]]\\w{0,31}))(\\()", 765 | "beginCaptures": { 766 | "2": { 767 | "name": "support.function.builtin.stata" 768 | }, 769 | "3": { 770 | "name": "support.function.custom.stata" 771 | }, 772 | "4": { 773 | "name": "punctuation.definition.parameters.begin.stata" 774 | } 775 | }, 776 | "end": "(\\))", 777 | "endCaptures": { 778 | "1": { 779 | "name": "punctuation.definition.parameters.end.stata" 780 | } 781 | }, 782 | "patterns": [ 783 | { 784 | "match": "[\\w&&[^0-9]]\\w{0,31}", 785 | "name": "variable.parameter.function.stata" 786 | }, 787 | { 788 | "begin": "\\(", 789 | "end": "\\)", 790 | "beginCaptures": { 791 | "0": { 792 | "name": "keyword.operator.parentheses.stata" 793 | } 794 | }, 795 | "endCaptures": { 796 | "0": { 797 | "name": "keyword.operator.parentheses.stata" 798 | } 799 | }, 800 | "patterns": [ 801 | { 802 | "include": "#ascii-regex-functions" 803 | }, 804 | { 805 | "include": "#unicode-regex-functions" 806 | }, 807 | { 808 | "include": "#functions" 809 | }, 810 | { 811 | "include": "#subscripts" 812 | }, 813 | { 814 | "include": "#constants" 815 | }, 816 | { 817 | "include": "#comments" 818 | }, 819 | { 820 | "include": "#operators" 821 | }, 822 | { 823 | "include": "#macro-local" 824 | }, 825 | { 826 | "include": "#macro-global" 827 | }, 828 | { 829 | "include": "#string-compound" 830 | }, 831 | { 832 | "include": "#string-regular" 833 | }, 834 | { 835 | "include": "#builtin_variables" 836 | }, 837 | { 838 | "include": "#macro-commands" 839 | }, 840 | { 841 | "include": "#braces-without-error" 842 | }, 843 | { 844 | "match": "[\\w&&[^0-9]]\\w{0,31}", 845 | "name": "variable.parameter.function.stata" 846 | } 847 | ] 848 | }, 849 | { 850 | "include": "#ascii-regex-functions" 851 | }, 852 | { 853 | "include": "#unicode-regex-functions" 854 | }, 855 | { 856 | "include": "#functions" 857 | }, 858 | { 859 | "include": "#subscripts" 860 | }, 861 | { 862 | "include": "#constants" 863 | }, 864 | { 865 | "include": "#comments" 866 | }, 867 | { 868 | "include": "#operators" 869 | }, 870 | { 871 | "include": "#macro-local" 872 | }, 873 | { 874 | "include": "#macro-global" 875 | }, 876 | { 877 | "include": "#string-compound" 878 | }, 879 | { 880 | "include": "#string-regular" 881 | }, 882 | { 883 | "include": "#builtin_variables" 884 | }, 885 | { 886 | "include": "#macro-commands" 887 | }, 888 | { 889 | "include": "#braces-without-error" 890 | } 891 | ] 892 | } 893 | ] 894 | }, 895 | "builtin_types": { 896 | "patterns": [ 897 | { 898 | "match": "\\b(byte|int|long|float|double|str[1-9]?[0-9]?[0-9]?[0-9]?|strL)\\b", 899 | "name": "support.type.stata" 900 | } 901 | ] 902 | }, 903 | "builtin_variables": { 904 | "patterns": [ 905 | { 906 | "match": "\\b(_b|_coef|_cons|_n|_N|_rc|_se)\\b", 907 | "name": "variable.object.stata" 908 | } 909 | ] 910 | }, 911 | "braces-without-error": { 912 | "patterns": [ 913 | { 914 | "begin": "\\{", 915 | "beginCaptures": { 916 | "0": { 917 | "name": "keyword.control.block.begin.stata" 918 | } 919 | }, 920 | "end": "\\}", 921 | "endCaptures": { 922 | "0": { 923 | "name": "keyword.control.block.end.stata" 924 | } 925 | } 926 | } 927 | ] 928 | }, 929 | "braces-with-error": { 930 | "patterns": [ 931 | { 932 | "comment": "correct with nothing else on the line but whitespace; before and after; before; after; correct", 933 | "begin": "(\\{)\\s*([^\\n]*)(?=\\n)", 934 | "beginCaptures": { 935 | "1": { 936 | "name": "keyword.control.block.begin.stata" 937 | }, 938 | "2": { 939 | "patterns": [ 940 | { 941 | "include": "#comments" 942 | }, 943 | { 944 | "match": "[^\\n]+", 945 | "name": "illegal.invalid.name.stata" 946 | } 947 | ] 948 | } 949 | }, 950 | "end": "^\\s*(\\})\\s*$|^\\s*([^\\*\"\\}]+)\\s+(\\})\\s*([^\\*\"\\}/\\n]+)|^\\s*([^\"\\*\\}]+)\\s+(\\})|\\s*(\\})\\s*([^\"\\*\\}/\\n]+)|(\\})$", 951 | "endCaptures": { 952 | "1": { 953 | "name": "keyword.control.block.end.stata" 954 | }, 955 | "2": { 956 | "name": "invalid.illegal.name.stata" 957 | }, 958 | "3": { 959 | "name": "keyword.control.block.end.stata" 960 | }, 961 | "4": { 962 | "name": "invalid.illegal.name.stata" 963 | }, 964 | "5": { 965 | "name": "invalid.illegal.name.stata" 966 | }, 967 | "6": { 968 | "name": "keyword.control.block.end.stata" 969 | }, 970 | "7": { 971 | "name": "keyword.control.block.end.stata" 972 | }, 973 | "8": { 974 | "name": "invalid.illegal.name.stata" 975 | }, 976 | "9": { 977 | "name": "keyword.control.block.end.stata" 978 | } 979 | }, 980 | "patterns": [ 981 | { 982 | "include": "$self" 983 | } 984 | ] 985 | } 986 | ] 987 | }, 988 | "commands-other": { 989 | "patterns": [ 990 | { 991 | "comment": "Add on commands", 992 | "match": "\\b(reghdfe|ivreghdfe|ivreg2|outreg|gcollapse|gcontract|gegen|gisid|glevelsof|gquantiles)\\b", 993 | "name": "keyword.control.flow.stata" 994 | }, 995 | { 996 | "comment": "Built in commands", 997 | "match": "\\b(about|ac|acprplot|ado|adopath|adoupdate|alpha|ameans|an|ano|anov|anova|anova_terms|anovadef|aorder|ap|app|appe|appen|append|arch|arch_dr|arch_estat|arch_p|archlm|areg|areg_p|args|arima|arima_dr|arima_estat|arima_p|asmprobit|asmprobit_estat|asmprobit_lf|asmprobit_mfx__dlg|asmprobit_p|avplot|avplots|bcskew0|bgodfrey|binreg|bip0_lf|biplot|bipp_lf|bipr_lf|bipr_p|biprobit|bitest|bitesti|bitowt|blogit|bmemsize|boot|bootsamp|boxco_l|boxco_p|boxcox|boxcox_p|bprobit|br|break|brier|bro|brow|brows|browse|brr|brrstat|bs|bsampl_w|bsample|bsqreg|bstat|bstrap|ca|ca_estat|ca_p|cabiplot|camat|canon|canon_estat|canon_p|caprojection|cat|cc|cchart|cci|cd|censobs_table|centile|cf|char|chdir|checkdlgfiles|checkestimationsample|checkhlpfiles|checksum|chelp|ci|cii|cl|class|classutil|clear|cli|clis|clist|clog|clog_lf|clog_p|clogi|clogi_sw|clogit|clogit_lf|clogit_p|clogitp|clogl_sw|cloglog|clonevar|clslistarray|cluster|cluster_measures|cluster_stop|cluster_tree|cluster_tree_8|clustermat|cmdlog|cnr|cnre|cnreg|cnreg_p|cnreg_sw|cnsreg|codebook|collaps4|collapse|colormult_nb|colormult_nw|compare|compress|conf|confi|confir|confirm|conren|cons|const|constr|constra|constrai|constrain|constraint|contract|copy|copyright|copysource|cor|corc|corr|corr2data|corr_anti|corr_kmo|corr_smc|corre|correl|correla|correlat|correlate|corrgram|cou|coun|count|cprplot|crc|cret|cretu|cretur|creturn|cross|cs|cscript|cscript_log|csi|ct|ct_is|ctset|ctst_st|cttost|cumsp|cumul|cusum|cutil|d|datasig|datasign|datasigna|datasignat|datasignatu|datasignatur|datasignature|datetof|db|dbeta|de|dec|deco|decod|decode|deff|des|desc|descr|descri|describ|describe|dfbeta|dfgls|dfuller|di|di_g|dir|dirstats|dis|discard|disp|disp_res|disp_s|displ|displa|display|do|doe|doed|doedi|doedit|dotplot|dprobit|drawnorm|ds|ds_util|dstdize|duplicates|durbina|dwstat|dydx|ed|edi|edit|eivreg|emdef|en|enc|enco|encod|encode|eq|erase|ereg|ereg_lf|ereg_p|ereg_sw|ereghet|ereghet_glf|ereghet_glf_sh|ereghet_gp|ereghet_ilf|ereghet_ilf_sh|ereghet_ip|eret|eretu|eretur|ereturn|err|erro|error|est|est_cfexist|est_cfname|est_clickable|est_expand|est_hold|est_table|est_unhold|est_unholdok|estat|estat_default|estat_summ|estat_vce_only|esti|estimates|etodow|etof|etomdy|expand|expandcl|fac|fact|facto|factor|factor_estat|factor_p|factor_pca_rotated|factor_rotate|factormat|fcast|fcast_compute|fcast_graph|fdades|fdadesc|fdadescr|fdadescri|fdadescrib|fdadescribe|fdasav|fdasave|fdause|fh_st|file|filefilter|fillin|find_hlp_file|findfile|findit|fit|fl|fli|flis|flist|fpredict|frac_adj|frac_chk|frac_cox|frac_ddp|frac_dis|frac_dv|frac_in|frac_mun|frac_pp|frac_pq|frac_pv|frac_wgt|frac_xo|fracgen|fracplot|fracpoly|fracpred|fron_ex|fron_hn|fron_p|fron_tn|fron_tn2|frontier|ftodate|ftoe|ftomdy|ftowdate|gamhet_glf|gamhet_gp|gamhet_ilf|gamhet_ip|gamma|gamma_d2|gamma_p|gamma_sw|gammahet|gdi_hexagon|gdi_spokes|genrank|genstd|genvmean|gettoken|gladder|glim_l01|glim_l02|glim_l03|glim_l04|glim_l05|glim_l06|glim_l07|glim_l08|glim_l09|glim_l10|glim_l11|glim_l12|glim_lf|glim_mu|glim_nw1|glim_nw2|glim_nw3|glim_p|glim_v1|glim_v2|glim_v3|glim_v4|glim_v5|glim_v6|glim_v7|glm|glm_p|glm_sw|glmpred|glogit|glogit_p|gmeans|gnbre_lf|gnbreg|gnbreg_p|gomp_lf|gompe_sw|gomper_p|gompertz|gompertzhet|gomphet_glf|gomphet_glf_sh|gomphet_gp|gomphet_ilf|gomphet_ilf_sh|gomphet_ip|gphdot|gphpen|gphprint|gprefs|gprobi_p|gprobit|gr|gr7|gr_copy|gr_current|gr_db|gr_describe|gr_dir|gr_draw|gr_draw_replay|gr_drop|gr_edit|gr_editviewopts|gr_example|gr_example2|gr_export|gr_print|gr_qscheme|gr_query|gr_read|gr_rename|gr_replay|gr_save|gr_set|gr_setscheme|gr_table|gr_undo|gr_use|graph|grebar|greigen|grmeanby|gs_fileinfo|gs_filetype|gs_graphinfo|gs_stat|gsort|gwood|h|hareg|hausman|haver|he|heck_d2|heckma_p|heckman|heckp_lf|heckpr_p|heckprob|hel|help|hereg|hetpr_lf|hetpr_p|hetprob|hettest|hexdump|hilite|hist|histogram|hlogit|hlu|hmeans|hotel|hotelling|hprobit|hreg|hsearch|icd9|icd9_ff|icd9p|iis|impute|imtest|inbase|include|inf|infi|infil|infile|infix|inp|inpu|input|ins|insheet|insp|inspe|inspec|inspect|integ|inten|intreg|intreg_p|intrg2_ll|intrg_ll|intrg_ll2|ipolate|iqreg|ir|irf|irf_create|irfm|iri|is_svy|is_svysum|isid|istdize|ivprobit|ivprobit_p|ivreg|ivreg_footnote|ivtob_lf|ivtobit|ivtobit_p|jacknife|jknife|jkstat|joinby|kalarma1|kap|kapmeier|kappa|kapwgt|kdensity|ksm|ksmirnov|ktau|kwallis|labelbook|ladder|levelsof|leverage|lfit|lfit_p|li|lincom|line|linktest|lis|list|lloghet_glf|lloghet_glf_sh|lloghet_gp|lloghet_ilf|lloghet_ilf_sh|lloghet_ip|llogi_sw|llogis_p|llogist|llogistic|llogistichet|lnorm_lf|lnorm_sw|lnorma_p|lnormal|lnormalhet|lnormhet_glf|lnormhet_glf_sh|lnormhet_gp|lnormhet_ilf|lnormhet_ilf_sh|lnormhet_ip|lnskew0|loadingplot|(?=|:=|==|!=|~=|<|>|=|!!|!)", 1935 | "name": "keyword.operator.comparison.stata" 1936 | }, 1937 | { 1938 | "match": "\\(|\\)", 1939 | "name": "keyword.operator.parentheses.stata" 1940 | }, 1941 | { 1942 | "match": "(##|#)", 1943 | "name": "keyword.operator.factor-variables.stata" 1944 | }, 1945 | { 1946 | "match": "%", 1947 | "name": "keyword.operator.format.stata" 1948 | }, 1949 | { 1950 | "match": ":", 1951 | "name": "punctuation.separator.key-value" 1952 | }, 1953 | { 1954 | "match": "\\[", 1955 | "name": "punctuation.definition.parameters.begin.stata" 1956 | }, 1957 | { 1958 | "match": "\\]", 1959 | "name": "punctuation.definition.parameters.end.stata" 1960 | }, 1961 | { 1962 | "match": ",", 1963 | "name": "punctuation.definition.variable.begin.stata" 1964 | }, 1965 | { 1966 | "match": ";", 1967 | "name": "keyword.operator.delimiter.stata" 1968 | } 1969 | ] 1970 | }, 1971 | "string-compound": { 1972 | "patterns": [ 1973 | { 1974 | "begin": "`\"", 1975 | "beginCaptures": { 1976 | "0": { 1977 | "name": "punctuation.definition.string.begin.stata" 1978 | } 1979 | }, 1980 | "end": "\"'|(?=\n)", 1981 | "endCaptures": { 1982 | "0": { 1983 | "name": "punctuation.definition.string.end.stata" 1984 | } 1985 | }, 1986 | "name": "string.quoted.double.compound.stata", 1987 | "patterns": [ 1988 | { 1989 | "match": "\"", 1990 | "name": "string.quoted.double.compound.stata", 1991 | "comment": "This must come before #string-regular and #string-compound to accurately color `\"\"\"' in strings" 1992 | }, 1993 | { 1994 | "match": "```(?=[^']*\")", 1995 | "name": "meta.markdown.code.block.stata", 1996 | "comment": "see https://github.com/kylebarron/language-stata/issues/53" 1997 | }, 1998 | { 1999 | "include": "#string-regular" 2000 | }, 2001 | { 2002 | "include": "#string-compound" 2003 | }, 2004 | { 2005 | "include": "#macro-local-escaped" 2006 | }, 2007 | { 2008 | "include": "#macro-global-escaped" 2009 | }, 2010 | { 2011 | "include": "#macro-local" 2012 | }, 2013 | { 2014 | "include": "#macro-global" 2015 | } 2016 | ] 2017 | } 2018 | ] 2019 | }, 2020 | "string-regular": { 2021 | "patterns": [ 2022 | { 2023 | "begin": "(?