diff --git a/.hypatia-ignore b/.hypatia-ignore index fa33ca1d..dae7e054 100644 --- a/.hypatia-ignore +++ b/.hypatia-ignore @@ -44,25 +44,6 @@ cicd_rules/banned_language_file:formal/Makefile.conf # handled by in-file `hypatia: allow` directives, not here.) code_safety/admitted:formal/Semantics.v -# ─── Stale duplicate linter (lib/linter.rs) ──────────────────────────────────── -# -# lib/linter.rs (178 lines) is a stale/legacy sibling of the live -# src/ephapax-tools/src/linter.rs (920 lines). Its two `line.find(..).unwrap_or(0)+1` -# sites compute 1-based diagnostic columns; 0 is a benign "column 1" default, not a -# masked fault. Exempted pending an owner decision on whether to remove the duplicate. -code_safety/unwrap_dangerous_default:lib/linter.rs - -# ─── SD009: legacy OCaml files without SPDX headers (src/*.ml) ────────────────── -# -# src/{lexer,parser,ast,typecheck}.ml are legacy OCaml artefacts in a Rust/Coq/Idris -# project (the live type checker is Rust). Adding licence headers is an SPDX edit, -# which estate policy reserves for the owner (no-automated-licence-edits). Flag-only: -# exempted here and surfaced to the owner — these are also candidates for removal. -structural_drift/SD009:src/lexer.ml -structural_drift/SD009:src/parser.ml -structural_drift/SD009:src/ast.ml -structural_drift/SD009:src/typecheck.ml - # ─── SD022: doc references to pre-restructure directories (deferred doc refresh) ─ # # EXPLAINME/README/ROADMAP.adoc + tests/fuzz/FUZZING_GUIDE.md reference dirs diff --git a/lib/formatter.rs b/lib/formatter.rs deleted file mode 100644 index a9432bf2..00000000 --- a/lib/formatter.rs +++ /dev/null @@ -1,99 +0,0 @@ -// SPDX-License-Identifier: MPL-2.0 -// Owner: Jonathan D.A. Jewell -// Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) -// -//! Ephapax Code Formatter — consistent formatting for .eph files. -//! -//! Formatting rules: -//! - 4-space indentation (no tabs) -//! - Opening brace on same line as declaration -//! - Closing brace on its own line, aligned with declaration -//! - One space around binary operators -//! - No trailing whitespace -//! - Single blank line between top-level declarations -//! - Region annotations (@r) directly attached to the method call (no space) -//! - let! aligned with let (the ! is part of the keyword, not punctuation) -//! -//! Integration: -//! - Used by ephapax-lsp for format-on-save -//! - Can be run standalone via `ephapax fmt ` - -/// Formatter configuration. -pub struct FormatConfig { - /// Number of spaces per indent level. - pub indent_width: usize, - /// Maximum line width before wrapping. - pub max_line_width: usize, - /// Whether to add a trailing newline. - pub trailing_newline: bool, -} - -impl Default for FormatConfig { - fn default() -> Self { - Self { - indent_width: 4, - max_line_width: 100, - trailing_newline: true, - } - } -} - -/// Format a source file. -/// -/// This is an intentional whitespace-only normaliser used by the -/// standalone heuristic tooling in `tools/`. The compiler-integrated -/// path goes through `ephapax-parser` + pretty-printer instead; this -/// shim exists to avoid linking the full compiler for lightweight -/// editor or MCP-cartridge use. -pub fn format_source(source: &str, config: &FormatConfig) -> String { - let mut output = String::with_capacity(source.len()); - let mut prev_blank = false; - - for line in source.lines() { - let trimmed = line.trim_end(); - - // Collapse multiple blank lines into one - if trimmed.is_empty() { - if !prev_blank { - output.push('\n'); - } - prev_blank = true; - continue; - } - prev_blank = false; - - // Normalise indentation: convert tabs to spaces - let indent_count = line.len() - line.trim_start().len(); - let current_char = line.as_bytes().get(0).copied().unwrap_or(b' '); - - if current_char == b'\t' { - // Replace tabs with spaces - let tab_count = line.bytes().take_while(|&b| b == b'\t').count(); - let spaces = " ".repeat(tab_count * config.indent_width); - output.push_str(&spaces); - output.push_str(line[tab_count..].trim_end()); - } else { - // Already space-indented — preserve but trim trailing whitespace - output.push_str(trimmed); - } - output.push('\n'); - } - - // Ensure trailing newline - if config.trailing_newline && !output.ends_with('\n') { - output.push('\n'); - } - - // Remove trailing blank lines (keep exactly one newline at end) - while output.ends_with("\n\n") { - output.pop(); - } - - output -} - -/// Check if a source file is already formatted. -/// Returns true if formatting would produce identical output. -pub fn is_formatted(source: &str, config: &FormatConfig) -> bool { - format_source(source, config) == source -} diff --git a/lib/linter.rs b/lib/linter.rs deleted file mode 100644 index 42658bc7..00000000 --- a/lib/linter.rs +++ /dev/null @@ -1,178 +0,0 @@ -// SPDX-License-Identifier: MPL-2.0 -// Owner: Jonathan D.A. Jewell -// Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) -// -//! Ephapax Linter — static analysis for code quality beyond type checking. -//! -//! The linter checks for: -//! - Style issues (naming conventions, indentation) -//! - Unused affine bindings (warning, not error — affine allows drop) -//! - Unconsumed linear bindings (error — also caught by type checker) -//! - Region escape attempts (error — also caught by type checker) -//! - Unnecessary copies (performance warning) -//! - Shadowed bindings (warning) -//! - Missing type annotations on public functions (style) -//! -//! The linter is separate from the type checker. It provides additional -//! diagnostics that improve code quality but are not soundness-critical. -//! -//! Integration: -//! - Used by ephapax-lsp for editor diagnostics -//! - Used by the BoJ lsp-mcp cartridge -//! - Can be run standalone via `ephapax lint ` - -/// Lint severity levels. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum Severity { - Error, - Warning, - Hint, - Info, -} - -/// A lint diagnostic. -#[derive(Debug, Clone)] -pub struct Diagnostic { - pub severity: Severity, - pub code: String, - pub message: String, - pub file: String, - pub line: usize, - pub column: usize, - pub help: Option, -} - -/// Lint rule identifiers. -/// -/// Error codes: -/// - E001: Linear variable not consumed -/// - E002: Variable used after consumption -/// - E003: Region escape detected (value type references exiting region) -/// - E004: Linear variable in region not consumed before region exit -/// - E005: Branches consume different linear variables -/// -/// Warning codes: -/// - W001: Unused affine binding -/// - W002: Unnecessary copy -/// - W003: Shadowed binding -/// - W004: Missing type annotation on public function -/// - W005: Region block with no allocations (unnecessary region) -/// - W006: Affine binding in region could be linear (resource handle pattern) -/// -/// Style codes: -/// - S001: Non-snake_case variable name -/// - S002: Non-PascalCase type name -/// - S003: Inconsistent indentation -/// - S004: Region name should be short lowercase identifier -pub const LINT_RULES: &[(&str, Severity, &str)] = &[ - ("E001", Severity::Error, "Linear variable not consumed"), - ("E002", Severity::Error, "Variable used after consumption"), - ("E003", Severity::Error, "Region escape detected"), - ("E004", Severity::Error, "Linear variable in region not consumed before exit"), - ("E005", Severity::Error, "Branches consume different linear variables"), - ("W001", Severity::Warning, "Unused affine binding"), - ("W002", Severity::Warning, "Unnecessary copy"), - ("W003", Severity::Warning, "Shadowed binding"), - ("W004", Severity::Warning, "Missing type annotation on public function"), - ("W005", Severity::Warning, "Region block with no allocations"), - ("W006", Severity::Warning, "Affine binding could be linear (resource pattern)"), - ("S001", Severity::Hint, "Non-snake_case variable name"), - ("S002", Severity::Hint, "Non-PascalCase type name"), - ("S003", Severity::Hint, "Inconsistent indentation"), - ("S004", Severity::Hint, "Region name should be short lowercase"), -]; - -/// Lint context — accumulates diagnostics during analysis. -pub struct LintContext { - pub diagnostics: Vec, - pub file: String, -} - -impl LintContext { - pub fn new(file: &str) -> Self { - Self { - diagnostics: Vec::new(), - file: file.to_string(), - } - } - - pub fn report(&mut self, severity: Severity, code: &str, message: &str, line: usize, column: usize) { - self.diagnostics.push(Diagnostic { - severity, - code: code.to_string(), - message: message.to_string(), - file: self.file.clone(), - line, - column, - help: None, - }); - } - - pub fn report_with_help(&mut self, severity: Severity, code: &str, message: &str, line: usize, column: usize, help: &str) { - self.diagnostics.push(Diagnostic { - severity, - code: code.to_string(), - message: message.to_string(), - file: self.file.clone(), - line, - column, - help: Some(help.to_string()), - }); - } - - pub fn has_errors(&self) -> bool { - self.diagnostics.iter().any(|d| d.severity == Severity::Error) - } -} - -/// Lint a source file (text-based, pre-AST). -/// -/// Intentional text-based linter for the standalone tooling in -/// `tools/` and the BoJ lsp-mcp cartridge. The compiler-integrated -/// path runs the parser + typechecker directly and gets richer -/// diagnostics; this shim avoids linking the full compiler. -pub fn lint_source(file: &str, source: &str) -> Vec { - let mut ctx = LintContext::new(file); - - for (line_num, line) in source.lines().enumerate() { - let trimmed = line.trim_start(); - - // S001: Check variable naming in let bindings - if trimmed.starts_with("let ") || trimmed.starts_with("let! ") { - let after_let = if trimmed.starts_with("let! ") { - &trimmed[5..] - } else { - &trimmed[4..] - }; - let var_name = after_let.split('=').next().unwrap_or("").trim(); - if !var_name.is_empty() && !var_name.starts_with('_') && !var_name.starts_with('(') { - if var_name.chars().any(|c| c.is_uppercase()) { - ctx.report_with_help( - Severity::Hint, - "S001", - &format!("Variable '{}' should use snake_case", var_name), - line_num + 1, - line.find(var_name).unwrap_or(0) + 1, - &format!("Rename to '{}'", var_name.to_lowercase()), - ); - } - } - } - - // S002: Check type naming - if trimmed.starts_with("type ") { - let type_name = trimmed[5..].split(&['=', '<', ' '][..]).next().unwrap_or("").trim(); - if !type_name.is_empty() && type_name.chars().next().map_or(false, |c| c.is_lowercase()) { - ctx.report( - Severity::Hint, - "S002", - &format!("Type '{}' should use PascalCase", type_name), - line_num + 1, - line.find(type_name).unwrap_or(0) + 1, - ); - } - } - } - - ctx.diagnostics -} diff --git a/src/ast.ml b/src/ast.ml deleted file mode 100644 index a4157338..00000000 --- a/src/ast.ml +++ /dev/null @@ -1,44 +0,0 @@ -(** Ephapax AST - Extended with Choreographic Sessions *) - -(** Literal values *) -type literal = - | Int of int - | String of string - | Bool of bool - -(** Type expressions *) -type typ = - | TypeVar of string - | SessionType of session_decl ref (* Use reference to break circularity *) - -(** Session type declaration *) -and session_decl = { - s_name: string; - s_roles: string list; - s_protocol: message list; -} - -(** Message in a session protocol *) -and message = { - msg_sender: string; - msg_receiver: string; - msg_type: typ; -} - -(** Expression types *) -type expr = - | Session of string * string list - | Send of expr * string * expr - | Receive of expr * string - | Close of expr - | Delegate of expr * string * string - | Var of string - | Literal of literal - -(** Program declarations *) -type decl = - | SessionDecl of session_decl - | ExprDecl of expr - -(** Complete program *) -type program = decl list diff --git a/src/lexer.ml b/src/lexer.ml deleted file mode 100644 index 59e9d821..00000000 --- a/src/lexer.ml +++ /dev/null @@ -1,558 +0,0 @@ -# 1 "src/lexer.mll" - (* Ephapax Lexer - Extended with Choreographic Sessions *) - -open Parser - - -# 8 "src/lexer.ml" -let __ocaml_lex_tables = { - Lexing.lex_base = - "\000\000\241\255\245\255\246\255\247\255\248\255\249\255\250\255\ - \000\000\001\000\078\000\163\000\238\000\057\001\153\000\255\255\ - \132\001\207\001\026\002\101\002\176\002\251\002\070\003\145\003\ - \220\003\039\004\114\004\189\004\008\005\083\005\158\005\252\255\ - \251\255"; - Lexing.lex_backtrk = - "\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\002\000\002\000\002\000\002\000\001\000\255\255\ - \002\000\002\000\002\000\002\000\002\000\002\000\002\000\002\000\ - \002\000\002\000\002\000\002\000\002\000\002\000\002\000\255\255\ - \255\255"; - Lexing.lex_default = - "\255\255\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \255\255\009\000\255\255\255\255\255\255\255\255\255\255\000\000\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\000\000\ - \000\000"; - Lexing.lex_trans = - "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\015\000\015\000\000\000\000\000\015\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \015\000\000\000\009\000\031\000\000\000\000\000\000\000\000\000\ - \005\000\004\000\000\000\000\000\006\000\008\000\000\000\000\000\ - \014\000\014\000\014\000\014\000\014\000\014\000\014\000\014\000\ - \014\000\014\000\007\000\000\000\000\000\000\000\032\000\000\000\ - \000\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\000\000\000\000\000\000\000\000\010\000\ - \000\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\012\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\011\000\010\000\010\000\013\000\010\000\ - \010\000\010\000\010\000\003\000\000\000\002\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\000\000\000\000\000\000\000\000\010\000\000\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\014\000\014\000\014\000\014\000\014\000\014\000\014\000\ - \014\000\014\000\014\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\000\000\000\000\ - \001\000\255\255\010\000\000\000\010\000\010\000\010\000\010\000\ - \022\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\000\000\000\000\000\000\000\000\010\000\000\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\017\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\000\000\000\000\000\000\000\000\ - \010\000\000\000\016\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\000\000\ - \000\000\000\000\000\000\010\000\000\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\000\000\000\000\000\000\000\000\010\000\000\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\018\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\000\000\000\000\000\000\ - \000\000\010\000\000\000\010\000\010\000\010\000\010\000\019\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \000\000\000\000\000\000\000\000\010\000\000\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\020\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\000\000\000\000\000\000\000\000\010\000\ - \000\000\021\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\000\000\000\000\ - \000\000\000\000\010\000\000\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\000\000\000\000\000\000\000\000\010\000\000\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\023\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\000\000\000\000\000\000\000\000\ - \010\000\000\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\024\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\000\000\ - \000\000\000\000\000\000\010\000\000\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\025\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\000\000\000\000\000\000\000\000\010\000\000\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\026\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\000\000\000\000\000\000\ - \000\000\010\000\000\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \027\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \000\000\000\000\000\000\000\000\010\000\000\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\028\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\000\000\000\000\000\000\000\000\010\000\ - \000\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\029\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\000\000\000\000\ - \000\000\000\000\010\000\000\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\030\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\000\000\000\000\000\000\000\000\010\000\000\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000"; - Lexing.lex_check = - "\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\000\000\000\000\255\255\255\255\000\000\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \000\000\255\255\000\000\009\000\255\255\255\255\255\255\255\255\ - \000\000\000\000\255\255\255\255\000\000\000\000\255\255\255\255\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\255\255\255\255\255\255\008\000\255\255\ - \255\255\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\255\255\255\255\255\255\255\255\000\000\ - \255\255\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\255\255\000\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\255\255\255\255\255\255\255\255\010\000\255\255\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\010\000\010\000\010\000\010\000\010\000\010\000\010\000\ - \010\000\014\000\014\000\014\000\014\000\014\000\014\000\014\000\ - \014\000\014\000\014\000\011\000\011\000\011\000\011\000\011\000\ - \011\000\011\000\011\000\011\000\011\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\011\000\011\000\011\000\011\000\ - \011\000\011\000\011\000\011\000\011\000\011\000\011\000\011\000\ - \011\000\011\000\011\000\011\000\011\000\011\000\011\000\011\000\ - \011\000\011\000\011\000\011\000\011\000\011\000\255\255\255\255\ - \000\000\009\000\011\000\255\255\011\000\011\000\011\000\011\000\ - \011\000\011\000\011\000\011\000\011\000\011\000\011\000\011\000\ - \011\000\011\000\011\000\011\000\011\000\011\000\011\000\011\000\ - \011\000\011\000\011\000\011\000\011\000\011\000\012\000\012\000\ - \012\000\012\000\012\000\012\000\012\000\012\000\012\000\012\000\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\012\000\ - \012\000\012\000\012\000\012\000\012\000\012\000\012\000\012\000\ - \012\000\012\000\012\000\012\000\012\000\012\000\012\000\012\000\ - \012\000\012\000\012\000\012\000\012\000\012\000\012\000\012\000\ - \012\000\255\255\255\255\255\255\255\255\012\000\255\255\012\000\ - \012\000\012\000\012\000\012\000\012\000\012\000\012\000\012\000\ - \012\000\012\000\012\000\012\000\012\000\012\000\012\000\012\000\ - \012\000\012\000\012\000\012\000\012\000\012\000\012\000\012\000\ - \012\000\013\000\013\000\013\000\013\000\013\000\013\000\013\000\ - \013\000\013\000\013\000\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\013\000\013\000\013\000\013\000\013\000\013\000\ - \013\000\013\000\013\000\013\000\013\000\013\000\013\000\013\000\ - \013\000\013\000\013\000\013\000\013\000\013\000\013\000\013\000\ - \013\000\013\000\013\000\013\000\255\255\255\255\255\255\255\255\ - \013\000\255\255\013\000\013\000\013\000\013\000\013\000\013\000\ - \013\000\013\000\013\000\013\000\013\000\013\000\013\000\013\000\ - \013\000\013\000\013\000\013\000\013\000\013\000\013\000\013\000\ - \013\000\013\000\013\000\013\000\016\000\016\000\016\000\016\000\ - \016\000\016\000\016\000\016\000\016\000\016\000\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\016\000\016\000\016\000\ - \016\000\016\000\016\000\016\000\016\000\016\000\016\000\016\000\ - \016\000\016\000\016\000\016\000\016\000\016\000\016\000\016\000\ - \016\000\016\000\016\000\016\000\016\000\016\000\016\000\255\255\ - \255\255\255\255\255\255\016\000\255\255\016\000\016\000\016\000\ - \016\000\016\000\016\000\016\000\016\000\016\000\016\000\016\000\ - \016\000\016\000\016\000\016\000\016\000\016\000\016\000\016\000\ - \016\000\016\000\016\000\016\000\016\000\016\000\016\000\017\000\ - \017\000\017\000\017\000\017\000\017\000\017\000\017\000\017\000\ - \017\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \017\000\017\000\017\000\017\000\017\000\017\000\017\000\017\000\ - \017\000\017\000\017\000\017\000\017\000\017\000\017\000\017\000\ - \017\000\017\000\017\000\017\000\017\000\017\000\017\000\017\000\ - \017\000\017\000\255\255\255\255\255\255\255\255\017\000\255\255\ - \017\000\017\000\017\000\017\000\017\000\017\000\017\000\017\000\ - \017\000\017\000\017\000\017\000\017\000\017\000\017\000\017\000\ - \017\000\017\000\017\000\017\000\017\000\017\000\017\000\017\000\ - \017\000\017\000\018\000\018\000\018\000\018\000\018\000\018\000\ - \018\000\018\000\018\000\018\000\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\018\000\018\000\018\000\018\000\018\000\ - \018\000\018\000\018\000\018\000\018\000\018\000\018\000\018\000\ - \018\000\018\000\018\000\018\000\018\000\018\000\018\000\018\000\ - \018\000\018\000\018\000\018\000\018\000\255\255\255\255\255\255\ - \255\255\018\000\255\255\018\000\018\000\018\000\018\000\018\000\ - \018\000\018\000\018\000\018\000\018\000\018\000\018\000\018\000\ - \018\000\018\000\018\000\018\000\018\000\018\000\018\000\018\000\ - \018\000\018\000\018\000\018\000\018\000\019\000\019\000\019\000\ - \019\000\019\000\019\000\019\000\019\000\019\000\019\000\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\019\000\019\000\ - \019\000\019\000\019\000\019\000\019\000\019\000\019\000\019\000\ - \019\000\019\000\019\000\019\000\019\000\019\000\019\000\019\000\ - \019\000\019\000\019\000\019\000\019\000\019\000\019\000\019\000\ - \255\255\255\255\255\255\255\255\019\000\255\255\019\000\019\000\ - \019\000\019\000\019\000\019\000\019\000\019\000\019\000\019\000\ - \019\000\019\000\019\000\019\000\019\000\019\000\019\000\019\000\ - \019\000\019\000\019\000\019\000\019\000\019\000\019\000\019\000\ - \020\000\020\000\020\000\020\000\020\000\020\000\020\000\020\000\ - \020\000\020\000\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\020\000\020\000\020\000\020\000\020\000\020\000\020\000\ - \020\000\020\000\020\000\020\000\020\000\020\000\020\000\020\000\ - \020\000\020\000\020\000\020\000\020\000\020\000\020\000\020\000\ - \020\000\020\000\020\000\255\255\255\255\255\255\255\255\020\000\ - \255\255\020\000\020\000\020\000\020\000\020\000\020\000\020\000\ - \020\000\020\000\020\000\020\000\020\000\020\000\020\000\020\000\ - \020\000\020\000\020\000\020\000\020\000\020\000\020\000\020\000\ - \020\000\020\000\020\000\021\000\021\000\021\000\021\000\021\000\ - \021\000\021\000\021\000\021\000\021\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\021\000\021\000\021\000\021\000\ - \021\000\021\000\021\000\021\000\021\000\021\000\021\000\021\000\ - \021\000\021\000\021\000\021\000\021\000\021\000\021\000\021\000\ - \021\000\021\000\021\000\021\000\021\000\021\000\255\255\255\255\ - \255\255\255\255\021\000\255\255\021\000\021\000\021\000\021\000\ - \021\000\021\000\021\000\021\000\021\000\021\000\021\000\021\000\ - \021\000\021\000\021\000\021\000\021\000\021\000\021\000\021\000\ - \021\000\021\000\021\000\021\000\021\000\021\000\022\000\022\000\ - \022\000\022\000\022\000\022\000\022\000\022\000\022\000\022\000\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\022\000\ - \022\000\022\000\022\000\022\000\022\000\022\000\022\000\022\000\ - \022\000\022\000\022\000\022\000\022\000\022\000\022\000\022\000\ - \022\000\022\000\022\000\022\000\022\000\022\000\022\000\022\000\ - \022\000\255\255\255\255\255\255\255\255\022\000\255\255\022\000\ - \022\000\022\000\022\000\022\000\022\000\022\000\022\000\022\000\ - \022\000\022\000\022\000\022\000\022\000\022\000\022\000\022\000\ - \022\000\022\000\022\000\022\000\022\000\022\000\022\000\022\000\ - \022\000\023\000\023\000\023\000\023\000\023\000\023\000\023\000\ - \023\000\023\000\023\000\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\023\000\023\000\023\000\023\000\023\000\023\000\ - \023\000\023\000\023\000\023\000\023\000\023\000\023\000\023\000\ - \023\000\023\000\023\000\023\000\023\000\023\000\023\000\023\000\ - \023\000\023\000\023\000\023\000\255\255\255\255\255\255\255\255\ - \023\000\255\255\023\000\023\000\023\000\023\000\023\000\023\000\ - \023\000\023\000\023\000\023\000\023\000\023\000\023\000\023\000\ - \023\000\023\000\023\000\023\000\023\000\023\000\023\000\023\000\ - \023\000\023\000\023\000\023\000\024\000\024\000\024\000\024\000\ - \024\000\024\000\024\000\024\000\024\000\024\000\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\024\000\024\000\024\000\ - \024\000\024\000\024\000\024\000\024\000\024\000\024\000\024\000\ - \024\000\024\000\024\000\024\000\024\000\024\000\024\000\024\000\ - \024\000\024\000\024\000\024\000\024\000\024\000\024\000\255\255\ - \255\255\255\255\255\255\024\000\255\255\024\000\024\000\024\000\ - \024\000\024\000\024\000\024\000\024\000\024\000\024\000\024\000\ - \024\000\024\000\024\000\024\000\024\000\024\000\024\000\024\000\ - \024\000\024\000\024\000\024\000\024\000\024\000\024\000\025\000\ - \025\000\025\000\025\000\025\000\025\000\025\000\025\000\025\000\ - \025\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \025\000\025\000\025\000\025\000\025\000\025\000\025\000\025\000\ - \025\000\025\000\025\000\025\000\025\000\025\000\025\000\025\000\ - \025\000\025\000\025\000\025\000\025\000\025\000\025\000\025\000\ - \025\000\025\000\255\255\255\255\255\255\255\255\025\000\255\255\ - \025\000\025\000\025\000\025\000\025\000\025\000\025\000\025\000\ - \025\000\025\000\025\000\025\000\025\000\025\000\025\000\025\000\ - \025\000\025\000\025\000\025\000\025\000\025\000\025\000\025\000\ - \025\000\025\000\026\000\026\000\026\000\026\000\026\000\026\000\ - \026\000\026\000\026\000\026\000\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\026\000\026\000\026\000\026\000\026\000\ - \026\000\026\000\026\000\026\000\026\000\026\000\026\000\026\000\ - \026\000\026\000\026\000\026\000\026\000\026\000\026\000\026\000\ - \026\000\026\000\026\000\026\000\026\000\255\255\255\255\255\255\ - \255\255\026\000\255\255\026\000\026\000\026\000\026\000\026\000\ - \026\000\026\000\026\000\026\000\026\000\026\000\026\000\026\000\ - \026\000\026\000\026\000\026\000\026\000\026\000\026\000\026\000\ - \026\000\026\000\026\000\026\000\026\000\027\000\027\000\027\000\ - \027\000\027\000\027\000\027\000\027\000\027\000\027\000\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\027\000\027\000\ - \027\000\027\000\027\000\027\000\027\000\027\000\027\000\027\000\ - \027\000\027\000\027\000\027\000\027\000\027\000\027\000\027\000\ - \027\000\027\000\027\000\027\000\027\000\027\000\027\000\027\000\ - \255\255\255\255\255\255\255\255\027\000\255\255\027\000\027\000\ - \027\000\027\000\027\000\027\000\027\000\027\000\027\000\027\000\ - \027\000\027\000\027\000\027\000\027\000\027\000\027\000\027\000\ - \027\000\027\000\027\000\027\000\027\000\027\000\027\000\027\000\ - \028\000\028\000\028\000\028\000\028\000\028\000\028\000\028\000\ - \028\000\028\000\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\028\000\028\000\028\000\028\000\028\000\028\000\028\000\ - \028\000\028\000\028\000\028\000\028\000\028\000\028\000\028\000\ - \028\000\028\000\028\000\028\000\028\000\028\000\028\000\028\000\ - \028\000\028\000\028\000\255\255\255\255\255\255\255\255\028\000\ - \255\255\028\000\028\000\028\000\028\000\028\000\028\000\028\000\ - \028\000\028\000\028\000\028\000\028\000\028\000\028\000\028\000\ - \028\000\028\000\028\000\028\000\028\000\028\000\028\000\028\000\ - \028\000\028\000\028\000\029\000\029\000\029\000\029\000\029\000\ - \029\000\029\000\029\000\029\000\029\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\029\000\029\000\029\000\029\000\ - \029\000\029\000\029\000\029\000\029\000\029\000\029\000\029\000\ - \029\000\029\000\029\000\029\000\029\000\029\000\029\000\029\000\ - \029\000\029\000\029\000\029\000\029\000\029\000\255\255\255\255\ - \255\255\255\255\029\000\255\255\029\000\029\000\029\000\029\000\ - \029\000\029\000\029\000\029\000\029\000\029\000\029\000\029\000\ - \029\000\029\000\029\000\029\000\029\000\029\000\029\000\029\000\ - \029\000\029\000\029\000\029\000\029\000\029\000\030\000\030\000\ - \030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\030\000\ - \030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ - \030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ - \030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ - \030\000\255\255\255\255\255\255\255\255\030\000\255\255\030\000\ - \030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ - \030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ - \030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ - \030\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255"; - Lexing.lex_base_code = - ""; - Lexing.lex_backtrk_code = - ""; - Lexing.lex_default_code = - ""; - Lexing.lex_trans_code = - ""; - Lexing.lex_check_code = - ""; - Lexing.lex_code = - ""; -} - -let rec token lexbuf = - __ocaml_lex_token_rec lexbuf 0 -and __ocaml_lex_token_rec lexbuf __ocaml_lex_state = - match Lexing.engine __ocaml_lex_tables __ocaml_lex_state lexbuf with - | 0 -> -# 8 "src/lexer.mll" - ( token lexbuf ) -# 475 "src/lexer.ml" - - | 1 -> -# 9 "src/lexer.mll" - ( INTEGER (int_of_string (Lexing.lexeme lexbuf)) ) -# 480 "src/lexer.ml" - - | 2 -> -# 10 "src/lexer.mll" - ( - match Lexing.lexeme lexbuf with - | "session" -> SESSION - | "send" -> SEND - | "receive" -> RECEIVE - | "close" -> CLOSE - | "delegate" -> DELEGATE - | id -> IDENT id - ) -# 493 "src/lexer.ml" - - | 3 -> -# 19 "src/lexer.mll" - ( STRING (String.sub (Lexing.lexeme lexbuf) 1 (String.length (Lexing.lexeme lexbuf) - 2)) ) -# 498 "src/lexer.ml" - - | 4 -> -# 20 "src/lexer.mll" - ( ARROW ) -# 503 "src/lexer.ml" - - | 5 -> -# 21 "src/lexer.mll" - ( COLON ) -# 508 "src/lexer.ml" - - | 6 -> -# 22 "src/lexer.mll" - ( COMMA ) -# 513 "src/lexer.ml" - - | 7 -> -# 23 "src/lexer.mll" - ( LPAREN ) -# 518 "src/lexer.ml" - - | 8 -> -# 24 "src/lexer.mll" - ( RPAREN ) -# 523 "src/lexer.ml" - - | 9 -> -# 25 "src/lexer.mll" - ( LBRACE ) -# 528 "src/lexer.ml" - - | 10 -> -# 26 "src/lexer.mll" - ( RBRACE ) -# 533 "src/lexer.ml" - - | 11 -> -# 27 "src/lexer.mll" - ( VAR ) -# 538 "src/lexer.ml" - - | 12 -> -# 28 "src/lexer.mll" - ( LITERAL ) -# 543 "src/lexer.ml" - - | 13 -> -# 29 "src/lexer.mll" - ( SESSIONTYPE ) -# 548 "src/lexer.ml" - - | 14 -> -# 30 "src/lexer.mll" - ( EOF ) -# 553 "src/lexer.ml" - - | __ocaml_lex_state -> lexbuf.Lexing.refill_buff lexbuf; - __ocaml_lex_token_rec lexbuf __ocaml_lex_state - -;; - diff --git a/src/parser.ml b/src/parser.ml deleted file mode 100644 index c5857776..00000000 --- a/src/parser.ml +++ /dev/null @@ -1,1067 +0,0 @@ - -module MenhirBasics = struct - - exception Error - - let _eRR = - fun _s -> - raise Error - - type token = - | VAR - | STRING of -# 9 "src/parser.mly" - (string) -# 16 "src/parser.ml" - - | SESSIONTYPE - | SESSION - | SEND - | RPAREN - | RECEIVE - | RBRACE - | LPAREN - | LITERAL - | LBRACE - | INTEGER of -# 8 "src/parser.mly" - (int) -# 30 "src/parser.ml" - - | IDENT of -# 7 "src/parser.mly" - (string) -# 35 "src/parser.ml" - - | EOF - | DELEGATE - | COMMA - | COLON - | CLOSE - | ARROW - -end - -include MenhirBasics - -# 3 "src/parser.mly" - -open Ast - -# 52 "src/parser.ml" - -type ('s, 'r) _menhir_state = - | MenhirState00 : ('s, _menhir_box_program) _menhir_state - (** State 00. - Stack shape : . - Start symbol: program. *) - - | MenhirState05 : (('s, _menhir_box_program) _menhir_cell1_SESSION _menhir_cell0_IDENT, _menhir_box_program) _menhir_state - (** State 05. - Stack shape : SESSION IDENT. - Start symbol: program. *) - - | MenhirState07 : (('s, _menhir_box_program) _menhir_cell1_IDENT, _menhir_box_program) _menhir_state - (** State 07. - Stack shape : IDENT. - Start symbol: program. *) - - | MenhirState11 : ((('s, _menhir_box_program) _menhir_cell1_SESSION _menhir_cell0_IDENT, _menhir_box_program) _menhir_cell1_role_list, _menhir_box_program) _menhir_state - (** State 11. - Stack shape : SESSION IDENT role_list. - Start symbol: program. *) - - | MenhirState18 : (('s, _menhir_box_program) _menhir_cell1_IDENT _menhir_cell0_IDENT _menhir_cell0_IDENT, _menhir_box_program) _menhir_state - (** State 18. - Stack shape : IDENT IDENT IDENT. - Start symbol: program. *) - - | MenhirState25 : (('s, _menhir_box_program) _menhir_cell1_message, _menhir_box_program) _menhir_state - (** State 25. - Stack shape : message. - Start symbol: program. *) - - | MenhirState28 : (('s, _menhir_box_program) _menhir_cell1_SEND, _menhir_box_program) _menhir_state - (** State 28. - Stack shape : SEND. - Start symbol: program. *) - - | MenhirState31 : (('s, _menhir_box_program) _menhir_cell1_SESSION _menhir_cell0_IDENT, _menhir_box_program) _menhir_state - (** State 31. - Stack shape : SESSION IDENT. - Start symbol: program. *) - - | MenhirState35 : (('s, _menhir_box_program) _menhir_cell1_RECEIVE, _menhir_box_program) _menhir_state - (** State 35. - Stack shape : RECEIVE. - Start symbol: program. *) - - | MenhirState39 : (('s, _menhir_box_program) _menhir_cell1_DELEGATE, _menhir_box_program) _menhir_state - (** State 39. - Stack shape : DELEGATE. - Start symbol: program. *) - - | MenhirState41 : (('s, _menhir_box_program) _menhir_cell1_CLOSE, _menhir_box_program) _menhir_state - (** State 41. - Stack shape : CLOSE. - Start symbol: program. *) - - | MenhirState57 : ((('s, _menhir_box_program) _menhir_cell1_SEND, _menhir_box_program) _menhir_cell1_expr _menhir_cell0_IDENT, _menhir_box_program) _menhir_state - (** State 57. - Stack shape : SEND expr IDENT. - Start symbol: program. *) - - | MenhirState65 : (('s, _menhir_box_program) _menhir_cell1_decl, _menhir_box_program) _menhir_state - (** State 65. - Stack shape : decl. - Start symbol: program. *) - - -and ('s, 'r) _menhir_cell1_decl = - | MenhirCell1_decl of 's * ('s, 'r) _menhir_state * -# 18 "src/parser.mly" - (Ast.decl) -# 125 "src/parser.ml" - - -and ('s, 'r) _menhir_cell1_expr = - | MenhirCell1_expr of 's * ('s, 'r) _menhir_state * -# 23 "src/parser.mly" - (Ast.expr) -# 132 "src/parser.ml" - - -and ('s, 'r) _menhir_cell1_message = - | MenhirCell1_message of 's * ('s, 'r) _menhir_state * -# 22 "src/parser.mly" - (Ast.message) -# 139 "src/parser.ml" - - -and ('s, 'r) _menhir_cell1_role_list = - | MenhirCell1_role_list of 's * ('s, 'r) _menhir_state * -# 20 "src/parser.mly" - (string list) -# 146 "src/parser.ml" - - -and ('s, 'r) _menhir_cell1_CLOSE = - | MenhirCell1_CLOSE of 's * ('s, 'r) _menhir_state - -and ('s, 'r) _menhir_cell1_DELEGATE = - | MenhirCell1_DELEGATE of 's * ('s, 'r) _menhir_state - -and ('s, 'r) _menhir_cell1_IDENT = - | MenhirCell1_IDENT of 's * ('s, 'r) _menhir_state * -# 7 "src/parser.mly" - (string) -# 159 "src/parser.ml" - - -and 's _menhir_cell0_IDENT = - | MenhirCell0_IDENT of 's * -# 7 "src/parser.mly" - (string) -# 166 "src/parser.ml" - - -and ('s, 'r) _menhir_cell1_RECEIVE = - | MenhirCell1_RECEIVE of 's * ('s, 'r) _menhir_state - -and ('s, 'r) _menhir_cell1_SEND = - | MenhirCell1_SEND of 's * ('s, 'r) _menhir_state - -and ('s, 'r) _menhir_cell1_SESSION = - | MenhirCell1_SESSION of 's * ('s, 'r) _menhir_state - -and _menhir_box_program = - | MenhirBox_program of -# 16 "src/parser.mly" - (Ast.program) -# 182 "src/parser.ml" - [@@unboxed] - -let _menhir_action_01 = - fun _1 -> - ( -# 40 "src/parser.mly" - ( SessionDecl _1 ) -# 190 "src/parser.ml" - : -# 18 "src/parser.mly" - (Ast.decl) -# 194 "src/parser.ml" - ) - -let _menhir_action_02 = - fun _1 -> - ( -# 41 "src/parser.mly" - ( ExprDecl _1 ) -# 202 "src/parser.ml" - : -# 18 "src/parser.mly" - (Ast.decl) -# 206 "src/parser.ml" - ) - -let _menhir_action_03 = - fun _1 -> - ( -# 35 "src/parser.mly" - ( [_1] ) -# 214 "src/parser.ml" - : -# 17 "src/parser.mly" - (Ast.decl list) -# 218 "src/parser.ml" - ) - -let _menhir_action_04 = - fun _1 _2 -> - ( -# 36 "src/parser.mly" - ( _1 :: _2 ) -# 226 "src/parser.ml" - : -# 17 "src/parser.mly" - (Ast.decl list) -# 230 "src/parser.ml" - ) - -let _menhir_action_05 = - fun _2 _4 -> - ( -# 75 "src/parser.mly" - ( Session(_2, _4) ) -# 238 "src/parser.ml" - : -# 23 "src/parser.mly" - (Ast.expr) -# 242 "src/parser.ml" - ) - -let _menhir_action_06 = - fun _3 _5 _7 -> - ( -# 77 "src/parser.mly" - ( Send(_3, _5, _7) ) -# 250 "src/parser.ml" - : -# 23 "src/parser.mly" - (Ast.expr) -# 254 "src/parser.ml" - ) - -let _menhir_action_07 = - fun _3 _5 -> - ( -# 79 "src/parser.mly" - ( Receive(_3, _5) ) -# 262 "src/parser.ml" - : -# 23 "src/parser.mly" - (Ast.expr) -# 266 "src/parser.ml" - ) - -let _menhir_action_08 = - fun _3 -> - ( -# 81 "src/parser.mly" - ( Close(_3) ) -# 274 "src/parser.ml" - : -# 23 "src/parser.mly" - (Ast.expr) -# 278 "src/parser.ml" - ) - -let _menhir_action_09 = - fun _3 _5 _7 -> - ( -# 83 "src/parser.mly" - ( Delegate(_3, _5, _7) ) -# 286 "src/parser.ml" - : -# 23 "src/parser.mly" - (Ast.expr) -# 290 "src/parser.ml" - ) - -let _menhir_action_10 = - fun _2 -> - ( -# 84 "src/parser.mly" - ( Var(_2) ) -# 298 "src/parser.ml" - : -# 23 "src/parser.mly" - (Ast.expr) -# 302 "src/parser.ml" - ) - -let _menhir_action_11 = - fun _2 -> - ( -# 85 "src/parser.mly" - ( Literal(Int(_2)) ) -# 310 "src/parser.ml" - : -# 23 "src/parser.mly" - (Ast.expr) -# 314 "src/parser.ml" - ) - -let _menhir_action_12 = - fun _1 _3 _5 -> - ( -# 65 "src/parser.mly" - ( { - msg_sender = _1; - msg_receiver = _3; - msg_type = _5 - } ) -# 326 "src/parser.ml" - : -# 22 "src/parser.mly" - (Ast.message) -# 330 "src/parser.ml" - ) - -let _menhir_action_13 = - fun _1 -> - ( -# 60 "src/parser.mly" - ( [_1] ) -# 338 "src/parser.ml" - : -# 21 "src/parser.mly" - (Ast.message list) -# 342 "src/parser.ml" - ) - -let _menhir_action_14 = - fun _1 _2 -> - ( -# 61 "src/parser.mly" - ( _1 :: _2 ) -# 350 "src/parser.ml" - : -# 21 "src/parser.mly" - (Ast.message list) -# 354 "src/parser.ml" - ) - -let _menhir_action_15 = - fun _1 -> - ( -# 31 "src/parser.mly" - ( _1 ) -# 362 "src/parser.ml" - : -# 16 "src/parser.mly" - (Ast.program) -# 366 "src/parser.ml" - ) - -let _menhir_action_16 = - fun _1 -> - ( -# 55 "src/parser.mly" - ( [_1] ) -# 374 "src/parser.ml" - : -# 20 "src/parser.mly" - (string list) -# 378 "src/parser.ml" - ) - -let _menhir_action_17 = - fun _1 _3 -> - ( -# 56 "src/parser.mly" - ( _1 :: _3 ) -# 386 "src/parser.ml" - : -# 20 "src/parser.mly" - (string list) -# 390 "src/parser.ml" - ) - -let _menhir_action_18 = - fun _2 _4 _6 -> - ( -# 47 "src/parser.mly" - ( { - s_name = _2; - s_roles = _4; - s_protocol = _6 - } ) -# 402 "src/parser.ml" - : -# 19 "src/parser.mly" - (Ast.session_decl) -# 406 "src/parser.ml" - ) - -let _menhir_action_19 = - fun _1 -> - ( -# 89 "src/parser.mly" - ( TypeVar _1 ) -# 414 "src/parser.ml" - : -# 24 "src/parser.mly" - (Ast.typ) -# 418 "src/parser.ml" - ) - -let _menhir_action_20 = - fun _2 _4 -> - ( -# 90 "src/parser.mly" - ( SessionType(ref { - s_name = _2; - s_roles = _4; - s_protocol = [] (* Will be filled during type checking *) - }) ) -# 430 "src/parser.ml" - : -# 24 "src/parser.mly" - (Ast.typ) -# 434 "src/parser.ml" - ) - -let _menhir_print_token : token -> string = - fun _tok -> - match _tok with - | VAR -> - "VAR" - | STRING _ -> - "STRING" - | SESSIONTYPE -> - "SESSIONTYPE" - | SESSION -> - "SESSION" - | SEND -> - "SEND" - | RPAREN -> - "RPAREN" - | RECEIVE -> - "RECEIVE" - | RBRACE -> - "RBRACE" - | LPAREN -> - "LPAREN" - | LITERAL -> - "LITERAL" - | LBRACE -> - "LBRACE" - | INTEGER _ -> - "INTEGER" - | IDENT _ -> - "IDENT" - | EOF -> - "EOF" - | DELEGATE -> - "DELEGATE" - | COMMA -> - "COMMA" - | COLON -> - "COLON" - | CLOSE -> - "CLOSE" - | ARROW -> - "ARROW" - -let _menhir_fail : unit -> 'a = - fun () -> - Printf.eprintf "Internal failure -- please contact the parser generator's developers.\n%!"; - assert false - -include struct - - [@@@ocaml.warning "-4-37"] - - let _menhir_run_63 : type ttv_stack. ttv_stack -> _ -> _menhir_box_program = - fun _menhir_stack _v -> - let _1 = _v in - let _v = _menhir_action_15 _1 in - MenhirBox_program _v - - let rec _menhir_goto_decl_list : type ttv_stack. ttv_stack -> _ -> (ttv_stack, _menhir_box_program) _menhir_state -> _menhir_box_program = - fun _menhir_stack _v _menhir_s -> - match _menhir_s with - | MenhirState00 -> - _menhir_run_63 _menhir_stack _v - | MenhirState65 -> - _menhir_run_66 _menhir_stack _v - | _ -> - _menhir_fail () - - and _menhir_run_66 : type ttv_stack. (ttv_stack, _menhir_box_program) _menhir_cell1_decl -> _ -> _menhir_box_program = - fun _menhir_stack _v -> - let MenhirCell1_decl (_menhir_stack, _menhir_s, _1) = _menhir_stack in - let _2 = _v in - let _v = _menhir_action_04 _1 _2 in - _menhir_goto_decl_list _menhir_stack _v _menhir_s - - let rec _menhir_run_01 : type ttv_stack. ttv_stack -> _ -> _ -> (ttv_stack, _menhir_box_program) _menhir_state -> _menhir_box_program = - fun _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s -> - let _tok = _menhir_lexer _menhir_lexbuf in - match (_tok : MenhirBasics.token) with - | IDENT _v -> - let _tok = _menhir_lexer _menhir_lexbuf in - let _2 = _v in - let _v = _menhir_action_10 _2 in - _menhir_goto_expr _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok - | _ -> - _eRR () - - and _menhir_goto_expr : type ttv_stack. ttv_stack -> _ -> _ -> _ -> (ttv_stack, _menhir_box_program) _menhir_state -> _ -> _menhir_box_program = - fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok -> - match _menhir_s with - | MenhirState41 -> - _menhir_run_42 _menhir_stack _menhir_lexbuf _menhir_lexer _v _tok - | MenhirState39 -> - _menhir_run_44 _menhir_stack _menhir_lexbuf _menhir_lexer _v _tok - | MenhirState35 -> - _menhir_run_50 _menhir_stack _menhir_lexbuf _menhir_lexer _v _tok - | MenhirState28 -> - _menhir_run_54 _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok - | MenhirState57 -> - _menhir_run_58 _menhir_stack _menhir_lexbuf _menhir_lexer _v _tok - | MenhirState00 -> - _menhir_run_62 _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok - | MenhirState65 -> - _menhir_run_62 _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok - | _ -> - _menhir_fail () - - and _menhir_run_42 : type ttv_stack. (ttv_stack, _menhir_box_program) _menhir_cell1_CLOSE -> _ -> _ -> _ -> _ -> _menhir_box_program = - fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _tok -> - match (_tok : MenhirBasics.token) with - | RPAREN -> - let _tok = _menhir_lexer _menhir_lexbuf in - let MenhirCell1_CLOSE (_menhir_stack, _menhir_s) = _menhir_stack in - let _3 = _v in - let _v = _menhir_action_08 _3 in - _menhir_goto_expr _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok - | _ -> - _eRR () - - and _menhir_run_44 : type ttv_stack. (ttv_stack, _menhir_box_program) _menhir_cell1_DELEGATE -> _ -> _ -> _ -> _ -> _menhir_box_program = - fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _tok -> - match (_tok : MenhirBasics.token) with - | COMMA -> - let _tok = _menhir_lexer _menhir_lexbuf in - (match (_tok : MenhirBasics.token) with - | IDENT _v_0 -> - let _tok = _menhir_lexer _menhir_lexbuf in - (match (_tok : MenhirBasics.token) with - | COMMA -> - let _tok = _menhir_lexer _menhir_lexbuf in - (match (_tok : MenhirBasics.token) with - | IDENT _v_1 -> - let _tok = _menhir_lexer _menhir_lexbuf in - (match (_tok : MenhirBasics.token) with - | RPAREN -> - let _tok = _menhir_lexer _menhir_lexbuf in - let MenhirCell1_DELEGATE (_menhir_stack, _menhir_s) = _menhir_stack in - let (_3, _7, _5) = (_v, _v_1, _v_0) in - let _v = _menhir_action_09 _3 _5 _7 in - _menhir_goto_expr _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok - | _ -> - _eRR ()) - | _ -> - _eRR ()) - | _ -> - _eRR ()) - | _ -> - _eRR ()) - | _ -> - _eRR () - - and _menhir_run_50 : type ttv_stack. (ttv_stack, _menhir_box_program) _menhir_cell1_RECEIVE -> _ -> _ -> _ -> _ -> _menhir_box_program = - fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _tok -> - match (_tok : MenhirBasics.token) with - | COMMA -> - let _tok = _menhir_lexer _menhir_lexbuf in - (match (_tok : MenhirBasics.token) with - | IDENT _v_0 -> - let _tok = _menhir_lexer _menhir_lexbuf in - (match (_tok : MenhirBasics.token) with - | RPAREN -> - let _tok = _menhir_lexer _menhir_lexbuf in - let MenhirCell1_RECEIVE (_menhir_stack, _menhir_s) = _menhir_stack in - let (_3, _5) = (_v, _v_0) in - let _v = _menhir_action_07 _3 _5 in - _menhir_goto_expr _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok - | _ -> - _eRR ()) - | _ -> - _eRR ()) - | _ -> - _eRR () - - and _menhir_run_54 : type ttv_stack. ((ttv_stack, _menhir_box_program) _menhir_cell1_SEND as 'stack) -> _ -> _ -> _ -> ('stack, _menhir_box_program) _menhir_state -> _ -> _menhir_box_program = - fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok -> - let _menhir_stack = MenhirCell1_expr (_menhir_stack, _menhir_s, _v) in - match (_tok : MenhirBasics.token) with - | COMMA -> - let _tok = _menhir_lexer _menhir_lexbuf in - (match (_tok : MenhirBasics.token) with - | IDENT _v -> - let _menhir_stack = MenhirCell0_IDENT (_menhir_stack, _v) in - let _tok = _menhir_lexer _menhir_lexbuf in - (match (_tok : MenhirBasics.token) with - | COMMA -> - let _menhir_s = MenhirState57 in - let _tok = _menhir_lexer _menhir_lexbuf in - (match (_tok : MenhirBasics.token) with - | VAR -> - _menhir_run_01 _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s - | SESSION -> - _menhir_run_29 _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s - | SEND -> - _menhir_run_27 _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s - | RECEIVE -> - _menhir_run_34 _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s - | LITERAL -> - _menhir_run_36 _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s - | DELEGATE -> - _menhir_run_38 _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s - | CLOSE -> - _menhir_run_40 _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s - | _ -> - _eRR ()) - | _ -> - _eRR ()) - | _ -> - _eRR ()) - | _ -> - _eRR () - - and _menhir_run_29 : type ttv_stack. ttv_stack -> _ -> _ -> (ttv_stack, _menhir_box_program) _menhir_state -> _menhir_box_program = - fun _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s -> - let _menhir_stack = MenhirCell1_SESSION (_menhir_stack, _menhir_s) in - let _tok = _menhir_lexer _menhir_lexbuf in - match (_tok : MenhirBasics.token) with - | IDENT _v -> - let _menhir_stack = MenhirCell0_IDENT (_menhir_stack, _v) in - let _tok = _menhir_lexer _menhir_lexbuf in - (match (_tok : MenhirBasics.token) with - | LPAREN -> - let _menhir_s = MenhirState31 in - let _tok = _menhir_lexer _menhir_lexbuf in - (match (_tok : MenhirBasics.token) with - | IDENT _v -> - _menhir_run_06 _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s - | _ -> - _eRR ()) - | _ -> - _eRR ()) - | _ -> - _eRR () - - and _menhir_run_06 : type ttv_stack. ttv_stack -> _ -> _ -> _ -> (ttv_stack, _menhir_box_program) _menhir_state -> _menhir_box_program = - fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s -> - let _tok = _menhir_lexer _menhir_lexbuf in - match (_tok : MenhirBasics.token) with - | COMMA -> - let _menhir_stack = MenhirCell1_IDENT (_menhir_stack, _menhir_s, _v) in - let _menhir_s = MenhirState07 in - let _tok = _menhir_lexer _menhir_lexbuf in - (match (_tok : MenhirBasics.token) with - | IDENT _v -> - _menhir_run_06 _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s - | _ -> - _eRR ()) - | RPAREN -> - let _1 = _v in - let _v = _menhir_action_16 _1 in - _menhir_goto_role_list _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s - | _ -> - _eRR () - - and _menhir_goto_role_list : type ttv_stack. ttv_stack -> _ -> _ -> _ -> (ttv_stack, _menhir_box_program) _menhir_state -> _menhir_box_program = - fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s -> - match _menhir_s with - | MenhirState07 -> - _menhir_run_08 _menhir_stack _menhir_lexbuf _menhir_lexer _v - | MenhirState05 -> - _menhir_run_09 _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s - | MenhirState18 -> - _menhir_run_19 _menhir_stack _menhir_lexbuf _menhir_lexer _v - | MenhirState31 -> - _menhir_run_32 _menhir_stack _menhir_lexbuf _menhir_lexer _v - | _ -> - _menhir_fail () - - and _menhir_run_08 : type ttv_stack. (ttv_stack, _menhir_box_program) _menhir_cell1_IDENT -> _ -> _ -> _ -> _menhir_box_program = - fun _menhir_stack _menhir_lexbuf _menhir_lexer _v -> - let MenhirCell1_IDENT (_menhir_stack, _menhir_s, _1) = _menhir_stack in - let _3 = _v in - let _v = _menhir_action_17 _1 _3 in - _menhir_goto_role_list _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s - - and _menhir_run_09 : type ttv_stack. ((ttv_stack, _menhir_box_program) _menhir_cell1_SESSION _menhir_cell0_IDENT as 'stack) -> _ -> _ -> _ -> ('stack, _menhir_box_program) _menhir_state -> _menhir_box_program = - fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s -> - let _tok = _menhir_lexer _menhir_lexbuf in - match (_tok : MenhirBasics.token) with - | LBRACE -> - let _menhir_stack = MenhirCell1_role_list (_menhir_stack, _menhir_s, _v) in - let _menhir_s = MenhirState11 in - let _tok = _menhir_lexer _menhir_lexbuf in - (match (_tok : MenhirBasics.token) with - | IDENT _v -> - _menhir_run_12 _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s - | _ -> - _eRR ()) - | CLOSE | DELEGATE | EOF | LITERAL | RECEIVE | SEND | SESSION | VAR -> - let MenhirCell0_IDENT (_menhir_stack, _2) = _menhir_stack in - let MenhirCell1_SESSION (_menhir_stack, _menhir_s) = _menhir_stack in - let _4 = _v in - let _v = _menhir_action_05 _2 _4 in - _menhir_goto_expr _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok - | _ -> - _eRR () - - and _menhir_run_12 : type ttv_stack. ttv_stack -> _ -> _ -> _ -> (ttv_stack, _menhir_box_program) _menhir_state -> _menhir_box_program = - fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s -> - let _menhir_stack = MenhirCell1_IDENT (_menhir_stack, _menhir_s, _v) in - let _tok = _menhir_lexer _menhir_lexbuf in - match (_tok : MenhirBasics.token) with - | ARROW -> - let _tok = _menhir_lexer _menhir_lexbuf in - (match (_tok : MenhirBasics.token) with - | IDENT _v_0 -> - let _menhir_stack = MenhirCell0_IDENT (_menhir_stack, _v_0) in - let _tok = _menhir_lexer _menhir_lexbuf in - (match (_tok : MenhirBasics.token) with - | COLON -> - let _tok = _menhir_lexer _menhir_lexbuf in - (match (_tok : MenhirBasics.token) with - | SESSIONTYPE -> - let _tok = _menhir_lexer _menhir_lexbuf in - (match (_tok : MenhirBasics.token) with - | IDENT _v -> - let _menhir_stack = MenhirCell0_IDENT (_menhir_stack, _v) in - let _tok = _menhir_lexer _menhir_lexbuf in - (match (_tok : MenhirBasics.token) with - | LPAREN -> - let _menhir_s = MenhirState18 in - let _tok = _menhir_lexer _menhir_lexbuf in - (match (_tok : MenhirBasics.token) with - | IDENT _v -> - _menhir_run_06 _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s - | _ -> - _eRR ()) - | _ -> - _eRR ()) - | _ -> - _eRR ()) - | IDENT _v_3 -> - let _tok = _menhir_lexer _menhir_lexbuf in - let _1 = _v_3 in - let _v = _menhir_action_19 _1 in - _menhir_goto_type_expr _menhir_stack _menhir_lexbuf _menhir_lexer _v _tok - | _ -> - _eRR ()) - | _ -> - _eRR ()) - | _ -> - _eRR ()) - | _ -> - _eRR () - - and _menhir_goto_type_expr : type ttv_stack. (ttv_stack, _menhir_box_program) _menhir_cell1_IDENT _menhir_cell0_IDENT -> _ -> _ -> _ -> _ -> _menhir_box_program = - fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _tok -> - let MenhirCell0_IDENT (_menhir_stack, _3) = _menhir_stack in - let MenhirCell1_IDENT (_menhir_stack, _menhir_s, _1) = _menhir_stack in - let _5 = _v in - let _v = _menhir_action_12 _1 _3 _5 in - match (_tok : MenhirBasics.token) with - | IDENT _v_0 -> - let _menhir_stack = MenhirCell1_message (_menhir_stack, _menhir_s, _v) in - _menhir_run_12 _menhir_stack _menhir_lexbuf _menhir_lexer _v_0 MenhirState25 - | RBRACE -> - let _1 = _v in - let _v = _menhir_action_13 _1 in - _menhir_goto_message_list _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s - | _ -> - _eRR () - - and _menhir_goto_message_list : type ttv_stack. ttv_stack -> _ -> _ -> _ -> (ttv_stack, _menhir_box_program) _menhir_state -> _menhir_box_program = - fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s -> - match _menhir_s with - | MenhirState11 -> - _menhir_run_23 _menhir_stack _menhir_lexbuf _menhir_lexer - | MenhirState25 -> - _menhir_run_26 _menhir_stack _menhir_lexbuf _menhir_lexer _v - | _ -> - _menhir_fail () - - and _menhir_run_23 : type ttv_stack. ((ttv_stack, _menhir_box_program) _menhir_cell1_SESSION _menhir_cell0_IDENT, _menhir_box_program) _menhir_cell1_role_list -> _ -> _ -> _menhir_box_program = - fun _menhir_stack _menhir_lexbuf _menhir_lexer -> - let _tok = _menhir_lexer _menhir_lexbuf in - let MenhirCell1_role_list (_menhir_stack, _, _4) = _menhir_stack in - let MenhirCell0_IDENT (_menhir_stack, _2) = _menhir_stack in - let MenhirCell1_SESSION (_menhir_stack, _menhir_s) = _menhir_stack in - let _6 = () in - let _v = _menhir_action_18 _2 _4 _6 in - let _1 = _v in - let _v = _menhir_action_01 _1 in - _menhir_goto_decl _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok - - and _menhir_goto_decl : type ttv_stack. ttv_stack -> _ -> _ -> _ -> (ttv_stack, _menhir_box_program) _menhir_state -> _ -> _menhir_box_program = - fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok -> - match (_tok : MenhirBasics.token) with - | VAR -> - let _menhir_stack = MenhirCell1_decl (_menhir_stack, _menhir_s, _v) in - _menhir_run_01 _menhir_stack _menhir_lexbuf _menhir_lexer MenhirState65 - | SESSION -> - let _menhir_stack = MenhirCell1_decl (_menhir_stack, _menhir_s, _v) in - _menhir_run_03 _menhir_stack _menhir_lexbuf _menhir_lexer MenhirState65 - | SEND -> - let _menhir_stack = MenhirCell1_decl (_menhir_stack, _menhir_s, _v) in - _menhir_run_27 _menhir_stack _menhir_lexbuf _menhir_lexer MenhirState65 - | RECEIVE -> - let _menhir_stack = MenhirCell1_decl (_menhir_stack, _menhir_s, _v) in - _menhir_run_34 _menhir_stack _menhir_lexbuf _menhir_lexer MenhirState65 - | LITERAL -> - let _menhir_stack = MenhirCell1_decl (_menhir_stack, _menhir_s, _v) in - _menhir_run_36 _menhir_stack _menhir_lexbuf _menhir_lexer MenhirState65 - | DELEGATE -> - let _menhir_stack = MenhirCell1_decl (_menhir_stack, _menhir_s, _v) in - _menhir_run_38 _menhir_stack _menhir_lexbuf _menhir_lexer MenhirState65 - | CLOSE -> - let _menhir_stack = MenhirCell1_decl (_menhir_stack, _menhir_s, _v) in - _menhir_run_40 _menhir_stack _menhir_lexbuf _menhir_lexer MenhirState65 - | EOF -> - let _1 = _v in - let _v = _menhir_action_03 _1 in - _menhir_goto_decl_list _menhir_stack _v _menhir_s - | _ -> - _eRR () - - and _menhir_run_03 : type ttv_stack. ttv_stack -> _ -> _ -> (ttv_stack, _menhir_box_program) _menhir_state -> _menhir_box_program = - fun _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s -> - let _menhir_stack = MenhirCell1_SESSION (_menhir_stack, _menhir_s) in - let _tok = _menhir_lexer _menhir_lexbuf in - match (_tok : MenhirBasics.token) with - | IDENT _v -> - let _menhir_stack = MenhirCell0_IDENT (_menhir_stack, _v) in - let _tok = _menhir_lexer _menhir_lexbuf in - (match (_tok : MenhirBasics.token) with - | LPAREN -> - let _menhir_s = MenhirState05 in - let _tok = _menhir_lexer _menhir_lexbuf in - (match (_tok : MenhirBasics.token) with - | IDENT _v -> - _menhir_run_06 _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s - | _ -> - _eRR ()) - | _ -> - _eRR ()) - | _ -> - _eRR () - - and _menhir_run_27 : type ttv_stack. ttv_stack -> _ -> _ -> (ttv_stack, _menhir_box_program) _menhir_state -> _menhir_box_program = - fun _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s -> - let _menhir_stack = MenhirCell1_SEND (_menhir_stack, _menhir_s) in - let _tok = _menhir_lexer _menhir_lexbuf in - match (_tok : MenhirBasics.token) with - | LPAREN -> - let _menhir_s = MenhirState28 in - let _tok = _menhir_lexer _menhir_lexbuf in - (match (_tok : MenhirBasics.token) with - | VAR -> - _menhir_run_01 _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s - | SESSION -> - _menhir_run_29 _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s - | SEND -> - _menhir_run_27 _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s - | RECEIVE -> - _menhir_run_34 _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s - | LITERAL -> - _menhir_run_36 _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s - | DELEGATE -> - _menhir_run_38 _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s - | CLOSE -> - _menhir_run_40 _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s - | _ -> - _eRR ()) - | _ -> - _eRR () - - and _menhir_run_34 : type ttv_stack. ttv_stack -> _ -> _ -> (ttv_stack, _menhir_box_program) _menhir_state -> _menhir_box_program = - fun _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s -> - let _menhir_stack = MenhirCell1_RECEIVE (_menhir_stack, _menhir_s) in - let _tok = _menhir_lexer _menhir_lexbuf in - match (_tok : MenhirBasics.token) with - | LPAREN -> - let _menhir_s = MenhirState35 in - let _tok = _menhir_lexer _menhir_lexbuf in - (match (_tok : MenhirBasics.token) with - | VAR -> - _menhir_run_01 _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s - | SESSION -> - _menhir_run_29 _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s - | SEND -> - _menhir_run_27 _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s - | RECEIVE -> - _menhir_run_34 _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s - | LITERAL -> - _menhir_run_36 _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s - | DELEGATE -> - _menhir_run_38 _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s - | CLOSE -> - _menhir_run_40 _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s - | _ -> - _eRR ()) - | _ -> - _eRR () - - and _menhir_run_36 : type ttv_stack. ttv_stack -> _ -> _ -> (ttv_stack, _menhir_box_program) _menhir_state -> _menhir_box_program = - fun _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s -> - let _tok = _menhir_lexer _menhir_lexbuf in - match (_tok : MenhirBasics.token) with - | INTEGER _v -> - let _tok = _menhir_lexer _menhir_lexbuf in - let _2 = _v in - let _v = _menhir_action_11 _2 in - _menhir_goto_expr _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok - | _ -> - _eRR () - - and _menhir_run_38 : type ttv_stack. ttv_stack -> _ -> _ -> (ttv_stack, _menhir_box_program) _menhir_state -> _menhir_box_program = - fun _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s -> - let _menhir_stack = MenhirCell1_DELEGATE (_menhir_stack, _menhir_s) in - let _tok = _menhir_lexer _menhir_lexbuf in - match (_tok : MenhirBasics.token) with - | LPAREN -> - let _menhir_s = MenhirState39 in - let _tok = _menhir_lexer _menhir_lexbuf in - (match (_tok : MenhirBasics.token) with - | VAR -> - _menhir_run_01 _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s - | SESSION -> - _menhir_run_29 _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s - | SEND -> - _menhir_run_27 _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s - | RECEIVE -> - _menhir_run_34 _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s - | LITERAL -> - _menhir_run_36 _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s - | DELEGATE -> - _menhir_run_38 _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s - | CLOSE -> - _menhir_run_40 _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s - | _ -> - _eRR ()) - | _ -> - _eRR () - - and _menhir_run_40 : type ttv_stack. ttv_stack -> _ -> _ -> (ttv_stack, _menhir_box_program) _menhir_state -> _menhir_box_program = - fun _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s -> - let _menhir_stack = MenhirCell1_CLOSE (_menhir_stack, _menhir_s) in - let _tok = _menhir_lexer _menhir_lexbuf in - match (_tok : MenhirBasics.token) with - | LPAREN -> - let _menhir_s = MenhirState41 in - let _tok = _menhir_lexer _menhir_lexbuf in - (match (_tok : MenhirBasics.token) with - | VAR -> - _menhir_run_01 _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s - | SESSION -> - _menhir_run_29 _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s - | SEND -> - _menhir_run_27 _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s - | RECEIVE -> - _menhir_run_34 _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s - | LITERAL -> - _menhir_run_36 _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s - | DELEGATE -> - _menhir_run_38 _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s - | CLOSE -> - _menhir_run_40 _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s - | _ -> - _eRR ()) - | _ -> - _eRR () - - and _menhir_run_26 : type ttv_stack. (ttv_stack, _menhir_box_program) _menhir_cell1_message -> _ -> _ -> _ -> _menhir_box_program = - fun _menhir_stack _menhir_lexbuf _menhir_lexer _v -> - let MenhirCell1_message (_menhir_stack, _menhir_s, _1) = _menhir_stack in - let _2 = _v in - let _v = _menhir_action_14 _1 _2 in - _menhir_goto_message_list _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s - - and _menhir_run_19 : type ttv_stack. (ttv_stack, _menhir_box_program) _menhir_cell1_IDENT _menhir_cell0_IDENT _menhir_cell0_IDENT -> _ -> _ -> _ -> _menhir_box_program = - fun _menhir_stack _menhir_lexbuf _menhir_lexer _v -> - let _tok = _menhir_lexer _menhir_lexbuf in - let MenhirCell0_IDENT (_menhir_stack, _2) = _menhir_stack in - let _4 = _v in - let _v = _menhir_action_20 _2 _4 in - _menhir_goto_type_expr _menhir_stack _menhir_lexbuf _menhir_lexer _v _tok - - and _menhir_run_32 : type ttv_stack. (ttv_stack, _menhir_box_program) _menhir_cell1_SESSION _menhir_cell0_IDENT -> _ -> _ -> _ -> _menhir_box_program = - fun _menhir_stack _menhir_lexbuf _menhir_lexer _v -> - let _tok = _menhir_lexer _menhir_lexbuf in - let MenhirCell0_IDENT (_menhir_stack, _2) = _menhir_stack in - let MenhirCell1_SESSION (_menhir_stack, _menhir_s) = _menhir_stack in - let _4 = _v in - let _v = _menhir_action_05 _2 _4 in - _menhir_goto_expr _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok - - and _menhir_run_58 : type ttv_stack. ((ttv_stack, _menhir_box_program) _menhir_cell1_SEND, _menhir_box_program) _menhir_cell1_expr _menhir_cell0_IDENT -> _ -> _ -> _ -> _ -> _menhir_box_program = - fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _tok -> - match (_tok : MenhirBasics.token) with - | RPAREN -> - let _tok = _menhir_lexer _menhir_lexbuf in - let MenhirCell0_IDENT (_menhir_stack, _5) = _menhir_stack in - let MenhirCell1_expr (_menhir_stack, _, _3) = _menhir_stack in - let MenhirCell1_SEND (_menhir_stack, _menhir_s) = _menhir_stack in - let _7 = _v in - let _v = _menhir_action_06 _3 _5 _7 in - _menhir_goto_expr _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok - | _ -> - _eRR () - - and _menhir_run_62 : type ttv_stack. ttv_stack -> _ -> _ -> _ -> (ttv_stack, _menhir_box_program) _menhir_state -> _ -> _menhir_box_program = - fun _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok -> - let _1 = _v in - let _v = _menhir_action_02 _1 in - _menhir_goto_decl _menhir_stack _menhir_lexbuf _menhir_lexer _v _menhir_s _tok - - let _menhir_run_00 : type ttv_stack. ttv_stack -> _ -> _ -> _menhir_box_program = - fun _menhir_stack _menhir_lexbuf _menhir_lexer -> - let _menhir_s = MenhirState00 in - let _tok = _menhir_lexer _menhir_lexbuf in - match (_tok : MenhirBasics.token) with - | VAR -> - _menhir_run_01 _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s - | SESSION -> - _menhir_run_03 _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s - | SEND -> - _menhir_run_27 _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s - | RECEIVE -> - _menhir_run_34 _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s - | LITERAL -> - _menhir_run_36 _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s - | DELEGATE -> - _menhir_run_38 _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s - | CLOSE -> - _menhir_run_40 _menhir_stack _menhir_lexbuf _menhir_lexer _menhir_s - | _ -> - _eRR () - -end - -let program = - fun _menhir_lexer _menhir_lexbuf -> - let _menhir_stack = () in - let MenhirBox_program v = _menhir_run_00 _menhir_stack _menhir_lexbuf _menhir_lexer in - v diff --git a/src/typecheck.ml b/src/typecheck.ml deleted file mode 100644 index d79e5d77..00000000 --- a/src/typecheck.ml +++ /dev/null @@ -1,128 +0,0 @@ -(** Ephapax Type Checker - Choreographic Session Extension *) - -open Ast - -exception TypeError of string - -(** Environment type *) -type env = { - sessions: (string, session_decl) Hashtbl.t; - types: (string, typ) Hashtbl.t; - (* other environment fields *) -} - -(** Initialize environment *) -let initial_env () = { - sessions = Hashtbl.create 16; - types = Hashtbl.create 16; -} - -(** Add session to environment *) -let add_session env name sdecl = - Hashtbl.add env.sessions name sdecl - -(** Get session from environment *) -let get_session env name = - try Hashtbl.find env.sessions name - with Not_found -> raise (TypeError ("Unknown session: " ^ name)) - -(** Check if type is linear *) -let rec is_linear_type env = function - | TypeVar name -> (* lookup type definition *) true - | SessionType _ -> true - | _ -> false - -(** Check session declaration *) -let check_session_decl env sdecl = - (* Check role uniqueness *) - let roles = sdecl.s_roles in - let unique_roles = List.sort_uniq String.compare roles in - if List.length roles <> List.length unique_roles then - raise (TypeError ("Duplicate roles in session " ^ sdecl.s_name)); - - (* Check all message types are linear *) - List.iter (fun msg -> - if not (is_linear_type env msg.msg_type) then - raise (TypeError "Session messages must have linear types") - ) sdecl.s_protocol; - - (* Add to environment *) - add_session env sdecl.s_name sdecl - -(** Check send expression *) -let check_send env (Send(sess, receiver, value)) = - (* In a real implementation, we would: - 1. Get the type of 'sess' expression - 2. Verify it's a SessionType - 3. Extract the session_decl ref - 4. Perform the send operation - - For now, we'll simulate this with a mock session *) - let mock_sdecl = ref { - s_name = "Transfer"; - s_roles = ["Alice"; "Bob"]; - s_protocol = [ - { msg_sender = "Alice"; msg_receiver = "Bob"; msg_type = TypeVar "Token" }; - { msg_sender = "Bob"; msg_receiver = "Alice"; msg_type = TypeVar "Receipt" } - ] - } in - let sdecl = !mock_sdecl in - (* Find expected message *) - let expected = List.find (fun m -> m.msg_receiver = receiver) sdecl.s_protocol in - (* Check value type *) - let value_ty = (* check_expr env value *) TypeVar "Token" in - if not ((* subtype value_ty expected.msg_type *) true) then - raise (TypeError "Value type doesn't match protocol"); - (* Return updated session type with remaining messages *) - SessionType(ref { - s_name = sdecl.s_name; - s_roles = sdecl.s_roles; - s_protocol = List.filter (fun m -> m.msg_sender <> expected.msg_sender || m.msg_receiver <> expected.msg_receiver) sdecl.s_protocol - }) - -(** Check receive expression *) -let check_receive env (Receive(sess, sender)) = - (* Mock session for demonstration *) - let mock_sdecl = ref { - s_name = "Transfer"; - s_roles = ["Alice"; "Bob"]; - s_protocol = [ - { msg_sender = "Alice"; msg_receiver = "Bob"; msg_type = TypeVar "Token" }; - { msg_sender = "Bob"; msg_receiver = "Alice"; msg_type = TypeVar "Receipt" } - ] - } in - let sdecl = !mock_sdecl in - let expected = List.find (fun m -> m.msg_sender = sender) sdecl.s_protocol in - expected.msg_type - -(** Check close expression *) -let check_close env (Close(sess)) = - (* Mock session for demonstration *) - let mock_sdecl = ref { - s_name = "Transfer"; - s_roles = ["Alice"; "Bob"]; - s_protocol = [] (* Empty protocol = complete *) - } in - let sdecl = !mock_sdecl in - if not (List.is_empty sdecl.s_protocol) then - raise (TypeError "Session not complete"); - (* Return unit type *) - TypeVar "()" - -(** Check delegate expression *) -let check_delegate env (Delegate(sess, old_role, new_role)) = - (* Mock session for demonstration *) - let mock_sdecl = ref { - s_name = "Transfer"; - s_roles = ["Alice"; "Bob"]; - s_protocol = [] - } in - let sdecl = !mock_sdecl in - if not (List.mem old_role sdecl.s_roles) then - raise (TypeError ("Role " ^ old_role ^ " not in session")); - (* Return updated session with replaced role *) - SessionType(ref { - s_name = sdecl.s_name; - s_roles = List.map (fun r -> if r = old_role then new_role else r) sdecl.s_roles; - s_protocol = sdecl.s_protocol - })