forked from jasder/antlr
Merge branch 'master-upstream'
This commit is contained in:
commit
a53c49ff44
|
@ -154,6 +154,10 @@ In order to execute this listener, you would simply add the following lines to t
|
|||
antlr4.tree.ParseTreeWalker.DEFAULT.walk(printer, tree);
|
||||
```
|
||||
|
||||
## What about TypeScript?
|
||||
|
||||
We currently do not have a TypeScript target, but Sam Harwell is [working on a port](https://github.com/tunnelvisionlabs/antlr4ts). [Here](https://github.com/ChuckJonas/extract-interface-ts) is Section 4.3 of [ANTLR 4 book](http://a.co/5jUJYmh) converted to typescript.
|
||||
|
||||
## How do I integrate my parser with ACE editor?
|
||||
|
||||
This specific task is described in this [dedicated page](ace-javascript-target.md).
|
||||
|
|
|
@ -19,13 +19,19 @@ type FileStream struct {
|
|||
filename string
|
||||
}
|
||||
|
||||
func NewFileStream(fileName string) *FileStream {
|
||||
func NewFileStream(fileName string) (*FileStream, error) {
|
||||
|
||||
buf := bytes.NewBuffer(nil)
|
||||
|
||||
f, _ := os.Open(fileName) // Error handling elided for brevity.
|
||||
io.Copy(buf, f) // Error handling elided for brevity.
|
||||
f.Close()
|
||||
f, err := os.Open(fileName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer f.Close()
|
||||
err = io.Copy(buf, f)
|
||||
if err != nil {
|
||||
return nil, er
|
||||
}
|
||||
|
||||
fs := new(FileStream)
|
||||
|
||||
|
@ -34,7 +40,7 @@ func NewFileStream(fileName string) *FileStream {
|
|||
|
||||
fs.InputStream = NewInputStream(s)
|
||||
|
||||
return fs
|
||||
return fs, nil
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue