Skip to content

Commit

Permalink
Match dot access.
Browse files Browse the repository at this point in the history
  • Loading branch information
thesoftwarephilosopher committed Aug 22, 2024
1 parent e03be8b commit e46764c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions site/monarch/samplecode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function TodoInput(attrs: { add: (v: string) => void }) {
return input;
}

class TodoList$1 {
class todoList$1 {
ul = <ul class='todolist' /> as HTMLUListElement;
add(v: string) {
const item = <li>{v}</li> as HTMLLIElement;
Expand All @@ -54,7 +54,7 @@ class TodoList$1 {
}

export const sample3 = () => {
const list = new TodoList$1();
const list = new todoList$1();
list.add('foo');
list.add('bar');
return <>
Expand Down
12 changes: 11 additions & 1 deletion site/token-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,10 @@ export const tokenProvider = {
[/0[bB](@binarydigits)n?/, 'number.binary'],
[/(@digits)n?/, 'number'],

[/\./, '@rematch', '@dot'],

// delimiter: after number because of .\d floats
[/[;,.]/, 'delimiter'],
[/[;,]/, 'delimiter'],

// strings
[/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string
Expand All @@ -124,6 +126,14 @@ export const tokenProvider = {
[/`/, 'string', '@string_backtick']
],

dot: [
[/\.\.\./, 'keyword', '@pop'],
[/#?[\w$]+\s*(?=[<(])/, 'method'],
[/#?[\w$]+\s*(?=[=.])/, 'property'],
[/\./, 'delimiter'],
[/./, '@rematch', '@pop'],
],

whitespace: [
[/[ \t\r\n]+/, ''],
[/\/\*\*(?!\/)/, 'comment.doc', '@jsdoc'],
Expand Down

0 comments on commit e46764c

Please sign in to comment.