Browse Source

Use a module.

Beoran 5 years ago
parent
commit
e06f8d90f4
5 changed files with 159 additions and 4 deletions
  1. 11 0
      go.mod
  2. 88 0
      raku/introduction.raku
  3. 52 0
      raku/raku.peg
  4. 3 3
      zori/css1.peg
  5. 5 1
      zori/css1_example.css

+ 11 - 0
go.mod

@@ -0,0 +1,11 @@
+module ebsgo
+
+require gitlab.com/beoran/al5go v0.0.0
+
+require gitlab.com/beoran/ebsgo v0.0.0
+
+require github.com/beevik/etree v1.0.1
+
+replace gitlab.com/beoran/al5go => ../al5go
+
+replace gitlab.com/beoran/ebsgo => ../ebsgo

+ 88 - 0
raku/introduction.raku

@@ -0,0 +1,88 @@
+# Introduction to the Raku scripting Language. This is a comment.
+#--- And so is this.  
+This is a multi line comment
+---#
+
+# Blank lines are generally ignored matter
+
+# This is a simple command call with a string argument
+say "hello"
+
+# assignment and arithmetic operators are supported and keep their precedence
+# floating point and integer numbers are supported 
+a = 5 + 7.0 * -3.14
+
+# Statements can be grouped between brackets or braces into blocks
+# Block statements must be terminated by new lines or semicolons
+[ say "First" ; say "Second" ; Say "third" ;]
+{ say "First" ; say "Second" ; Say "third" ;}
+{ 
+    say "First" 
+    say "Second"
+    say "Third"
+}
+
+# A parenthesis block may only contain a single statement.
+( a + sqrt 2.0 )  
+
+# But it can be used as arguments to a command, or in an operator expression
+
+z = ( a * sqrt 2.0 ) + (b * sqrt 3.0 ) 
+
+# A block can be passed to a command as an argument
+
+repeat 3 {
+    say "Repeat"
+}
+
+a > b
+
+# Control statements are just normal commands with block arguments
+if ( a  > 10 ) { 
+    say "Greater" 
+} else { # Watch out, no newline is allowed before the "else", or the "else" would become a separate command.
+    say "Lesser"
+}
+
+# Define a new command like this:
+def say_hello [] {
+    say "Hello!"
+}
+
+
+
+#---
+
+set aa b 
+set foobar to 10
+# set the foobar's pianos' size to 10 + 10
+open the door at the front .
+cast cure at the big green dog behind the red door.
+# loop for i from -1 to 10 do 
+#    print i
+#    print i * 2
+# end
+# check length of foo equals 5 and bar's size equals 7 do
+#     print "foo OK"
+# end else do
+#     print "not foo OK"
+# end
+# 10 + 10 
+# set foobar to the the 10 + 10
+# type Being is an Object do
+#    field its name is a String
+#    field its hp is an Integer
+#    field its hpx is an Integer 
+# end
+
+
+make Being 
+
+# set foo expr not expr bar and baz end end
+set foo to 10
+cast cure light beastly fido
+cast cure light at beastly fido
+# set foo to ( 1 lshift 2 binand 78 rshift 1) greater_or_equal 77 
+
+set bar to true or false
+---#

+ 52 - 0
raku/raku.peg

@@ -0,0 +1,52 @@
+# RAKU is a simple, fun to use and to embed scripting language. 
+# The syntax resembles TCL somewhat but it's semantics are somewhat lisp like.
+
+STATEMENTS   ←  ((STATEMENT COMMENT? / COMMENT) EOS)+
+~COMMENT     ←  "#---" (!("---#").)* "---#" /  "#" (!([\r\n]+).)*
+STATEMENT    ←  TERM ( OPERATOR TERM )*
+TERM         ←  CALL / VALUE / BLOCK / PBLOCK / BBLOCK
+CALL         ←  VALUE ARGUMENTS
+BLOCK        ←  "{" EOS? STATEMENTS? "}" 
+BBLOCK       ←  "[" EOS? STATEMENTS? "]"
+PBLOCK       ←  "(" EOS? STATEMENT EOS? ")"
+ARGUMENTS    ←  (BLOCK / PBLOCK / BBLOCK / VALUE)+ 
+OPERATOR     ←  < [-+/*] / "<<" / ">>" / "<-" / "->" / "<=>" / "<=" / ">=" / "<" / ">" / 
+                  ".." / "." /
+                  "&&"/ "&" / "||" / "|" / "^^" / "^" / "==" / "="  > 
+VALUE        ←  WORD / SYMBOL / STRING / NUMBER
+STRING       ←  SYMBOL / ESCSTR / RAWSTR
+# Raw string macro
+RAWSM(O,C)   ← O < (!(C).)* > C
+# Escaped string macro.
+ESCSM(O,C)   ← O < (!(C)STRCHAR)* > C
+SYMBOL       ← < ":" WORD >
+ESCSTR       ← ESCSM("`", "`") / ESCSM('"', '"')
+RAWSTR       ← RAWSM("'", "'") /  RAWSM('«', '»') / RAWSM('‹', '›') / RAWSM('“', '”')
+STRESC1      ← "\\" [nrtfv\'\\"\[\]\\]
+STRESC2      ← "\\" [0-3] [0-7] [0-7]
+STRESC3      ← "\\" [0-7] [0-7]*
+STRESC4      ← "\\x" [0-9a-fA-F] [0-9a-fA-F]?
+STRESC5      ← "\\u" [0-9a-fA-F]+
+STRNOESC     ← (!('\\\\').)
+STRCHAR      ←   STRESC1 / STRESC2 / STRESC3 / STRESC4 / STRESC5 / STRNOESC    
+NUMBER       ←  DECIMAL / INTEGER
+DECIMAL      ← < [-+]?[0-9]+[.][0-9]+ >
+INTEGER      ← < [-+]?[0-9]+ >
+~EOS         ← ([ \t]*[\r\n;]+[ \t]*)+
+WORD         ← < [_a-zA-Z][-_a-zA-Z0-9]* >
+WHITESPACE   ← < [ \t]* >
+%whitespace  ←  [ \t]*
+%word        ← [a-zA-Z][-+/*a-zA-Z0-9]*
+---
+# Expression parsing option
+%expr  = STATEMENT   # Rule to apply 'precedence climbing method' to
+%binop = L =
+%binop = L <- ->
+%binop = L + - | ^
+%binop = L * / & << >>
+%binop = L && || ^^
+%binop = L == <=> <= >= < >
+%binop = L . ..
+ 
+
+

+ 3 - 3
zori/css1.peg

@@ -6,11 +6,11 @@
 STYLESHEET      ← (CDO / CDC)*  (RULESET/DECLARATIONS/COMMENT/ATRULE)* (CDO / CDC)*
 RULESET         ← SELECTORS "{" DECLARATIONS? "}"
 SELECTORS       ← SELECTOR ("," SELECTOR)*
-SELECTOR        ← ( NAME ID? CLASS? PSEUDO_CLASS? /
+SELECTOR        ← ( "*" / NAME ID? CLASS? PSEUDO_CLASS? /
                   ID CLASS? PSEUDO_CLASS? /
                   CLASS PSEUDO_CLASS? /
                   PSEUDO_CLASS )+ PSEUDO_ELEMENT* / PSEUDO_ELEMENT 
-ATRULE          ← ATID STRING ";" / ATID "{" DECLARATIONS "}" 
+ATRULE          ← ATID (STRING / URL) ";" / ATID "{" DECLARATIONS "}" 
 NAME            ← <IDENT>
 DECLARATIONS    ← DECLARATION (';' DECLARATION)* ';'?
 DECLARATION     ← NAME ":" EXPR PRIO? / COMMENT 
@@ -53,5 +53,5 @@ RGB                 ← < "rgb("[ \t]*[0-9]+[ \t]* "," [ \t]*[0-9]+[ \t]* "," [
 CDO                 ←   "<!--"
 CDC                 ←   "-->"
 %whitespace         ←   [ \t\n\r]*
-# %word               ←  [a-zA-Z][-+/*_a-zA-Z0-9]*
+# %word             ←  [a-zA-Z][-+/*_a-zA-Z0-9]*
 

+ 5 - 1
zori/css1_example.css

@@ -1,3 +1,7 @@
+* {
+  foo:bar;
+}
+
 :hover {
     background-color: red;
 }
@@ -18,4 +22,4 @@ bar   : quux;
     bar : 50px;
 }
 
-@import "foo.bar" ;
+@import url("foo.bar") ;