diff options
author | bnewbold <bnewbold@robocracy.org> | 2016-12-17 18:34:47 -0800 |
---|---|---|
committer | bnewbold <bnewbold@robocracy.org> | 2016-12-17 18:34:47 -0800 |
commit | 9f82aceb9fbdb42f332d68f4a423123bd0788b2c (patch) | |
tree | c082b9795be8e9e9d286c8f8f1345d22f3ec1b59 /src/modelica_parser.lalrpop.full | |
parent | f6364ebcac0d0a88a3cc6812fd2120c97b42cc26 (diff) | |
download | modelthing-9f82aceb9fbdb42f332d68f4a423123bd0788b2c.tar.gz modelthing-9f82aceb9fbdb42f332d68f4a423123bd0788b2c.zip |
refactor modelica parser into separate crate
Diffstat (limited to 'src/modelica_parser.lalrpop.full')
-rw-r--r-- | src/modelica_parser.lalrpop.full | 171 |
1 files changed, 0 insertions, 171 deletions
diff --git a/src/modelica_parser.lalrpop.full b/src/modelica_parser.lalrpop.full deleted file mode 100644 index d453bc7..0000000 --- a/src/modelica_parser.lalrpop.full +++ /dev/null @@ -1,171 +0,0 @@ -use std::str::FromStr; - -// Based on the Modelica 3.3r1 Spec - -grammar; - -//// B.1 Lexical Convetions - -//digit: = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" -//q_ident = "’" ( q_char | s_escape ) { q_char | s_escape } "’" -//nondigit = "_" | letters "a" to "z" | letters "A" to "Z" -//s_char = any member of the Unicode character set (http://www.unicode.org; see Section 13.2.2 for storing as UTF-8 on files) except double-quote """, and backslash "\" -//q_char = nondigit | digit | "!" | "#" | "$" | "%" | "&" | "(" | ")" | "*" | "+" | "," | "-" | "." | "/" | ":" | ";" | "<" | ">" | "=" | "?" | "@" | "[" | "]" | "^" | "{" | "}" | "|" | "~" | " " -//s_escape = "\’" | "\"" | "\?" | "\\" | "\a" | "\b" | "\f" | "\n" | "\r" | "\t" | "\v" -// -//ident = nondigit { digit | nondigit } | q_ident -//string = """ { s_char | s_escape } """ -//unsigned_integer = digit { digit } -//unsigned_number = unsigned_integer [ "." [ unsigned_integer ] ] [ ( "e" | "E" ) [ "+" | "-" ] unsigned_integer ] - -IDENT: () = { - r"[a-zA-Z_][a-zA-Z_0-9]*", - // TODO: quoted identifier: "’" ... "’" -}; - -STRING: () = { - //"\"" r"[^\"^\\]*" "\"", - "\"" r"[^\\]*" "\"", // XXX: not \ and not " -}; - -UNSIGNED_INTEGER: () = { - r"\d+", -}; - -UNSIGNED_NUMBER: () = { - UNSIGNED_INTEGER, - r"\d+\.?\d*([eE][-+]?\d+)?", -}; - - -//// B.2 Grammar - -//// B.2.1 - -//stored_definition: -// [ within [ name ] ";" ] -// { [ final ] class_definition ";" } - -//// B.2.2 Class Definition - - -//// B.2.7 Expressions - -expression: () = { - simple_expression, - if expression then expression { elseif expression then expression } else expression -}; - -simple_expression: () = { - logical_expression [ ":" logical_expression [ ":" logical_expression ] ] -}; - -logical_expression: () = { - logical_term { or logical_term } -}; - -logical_term: () = { - logical_factor { and logical_factor } -}; - -logical_factor: () = { - [ not ] relation -}; - -relation: () = { - arithmetic_expression [ rel_op arithmetic_expression ] -}; - -rel_op: () = { - "<", "<=", ">", ">=", "==", "<>" -}; - -arithmetic_expression: () = { - [ add_op ] term { add_op term } -}; - -add_op: () = { - "+", "-", ".+", ".-" -}; - -term: () = { - factor { mul_op factor } -}; - -mul_op: () = { - "*", "/", ".*", "./" -}; - -factor: () = { - primary [ ("^" | ".^") primary ] -}; - -primary: () = { - UNSIGNED_NUMBER, - STRING, - false, - true, - ( name | der | initial ) function_call_args, - component_reference, - "(" output_expression_list ")", - "[" expression_list { ";" expression_list } "]", - "{" function_arguments "}", - end, -}; - -name: () = { - [ "." ] IDENT { "." IDENT } -}; - -component_reference: () = { - [ "." ] IDENT [ array_subscripts ] { "." IDENT [ array_subscripts ] } -}; - -function_call_args: () = { - "(" [ function_arguments ] ")", - function_arguments, - function_argument [ "," function_arguments | for for_indices ], - named_arguments, -}; - -named_arguments: () = { - named_argument [ "," named_arguments ] -}; - -named_argument: - IDENT "=" function_argument -}; - -function_argument: () = { - function name "(" [ named_arguments ] ")" | expression -}; - - -output_expression_list: - [ expression ] { "," [ expression ] } - -expression_list: () = { - expression { "," expression } -}; - -array_subscripts: () = { - "[" subscript { "," subscript } "]" - -}; - -subscript: () = { - ":" | expression - -}; - -comment: () = { - string_comment [ annotation ] -}; - -string_comment: () = { - [ STRING { "+" STRING } ] -}; - -annotation: () = { - annotation class_modification -}; |