diff --git a/examples/.snapshot b/examples/.snapshot index 906d1a1..d6372df 100644 --- a/examples/.snapshot +++ b/examples/.snapshot @@ -3,7 +3,7 @@ exports[`examples > fibonacci.plz --input="not a number" > stderr 1`] = ` `; exports[`examples > fibonacci.plz --input="not a number" > stdout 1`] = ` -"input must be a natural number" +"--input must be a natural number" `; @@ -12,7 +12,7 @@ exports[`examples > fibonacci.plz --input=-1 > stderr 1`] = ` `; exports[`examples > fibonacci.plz --input=-1 > stdout 1`] = ` -"input must be a natural number" +"--input must be a natural number" `; @@ -57,7 +57,7 @@ exports[`examples > fibonacci.plz > stderr 1`] = ` `; exports[`examples > fibonacci.plz > stdout 1`] = ` -"missing input argument" +"missing --input argument" `; diff --git a/examples/fibonacci.plz b/examples/fibonacci.plz index 0080f70..6e1825e 100644 --- a/examples/fibonacci.plz +++ b/examples/fibonacci.plz @@ -1,21 +1,22 @@ { fibonacci: n => @if { - condition: :n < 2 + :n < 2 then: :n else: :fibonacci(:n - 1) + :fibonacci(:n - 2) } input: @runtime { context => + // read --input from command-line arguments :context.arguments.lookup(input) } output: :input match { - none: _ => "missing input argument" + none: _ => "missing --input argument" some: input => @if { - condition: :natural_number.is(:input) + :natural_number.is(:input) then: :fibonacci(:input) - else: "input must be a natural number" + else: "--input must be a natural number" } } }.output diff --git a/package.json b/package.json index 307a4e8..8049fd4 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "0.0.0", "type": "module", "bin": { - "please": "./please" + "please": "please" }, "scripts": { "0": "node ./dist/language/cli/0.js", diff --git a/src/language/parsing/atom.ts b/src/language/parsing/atom.ts index adf87a7..18edad1 100644 --- a/src/language/parsing/atom.ts +++ b/src/language/parsing/atom.ts @@ -11,6 +11,7 @@ import { zeroOrMore, } from '@matt.kantor/parsing' import { + arrow, atSign, backslash, closingBlockCommentDelimiter, @@ -32,6 +33,7 @@ import { whitespace } from './trivia.js' export type Atom = string const atomComponentsRequiringQuotation = [ + arrow, atSign, backslash, closingBlockCommentDelimiter, @@ -46,10 +48,8 @@ const atomComponentsRequiringQuotation = [ singleLineCommentDelimiter, whitespace, - // Reserved to allow symbols like `=>` to not be conflated with atoms: - literal('='), - // Reserved for future use: + literal('='), literal('['), literal(']'), literal('#'),