From 8c05696ed4c2ec77abb921b6c3c73e6589a3efc0 Mon Sep 17 00:00:00 2001 From: parrt Date: Wed, 26 Apr 2017 09:56:31 -0700 Subject: [PATCH 1/2] update js doc --- doc/javascript-target.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/javascript-target.md b/doc/javascript-target.md index fc3c22e54..144aa5f81 100644 --- a/doc/javascript-target.md +++ b/doc/javascript-target.md @@ -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). From 32a8874a29d270a3df9b5d25dcb82006e40adff7 Mon Sep 17 00:00:00 2001 From: David Sisson Date: Thu, 27 Apr 2017 21:40:44 -0700 Subject: [PATCH 2/2] Add proper error handling semantics to FileStream. --- runtime/Go/antlr/file_stream.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/runtime/Go/antlr/file_stream.go b/runtime/Go/antlr/file_stream.go index f4692ec9d..540cf5030 100644 --- a/runtime/Go/antlr/file_stream.go +++ b/runtime/Go/antlr/file_stream.go @@ -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 }