Skip to content

Commit

Permalink
linter: Add edn dialect
Browse files Browse the repository at this point in the history
  • Loading branch information
candid82 committed Feb 9, 2017
1 parent 8b88dae commit 70942ae
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
3 changes: 2 additions & 1 deletion core/procs.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const (
CLJ Dialect = iota
CLJS
JOKER
EDN
)

func ensureArrayMap(args []Object, index int) *ArrayMap {
Expand Down Expand Up @@ -1317,7 +1318,7 @@ func processData(data []byte) {
}

func ProcessLinterData(dialect Dialect) {
if dialect == JOKER {
if dialect == JOKER || dialect == EDN {
return
}
reader := bytes.NewReader(linter_cljxData)
Expand Down
11 changes: 7 additions & 4 deletions core/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type (
const EOF = -1

var LINTER_MODE bool = false
var DIALECT Dialect

var (
ARGS map[int]Symbol
Expand Down Expand Up @@ -741,11 +742,13 @@ func makeSyntaxQuote(obj Object, env map[*string]Symbol, reader *Reader) Object

func handleNoReaderError(reader *Reader, s Symbol) Object {
if LINTER_MODE {
filename := "<file>"
if reader.filename != nil {
filename = *reader.filename
if DIALECT != EDN {
filename := "<file>"
if reader.filename != nil {
filename = *reader.filename
}
fmt.Fprintf(os.Stderr, "%s:%d:%d: Read warning: No reader function for tag %s\n", filename, reader.line, reader.column, s.ToString(false))
}
fmt.Fprintf(os.Stderr, "%s:%d:%d: Read warning: No reader function for tag %s\n", filename, reader.line, reader.column, s.ToString(false))
return Read(reader)
}
panic(MakeReadError(reader, "No reader function for tag "+s.ToString(false)))
Expand Down
4 changes: 4 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ func repl(phase Phase) {

func configureLinterMode(dialect Dialect) {
LINTER_MODE = true
DIALECT = dialect
lm, _ := GLOBAL_ENV.Resolve(MakeSymbol("core/*linter-mode*"))
lm.Value = Bool{B: true}
ProcessLinterData(dialect)
Expand Down Expand Up @@ -184,6 +185,9 @@ func main() {
case "--lintjoker":
configureLinterMode(JOKER)
processFile(os.Args[2], PARSE)
case "--lintedn":
configureLinterMode(EDN)
processFile(os.Args[2], READ)
default:
processFile(os.Args[1], EVAL)
}
Expand Down

0 comments on commit 70942ae

Please sign in to comment.