Merge branch 'test' of https://github.com/urbit/urbit into test

This commit is contained in:
C. Guy Yarvin 2015-05-19 21:08:20 -07:00
commit e847993b7d
6 changed files with 248 additions and 88 deletions

49
base/lib/react/core.hook Normal file
View File

@ -0,0 +1,49 @@
!:
|%
++ react-elems :: XX /~
~+ %- sa ^- (list term)
:~ %a %abbr %address %area %article %aside %audio %b %base
%bdi %bdo %big %blockquote %body %br %button %canvas %caption
%cite %code %col %colgroup %data %datalist %dd %del %details
%dfn %dialog %div %dl %dt %em %embed %fieldset %figcaption
%figure %footer %form %h1 %h2 %h3 %h4 %h5 %h6 %head %header
%hr %html %i %iframe %img %input %ins %kbd %keygen %label
%legend %li %link %main %map %mark %menu %menuitem %meta
%meter %nav %noscript %object %ol %optgroup %option %output %p
%param %picture %pre %progress %q %rp %rt %ruby %s %samp
%script %section %select %small %source %span %strong %style
%sub %summary %sup %table %tbody %td %textarea %tfoot %th
%thead %time %title %tr %track %u %ul %var %video %wbr
%circle %defs %ellipse %g %line %linear-gradient %mask %path
%pattern %polygon %polyline %radial-gradient %rect %stop %svg
%text %tspan
==
++ react-vale
~(has in react-elems)
++ react-to-tape
|= src=manx ^- tape
:: ?: =(%script n.g.src)
;: weld
"React.createElement("
=* tan n.g.src
?^ tan !! :: namespaces unsupported
?: (react-vale tan)
"'{(trip tan)}'"
(trip tan)
::
", "
=- (pojo (jobe (turn a.g.src -)))
|= [a=mane b=tape]
=. a ?+(a a %class 'className')
?^(a !! [a (jape b)])
", "
::
=< ~(ram re %rose [", " "[" "]"] (turn c.src .))
|= a=manx
?: ?=(_:/(**) a)
leaf/(pojo (jape v.i.a.g.a))
leaf/^$(src a)
::
")"
==
--

View File

@ -0,0 +1,10 @@
.CodeMirror {
height: 100%
}
.cm-s-default .cm-atom {color: #70f}
.cm-s-default .cm-operator {color: #097}
#err {
background: #fdd;
display: none;
}

157
base/lib/syntax/hoon.js Normal file
View File

@ -0,0 +1,157 @@
CodeMirror.defineMode("hoon", function() {
glyph = /[+\-|$%:.#^~;=?!_,&\/<>%*]/
term = /^[$&|]|^[a-z]([a-z0-9\-]*[a-z0-9])?/
num = /-?-?^[0-9]([0-9.]*|[xwbv]?[0-9a-zA-Z.-~]*)/
res = {}
res.startState = function(){return {soblock: false, doqblock:false, sail:false, space:true}}
var propOrVar = function(c){
if(c == '.')
return 'property'
return 'variable'
}
res.token = function(stream, state){
if(state.soqblock && stream.sol()){
if(stream.match(/\s*'''/)){
state.soqblock = false
}
else {
stream.skipToEnd()
}
return "string"
}
if(state.doqblock){
if(stream.match(/\s*"""/)){
state.doqblock = false
}
else {
stream.skipToEnd()
}
return "string"
}
if(stream.sol())
state.space = true
if(state.sail){
if(stream.peek().match(/[^#./() ]/)||stream.eol()){
state.sail = false
if(stream.match(/:? /)){
stream.skipToEnd()
return 'string'
}
if(stream.match(term))
state.sail = true
return;
if(stream.match(':'))
state.sail = true
return 'operator'
}
}
if(stream.match("'")){
if(stream.match("''")){
state.soqblock = true
return 'string'
}
while(stream.match(/^[^'\\]/) || stream.match(/\\./));
stream.eat("'")
return 'string'
}
if(stream.match('"')){
if(stream.match('""')){
state.doqblock = true
stream.skipToEnd()
return 'string'
}
while(stream.match(/^[^"\\]/) || stream.match(/\\./));
stream.eat('"')
return 'string'
}
if(stream.match(' ;')){
if(stream.eat(' ')){
stream.skipToEnd()
return 'string'
}
if(!stream.match(glyph)){
state.sail = true
}
return 'builtin'
}
if(stream.match('::')){
stream.skipToEnd()
return 'comment'
}
if(stream.match('++ ') || stream.match('+- ')){
stream.match(term)
return 'header'
}
if(state.space && stream.match('--')){
if(stream.eat(glyph) || stream.eat(/[a-z0-9]/))
stream.backUp(3)
else return 'header'
}
if(stream.eat('%'))
if(stream.match(term) || stream.match(num))
return 'tag'
else stream.backUp(1)
if(state.space && stream.match('==')){
return 'tag'
}
if(stream.match(/^@[a-z]*[A-Z]?/))
return 'atom'
if(stream.match(num))
return 'number'
if(stream.eat(/[+\-]/)){
while(stream.eat(/[<>]/) && stream.eat(/[+\-]/));
return propOrVar(stream.peek())
}
if(stream.eat('`')){
state.space = false
return 'operator'
}
if(stream.sol() && stream.eatWhile(glyph)){
state.space = false
return 'builtin'
}
if(stream.eat(glyph)){
state.space = false
stream.backUp(2)
if(stream.eat(/[ ([{]/) || (stream.peek().match(/[^+\-<>]/)
&& stream.eat(glyph))){ // expression start
stream.eatWhile(glyph)
return 'builtin'
}
stream.next()
if(state.space && stream.eat('=')){
if(/[()]/.exec(stream.peek()))
return 'builtin'
return 'operator'
}
if(stream.eat(/[=:.^]/))
return 'operator'
stream.next()
return 'builtin'
}
if(stream.match(term)){
if(state.space && stream.match('/'))
return 'tag'
state.space = false
return propOrVar(stream.peek())
}
if(stream.eat(/[ \[(]/)){
state.space = true
return
}
stream.next()
}
res.lineComment = '::'
res.fold = "indent"
return res
});
CodeMirror.defineMIME("text/x-hoon", "hoon");

View File

@ -8,8 +8,34 @@
++ grow :: convert to
|%
++ mime [/text/hoon (taco own)] :: convert to %mime
++ psal ;div:(pre:"{(trip own)}") :: convert to %html
++ hymn ;html:(head:title:"Source" "+{psal}")
++ psal :: convert to %html
;div:(pre:"{(trip own)}")
:: =+ gen-id="src-{<`@ui`(mug own)>}"
:: ;div
:: ;textarea(id "{gen-id}"):"{(trip own)}"
:: ;script:"""
:: CodeMirror.fromTextArea(
:: window[{<gen-id>}],
:: \{lineNumbers:true, readOnly:true}
:: )
:: """
:: ==
++ hymn
:: ;html:(head:title:"Source" "+{psal}")
;html
;head
;title:"Source"
;script@"//cdnjs.cloudflare.com/ajax/libs/codemirror/4.3.0/codemirror.js";
;script@"/{(trip &2:%)}/lib/syntax/hoon.js";
;link(rel "stylesheet", href "//cdnjs.cloudflare.com/ajax/libs/".
"codemirror/4.3.0/codemirror.min.css");
;link/"/{(trip &2:%)}/lib/syntax/codemirror.css"(rel "stylesheet");
==
;body
;textarea#src:"{(trip own)}"
;script:'CodeMirror.fromTextArea(src, {lineNumbers:true, readOnly:true})'
==
==
++ txt (lore (cat 3 own '\0a'))
--
++ grab

View File

@ -2,56 +2,15 @@
:::: /hoon/core/react-snip/mar
::
/? 314
/= react-elems
/; sa /~
:~ %a %abbr %address %area %article %aside %audio %b %base
%bdi %bdo %big %blockquote %body %br %button %canvas %caption
%cite %code %col %colgroup %data %datalist %dd %del %details
%dfn %dialog %div %dl %dt %em %embed %fieldset %figcaption
%figure %footer %form %h1 %h2 %h3 %h4 %h5 %h6 %head %header
%hr %html %i %iframe %img %input %ins %kbd %keygen %label
%legend %li %link %main %map %mark %menu %menuitem %meta
%meter %nav %noscript %object %ol %optgroup %option %output %p
%param %picture %pre %progress %q %rp %rt %ruby %s %samp
%script %section %select %small %source %span %strong %style
%sub %summary %sup %table %tbody %td %textarea %tfoot %th
%thead %time %title %tr %track %u %ul %var %video %wbr
%circle %defs %ellipse %g %line %linear-gradient %mask %path
%pattern %polygon %polyline %radial-gradient %rect %stop %svg
%text %tspan
==
/+ react
!:
::::
::
|_ own=manx
::
++ vale ~(has in react-elems)
++ grow :: convert to
|%
++ tape
;: weld
"React.createElement("
=* tan n.g.own
?^ tan !! :: namespaces unsupported
?: (vale tan)
"'{(trip tan)}'"
(trip tan)
::
", "
=- (pojo (jobe (turn a.g.own -)))
|= [a=mane b=^tape]
=. a ?+(a a %class 'className')
?^(a !! [a (jape b)])
", "
::
=- ~(ram re %rose [", " "[" "]"] (turn c.own -))
|= a=manx
?: ?=(_:/(**) a)
leaf/(pojo (jape v.i.a.g.a))
leaf/tape(own a)
::
")"
==
++ tape (react-to-tape own)
++ react-snip-js (crip tape)
++ react-snip-json
::?> ?=([[%div ~] [[%h1 ~] *] [[%div ~] *] ~]] own) :: xx mystery fish-loop

View File

@ -2,56 +2,15 @@
:::: /hoon/core/react/mar
::
/? 314
/= react-elems
/; sa /~
:~ %a %abbr %address %area %article %aside %audio %b %base
%bdi %bdo %big %blockquote %body %br %button %canvas %caption
%cite %code %col %colgroup %data %datalist %dd %del %details
%dfn %dialog %div %dl %dt %em %embed %fieldset %figcaption
%figure %footer %form %h1 %h2 %h3 %h4 %h5 %h6 %head %header
%hr %html %i %iframe %img %input %ins %kbd %keygen %label
%legend %li %link %main %map %mark %menu %menuitem %meta
%meter %nav %noscript %object %ol %optgroup %option %output %p
%param %picture %pre %progress %q %rp %rt %ruby %s %samp
%script %section %select %small %source %span %strong %style
%sub %summary %sup %table %tbody %td %textarea %tfoot %th
%thead %time %title %tr %track %u %ul %var %video %wbr
%circle %defs %ellipse %g %line %linear-gradient %mask %path
%pattern %polygon %polyline %radial-gradient %rect %stop %svg
%text %tspan
==
/+ react
!:
::::
::
|_ own=manx
::
++ vale ~(has in react-elems)
++ grow :: convert to
|%
++ tape
;: weld
"React.createElement("
=* tan n.g.own
?^ tan !! :: namespaces unsupported
?: (vale tan)
"'{(trip tan)}'"
(trip tan)
::
", "
=- (pojo (jobe (turn a.g.own -)))
|= [a=mane b=^tape]
=. a ?+(a a %class 'className')
?^(a !! [a (jape b)])
", "
::
=- ~(ram re %rose [", " "[" "]"] (turn c.own -))
|= a=manx
?: ?=(_:/(**) a)
leaf/(pojo (jape v.i.a.g.a))
leaf/tape(own a)
::
")"
==
++ tape (react-to-tape own)
++ react-js (crip tape)
:: ++ js react-js :: convert to %js
++ mime [/text/javascript (taco react-js)] :: convert to %mime