Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # there's a tl note for every translation i did, comments which do not
- # involve translations are ones im making to simplify python's grammar to be usable to
- # parsing to my own ast
- # i highly doubt you're interested in the semantics of python's grammar and is advised to
- # mainly go over the burmese translations
- <file> ::= <statement>*
- # GENERAL STATEMENTS
- # ==================
- <statement> ::= <compound_stmt> | <simple_stmts>
- <simple_stmts> ::= # icl ts pmo ngl, lk plz btr cmts
- | <simple_stmt> !';' NEWLINE # Not needed, there for speedup
- | <simple_stmt> (';' <simple_stmt>)* ';'? NEWLINE
- # | ';'.<simple_stmt>+ (';')? NEWLINE
- <simple_stmt> ::=
- | <assignment>
- | <type_alias>
- | <star_expressions>
- | <return_stmt>
- | <import_stmt>
- | <raise_stmt>
- # | 'pass' i genuinely dont know how to translate this, you can always do ... in python
- # | <del_stmt> honestly i think i used this once and it was because i didnt know pop exist
- # | <yield_stmt> dk how to translate
- # | <assert_stmt> dk how to translate
- | 'ရပ်ဆဲ'
- | 'ဆက်လက်'
- # | <global_stmt> not willing to translate these as i doubt modern python uses it
- # | <nonlocal_stmt>
- <compound_stmt> ::=
- | <function_def>
- | <if_stmt>
- | <class_def>
- # | <with_stmt> dont know how to translate
- | <for_stmt>
- | <try_stmt>
- | <while_stmt>
- # | <match_stmt> just cant be bothered with python's overly verbose switches
- <assignment> ::=
- | NAME ':' <expression> ('=' <annotated_rhs> )?
- | ('(' <single_target> ')'
- | <single_subscript_attribute_target>) ':' <expression> ('=' <annotated_rhs> )?
- | (<star_targets> '=' )+ (<yield_expr> | <star_expressions>) !'=' TYPE_COMMENT?
- | <single_target> <augassign> ~ (<yield_expr> | <star_expressions>)
- <annotated_rhs> ::= <yield_expr> | <star_expressions>
- <augassign> ::=
- | '+='
- | '-='
- | '*='
- | '@='
- | '/='
- | '%='
- | '&='
- | '|='
- | '^='
- | '<<='
- | '>>='
- | '**='
- | '//='
- # PLEASE USE
- <return_stmt> ::=
- | (<star_expressions>)? 'ရသည်'
- <raise_stmt> ::=
- | 'ပစ်'
- | (<expression> 'မှ')? <expression> 'ပစ်ပေး'
- # <global_stmt> ::= 'global' NAME (',' NAME)*
- # <nonlocal_stmt> ::= 'nonlocal' NAME (',' NAME)*
- # <del_stmt> ::=
- # | 'del' <del_targets> &(';' | NEWLINE)
- # <yield_stmt> ::= <yield_expr>
- # <assert_stmt> ::= 'assert' <expression> (',' <expression> )?
- <import_stmt> ::=
- | <import_name>
- # | <import_from>
- # Import statements
- # -----------------
- <import_name> ::= 'import' <dotted_as_names>
- <import_from> ::=
- # xD 'from ..' ends up working anyways
- | 'from' ('.' | '...')* <dotted_name> 'import' <import_from_targets>
- | 'from' ('.' | '...')+ 'import' <import_from_targets>
- <import_from_targets> ::=
- | '(' <import_from_as_names> (',')? ')'
- | <import_from_as_names> !','
- | '*'
- <import_from_as_names> ::=
- | <import_from_as_name> (',' <import_from_as_name>)*
- <import_from_as_name> ::=
- | NAME ('as' NAME )?
- <dotted_as_names> ::=
- | <dotted_as_name> (',' <dotted_as_name>)*
- <dotted_as_name> ::=
- | <dotted_name> ('as' NAME )?
- <dotted_name> ::=
- | <dotted_name> '.' NAME
- | NAME
- # COMPOUND STATEMENTS
- # ===================
- # Common elements
- # ---------------
- <block> ::=
- | NEWLINE INDENT <statements> DEDENT
- | <simple_stmts>
- <decorators> ::= ('@' <named_expression> NEWLINE )+
- # Class definitions
- # -----------------
- <class_def> ::=
- | <decorators> <class_def_raw>
- | <class_def_raw>
- # this will probably be the weirdest one, i felt 'အရာဝတ္ထု' was 1. too verbose and 2. အရာဝတ္ထု Human feels weird...
- # maybe i shouldve opted for some other stuff especially since 'ဝတ္ထု' and 'အရာဝတ္ထု' are two completely different things
- # or so some people have said
- # or so i said but im js gonna use အရာဝတ္ထု :/
- <class_def_raw> ::=
- | 'အရာဝတ္ထု' NAME <type_params>? ('(' <arguments>? ')' )? ':' <block>
- # Function definitions
- # --------------------
- <function_def> ::=
- | <decorators> <function_def_raw>
- | <function_def_raw>
- <function_def_raw> ::=
- | 'သတ်မှတ်ချက်' NAME <type_params>? '(' <params>? ')' ('->' <expression> )? ':' <func_type_comment>? <block>
- # | 'async' 'def' NAME <type_params>? '(' <params>? ')' ('->' <expression> )? ':' <func_type_comment>? <block>
- # dk of a way to translate async
- # Function parameters
- # -------------------
- <params> ::=
- | <parameters>
- <parameters> ::=
- | <slash_no_default> <param_no_default>* <param_with_default>* <star_etc>?
- | <slash_with_default> <param_with_default>* <star_etc>?
- | <param_no_default>+ <param_with_default>* <star_etc>?
- | <param_with_default>+ <star_etc>?
- | <star_etc>
- # Some duplication here because we can't write (',' | &')'),
- # which is because we don't support empty alternatives (yet).
- # yea and dont ever support that, i dont wanna deal w/ it
- <slash_no_default> ::=
- | <param_no_default>+ '/' ','
- | <param_no_default>+ '/' &')'
- <slash_with_default> ::=
- | <param_no_default>* <param_with_default>+ '/' ','
- | <param_no_default>* <param_with_default>+ '/' &')'
- <star_etc> ::=
- | '*' <param_no_default> <param_maybe_default>* <kwds>?
- | '*' <param_no_default_star_annotation> <param_maybe_default>* <kwds>?
- | '*' ',' <param_maybe_default>+ <kwds>?
- | <kwds>
- <kwds> ::=
- | '**' <param_no_default>
- <param_no_default> ::=
- | <param> ',' TYPE_COMMENT?
- | <param> TYPE_COMMENT? &')'
- <param_no_default_star_annotation> ::=
- | <param_star_annotation> ',' TYPE_COMMENT?
- | <param_star_annotation> TYPE_COMMENT? &')'
- <param_with_default> ::=
- | <param> <default> ',' TYPE_COMMENT?
- | <param> <default> TYPE_COMMENT? &')'
- <param_maybe_default> ::=
- | <param> <default>? ',' TYPE_COMMENT?
- | <param> <default>? TYPE_COMMENT? &')'
- <param> ::= NAME <annotation>?
- <param_star_annotation> ::= NAME <star_annotation>
- <annotation> ::= ':' <expression>
- <star_annotation> ::= ':' <star_expression>
- <default> ::= '=' <expression>
- # If statement
- # ------------
- <if_stmt> ::=
- | <named_expression> 'ဖြစ်ရင်' ':' <block> <elif_stmt>
- | <named_expression> 'ဖြစ်ရင်' ':' <block> <else_block>?
- <elif_stmt> ::=
- | 'သိုမဟုတ်' <named_expression> 'ဖြစ်ရင်' ':' <block> <elif_stmt>
- | 'သိုမဟုတ်' <named_expression> 'ဖြစ်ရင်' ':' <block> <else_block>?
- <else_block> ::=
- | 'သိုမဟုတ်' ':' <block>
- # While statement
- # ---------------
- <while_stmt> ::=
- | <named_expression> 'ဖြစ်နေစဉ်' ':' <block> <else_block>?
- # For statement
- # -------------
- <for_stmt> ::=
- | <star_expressions> 'ရှိ' <star_targets> 'အတွက်' ':' TYPE_COMMENT? <block> <else_block>?
- # | 'async' 'for' <star_targets> 'in' ~ <star_expressions> ':' TYPE_COMMENT? <block> <else_block>?
- # yet again the async
- # With statement
- # --------------
- # again dk how i would translate this
- # <with_stmt> ::=
- # | 'with' '(' <with_item> (',' <with_item>)* ','? ')' ':' TYPE_COMMENT? <block>
- # | 'with' <with_item> (',' <with_item>)* ':' TYPE_COMMENT? <block>
- # | 'async' 'with' '(' <with_item> (',' <with_item>)* ','? ')' ':' <block>
- # | 'async' 'with' <with_item> (',' <with_item>)* ':' TYPE_COMMENT? <block>
- # <with_item> ::=
- # | <expression> 'as' <star_target> &(',' | ')' | ':')
- # | <expression>
- # Try statement
- # -------------
- <try_stmt> ::=
- | 'စမ်းကြည့်' ':' <block> <finally_block>
- | 'စမ်းကြည့်' ':' <block> <except_block>+ <else_block>? <finally_block>?
- # | 'စမ်းကြည့်' ':' <block> <except_star_block>+ <else_block>? <finally_block>?
- # refer to <except_star_block>
- # Except statement
- # ----------------
- <except_block> ::=
- | <expression> ('ကို' NAME 'အနေဖြင့်' )? 'ဖမ်း၍' ':' <block>
- | 'ဖမ်း' ':' <block>
- <except_star_block> ::=
- # the last thing i can find about this is
- # https://groups.google.com/g/dev-python/c/G3p9_jovyus?pli=1
- | 'except' '*' <expression> ('as' NAME )? ':' <block>
- <finally_block> ::=
- | 'နောက်ဆုံး' ':' <block>
- # Match statement
- # ---------------
- <match_stmt> ::=
- | "match" <subject_expr> ':' NEWLINE INDENT <case_block>+ DEDENT
- <subject_expr> ::=
- | <star_named_expression> ',' <star_named_expressions>?
- | <named_expression>
- <case_block> ::=
- | "case" <patterns> <guard>? ':' <block>
- <guard> ::= 'if' <named_expression>
- <patterns> ::=
- | <open_sequence_pattern>
- | <pattern>
- <pattern> ::=
- | <as_pattern>
- | <or_pattern>
- <as_pattern> ::=
- | <or_pattern> 'as' <pattern_capture_target>
- <or_pattern> ::=
- | <closed_pattern> ('|' <closed_pattern>)*
- <closed_pattern> ::=
- | <literal_pattern>
- | <capture_pattern>
- | <wildcard_pattern>
- | <value_pattern>
- | <group_pattern>
- | <sequence_pattern>
- | <mapping_pattern>
- | <class_pattern>
- # Literal patterns are used for equality and identity constraints
- <literal_pattern> ::=
- | <signed_number> !('+' | '-')
- | <complex_number>
- | <strings>
- | 'ဗလာ'
- | 'မှန်'
- | 'မှား'
- # Literal expressions are used to restrict permitted mapping <pattern> keys
- <literal_expr> ::=
- | <signed_number> !('+' | '-')
- | <complex_number>
- | <strings>
- | 'ဗလာ'
- | 'မှန်'
- | 'မှား'
- <complex_number> ::=
- | <signed_real_number> '+' <imaginary_number>
- | <signed_real_number> '-' <imaginary_number>
- <signed_number> ::=
- | NUMBER
- | '-' NUMBER
- <signed_real_number> ::=
- | <real_number>
- | '-' <real_number>
- <real_number> ::=
- | NUMBER
- <imaginary_number> ::=
- | NUMBER
- <capture_pattern> ::=
- | <pattern_capture_target>
- <pattern_capture_target> ::=
- | !"_" NAME !('.' | '(' | '=')
- <wildcard_pattern> ::=
- | "_"
- <value_pattern> ::=
- | <attr> !('.' | '(' | '=')
- <attr> ::=
- | <name_or_attr> '.' NAME
- <name_or_attr> ::=
- | <attr>
- | NAME
- <group_pattern> ::=
- | '(' <pattern> ')'
- <sequence_pattern> ::=
- | '[' <maybe_sequence_pattern>? ']'
- | '(' <open_sequence_pattern>? ')'
- <open_sequence_pattern> ::=
- | <maybe_star_pattern> ',' <maybe_sequence_pattern> ?
- <maybe_sequence_pattern> ::=
- | <maybe_star_pattern> (',' <maybe_star_pattern>)* ','?
- <maybe_star_pattern> ::=
- | <star_pattern>
- | <pattern>
- <star_pattern> ::=
- | '*' <pattern_capture_target>
- | '*' <wildcard_pattern>
- <mapping_pattern> ::=
- | '{' '}'
- | '{' <double_star_pattern> ','? '}'
- | '{' <items_pattern> ',' <double_star_pattern> ','? '}'
- | '{' <items_pattern> ','? '}'
- <items_pattern> ::=
- | <key_value_pattern> (',' <key_value_pattern>)*
- <key_value_pattern> ::=
- | (<literal_expr> | <attr>) ':' <pattern>
- <double_star_pattern> ::=
- | '**' <pattern_capture_target>
- <class_pattern> ::=
- | <name_or_attr> '(' ')'
- | <name_or_attr> '(' <positional_patterns> ','? ')'
- | <name_or_attr> '(' <keyword_patterns> ','? ')'
- | <name_or_attr> '(' <positional_patterns> ',' <keyword_patterns> ','? ')'
- <positional_patterns> ::=
- | <pattern> (',' <pattern>)*
- <keyword_patterns> ::=
- | <key_value_pattern> (',' <keyword_pattern>)*
- <keyword_pattern> ::=
- | NAME '=' <pattern>
- # Type <statement>
- # ---------------
- <type_alias> ::=
- | "type" NAME <type_params>? '=' <expression>
- # Type <param>eter declaration
- # --------------------------
- <type_params> ::=
- | '[' <type_param_seq> ']'
- <type_param_seq> ::= <type_param> (',' <type_param>)* ','?
- <type_param> ::=
- | NAME <type_param_bound>? <type_param_default>?
- | '*' NAME <type_param_starred_default>?
- | '**' NAME <type_param_default>?
- <type_param_bound> ::= ':' <expression>
- <type_param_default> ::= '=' <expression>
- <type_param_starred_default> ::= '=' <star_expression>
- # EXPRESSIONS
- # -----------
- <expressions> ::=
- | <expression> (',' <expression> )+ ','?
- | <expression> ','
- | <expression>
- <expression> ::=
- | <disjunction> 'if' <disjunction> 'else' <expression>
- | <disjunction>
- | <lambdef>
- <yield_expr> ::=
- | 'yield' 'from' <expression>
- | 'yield' <star_expressions>?
- <star_expressions> ::=
- | <star_expression> (',' <star_expression> )+ ','?
- | <star_expression> ','
- | <star_expression>
- <star_expression> ::=
- | '*' <bitwise_or>
- | <expression>
- <star_named_expressions> ::= <star_named_expression> (',' <star_named_expression>)* ','?
- <star_named_expression> ::=
- | '*' <bitwise_or>
- | <named_expression>
- <assignment_expression> ::=
- | NAME ':=' ~ <expression>
- <named_expression> ::=
- | <assignment_expression>
- | <expression> !':='
- <disjunction> ::=
- | <conjunction> ('သို့မဟုတ်' <conjunction> )+
- | <conjunction>
- # 'ဖြစ်၍' is the only one that works with the other stuff
- <conjunction> ::=
- | <inversion> ('ဖြစ်၍' <inversion> )+
- | <inversion>
- # python allowing (not not not not not foo)
- # to be parsable is so strange
- # dont think we can do that
- <inversion> ::=
- | <inversion> 'မ' # this will prob be troublesome for most parser generators and could lead
- | <comparison> # lead to recursion errors, im hoping that itll
- # what im hoping with this is that the parser will fail to parse 'မ' and parse comparison
- # i just woke up and found out thats only an issue with LL parsing which is how my
- # parser generator works so alas, im the one dealing w/ that, yikes
- # Comparison operators
- # --------------------
- <comparison> ::=
- | <bitwise_or> <compare_op_bitwise_or_pair>+
- | <bitwise_or>
- <compare_op_bitwise_or_pair> ::=
- | <eq_bitwise_or>
- | <noteq_bitwise_or>
- | <lte_bitwise_or>
- | <lt_bitwise_or>
- | <gte_bitwise_or>
- | <gt_bitwise_or>
- | <notin_bitwise_or>
- | <in_bitwise_or>
- | <isnot_bitwise_or>
- | <is_bitwise_or>
- <eq_bitwise_or> ::= '==' <bitwise_or>
- <noteq_bitwise_or> ::=
- | ('!=' ) <bitwise_or>
- <lte_bitwise_or> ::= '<=' <bitwise_or>
- <lt_bitwise_or> ::= '<' <bitwise_or>
- <gte_bitwise_or> ::= '>=' <bitwise_or>
- <gt_bitwise_or> ::= '>' <bitwise_or>
- <notin_bitwise_or> ::= 'not' 'in' <bitwise_or>
- <in_bitwise_or> ::= 'in' <bitwise_or>
- <isnot_bitwise_or> ::= 'သည်' 'not' <bitwise_or>
- <is_bitwise_or> ::= 'သည်' <bitwise_or>
- # Bitwise operators
- # -----------------
- <bitwise_or> ::=
- | <bitwise_or> '|' <bitwise_xor>
- | <bitwise_xor>
- <bitwise_xor> ::=
- | <bitwise_xor> '^' <bitwise_and>
- | <bitwise_and>
- <bitwise_and> ::=
- | <bitwise_and> '&' <shift_expr>
- | <shift_expr>
- <shift_expr> ::=
- | <shift_expr> '<<' <sum>
- | <shift_expr> '>>' <sum>
- | <sum>
- # Arithmetic operators
- # --------------------
- <sum> ::=
- | <sum> '+' <term>
- | <sum> '-' <term>
- | <term>
- <term> ::=
- | <term> '*' <factor>
- | <term> '/' <factor>
- | <term> '//' <factor>
- | <term> '%' <factor>
- | <term> '@' <factor>
- | <factor>
- <factor> ::=
- | '+' <factor>
- | '-' <factor>
- | '~' <factor>
- | <power>
- <power> ::=
- | <await_primary> '**' <factor>
- | <await_primary>
- # Primary elements
- # ----------------
- # Primary elements are things like "obj.something.something", "obj[something]", "obj(something)", "obj" ...
- <await_primary> ::=
- | 'စောင့်ဆိုင်း' <primary>
- | <primary>
- <primary> ::=
- | <primary> '.' NAME
- | <primary> <genexp>
- | <primary> '(' (<arguments>)? ')'
- | <primary> '[' <slices> ']'
- | <atom>
- <slices> ::=
- | <slice> !','
- | (<slice> | <starred_expression>) (',' (<slice> | <starred_expression>))* (',')?
- <slice> ::=
- | <expression>? ':' <expression>? (':' <expression>? )?
- | <named_expression>
- <atom> ::=
- | NAME
- | 'မှန်'
- | 'မှား'
- | 'ဗလာ'
- | <strings>
- | NUMBER
- | (<tuple> | <group> | <genexp>)
- | (<list> | <listcomp>)
- | (<dict> | <set> | <dictcomp> | <setcomp>)
- | '...'
- <group> ::=
- | '(' (<yield_expr> | <named_expression>) ')'
- # Lambda functions
- # ----------------
- <lambdef> ::=
- | 'lambda' <lambda_params>? ':' <expression>
- <lambda_params> ::=
- | <lambda_parameters>
- <lambda_parameters> ::=
- | <lambda_slash_no_default> <lambda_param_no_default>* <lambda_param_with_default>* <lambda_star_etc>?
- | <lambda_slash_with_default> <lambda_param_with_default>* <lambda_star_etc>?
- | <lambda_param_no_default>+ <lambda_param_with_default>* <lambda_star_etc>?
- | <lambda_param_with_default>+ <lambda_star_etc>?
- | <lambda_star_etc>
- <lambda_slash_no_default> ::=
- | <lambda_param_no_default>+ '/' ','
- | <lambda_param_no_default>+ '/' &':'
- <lambda_slash_with_default> ::=
- | <lambda_param_no_default>* <lambda_param_with_default>+ '/' ','
- | <lambda_param_no_default>* <lambda_param_with_default>+ '/' &':'
- <lambda_star_etc> ::=
- | '*' <lambda_param_no_default> <lambda_param_maybe_default>* <lambda_kwds>?
- | '*' ',' <lambda_param_maybe_default>+ <lambda_kwds>?
- | <lambda_kwds>
- <lambda_kwds> ::=
- | '**' <lambda_param_no_default>
- <lambda_param_no_default> ::=
- | <lambda_param> ','
- | <lambda_param> &':'
- <lambda_param_with_default> ::=
- | <lambda_param> <default> ','
- | <lambda_param> <default> &':'
- <lambda_param_maybe_default> ::=
- | <lambda_param> <default>? ','
- | <lambda_param> <default>? &':'
- <lambda_param> ::= NAME
- # LITERALS
- # ========
- <fstring_middle> ::=
- | <fstring_replacement_field>
- | FSTRING_MIDDLE
- <fstring_replacement_field> ::=
- | '{' <annotated_rhs> '='? <fstring_conversion>? <fstring_full_format_spec>? '}'
- <fstring_conversion> ::=
- | "!" NAME
- <fstring_full_format_spec> ::=
- | ':' <fstring_format_spec>*
- <fstring_format_spec> ::=
- | FSTRING_MIDDLE
- | <fstring_replacement_field>
- <fstring> ::=
- | FSTRING_START <fstring_middle>* FSTRING_END
- <string> ::= STRING
- <strings> ::= (<fstring>|<string>)+
- <list> ::=
- | '[' <star_named_expressions>? ']'
- <tuple> ::=
- | '(' (<star_named_expression> ',' <star_named_expressions>? )? ')'
- <set> ::= '{' <star_named_expressions> '}'
- # Dicts
- # -----
- <dict> ::=
- | '{' <double_starred_kvpairs>? '}'
- <double_starred_kvpairs> ::= <double_starred_kvpair> (',' <double_starred_kvpair>)* ','?
- <double_starred_kvpair> ::=
- | '**' <bitwise_or>
- | <kvpair>
- <kvpair> ::= <expression> ':' <expression>
- # Comprehensions & Generators
- # ---------------------------
- <for_if_clauses> ::=
- | <for_if_clause>+
- <for_if_clause> ::=
- | 'async' 'for' <star_targets> 'in' ~ <disjunction> ('if' <disjunction> )*
- | 'for' <star_targets> 'in' ~ <disjunction> ('if' <disjunction> )*
- <listcomp> ::=
- | '[' <named_expression> <for_if_clauses> ']'
- <setcomp> ::=
- | '{' <named_expression> <for_if_clauses> '}'
- <genexp> ::=
- | '(' ( <assignment_expression> | <expression> !':=') <for_if_clauses> ')'
- <dictcomp> ::=
- | '{' <kvpair> <for_if_clauses> '}'
- # FUNCTION CALL ARGUMENTS
- # =======================
- <arguments> ::=
- | <args> ','? &')'
- <args> ::= # girl wtf
- | (<starred_expression> | ( <assignment_expression> | <expression> !':=') !'=') (',' (<starred_expression> | ( <assignment_expression> | <expression> !':=') !'='))* (',' <kwargs>)?
- | <kwargs>
- <kwargs> ::=
- | <kwarg_or_starred> (',' <kwarg_or_starred>)* ',' <kwarg_or_double_starred> (',' <kwarg_or_double_starred>)*
- | <kwarg_or_starred> (',' <kwarg_or_starred>)*
- | <kwarg_or_double_starred> (',' <kwarg_or_double_starred>)*
- <starred_expression> ::=
- | '*' <expression>
- <kwarg_or_starred> ::=
- | NAME '=' <expression>
- | <starred_expression>
- <kwarg_or_double_starred> ::=
- | NAME '=' <expression>
- | '**' <expression>
- <star_targets> ::=
- | <star_target> !','
- | <star_target> (',' <star_target> )* ','?
- <star_targets_list_seq> ::= <star_target> (',' <star_target>)* ','?
- <star_targets_tuple_seq> ::=
- | <star_target> (',' <star_target> )+ ','?
- | <star_target> ','
- <star_target> ::=
- | '*' (!'*' <star_target>)
- | <target_with_star_atom>
- <target_with
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement