Skip to content

Commit

Permalink
Change the default suffix of a grammar file from .vr to .vartan
Browse files Browse the repository at this point in the history
  • Loading branch information
nihei9 committed May 10, 2022
1 parent 0ff00d2 commit 0b858d6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ div
: '/';
```

Save the above grammar to a file in UTF-8. In this explanation, the file name is `expr.vr`.
Save the above grammar to a file in UTF-8. In this explanation, the file name is `expr.vartan`.

⚠️ The input file must be encoded in UTF-8.

Expand All @@ -76,7 +76,7 @@ Save the above grammar to a file in UTF-8. In this explanation, the file name is
Next, generate a parsing table using `vartan compile` command.

```sh
$ vartan compile expr.vr -o expr.json
$ vartan compile expr.vartan -o expr.json
```

### 3. Debug
Expand Down
6 changes: 3 additions & 3 deletions cmd/vartan/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func init() {
cmd := &cobra.Command{
Use: "compile",
Short: "Compile grammar you defined into a parsing table",
Example: ` vartan compile grammar.vr -o grammar.json`,
Example: ` vartan compile grammar.vartan -o grammar.json`,
Args: cobra.MaximumNArgs(1),
RunE: runCompile,
}
Expand Down Expand Up @@ -95,7 +95,7 @@ func runCompile(cmd *cobra.Command, args []string) (retErr error) {
return err
}

grmPath = filepath.Join(tmpDirPath, "stdin.vr")
grmPath = filepath.Join(tmpDirPath, "stdin.vartan")
err = ioutil.WriteFile(grmPath, src, 0600)
if err != nil {
return err
Expand All @@ -110,7 +110,7 @@ func runCompile(cmd *cobra.Command, args []string) (retErr error) {
var reportFileName string
{
_, grmFileName := filepath.Split(grmPath)
reportFileName = fmt.Sprintf("%v-report.json", strings.TrimSuffix(grmFileName, ".vr"))
reportFileName = fmt.Sprintf("%v-report.json", strings.TrimSuffix(grmFileName, ".vartan"))
}

opts := []grammar.CompileOption{
Expand Down

0 comments on commit 0b858d6

Please sign in to comment.