open Parsing;;
# 30 "parser.mly"
-\r
-\r
-(** Modelica parser. *)\r
-\r
-(** Implementation based on {i Modelica language specification 2.0 } *)\r
-\r
-open Syntax\r
-\r
-exception Unclosed of int * string * int * string\r
-exception Invalid_matrix of int * int\r
-exception Invalid_array of int * int\r
-exception End_of_file\r
-\r
-type location =\r
- {\r
- start: int; (* offset in the parsed stream *)\r
- enddd: int; (* offset in the parsed stream *)\r
- filename: filename\r
- }\r
-\r
-and filename =\r
- | LibraryFile of string\r
- | CommandLine\r
-\r
-type error_description =\r
- {\r
- err_msg: string list;\r
- err_info: (string * string) list;\r
- err_ctx: err_ctx\r
- }\r
-\r
-and err_ctx =\r
- {\r
- location: location;\r
- }\r
-\r
-exception SyntacticError of error_description\r
-\r
-let inputfile = ref CommandLine\r
-\r
-let node nature =\r
- {\r
- nature = nature;\r
- info = { start = Parsing.symbol_start ();\r
- enddd = Parsing.symbol_end ();\r
- filename = !inputfile }\r
- }\r
-\r
-let rhs_nodes n n' nature =\r
- {\r
- nature = nature;\r
- info = { start = Parsing.rhs_start n;\r
- enddd = Parsing.rhs_end n';\r
- filename = !inputfile }\r
- }\r
-\r
-let unclosed opening_symbol opening_pos closing_symbol closing_pos =\r
- let offset = Parsing.rhs_start opening_pos\r
- and offset' = Parsing.rhs_start closing_pos in\r
- raise (Unclosed (offset, opening_symbol, offset', closing_symbol))\r
-\r
-let invalid_matrix_construction opening_pos error_pos =\r
- raise (Invalid_matrix (\r
- Parsing.rhs_start opening_pos, Parsing.rhs_start error_pos))\r
-\r
-let invalid_literal_array_construction opening_pos error_pos =\r
- raise (Invalid_array (\r
- Parsing.rhs_start opening_pos, Parsing.rhs_start error_pos))\r
-\r
+
+
+(** Modelica parser. *)
+
+(** Implementation based on {i Modelica language specification 2.0 } *)
+
+open Syntax
+
+exception Unclosed of int * string * int * string
+exception Invalid_matrix of int * int
+exception Invalid_array of int * int
+exception End_of_file
+
+type location =
+ {
+ start: int; (* offset in the parsed stream *)
+ enddd: int; (* offset in the parsed stream *)
+ filename: filename
+ }
+
+and filename =
+ | LibraryFile of string
+ | CommandLine
+
+type error_description =
+ {
+ err_msg: string list;
+ err_info: (string * string) list;
+ err_ctx: err_ctx
+ }
+
+and err_ctx =
+ {
+ location: location;
+ }
+
+exception SyntacticError of error_description
+
+let inputfile = ref CommandLine
+
+let node nature =
+ {
+ nature = nature;
+ info = { start = Parsing.symbol_start ();
+ enddd = Parsing.symbol_end ();
+ filename = !inputfile }
+ }
+
+let rhs_nodes n n' nature =
+ {
+ nature = nature;
+ info = { start = Parsing.rhs_start n;
+ enddd = Parsing.rhs_end n';
+ filename = !inputfile }
+ }
+
+let unclosed opening_symbol opening_pos closing_symbol closing_pos =
+ let offset = Parsing.rhs_start opening_pos
+ and offset' = Parsing.rhs_start closing_pos in
+ raise (Unclosed (offset, opening_symbol, offset', closing_symbol))
+
+let invalid_matrix_construction opening_pos error_pos =
+ raise (Invalid_matrix (
+ Parsing.rhs_start opening_pos, Parsing.rhs_start error_pos))
+
+let invalid_literal_array_construction opening_pos error_pos =
+ raise (Invalid_array (
+ Parsing.rhs_start opening_pos, Parsing.rhs_start error_pos))
+
# 164 "parser.ml"
let yytransl_const = [|
262 (* ALGORITHM *);
let _2 = (Parsing.peek_val __caml_parser_env 0 : 'component_list) in
Obj.repr(
# 165 "parser.mly"
- ( match _1.nature with\r
- | IndexedAccess (type_spec_node, subscripts_node) ->\r
- node (VariablesDefinitions (type_spec_node, Some subscripts_node, (List.rev _2)))\r
- | type_spec ->\r
+ ( match _1.nature with
+ | IndexedAccess (type_spec_node, subscripts_node) ->
+ node (VariablesDefinitions (type_spec_node, Some subscripts_node, (List.rev _2)))
+ | type_spec ->
node (VariablesDefinitions (rhs_nodes 1 1 type_spec, None, (List.rev _2))) )
# 1712 "parser.ml"
: 'toplevel_expression))
let _4 = (Parsing.peek_val __caml_parser_env 0 : string) in
Obj.repr(
# 245 "parser.mly"
- ( if _1 <> _4 then unclosed _1 1 _1 4\r
+ ( if _1 <> _4 then unclosed _1 1 _1 4
else node (LongSpecifier (_1, _2, _3)) )
# 1908 "parser.ml"
: 'class_specifier))
let _6 = (Parsing.peek_val __caml_parser_env 0 : string) in
Obj.repr(
# 255 "parser.mly"
- ( if _2 <> _6 then unclosed _2 2 _2 6\r
+ ( if _2 <> _6 then unclosed _2 2 _2 6
else node (ExtensionSpecifier (_2, _3, _4, _5)) )
# 1949 "parser.ml"
: 'class_specifier))
let _3 = (Parsing.peek_val __caml_parser_env 0 : 'component_declaration) in
Obj.repr(
# 600 "parser.mly"
- ( let cpnt = node (ComponentClause (_1, _2, None, [_3])) in\r
+ ( let cpnt = node (ComponentClause (_1, _2, None, [_3])) in
node (ComponentClauseElement (None, cpnt, [])) )
# 2716 "parser.ml"
: 'class_definition_or_component_clause1))
let _4 = (Parsing.peek_val __caml_parser_env 0 : 'component_declaration) in
Obj.repr(
# 608 "parser.mly"
- ( let cpnt = node (ComponentClause (_2, _3, None, [_4])) in\r
+ ( let cpnt = node (ComponentClause (_2, _3, None, [_4])) in
node (ComponentClauseElement (Some Replaceable, cpnt, [])) )
# 2741 "parser.ml"
: 'class_definition_or_component_clause1))
let _5 = (Parsing.peek_val __caml_parser_env 0 : 'constraining_clauses) in
Obj.repr(
# 612 "parser.mly"
- ( let cpnt = node (ComponentClause (_2, _3, None, [_4])) in\r
+ ( let cpnt = node (ComponentClause (_2, _3, None, [_4])) in
node (ComponentClauseElement (Some Replaceable, cpnt, List.rev _5)) )
# 2752 "parser.ml"
: 'class_definition_or_component_clause1))
let _2 = (Parsing.peek_val __caml_parser_env 1 : 'expression_list) in
Obj.repr(
# 981 "parser.mly"
- ( match _2 with\r
- | [expr] -> node expr.Syntax.nature\r
+ ( match _2 with
+ | [expr] -> node expr.Syntax.nature
| _ -> node (Tuple _2) )
# 3610 "parser.ml"
: 'primary))
(Parsing.yyparse yytables 1 lexfun lexbuf : (location Syntax.toplevel_element_desc, location) Syntax.node)
;;
# 1113 "parser.mly"
-\r
-\r
-let parse filename token_fun lexbuf =\r
- inputfile := filename;\r
- try\r
- definition token_fun lexbuf\r
- with\r
- | Unclosed (pos, symbol, pos', symbol') ->\r
- raise (SyntacticError\r
- {err_msg = ["_Unclosed"; symbol];\r
- err_info = [];\r
- err_ctx =\r
- {location = {start = pos;\r
- enddd = pos';\r
- filename = filename}}})\r
- | Invalid_matrix (pos, pos') ->\r
- raise (SyntacticError\r
- {err_msg = ["_InvalidMatrixConstruct"];\r
- err_info = [];\r
- err_ctx =\r
- {location = {start = pos;\r
- enddd = pos';\r
- filename = filename}}})\r
- | Invalid_array (pos, pos') ->\r
- raise (SyntacticError\r
- {err_msg = ["_InvalidArrayConstruct"];\r
- err_info = [];\r
- err_ctx =\r
- {location = {start = pos;\r
- enddd = pos';\r
- filename = filename}}})\r
- | Parsing.Parse_error ->\r
- raise (SyntacticError\r
- {err_msg = ["_SyntaxError"];\r
- err_info = [];\r
- err_ctx =\r
- {location = {start = Lexing.lexeme_start lexbuf;\r
- enddd = Lexing.lexeme_end lexbuf;\r
- filename = filename}}})\r
+
+
+let parse filename token_fun lexbuf =
+ inputfile := filename;
+ try
+ definition token_fun lexbuf
+ with
+ | Unclosed (pos, symbol, pos', symbol') ->
+ raise (SyntacticError
+ {err_msg = ["_Unclosed"; symbol];
+ err_info = [];
+ err_ctx =
+ {location = {start = pos;
+ enddd = pos';
+ filename = filename}}})
+ | Invalid_matrix (pos, pos') ->
+ raise (SyntacticError
+ {err_msg = ["_InvalidMatrixConstruct"];
+ err_info = [];
+ err_ctx =
+ {location = {start = pos;
+ enddd = pos';
+ filename = filename}}})
+ | Invalid_array (pos, pos') ->
+ raise (SyntacticError
+ {err_msg = ["_InvalidArrayConstruct"];
+ err_info = [];
+ err_ctx =
+ {location = {start = pos;
+ enddd = pos';
+ filename = filename}}})
+ | Parsing.Parse_error ->
+ raise (SyntacticError
+ {err_msg = ["_SyntaxError"];
+ err_info = [];
+ err_ctx =
+ {location = {start = Lexing.lexeme_start lexbuf;
+ enddd = Lexing.lexeme_end lexbuf;
+ filename = filename}}})
# 3974 "parser.ml"