Bläddra i källkod

writing custom BNF for pity lang

tcheukueppo 2 år sedan
förälder
incheckning
25c36d37f1
2 ändrade filer med 29 tillägg och 4 borttagningar
  1. 27 0
      custom_bnf.bnf
  2. 2 4
      example_scripts/fibonacci.pi

+ 27 - 0
custom_bnf.bnf

@@ -0,0 +1,27 @@
+# list of terminals
+Term_var_name: 
+Term_sep: 
+Term_real_sep: [;|\n]
+Term_space:    [\t\r]* # TODO
+
+sep                  -> Term_space Term_real_sep Term_space
+statements           -> statement [ sep statement, sep ... ]
+statement            -> declaration | flow_construct
+delcaration          -> variable_declaration | block_declaration | class_declaration
+block_declaration    -> named_block_declaration | function_declaration
+class_declaration    -> class Term_class_name
+variable_declaration -> var_modifier variables '=' expression
+variables            -> Term_varname | '(' Term_varname [ ',' Term_varname ',' ... ] ')'
+expresion            -> builtin_object_declaration | do_block | literal | tenary_op
+flow_construct       ->
+
+# parsing algorithm
+
+list of parsing functions
+
+-
+-
+-
+-
+
+Parse

+ 2 - 4
example_scripts/fibonacci.pi

@@ -1,4 +1,4 @@
-#!/usr/bin/env perl
+#!/usr/bin/env perl 
 
 # x is a global variable which can be accessed from other namespaces
 # ex: if we were in the namespace ONE::TWO then access 'a' with ONE::TWO::W
@@ -113,7 +113,7 @@ foreach v in array { ... }
 
 # classes
 class Person { ... }
-class Student << Person [, classA classB ] {
+class Student << Person {
    has class is rw
    has notes is ro
 
@@ -125,6 +125,4 @@ class Student << Person [, classA classB ] {
    multi method get_nodes(v, k) {
       self.notes.each{x < _ < k}
    }
-
-   ...
 }