All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.dingyi222666.monarch.languages.LanguageFlow9.kt Maven / Gradle / Ivy

The newest version!
package io.github.dingyi222666.monarch.languages

import io.github.dingyi222666.monarch.common.*
 import io.github.dingyi222666.monarch.loader.dsl.*
import io.github.dingyi222666.monarch.types.IMonarchLanguage

public val Flow9Language: IMonarchLanguage by lazy {
  buildMonarchLanguage {
    tokenPostfix = ".flow"
    defaultToken = ""
    keywords("import", "require", "export", "forbid", "native", "if", "else", "cast", "unsafe",
        "switch", "default")
    "types" and listOf("io", "mutable", "bool", "int", "double", "string", "flow", "void", "ref",
        "true", "false", "with")
    operators("=", ">", "<", "<=", ">=", "==", "!", "!=", ":=", "::=", "&&", "||", "+", "-", "*",
        "/", "@", "&", "%", ":", "->", "\\", "\$", "??", "^")
    symbols("[@${'$'}=>](?!@symbols)".token("delimiter")
        "@symbols".action {
          cases {
            "@operators" and "delimiter"
            "@default" and ""
          }
        }
        "((0(x|X)[0-9a-fA-F]*)|(([0-9]+\\.?[0-9]*)|(\\.[0-9]+))((e|E)(\\+|-)?[0-9]+)?)".token("number")
        "[;,.]".token("delimiter")
        "\"([^\"\\\\]|\\\\.)*${'$'}".token("string.invalid")
        "\"".action("string").state("@string")
      }
      whitespace {
        "[ \\t\\r\\n]+".token("")
        "\\/\\*".action("comment").state("@comment")
        "\\/\\/.*${'$'}".token("comment")
      }
      comment {
        "[^\\/*]+".token("comment")
        "\\*\\/".action("comment").state("@pop")
        "[\\/*]".token("comment")
      }
      string {
        "[^\\\\\"]+".token("string")
        "@escapes".token("string.escape")
        "\\\\.".token("string.escape.invalid")
        "\"".action("string").state("@pop")
      }
    }
  }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy