start new project
This commit is contained in:
28
compiler/scanner.sml
Normal file
28
compiler/scanner.sml
Normal file
@@ -0,0 +1,28 @@
|
||||
structure Scanner =
|
||||
struct
|
||||
structure Dfa = CaseSesitiveDfa
|
||||
|
||||
val intDfa = Dfa.fromString "[0-9]+"
|
||||
val wordDfa = Dfa.fromString "0w[0-9]+"
|
||||
val realDfa = "[0-9]+.[0-9]+"
|
||||
val idDfa = Dfa.fromString "[a-zA-Z][a-zA-Z0-9_']*"
|
||||
|
||||
fun helpExtractString (pos, str, acc) =
|
||||
if pos >= String.size str then
|
||||
raise Fail ("unterminated string: [" ^ acc ^ "]\n")
|
||||
else
|
||||
case String.sub (str, pos) of
|
||||
#"\"" => (pos + 1, acc)
|
||||
| #"\\" =>
|
||||
if pos + 1 >= String.size str then
|
||||
raise Fail ("unterminated string: [" ^ acc ^ "\\]\n")
|
||||
else
|
||||
(
|
||||
case String.sub (str, pos + 1) of
|
||||
|
||||
)
|
||||
| chr =>
|
||||
helpExtractString (pos + 1, str, acc ^ String.implode [chr])
|
||||
|
||||
fun extractString (pos, str) = helpExtractString (pos. str, "")
|
||||
end
|
||||
1
compiler/uses.sml
Normal file
1
compiler/uses.sml
Normal file
@@ -0,0 +1 @@
|
||||
use "../dfa-gen/dfa-gen.sml";
|
||||
Reference in New Issue
Block a user