Sha256: 7335aeac219ad4be4f8829a8949d2ed3eb3e49aa13cfad298dc420a0d93e9dc3

Contents?: true

Size: 1.09 KB

Versions: 5

Compression:

Stored size: 1.09 KB

Contents

grammar Finitio::Syntax::Lexer

  # LEXER (keywords)

  rule keyword
    'and' | 'or' | 'not' | 'true' | 'false'
  end

  # LEXER (names)

  rule var_name
    /[a-z]+/
  end

  rule contract_name
    /[a-z][a-z0-9]*/
  end

  rule constraint_name
    /[a-z][a-zA-Z_]*/
  end

  rule attribute_name
    /[a-z_][a-zA-Z0-9_\-]*/
  end

  rule type_name
    /[A-Z][a-zA-Z]*(\.[A-Z][a-zA-Z]+)*/
  end

  rule builtin_type_name
    /[a-zA-Z0-9:]+/
  end

  rule import_url
    (!space .)+
  end

  # LEXER symbols

  rule equal
    spacing '=' spacing
  end

  rule dots
    spacing '...' spacing
  end

  rule opt_comma
    spacing ',' spacing | spacing
  end

  rule comma
    spacing ',' spacing
  end

  rule pipe
    spacing '|' spacing
  end

  rule colon
    spacing ':' spacing
  end

  rule open_metadata
    spacing '/-' spacing
  end

  rule close_metadata
    spacing '-/' spacing
  end

  # LEXER (spacing & comments)

  rule spacing
    (spaces | comment)*
  end

  rule comment
    '#' (![\n] .)* [\n]?
  end

  rule spaces
    space+
  end

  rule space
    [ \t\n]
  end

  rule eof
    !.
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
finitio-0.12.0 lib/finitio/syntax/lexer.citrus
finitio-0.11.4 lib/finitio/syntax/lexer.citrus
finitio-0.11.3 lib/finitio/syntax/lexer.citrus
finitio-0.11.2 lib/finitio/syntax/lexer.citrus
finitio-0.11.1 lib/finitio/syntax/lexer.citrus