Skip to content

Commit

Permalink
Restrict token names a bit more
Browse files Browse the repository at this point in the history
  • Loading branch information
baioc committed Aug 13, 2021
1 parent 5b58325 commit 3cb6b74
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 24 deletions.
48 changes: 25 additions & 23 deletions src/Client/Index.fs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ let project (spec: Map<string, RegularDefinition>) (kind, name, body) (dispatch:
#else // on release, show user-facing regex
prop.text (String.visual userRegexp.String)
#endif
text.isFamilyCode
text.isFamilyMonospace
]
]
]
Expand Down Expand Up @@ -431,6 +431,7 @@ let project (spec: Map<string, RegularDefinition>) (kind, name, body) (dispatch:
|> SetRegularDefinitionText
|> dispatch)
if not nameIsValid then color.isDanger
text.isFamilyMonospace
]
]
]
Expand Down Expand Up @@ -487,8 +488,9 @@ let recognition (lexer: Lexer option) (symbolTable: Result<TokenInstance, Lexica
prop.custom ("rows", 24)
prop.onChange (SetInputText >> dispatch)
prop.disabled (Option.isNone lexer)
prop.placeholder (if Option.isSome lexer then "Forneça uma entrada ao lexer."
else "O lexer ainda não foi gerado.")
prop.placeholder
(if Option.isSome lexer then "Forneça uma entrada ao lexer."
else "O lexer ainda não foi gerado.")
]
]
]
Expand Down Expand Up @@ -526,7 +528,7 @@ let recognition (lexer: Lexer option) (symbolTable: Result<TokenInstance, Lexica
match entry with
| Ok token ->
token.Token, token.Lexeme, token.Position, false
| Result.Error error ->
| Error error ->
let pseudoLexeme =
error.String
|> Seq.map (sprintf "%c")
Expand All @@ -538,10 +540,12 @@ let recognition (lexer: Lexer option) (symbolTable: Result<TokenInstance, Lexica
if isError then color.hasTextDanger
else color.hasTextInfo
]
Html.td
(lexeme
|> Regexp.escape
|> String.visual)
Html.td [
prop.text
(lexeme
|> Regexp.escape
|> String.visual)
]
Html.td [
prop.text (sprintf "%d" position)
color.hasTextLink
Expand Down Expand Up @@ -606,22 +610,20 @@ let toolbar (project: Project) (dispatch: Msg -> unit) =
Bulma.level [
prop.children [
Bulma.levelLeft [
Bulma.levelItem [
// project mode selector
Bulma.tabs [
tabs.isBoxed
prop.children [
Html.ul [
Bulma.tab [
tab.isActive
prop.children [
Html.a [ prop.text "Lexicon" ]
]
// project mode selector
Bulma.tabs [
tabs.isBoxed
prop.children [
Html.ul [
Bulma.tab [
tab.isActive
prop.children [
Html.a [ prop.text "Lexicon" ]
]
Bulma.tab [
prop.children [
Html.a [ prop.text "Sintaxe" ]
]
]
Bulma.tab [
prop.children [
Html.a [ prop.text "Sintaxe" ]
]
]
]
Expand Down
2 changes: 1 addition & 1 deletion src/Shared/Shared.fs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ type RegularDefinition =
type Identifier = string

module Identifier =
let isValid str = Regex.IsMatch(str, @"\w+")
let isValid str = Regex.IsMatch(str, @"^\w(\w|\d)*$")

type LexicalSpecification = Map<Identifier, RegularDefinition>

Expand Down

0 comments on commit 3cb6b74

Please sign in to comment.