Lexical Structure

Comments

Lexer
LINE_COMMENT :
      // (~\n)*

BLOCK_COMMENT :
      /* (BLOCK_COMMENT | ~*/)* */

Comments have no effect on the program.

// This is a line comment

/*
 * And this is a multiline (block) comment.
 * The stars on the left are purely for aesthetics
 */

Names

Lexer
ID :
      (ID_START ID_CONT*)Expect keywords

ID_START :
      [a-z A-Z]

ID_CONT :
      [_ a-z A-Z 0-9]

Syntax
ID_List :
      ID (, ID)* ,?

Some valid identifiers are:

  • snake_case
  • PascalCase
  • letters123

Some invalid identifiers are:

  • chan, a keyword
  • 3D, starts with a number
  • kebab-case, same as kebab - case

Keywords

KeywordUsage
typeDefine a type, Existentials, Universals
decDeclare a value
defDefine a value
chanChannel expressions, Dualize types
letLet expressions and statements
doDo expressions
inLet expressions, Do expressions
begin, loopIterative constructions, Recursive destruction (expression or statement)
eitherEither types
recursiveRecursive types
iterativeIterative types
selfRecursive and iterative types
unfoundedEscape totality checker in recursive expressions and statements

Punctuation

SymbolUsage
=Definitions (values and types), Let expressions and statements
:Type annotations, Value declarations, Loop labels
,Various enumerations
!Unit type, expression, pattern, Break command
?Bottom type, Continue command
.Labels of either or choice types, used in various places
<>Link commands
<Type parameters and arguments
>Type parameters and arguments
=>Choice types and constructions, Match expressions and commands
()Pairs, function application
[]Functions, pair destruction
{}Either and choice types, processes

Whitespace

Whitespace in Par serves merely the purpose of separating tokens. Whitespace characters are:

  • The whitespace ' '
  • Tabs '\t', '\v'
  • Newline '\n'
  • Carriage return '\r'