mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Compare commits
33 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7133c3b11a | ||
|
|
d72114083b | ||
|
|
683925fcd5 | ||
|
|
1c8bf32d35 | ||
|
|
28913833f4 | ||
|
|
c6752be546 | ||
|
|
395e474cad | ||
|
|
16ea189aa6 | ||
|
|
ac81fc5da9 | ||
|
|
58191c10b3 | ||
|
|
c2ca23d580 | ||
|
|
b5dfb40c7d | ||
|
|
7e647fd915 | ||
|
|
5b9f9bc0e6 | ||
|
|
b1c057fa30 | ||
|
|
ca348dd373 | ||
|
|
b802045c5c | ||
|
|
3c244a9501 | ||
|
|
832a7b9b06 | ||
|
|
e7d856345f | ||
|
|
ac559effaa | ||
|
|
95d0daba80 | ||
|
|
a0ad1523a1 | ||
|
|
06c049b8c0 | ||
|
|
24c7380765 | ||
|
|
73ef1bf156 | ||
|
|
f46e053633 | ||
|
|
d2e739ba8c | ||
|
|
37174e1d2c | ||
|
|
cdb5206def | ||
|
|
d636eaf1e3 | ||
|
|
538f479b60 | ||
|
|
88cc73fa49 |
9
.gitmodules
vendored
9
.gitmodules
vendored
@@ -683,9 +683,18 @@
|
||||
[submodule "vendor/grammars/language-babel"]
|
||||
path = vendor/grammars/language-babel
|
||||
url = https://github.com/gandm/language-babel
|
||||
[submodule "vendor/grammars/UrWeb-Language-Definition"]
|
||||
path = vendor/grammars/UrWeb-Language-Definition
|
||||
url = https://github.com/gwalborn/UrWeb-Language-Definition.git
|
||||
[submodule "vendor/grammars/Stata.tmbundle"]
|
||||
path = vendor/grammars/Stata.tmbundle
|
||||
url = https://github.com/pschumm/Stata.tmbundle
|
||||
[submodule "vendor/grammars/FreeMarker.tmbundle"]
|
||||
path = vendor/grammars/FreeMarker.tmbundle
|
||||
url = https://github.com/freemarker/FreeMarker.tmbundle
|
||||
[submodule "vendor/grammars/language-click"]
|
||||
path = vendor/grammars/language-click
|
||||
url = https://github.com/stenverbois/language-click.git
|
||||
[submodule "vendor/grammars/language-maxscript"]
|
||||
path = vendor/grammars/language-maxscript
|
||||
url = https://github.com/Alhadis/language-maxscript
|
||||
|
||||
@@ -142,6 +142,8 @@ vendor/grammars/TXL/:
|
||||
- source.txl
|
||||
vendor/grammars/Textmate-Gosu-Bundle:
|
||||
- source.gosu.2
|
||||
vendor/grammars/UrWeb-Language-Definition:
|
||||
- source.ur
|
||||
vendor/grammars/VBDotNetSyntax:
|
||||
- source.vbnet
|
||||
vendor/grammars/Vala-TMBundle:
|
||||
@@ -322,6 +324,8 @@ vendor/grammars/kotlin-sublime-package:
|
||||
vendor/grammars/language-babel/:
|
||||
- source.js.jsx
|
||||
- source.regexp.babel
|
||||
vendor/grammars/language-click/:
|
||||
- source.click
|
||||
vendor/grammars/language-clojure:
|
||||
- source.clojure
|
||||
vendor/grammars/language-coffee-script:
|
||||
@@ -345,6 +349,8 @@ vendor/grammars/language-javascript:
|
||||
vendor/grammars/language-jsoniq/:
|
||||
- source.jq
|
||||
- source.xq
|
||||
vendor/grammars/language-maxscript:
|
||||
- source.maxscript
|
||||
vendor/grammars/language-ncl:
|
||||
- source.ncl
|
||||
vendor/grammars/language-python:
|
||||
|
||||
@@ -238,8 +238,10 @@ module Linguist
|
||||
disambiguate ".ms" do |data|
|
||||
if /^[.'][a-z][a-z](\s|$)/i.match(data)
|
||||
Language["Groff"]
|
||||
elsif /((^|\s)move?[. ])|\.(include|globa?l)\s/.match(data)
|
||||
elsif /(?<!\S)\.(include|globa?l)\s/.match(data) || /(?<!\/\*)(\A|\n)\s*\.[A-Za-z]/.match(data.gsub(/"([^\\"]|\\.)*"|'([^\\']|\\.)*'|\\\s*(?:--.*)?\n/, ""))
|
||||
Language["GAS"]
|
||||
else
|
||||
Language["MAXScript"]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ Agda:
|
||||
|
||||
Alloy:
|
||||
type: programming # 'modeling' would be more appropiate
|
||||
color: "#cc5c24"
|
||||
color: "#64C800"
|
||||
extensions:
|
||||
- .als
|
||||
ace_mode: text
|
||||
@@ -541,6 +541,14 @@ Clean:
|
||||
tm_scope: none
|
||||
ace_mode: text
|
||||
|
||||
Click:
|
||||
type: programming
|
||||
color: "#E4E6F3"
|
||||
extensions:
|
||||
- .click
|
||||
tm_scope: source.click
|
||||
ace_mode: text
|
||||
|
||||
Clojure:
|
||||
type: programming
|
||||
ace_mode: clojure
|
||||
@@ -887,6 +895,8 @@ Elixir:
|
||||
ace_mode: elixir
|
||||
filenames:
|
||||
- mix.lock
|
||||
interpreters:
|
||||
- elixir
|
||||
|
||||
Elm:
|
||||
type: programming
|
||||
@@ -1694,6 +1704,18 @@ Julia:
|
||||
color: "#a270ba"
|
||||
ace_mode: julia
|
||||
|
||||
Jupyter Notebook:
|
||||
type: markup
|
||||
ace_mode: json
|
||||
tm_scope: source.json
|
||||
color: "#DA5B0B"
|
||||
extensions:
|
||||
- .ipynb
|
||||
filenames:
|
||||
- Notebook
|
||||
aliases:
|
||||
- IPython Notebook
|
||||
|
||||
KRL:
|
||||
type: programming
|
||||
color: "#28431f"
|
||||
@@ -1956,6 +1978,15 @@ M:
|
||||
tm_scope: source.lisp
|
||||
ace_mode: lisp
|
||||
|
||||
MAXScript:
|
||||
type: programming
|
||||
color: "#00a6a6"
|
||||
extensions:
|
||||
- .ms
|
||||
- .mcr
|
||||
tm_scope: source.maxscript
|
||||
ace_mode: text
|
||||
|
||||
MTML:
|
||||
type: markup
|
||||
color: "#b7e1f4"
|
||||
@@ -2041,6 +2072,8 @@ Mathematica:
|
||||
Matlab:
|
||||
type: programming
|
||||
color: "#bb92ac"
|
||||
aliases:
|
||||
- octave
|
||||
extensions:
|
||||
- .matlab
|
||||
- .m
|
||||
@@ -3529,6 +3562,17 @@ UnrealScript:
|
||||
tm_scope: source.java
|
||||
ace_mode: java
|
||||
|
||||
UrWeb:
|
||||
type: programming
|
||||
aliases:
|
||||
- Ur/Web
|
||||
- Ur
|
||||
extensions:
|
||||
- .ur
|
||||
- .urs
|
||||
tm_scope: source.ur
|
||||
ace_mode: text
|
||||
|
||||
VCL:
|
||||
group: Perl
|
||||
type: programming
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
module Linguist
|
||||
VERSION = "4.7.2"
|
||||
VERSION = "4.7.3"
|
||||
end
|
||||
|
||||
133
samples/Click/sr2.click
Normal file
133
samples/Click/sr2.click
Normal file
@@ -0,0 +1,133 @@
|
||||
rates :: AvailableRates
|
||||
elementclass sr2 {
|
||||
$sr2_ip, $sr2_nm, $wireless_mac, $gateway, $probes|
|
||||
|
||||
|
||||
arp :: ARPTable();
|
||||
lt :: LinkTable(IP $sr2_ip);
|
||||
|
||||
|
||||
gw :: SR2GatewaySelector(ETHTYPE 0x062c,
|
||||
IP $sr2_ip,
|
||||
ETH $wireless_mac,
|
||||
LT lt,
|
||||
ARP arp,
|
||||
PERIOD 15,
|
||||
GW $gateway);
|
||||
|
||||
|
||||
gw -> SR2SetChecksum -> [0] output;
|
||||
|
||||
set_gw :: SR2SetGateway(SEL gw);
|
||||
|
||||
|
||||
es :: SR2ETTStat(ETHTYPE 0x0641,
|
||||
ETH $wireless_mac,
|
||||
IP $sr2_ip,
|
||||
PERIOD 30000,
|
||||
TAU 300000,
|
||||
ARP arp,
|
||||
PROBES $probes,
|
||||
ETT metric,
|
||||
RT rates);
|
||||
|
||||
|
||||
metric :: SR2ETTMetric(LT lt);
|
||||
|
||||
|
||||
forwarder :: SR2Forwarder(ETHTYPE 0x0643,
|
||||
IP $sr2_ip,
|
||||
ETH $wireless_mac,
|
||||
ARP arp,
|
||||
LT lt);
|
||||
|
||||
|
||||
querier :: SR2Querier(ETH $wireless_mac,
|
||||
SR forwarder,
|
||||
LT lt,
|
||||
ROUTE_DAMPENING true,
|
||||
TIME_BEFORE_SWITCH 5,
|
||||
DEBUG true);
|
||||
|
||||
|
||||
query_forwarder :: SR2MetricFlood(ETHTYPE 0x0644,
|
||||
IP $sr2_ip,
|
||||
ETH $wireless_mac,
|
||||
LT lt,
|
||||
ARP arp,
|
||||
DEBUG false);
|
||||
|
||||
query_responder :: SR2QueryResponder(ETHTYPE 0x0645,
|
||||
IP $sr2_ip,
|
||||
ETH $wireless_mac,
|
||||
LT lt,
|
||||
ARP arp,
|
||||
DEBUG true);
|
||||
|
||||
|
||||
query_responder -> SR2SetChecksum -> [0] output;
|
||||
query_forwarder -> SR2SetChecksum -> SR2Print(forwarding) -> [0] output;
|
||||
query_forwarder [1] -> query_responder;
|
||||
|
||||
data_ck :: SR2SetChecksum()
|
||||
|
||||
input [1]
|
||||
-> host_cl :: IPClassifier(dst net $sr2_ip mask $sr2_nm,
|
||||
-)
|
||||
-> querier
|
||||
-> data_ck;
|
||||
|
||||
|
||||
host_cl [1] -> [0] set_gw [0] -> querier;
|
||||
|
||||
forwarder[0]
|
||||
-> dt ::DecIPTTL
|
||||
-> data_ck
|
||||
-> [2] output;
|
||||
|
||||
|
||||
dt[1]
|
||||
-> Print(ttl-error)
|
||||
-> ICMPError($sr2_ip, timeexceeded, 0)
|
||||
-> querier;
|
||||
|
||||
|
||||
// queries
|
||||
querier [1] -> [1] query_forwarder;
|
||||
es -> SetTimestamp() -> [1] output;
|
||||
|
||||
|
||||
forwarder[1] //ip packets to me
|
||||
-> SR2StripHeader()
|
||||
-> CheckIPHeader()
|
||||
-> from_gw_cl :: IPClassifier(src net $sr2_ip mask $sr2_nm,
|
||||
-)
|
||||
-> [3] output;
|
||||
|
||||
from_gw_cl [1] -> [1] set_gw [1] -> [3] output;
|
||||
|
||||
input [0]
|
||||
-> ncl :: Classifier(
|
||||
12/0643 , //sr2_forwarder
|
||||
12/0644 , //sr2
|
||||
12/0645 , //replies
|
||||
12/0641 , //sr2_es
|
||||
12/062c , //sr2_gw
|
||||
);
|
||||
|
||||
|
||||
ncl[0] -> SR2CheckHeader() -> [0] forwarder;
|
||||
ncl[1] -> SR2CheckHeader() -> PrintSR(query) -> query_forwarder
|
||||
ncl[2] -> SR2CheckHeader() -> query_responder;
|
||||
ncl[3] -> es;
|
||||
ncl[4] -> SR2CheckHeader() -> gw;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Idle -> s :: sr2(2.0.0.1, 255.0.0.0, 00:00:00:00:00:01, false, "12 60 12 1500") -> Discard;
|
||||
Idle -> [1] s;
|
||||
s[1] -> Discard;
|
||||
s[2] -> Discard;
|
||||
s[3] -> Discard;
|
||||
142
samples/Click/thomer-nat.click
Normal file
142
samples/Click/thomer-nat.click
Normal file
@@ -0,0 +1,142 @@
|
||||
// This Click configuration implements a firewall and NAT, roughly based on the
|
||||
// mazu-nat.click example.
|
||||
//
|
||||
// This example assumes there is one interface that is IP-aliased. In this
|
||||
// example, eth0 and eth0:0 have IP addresses 66.68.65.90 and 192.168.1.1,
|
||||
// respectively. There is a local network, 192.168.1.0/24, and an upstream
|
||||
// gateway, 66.58.65.89. Traffic from the local network is NATed.
|
||||
//
|
||||
// Connections can be initiated from the NAT box itself, also.
|
||||
//
|
||||
// For bugs, suggestions, and, corrections, please email me.
|
||||
//
|
||||
// Author: Thomer M. Gil (click@thomer.com)
|
||||
|
||||
AddressInfo(
|
||||
eth0-in 192.168.1.1 192.168.1.0/24 00:0d:87:9d:1c:e9,
|
||||
eth0-ex 66.58.65.90 00:0d:87:9d:1c:e9,
|
||||
gw-addr 66.58.65.89 00:20:6f:14:54:c2
|
||||
);
|
||||
|
||||
|
||||
elementclass SniffGatewayDevice {
|
||||
$device |
|
||||
from :: FromDevice($device)
|
||||
-> t1 :: Tee
|
||||
-> output;
|
||||
input -> q :: Queue(1024)
|
||||
-> t2 :: PullTee
|
||||
-> to :: ToDevice($device);
|
||||
t1[1] -> ToHostSniffers;
|
||||
t2[1] -> ToHostSniffers($device);
|
||||
ScheduleInfo(from .1, to 1);
|
||||
}
|
||||
|
||||
|
||||
device :: SniffGatewayDevice(eth0);
|
||||
arpq_in :: ARPQuerier(eth0-in) -> device;
|
||||
ip_to_extern :: GetIPAddress(16)
|
||||
-> CheckIPHeader
|
||||
-> EtherEncap(0x800, eth0-ex, gw-addr)
|
||||
-> device;
|
||||
ip_to_host :: EtherEncap(0x800, gw-addr, eth0-ex)
|
||||
-> ToHost;
|
||||
ip_to_intern :: GetIPAddress(16)
|
||||
-> CheckIPHeader
|
||||
-> arpq_in;
|
||||
|
||||
|
||||
arp_class :: Classifier(
|
||||
12/0806 20/0001, // [0] ARP requests
|
||||
12/0806 20/0002, // [1] ARP replies to host
|
||||
12/0800); // [2] IP packets
|
||||
|
||||
device -> arp_class;
|
||||
|
||||
// ARP crap
|
||||
arp_class[0] -> ARPResponder(eth0-in, eth0-ex) -> device;
|
||||
arp_class[1] -> arp_t :: Tee;
|
||||
arp_t[0] -> ToHost;
|
||||
arp_t[1] -> [1]arpq_in;
|
||||
|
||||
|
||||
// IP packets
|
||||
arp_class[2] -> Strip(14)
|
||||
-> CheckIPHeader
|
||||
-> ipclass :: IPClassifier(dst host eth0-ex,
|
||||
dst host eth0-in,
|
||||
src net eth0-in);
|
||||
|
||||
// Define pattern NAT
|
||||
iprw :: IPRewriterPatterns(NAT eth0-ex 50000-65535 - -);
|
||||
|
||||
// Rewriting rules for UDP/TCP packets
|
||||
// output[0] rewritten to go into the wild
|
||||
// output[1] rewritten to come back from the wild or no match
|
||||
rw :: IPRewriter(pattern NAT 0 1,
|
||||
pass 1);
|
||||
|
||||
// Rewriting rules for ICMP packets
|
||||
irw :: ICMPPingRewriter(eth0-ex, -);
|
||||
irw[0] -> ip_to_extern;
|
||||
irw[1] -> icmp_me_or_intern :: IPClassifier(dst host eth0-ex, -);
|
||||
icmp_me_or_intern[0] -> ip_to_host;
|
||||
icmp_me_or_intern[1] -> ip_to_intern;
|
||||
|
||||
// Rewriting rules for ICMP error packets
|
||||
ierw :: ICMPRewriter(rw irw);
|
||||
ierw[0] -> icmp_me_or_intern;
|
||||
ierw[1] -> icmp_me_or_intern;
|
||||
|
||||
|
||||
// Packets directed at eth0-ex.
|
||||
// Send it through IPRewriter(pass). If there was a mapping, it will be
|
||||
// rewritten such that dst is eth0-in:net, otherwise dst will still be for
|
||||
// eth0-ex.
|
||||
ipclass[0] -> [1]rw;
|
||||
|
||||
// packets that were rewritten, heading into the wild world.
|
||||
rw[0] -> ip_to_extern;
|
||||
|
||||
// packets that come back from the wild or are not part of an established
|
||||
// connection.
|
||||
rw[1] -> established_class :: IPClassifier(dst host eth0-ex,
|
||||
dst net eth0-in);
|
||||
|
||||
// not established yet or returning packets for a connection that was
|
||||
// established from this host itself.
|
||||
established_class[0] ->
|
||||
firewall :: IPClassifier(dst tcp port ssh,
|
||||
dst tcp port smtp,
|
||||
dst tcp port domain,
|
||||
dst udp port domain,
|
||||
icmp type echo-reply,
|
||||
proto icmp,
|
||||
port > 4095,
|
||||
-);
|
||||
|
||||
firewall[0] -> ip_to_host; // ssh
|
||||
firewall[1] -> ip_to_host; // smtp
|
||||
firewall[2] -> ip_to_host; // domain (t)
|
||||
firewall[3] -> ip_to_host; // domain (u)
|
||||
firewall[4] -> [0]irw; // icmp reply
|
||||
firewall[5] -> [0]ierw; // other icmp
|
||||
firewall[6] -> ip_to_host; // port > 4095, probably for connection
|
||||
// originating from host itself
|
||||
firewall[7] -> Discard; // don't allow incoming for port <= 4095
|
||||
|
||||
// established connection
|
||||
established_class[1] -> ip_to_intern;
|
||||
|
||||
// To eth0-in. Only accept from inside network.
|
||||
ipclass[1] -> IPClassifier(src net eth0-in) -> ip_to_host;
|
||||
|
||||
// Packets from eth0-in:net either stay on local network or go to the wild.
|
||||
// Those that go into the wild need to go through the appropriate rewriting
|
||||
// element. (Either UDP/TCP rewriter or ICMP rewriter.)
|
||||
ipclass[2] -> inter_class :: IPClassifier(dst net eth0-in, -);
|
||||
inter_class[0] -> ip_to_intern;
|
||||
inter_class[1] -> ip_udp_class :: IPClassifier(tcp or udp,
|
||||
icmp type echo);
|
||||
ip_udp_class[0] -> [0]rw;
|
||||
ip_udp_class[1] -> [0]irw;
|
||||
210
samples/Jupyter Notebook/JupyterNotebook.ipynb
Normal file
210
samples/Jupyter Notebook/JupyterNotebook.ipynb
Normal file
File diff suppressed because one or more lines are too long
29
samples/MAXScript/macro-1.mcr
Normal file
29
samples/MAXScript/macro-1.mcr
Normal file
@@ -0,0 +1,29 @@
|
||||
-- Taken from an example from Autodesk's MAXScript reference:
|
||||
-- http://help.autodesk.com/view/3DSMAX/2016/ENU/?guid=__files_GUID_84E24969_C175_4389_B9A6_3B2699B66785_htm
|
||||
|
||||
macroscript MoveToSurface
|
||||
category: "HowTo"
|
||||
(
|
||||
fn g_filter o = superclassof o == Geometryclass
|
||||
fn find_intersection z_node node_to_z = (
|
||||
local testRay = ray node_to_z.pos [0,0,-1]
|
||||
local nodeMaxZ = z_node.max.z
|
||||
testRay.pos.z = nodeMaxZ + 0.0001 * abs nodeMaxZ
|
||||
intersectRay z_node testRay
|
||||
)
|
||||
|
||||
on isEnabled return selection.count > 0
|
||||
|
||||
on Execute do (
|
||||
target_mesh = pickObject message:"Pick Target Surface:" filter:g_filter
|
||||
|
||||
if isValidNode target_mesh then (
|
||||
undo "MoveToSurface" on (
|
||||
for i in selection do (
|
||||
int_point = find_intersection target_mesh i
|
||||
if int_point != undefined then i.pos = int_point.pos
|
||||
)--end i loop
|
||||
)--end undo
|
||||
)--end if
|
||||
)--end execute
|
||||
)--end script
|
||||
53
samples/MAXScript/macro-2.mcr
Normal file
53
samples/MAXScript/macro-2.mcr
Normal file
@@ -0,0 +1,53 @@
|
||||
-- Taken from an example from Autodesk's MAXScript reference:
|
||||
-- http://help.autodesk.com/view/3DSMAX/2016/ENU/?guid=__files_GUID_0876DF46_FAA3_4131_838D_5739A67FF2C1_htm
|
||||
|
||||
macroscript FreeSpline category:"HowTo" tooltip:"FreeSpline" (
|
||||
local old_pos
|
||||
local new_spline
|
||||
local second_knot_set
|
||||
|
||||
fn get_mouse_pos pen_pos old_pen_pos = (
|
||||
if old_pos == undefined then old_pos = old_pen_pos
|
||||
if distance pen_pos old_pos > 10 then
|
||||
(
|
||||
if second_knot_set then
|
||||
addKnot new_spline 1 #smooth #curve pen_pos
|
||||
else
|
||||
(
|
||||
setKnotPoint new_spline 1 2 pen_pos
|
||||
second_knot_set = true
|
||||
)
|
||||
old_pos = pen_pos
|
||||
updateShape new_spline
|
||||
)-- end if
|
||||
)-- end fn
|
||||
|
||||
fn draw_new_line old_pen_pos = (
|
||||
pickPoint mouseMoveCallback:#(get_mouse_pos,old_pen_pos)
|
||||
)
|
||||
|
||||
undo"Free Spline"on(
|
||||
new_spline = splineShape ()
|
||||
old_pen_pos = pickPoint ()
|
||||
|
||||
if old_pen_pos == #RightClick then
|
||||
delete new_spline
|
||||
else
|
||||
(
|
||||
select new_spline
|
||||
new_spline.pos = old_pen_pos
|
||||
addNewSpline new_spline
|
||||
addKnot new_spline 1 #smooth #curve old_pen_pos
|
||||
addKnot new_spline 1 #smooth #curve old_pen_pos
|
||||
second_knot_set = false
|
||||
draw_new_line old_pen_pos
|
||||
q = querybox "Close Spline?" title:"Free Spline"
|
||||
if q then
|
||||
(
|
||||
close new_spline 1
|
||||
updateshape new_spline
|
||||
)
|
||||
select new_spline
|
||||
)--end else
|
||||
)--end undo
|
||||
)--end script
|
||||
64
samples/MAXScript/svg-renderer.ms
Normal file
64
samples/MAXScript/svg-renderer.ms
Normal file
@@ -0,0 +1,64 @@
|
||||
-- Taken from a 3-part tutorial from Autodesk's MAXScript reference
|
||||
-- Source: http://help.autodesk.com/view/3DSMAX/2016/ENU/?guid=__files_GUID_6B5EDC11_A154_4AA7_A972_A11AC36949E9_htm
|
||||
|
||||
fn ColourToHex col = (
|
||||
local theComponents = #(bit.intAsHex col.r, bit.intAsHex col.g, bit.intAsHex col.b)
|
||||
local theValue = "#"
|
||||
for i in theComponents do
|
||||
theValue += (if i.count == 1 then "0" else "") + i
|
||||
theValue
|
||||
)
|
||||
|
||||
local st = timestamp()
|
||||
local theFileName = (getDir #userscripts + "\\PolygonRendering3.svg")
|
||||
local theSVGfile = createFile theFileName
|
||||
format "<svg xmlns=\"http://www.w3.org/2000/svg\"\n" to:theSVGfile
|
||||
format "\t\txmlns:xlink=\"http://www.w3.org/1999/xlink\">\n" to:theSVGfile
|
||||
|
||||
local theViewTM = viewport.getTM()
|
||||
theViewTM.row4 = [0,0,0]
|
||||
|
||||
local theViewTM2 = viewport.getTM()
|
||||
local theViewSize = getViewSize()
|
||||
local theViewScale = getViewSize()
|
||||
theViewScale.x /= 1024.0
|
||||
theViewScale.y /= 1024.0
|
||||
|
||||
local theStrokeThickness = 3
|
||||
|
||||
gw.setTransform (matrix3 1)
|
||||
for o in Geometry where not o.isHiddenInVpt and classof o != TargetObject do (
|
||||
local theStrokeColour = white
|
||||
local theFillColour = o.wirecolor
|
||||
|
||||
local theMesh = snapshotAsMesh o
|
||||
for f = 1 to theMesh.numfaces do (
|
||||
local theNormal = normalize (getFaceNormal theMesh f)
|
||||
|
||||
if (theNormal*theViewTM).z > 0 do
|
||||
(
|
||||
local theFace = getFace theMesh f
|
||||
local v1 = gw.transPoint (getVert theMesh theFace.x)
|
||||
local v2 = gw.transPoint (getVert theMesh theFace.y)
|
||||
local v3 = gw.transPoint (getVert theMesh theFace.z)
|
||||
|
||||
v1.x /= theViewScale.x
|
||||
v1.y /= theViewScale.y
|
||||
v2.x /= theViewScale.x
|
||||
v2.y /= theViewScale.y
|
||||
v3.x /= theViewScale.x
|
||||
v3.y /= theViewScale.y
|
||||
|
||||
format "\t<polygon points='%,% %,% %,%' \n" v1.x v1.y v2.x v2.y v3.x v3.y to:theSVGfile
|
||||
format "\tstyle='stroke:%; fill:%; stroke-width:%'/>\n" (ColourToHex theStrokeColour) (ColourToHex theFillColour) theStrokeThickness to:theSVGfile
|
||||
)--end if normal positive
|
||||
)--end f loop
|
||||
)--end o loop
|
||||
|
||||
format "</svg>\n" to:theSVGfile
|
||||
close theSVGfile
|
||||
local theSVGMap = VectorMap vectorFile:theFileName alphasource:0
|
||||
local theBitmap = bitmap theViewSize.x theViewSize.y
|
||||
renderMap theSVGMap into:theBitmap filter:true
|
||||
display theBitmap
|
||||
format "Render Time: % sec.\n" ((timestamp()-st)/1000.0)
|
||||
22
samples/MAXScript/volume-calc.ms
Normal file
22
samples/MAXScript/volume-calc.ms
Normal file
@@ -0,0 +1,22 @@
|
||||
fn CalculateVolumeAndCentreOfMass obj =
|
||||
(
|
||||
local Volume= 0.0
|
||||
local Centre= [0.0, 0.0, 0.0]
|
||||
local theMesh = snapshotasmesh obj
|
||||
local numFaces = theMesh.numfaces
|
||||
for i = 1 to numFaces do
|
||||
(
|
||||
local Face= getFace theMesh i
|
||||
local vert2 = getVert theMesh Face.z
|
||||
local vert1 = getVert theMesh Face.y
|
||||
local vert0 = getVert theMesh Face.x
|
||||
local dV = Dot (Cross (vert1 - vert0) (vert2 - vert0)) vert0
|
||||
Volume+= dV
|
||||
Centre+= (vert0 + vert1 + vert2) * dV
|
||||
)
|
||||
delete theMesh
|
||||
Volume /= 6
|
||||
Centre /= 24
|
||||
Centre /= Volume
|
||||
#(Volume,Centre)
|
||||
)
|
||||
79
samples/UrWeb/iso8601.ur
Normal file
79
samples/UrWeb/iso8601.ur
Normal file
@@ -0,0 +1,79 @@
|
||||
open Parse.String
|
||||
|
||||
val digit = satisfy isdigit
|
||||
|
||||
val decimal_of_len n =
|
||||
ds <- count n digit;
|
||||
return (List.foldl (fn d acc => 10*acc + ((ord d)-(ord #"0"))) 0 ds)
|
||||
|
||||
val date =
|
||||
y <- decimal_of_len 4;
|
||||
char' #"-";
|
||||
m <- decimal_of_len 2;
|
||||
char' #"-";
|
||||
d <- decimal_of_len 2;
|
||||
if m > 0 && m <= 12 then
|
||||
return {Year=y, Month=(Datetime.intToMonth (m-1)), Day=d}
|
||||
else
|
||||
fail
|
||||
|
||||
(* We parse fractions of a second, but ignore them since Datetime
|
||||
doesn't permit representing them. *)
|
||||
val time =
|
||||
h <- decimal_of_len 2;
|
||||
char' #":";
|
||||
m <- decimal_of_len 2;
|
||||
s <- maybe (char' #":";
|
||||
s <- decimal_of_len 2;
|
||||
maybe' (char' #"."; skipWhile isdigit);
|
||||
return s);
|
||||
return {Hour=h, Minute=m, Second=Option.get 0 s}
|
||||
|
||||
val timezone_offset =
|
||||
let val zulu = char' #"Z"; return 0
|
||||
val digits = decimal_of_len 2
|
||||
val sign = or (char' #"+"; return 1)
|
||||
(char' #"-"; return (-1))
|
||||
in
|
||||
zulu `or` (s <- sign;
|
||||
h <- digits;
|
||||
m <- (maybe' (char' #":"); or digits (return 0));
|
||||
return (s*(h*60+m)))
|
||||
end
|
||||
|
||||
val datetime_with_tz =
|
||||
d <- date; char' #"T"; t <- time;
|
||||
tz <- timezone_offset;
|
||||
return (d ++ t ++ {TZOffsetMinutes=tz})
|
||||
|
||||
val datetime =
|
||||
d <- datetime_with_tz;
|
||||
return (d -- #TZOffsetMinutes)
|
||||
|
||||
fun process v =
|
||||
case parse (d <- datetime_with_tz; eof; return d) v of
|
||||
Some r =>
|
||||
let
|
||||
val {Year=year,Month=month,Day=day,
|
||||
Hour=hour,Minute=minute,Second=second} =
|
||||
Datetime.addMinutes (r.TZOffsetMinutes) (r -- #TZOffsetMinutes)
|
||||
fun pad x =
|
||||
if x < 10 then "0" `strcat` show x else show x
|
||||
in
|
||||
<xml>{[pad hour]}:{[pad minute]}:{[pad second]} {[month]} {[day]}, {[year]}</xml>
|
||||
end
|
||||
| None => <xml>none</xml>
|
||||
|
||||
fun main () : transaction page =
|
||||
input <- source "2012-01-01T01:10:42Z";
|
||||
return <xml>
|
||||
<body>
|
||||
<label>
|
||||
Enter an
|
||||
<a href="https://en.wikipedia.org/wiki/ISO_8601">ISO 8601</a>
|
||||
datetime here:
|
||||
<ctextbox source={input} />
|
||||
</label>
|
||||
<ul><dyn signal={v <- signal input; return (process v)} /></ul>
|
||||
</body>
|
||||
</xml>
|
||||
85
samples/UrWeb/parse.urs
Normal file
85
samples/UrWeb/parse.urs
Normal file
@@ -0,0 +1,85 @@
|
||||
functor Make(Stream : sig type t end) : sig
|
||||
con t :: Type -> Type
|
||||
|
||||
val mreturn : a ::: Type -> a -> t a
|
||||
val mbind : a ::: Type -> b ::: Type ->
|
||||
(t a) -> (a -> t b) -> (t b)
|
||||
val monad_parse : monad t
|
||||
|
||||
val parse : a ::: Type -> t a -> Stream.t -> option a
|
||||
|
||||
(** Combinators *)
|
||||
val fail : a ::: Type -> t a
|
||||
val or : a ::: Type -> t a -> t a -> t a
|
||||
val maybe : a ::: Type -> t a -> t (option a)
|
||||
val maybe' : a ::: Type -> t a -> t unit
|
||||
val many : a ::: Type -> t a -> t (list a)
|
||||
val count : a ::: Type -> int -> t a -> t (list a)
|
||||
val skipMany : a ::: Type -> t a -> t unit
|
||||
val sepBy : a ::: Type -> s ::: Type -> t a -> t s -> t (list a)
|
||||
end
|
||||
|
||||
structure String : sig
|
||||
con t :: Type -> Type
|
||||
val monad_parse : monad t
|
||||
|
||||
val parse : a ::: Type -> t a -> string -> option a
|
||||
|
||||
(** Combinators *)
|
||||
val fail : a ::: Type -> t a
|
||||
val or : a ::: Type -> t a -> t a -> t a
|
||||
val maybe : a ::: Type -> t a -> t (option a)
|
||||
val maybe' : a ::: Type -> t a -> t unit
|
||||
val many : a ::: Type -> t a -> t (list a)
|
||||
val count : a ::: Type -> int -> t a -> t (list a)
|
||||
val skipMany : a ::: Type -> t a -> t unit
|
||||
val sepBy : a ::: Type -> s ::: Type -> t a -> t s -> t (list a)
|
||||
|
||||
val eof : t unit
|
||||
(* We provide alternative versions of some of these predicates
|
||||
* that return t unit as a monadic syntactical convenience. *)
|
||||
val string : string -> t string
|
||||
val string' : string -> t unit
|
||||
val stringCI : string -> t string
|
||||
val stringCI' : string -> t unit
|
||||
val char : char -> t char
|
||||
val char' : char -> t unit
|
||||
val take : int -> t (string*int)
|
||||
val drop : int -> t unit
|
||||
val satisfy : (char -> bool) -> t char
|
||||
val skip : (char -> bool) -> t unit
|
||||
val skipWhile : (char -> bool) -> t unit
|
||||
val takeWhile : (char -> bool) -> t (string*int)
|
||||
val takeWhile' : (char -> bool) -> t string (* conses *)
|
||||
(* Well, "till" is the correct form; but "til" is in common enough
|
||||
* usage that I'll prefer it for terseness. *)
|
||||
val takeTil : (char -> bool) -> t (string*int)
|
||||
val takeTil' : (char -> bool) -> t string (* conses *)
|
||||
val takeRest : t string
|
||||
|
||||
(** Convenience functions *)
|
||||
val skipSpace : t unit
|
||||
val endOfLine : t unit
|
||||
val unsigned_int_of_radix : int -> t int
|
||||
(*
|
||||
* val signed_int_of_radix : int -> t int
|
||||
* val double : t float
|
||||
*)
|
||||
end
|
||||
|
||||
structure Blob : sig
|
||||
con t :: Type -> Type
|
||||
val monad_parse : monad t
|
||||
|
||||
val parse : a ::: Type -> t a -> blob -> option a
|
||||
|
||||
(** Combinators *)
|
||||
val fail : a ::: Type -> t a
|
||||
val or : a ::: Type -> t a -> t a -> t a
|
||||
val maybe : a ::: Type -> t a -> t (option a)
|
||||
val maybe' : a ::: Type -> t a -> t unit
|
||||
val many : a ::: Type -> t a -> t (list a)
|
||||
val count : a ::: Type -> int -> t a -> t (list a)
|
||||
val skipMany : a ::: Type -> t a -> t unit
|
||||
val sepBy : a ::: Type -> s ::: Type -> t a -> t s -> t (list a)
|
||||
end
|
||||
2
vendor/grammars/AutoHotkey
vendored
2
vendor/grammars/AutoHotkey
vendored
Submodule vendor/grammars/AutoHotkey updated: ad157bcfcd...77b8f2d785
2
vendor/grammars/Elm.tmLanguage
vendored
2
vendor/grammars/Elm.tmLanguage
vendored
Submodule vendor/grammars/Elm.tmLanguage updated: f17b1914dd...ab79692fed
2
vendor/grammars/NimLime
vendored
2
vendor/grammars/NimLime
vendored
Submodule vendor/grammars/NimLime updated: 7aea8846e1...4e60e5657f
1
vendor/grammars/UrWeb-Language-Definition
vendored
Submodule
1
vendor/grammars/UrWeb-Language-Definition
vendored
Submodule
Submodule vendor/grammars/UrWeb-Language-Definition added at cd47cc7891
2
vendor/grammars/atom-fsharp
vendored
2
vendor/grammars/atom-fsharp
vendored
Submodule vendor/grammars/atom-fsharp updated: 2622af4d4f...500cdb5f04
2
vendor/grammars/atom-language-purescript
vendored
2
vendor/grammars/atom-language-purescript
vendored
Submodule vendor/grammars/atom-language-purescript updated: 5fd5b6460e...21ed0c417a
2
vendor/grammars/carto-atom
vendored
2
vendor/grammars/carto-atom
vendored
Submodule vendor/grammars/carto-atom updated: 9895909323...08a80dc54a
2
vendor/grammars/cmake.tmbundle
vendored
2
vendor/grammars/cmake.tmbundle
vendored
Submodule vendor/grammars/cmake.tmbundle updated: 926867a414...1421c6ba47
2
vendor/grammars/factor
vendored
2
vendor/grammars/factor
vendored
Submodule vendor/grammars/factor updated: e84e63fd0c...9d95602591
2
vendor/grammars/haskell.tmbundle
vendored
2
vendor/grammars/haskell.tmbundle
vendored
Submodule vendor/grammars/haskell.tmbundle updated: c3137ccc28...df3d54278a
2
vendor/grammars/jade-tmbundle
vendored
2
vendor/grammars/jade-tmbundle
vendored
Submodule vendor/grammars/jade-tmbundle updated: 6cde1da688...d27b61d178
2
vendor/grammars/json.tmbundle
vendored
2
vendor/grammars/json.tmbundle
vendored
Submodule vendor/grammars/json.tmbundle updated: 4100e5b016...06b38d5532
2
vendor/grammars/language-babel
vendored
2
vendor/grammars/language-babel
vendored
Submodule vendor/grammars/language-babel updated: d6cfe25210...4b0e9658e0
1
vendor/grammars/language-click
vendored
Submodule
1
vendor/grammars/language-click
vendored
Submodule
Submodule vendor/grammars/language-click added at 1ee1fe012b
2
vendor/grammars/language-clojure
vendored
2
vendor/grammars/language-clojure
vendored
Submodule vendor/grammars/language-clojure updated: 3173abe995...12b73d41a0
2
vendor/grammars/language-coffee-script
vendored
2
vendor/grammars/language-coffee-script
vendored
Submodule vendor/grammars/language-coffee-script updated: 541448297e...afa4f6f157
2
vendor/grammars/language-gfm
vendored
2
vendor/grammars/language-gfm
vendored
Submodule vendor/grammars/language-gfm updated: 597d382a8c...e5b24d57e7
2
vendor/grammars/language-javascript
vendored
2
vendor/grammars/language-javascript
vendored
Submodule vendor/grammars/language-javascript updated: efaa34df8b...b227486fc8
1
vendor/grammars/language-maxscript
vendored
Submodule
1
vendor/grammars/language-maxscript
vendored
Submodule
Submodule vendor/grammars/language-maxscript added at a465c9ca4a
2
vendor/grammars/language-shellscript
vendored
2
vendor/grammars/language-shellscript
vendored
Submodule vendor/grammars/language-shellscript updated: 331dbfea1f...bbaca532de
2
vendor/grammars/language-yaml
vendored
2
vendor/grammars/language-yaml
vendored
Submodule vendor/grammars/language-yaml updated: 7b2c3e09b5...e1d62e5aff
2
vendor/grammars/make.tmbundle
vendored
2
vendor/grammars/make.tmbundle
vendored
Submodule vendor/grammars/make.tmbundle updated: 371a9e8a56...e0d96dc1d6
2
vendor/grammars/matlab.tmbundle
vendored
2
vendor/grammars/matlab.tmbundle
vendored
Submodule vendor/grammars/matlab.tmbundle updated: e1460dd9e7...2cdc1f8414
2
vendor/grammars/smali-sublime
vendored
2
vendor/grammars/smali-sublime
vendored
Submodule vendor/grammars/smali-sublime updated: b9eba91397...28a4336421
2
vendor/grammars/sublime-typescript
vendored
2
vendor/grammars/sublime-typescript
vendored
Submodule vendor/grammars/sublime-typescript updated: edea3b9e78...6540de452e
2
vendor/grammars/sublimeprolog
vendored
2
vendor/grammars/sublimeprolog
vendored
Submodule vendor/grammars/sublimeprolog updated: 9fd46df4b6...c71d8a1e0f
2
vendor/grammars/vue-syntax-highlight
vendored
2
vendor/grammars/vue-syntax-highlight
vendored
Submodule vendor/grammars/vue-syntax-highlight updated: 3b5c4183bf...a2336ddc7e
Reference in New Issue
Block a user